public void CommandMoveInToBuilding(Building building, float differ = 0.5f) { targetType = ETroopTargetType.MoveIntoBuilding; targetBuilding = building; targetTroop = null; moveToDiff = differ;//小于这个距离直接enter }
public void CommandFollowTroop(Troop troop, float differ = 0.5f) { targetType = ETroopTargetType.FollowTroop; targetBuilding = null; targetTroop = troop; moveToDiff = differ; }
public void CommandMoveToPoint(Vector3 point, float differ = 0.5f) { if (point.y < 1) { point.y = 1f; } targetType = ETroopTargetType.MoveToPoint; targetPoint = point; targetBuilding = null; targetTroop = null; moveToDiff = differ; // Debug.Log("" + this.entityname + "move destination" + point.ToString()); agent.SetDestination(point); }
public void CommandAttackBuilding(Building building) { targetType = ETroopTargetType.AttackBuilding; targetBuilding = building; targetTroop = null; }
//这个必须使用update操作,并非一次性 public void CommadAttackTroop(Troop troop) { targetType = ETroopTargetType.AttackTroop; targetBuilding = null; targetTroop = troop; }
private void Update() { if (GameMgr.Instacne.state != EGameState.Running) { agent.isStopped = true; return; } agent.isStopped = false; runningtime += Time.deltaTime; if (runningtime > lastAutoAttackStartTime + AtkFrequency)//过了一个周期 { lastAutoAttackStartTime = runningtime; DoAutoAttack(); //自动近战攻击 } UpdateAI(); //主要是设定目标 UpdateSkillAI(); //技能释放 //下面都是被动的,主动的技能通过UI if (targetType == ETroopTargetType.None) { } else if (targetType == ETroopTargetType.AttackBuilding || targetType == ETroopTargetType.RePairBuilding) {//只有工程队可以,都是近战 if (targetBuilding != null) { if (!interActionCheck.list_InterBuilding.Contains(targetBuilding)) { //不在interAction区域内,往前移动 agent.isStopped = false; agent.SetDestination(targetBuilding.transform.position); } else { //已经在范围内了 agent.isStopped = true; } } else { } } else if (targetType == ETroopTargetType.MoveIntoBuilding) { if (targetBuilding != null && targetBuilding.ParentFaction == this.ParentFaction) { CityBuilding parentCity = targetBuilding as CityBuilding; if (!interActionCheck.list_InterBuilding.Contains(targetBuilding)) { //不在interAction区域内,往前移动 agent.isStopped = false; agent.SetDestination(targetBuilding.transform.position); } else { //已经在范围内了 agent.isStopped = true; parentCity.EnterTroop(this); return; } } else if (targetBuilding != null && targetBuilding.ParentFaction != this.ParentFaction) { targetType = ETroopTargetType.AttackBuilding; } } else if (targetType == ETroopTargetType.AttackTroop || targetType == ETroopTargetType.FollowTroop) { if (targetTroop != null) { if (!interActionCheck.list_InterBuilding.Contains(targetBuilding)) { //不在interAction区域内,往前移动 agent.isStopped = false; agent.SetDestination(targetBuilding.transform.position); } else { //已经在范围内了,啥也不干,攻击是自动攻击 agent.isStopped = true; } } else { } } else if (targetType == ETroopTargetType.MoveToPoint) { if (Vector3.Distance(targetPoint, transform.position) <= moveToDiff) { agent.isStopped = true; } else { agent.isStopped = false; agent.SetDestination(targetPoint); } } }