feat: 支持多精灵战斗位操作
This commit is contained in:
@@ -141,13 +141,21 @@ func (f *FightC) Over(c common.PlayerI, res model.EnumBattleOverReason) {
|
||||
|
||||
// 切换精灵 主动和被驱逐
|
||||
func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
f.ChangePetAt(c, id, 0)
|
||||
}
|
||||
|
||||
func (f *FightC) ChangePetAt(c common.PlayerI, id uint32, actorIndex int) {
|
||||
|
||||
if f.closefight {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ii, _ := f.GetInputByPlayer(c, false).GetPet(id)
|
||||
self := f.getInputByUserID(c.GetInfo().UserID, actorIndex, false)
|
||||
if self == nil {
|
||||
return
|
||||
}
|
||||
ii, _ := self.GetPet(id)
|
||||
if ii == nil {
|
||||
//无法切换不允许切换的精灵
|
||||
return
|
||||
@@ -157,12 +165,17 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
BaseAction: action.NewBaseAction(c.GetInfo().UserID),
|
||||
Cid: id,
|
||||
}
|
||||
ret.ActorIndex = actorIndex
|
||||
f.submitAction(ret)
|
||||
|
||||
}
|
||||
|
||||
// 玩家使用技能
|
||||
func (f *FightC) UseSkill(c common.PlayerI, id uint32) {
|
||||
f.UseSkillAt(c, id, 0, 0)
|
||||
}
|
||||
|
||||
func (f *FightC) UseSkillAt(c common.PlayerI, id uint32, actorIndex, targetIndex int) {
|
||||
if f.closefight {
|
||||
|
||||
return
|
||||
@@ -170,19 +183,26 @@ func (f *FightC) UseSkill(c common.PlayerI, id uint32) {
|
||||
ret := &action.SelectSkillAction{
|
||||
BaseAction: action.NewBaseAction(c.GetInfo().UserID),
|
||||
}
|
||||
ret.ActorIndex = actorIndex
|
||||
ret.TargetIndex = targetIndex
|
||||
|
||||
if f.GetInputByPlayer(c, false).CurrentPet == nil {
|
||||
self := f.getInputByUserID(c.GetInfo().UserID, actorIndex, false)
|
||||
if self == nil {
|
||||
return
|
||||
}
|
||||
if f.GetInputByPlayer(c, false).CurrentPet.Info.Hp <= 0 {
|
||||
currentPet := self.PrimaryCurrentPet()
|
||||
if currentPet == nil {
|
||||
return
|
||||
}
|
||||
// t, ok := f.GetInputByPlayer(c, false).CurrentPet.Skills[id]
|
||||
if currentPet.Info.Hp <= 0 {
|
||||
return
|
||||
}
|
||||
// t, ok := f.GetInputByPlayer(c, false).CurrentPet[0].Skills[id]
|
||||
// if ok {
|
||||
// ret.SkillEntity = t
|
||||
|
||||
// }
|
||||
for _, v := range f.GetInputByPlayer(c, false).CurrentPet.Skills {
|
||||
for _, v := range currentPet.Skills {
|
||||
if v.XML.ID == int(id) {
|
||||
ret.SkillEntity = v
|
||||
|
||||
@@ -204,6 +224,10 @@ func (f *FightC) Capture(c common.PlayerI, id uint32) {
|
||||
}
|
||||
|
||||
func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
|
||||
f.UseItemAt(c, cacthid, itemid, 0, 0)
|
||||
}
|
||||
|
||||
func (f *FightC) UseItemAt(c common.PlayerI, cacthid, itemid uint32, actorIndex, targetIndex int) {
|
||||
if f.closefight {
|
||||
|
||||
return
|
||||
@@ -212,7 +236,10 @@ func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
|
||||
go f.UseSkill(c, 0)
|
||||
return
|
||||
}
|
||||
f.submitAction(&action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid})
|
||||
actionInfo := &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid}
|
||||
actionInfo.ActorIndex = actorIndex
|
||||
actionInfo.TargetIndex = targetIndex
|
||||
f.submitAction(actionInfo)
|
||||
}
|
||||
|
||||
// ReadyFight 处理玩家战斗准备逻辑,当满足条件时启动战斗循环
|
||||
|
||||
Reference in New Issue
Block a user