public void EnterExcute() { //Debug.Log("TowerIdle"); towerInfo.DoAction("idle"); CharacterInfo targetInfo = RunAI(towerInfo); if (targetInfo != null) { //towerInfo.SetTargetInfo(targetInfo); towerInfo.ChangeState("attack", new StateParam(targetInfo)); } }
public void AttackEnd() { //CharacterInfo attackCharInfo = towerInfo.GetTargetInfo(); //若死亡或者超出了攻击范围,则回归待机重新寻找目标 if (attackInfo.IsDead() || !WithinRange(towerInfo, attackInfo)) { towerInfo.ChangeState("idle"); } else { towerInfo.ChangeState("attack", new StateParam(attackInfo)); } }
public void Attack() { CharacterInfo targetInfo = towerInfo.RunAI(); if (targetInfo != null && towerInfo.WithinRange(targetInfo)) { towerInfo.SetAttackInfo(targetInfo); towerInfo.ChangeState("attack", targetInfo); } else { towerInfo.ChangeState("idle"); } }
//添加防御塔 public TowerInfo AddTower(int towerId) { towerIndexId += 1; int towerType = J_Tower.GetData(towerId)._towerType; //增加兵营 if (towerType == 4) { BarrackTowerInfo towerInfo = new BarrackTowerInfo(towerIndexId, towerId); this.eventDispatcher.Broadcast("AddTower", towerInfo); towers.Add(towerIndexId, towerInfo); towerInfo.ChangeState("idle"); return(towerInfo); } //增加空地 else if (towerType == 5) { OpenSpaceInfo spaceInfo = new OpenSpaceInfo(towerIndexId, towerId); this.eventDispatcher.Broadcast("AddTower", spaceInfo); towers.Add(towerIndexId, spaceInfo); spaceInfo.ChangeState("idle"); return(spaceInfo); } //增加攻击塔 else { AttackTowerInfo towerInfo = new AttackTowerInfo(towerIndexId, towerId); this.eventDispatcher.Broadcast("AddTower", towerInfo); towers.Add(towerIndexId, towerInfo); towerInfo.ChangeState("idle"); return(towerInfo); } }
public void AttackEnd() { CharacterInfo attackCharInfo = towerInfo.GetAttackInfo(); //若死亡或者超出了攻击范围,则回归待机重新寻找目标 if (attackCharInfo.IsDead()) { attackCharInfo.ChangeState("die"); towerInfo.ChangeState("idle"); } else if (!towerInfo.WithinRange(attackCharInfo)) { towerInfo.ChangeState("idle"); } else { towerInfo.ChangeState("attack"); } }