feat(space): 更新地图BOSS生成逻辑并优化天气变化处理 - 修改GetMapPlayerList方法中BOSS信息发送方式为调用GenBoss方法 - 注释掉Space结构体中的IsChange字段,不再使用该标志位 - 调整GenBoss方法参数,添加isfrist参数用于区分首次调用 - 重构定时任务中的GenBoss调用逻辑,改为匿名函数包装广播消息 - 移除GenBoss
This commit is contained in:
@@ -68,7 +68,7 @@ func (h Controller) GetMapPlayerList(data *space.ListMapPlayerInboundInfo, c *pl
|
|||||||
if atomic.LoadUint32(&c.GetSpace().TimeBoss.Flag) == 1 {
|
if atomic.LoadUint32(&c.GetSpace().TimeBoss.Flag) == 1 {
|
||||||
c.SendPackCmd(2022, &c.GetSpace().TimeBoss)
|
c.SendPackCmd(2022, &c.GetSpace().TimeBoss)
|
||||||
}
|
}
|
||||||
c.SendPackCmd(2021, &c.GetSpace().MapBossSInfo)
|
c.SendPackCmd(2021, c.GetSpace().GenBoss(true))
|
||||||
|
|
||||||
return nil, -1
|
return nil, -1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ type Space struct {
|
|||||||
Name string //地图名称
|
Name string //地图名称
|
||||||
Owner ARENA
|
Owner ARENA
|
||||||
info.MapBossSInfo
|
info.MapBossSInfo
|
||||||
IsChange bool
|
//IsChange bool
|
||||||
WeatherType []uint32
|
WeatherType []uint32
|
||||||
TimeBoss info.S2C_2022
|
TimeBoss info.S2C_2022
|
||||||
//Weather uint32
|
//Weather uint32
|
||||||
@@ -215,7 +215,10 @@ func (ret *Space) init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(ret.MapBossSInfo.INFO) > 0 {
|
if len(ret.MapBossSInfo.INFO) > 0 {
|
||||||
cool.Cron.ScheduleFunc(10*time.Second, ret.GenBoss)
|
cool.Cron.ScheduleFunc(10*time.Second, func() {
|
||||||
|
|
||||||
|
ret.Broadcast(nil, 2022, ret.GenBoss(false))
|
||||||
|
})
|
||||||
cool.Cron.ScheduleFunc(300*time.Second, ret.HealHP)
|
cool.Cron.ScheduleFunc(300*time.Second, ret.HealHP)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +244,7 @@ func (p *Space) IsMatch(t model.Event) bool {
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
func (ret *Space) GenBoss() {
|
func (ret *Space) GenBoss(isfrist bool) *info.MapBossSInfo {
|
||||||
var res info.MapBossSInfo
|
var res info.MapBossSInfo
|
||||||
res.Wer = ret.Wer
|
res.Wer = ret.Wer
|
||||||
for i := 0; i < len(ret.MapBossSInfo.INFO); i++ {
|
for i := 0; i < len(ret.MapBossSInfo.INFO); i++ {
|
||||||
@@ -260,14 +263,14 @@ func (ret *Space) GenBoss() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret.MapBossSInfo.INFO[i].IsShow = 1
|
ret.MapBossSInfo.INFO[i].IsShow = 1
|
||||||
if ret.IsChange {
|
if isfrist {
|
||||||
ret.MapBossSInfo.INFO[i].IsShow = 2
|
ret.MapBossSInfo.INFO[i].IsShow = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
res.INFO = append(res.INFO, ret.MapBossSInfo.INFO[i])
|
res.INFO = append(res.INFO, ret.MapBossSInfo.INFO[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.Broadcast(nil, 2021, &res)
|
return &res
|
||||||
|
|
||||||
}
|
}
|
||||||
func (ret *Space) HealHP() {
|
func (ret *Space) HealHP() {
|
||||||
|
|
||||||
@@ -287,13 +290,12 @@ func (ret *Space) GenWer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if neww != uint32(ret.MapBossSInfo.Wer) {
|
if neww != uint32(ret.MapBossSInfo.Wer) {
|
||||||
ret.IsChange = true
|
|
||||||
ret.MapBossSInfo.Wer = int32(neww)
|
ret.MapBossSInfo.Wer = int32(neww)
|
||||||
ret.GenBoss()
|
|
||||||
|
ret.Broadcast(nil, 2021, ret.GenBoss(true))
|
||||||
println(ret.Name, "change weather", neww)
|
println(ret.Name, "change weather", neww)
|
||||||
|
|
||||||
} else {
|
|
||||||
ret.IsChange = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user