public override void OnUpdate() { Move(); if (CBattleHelper.CheckTargetInAttackRange(Entity, m_targetEntity)) { //move over StateTransite((int)E_RoleState.Attack); } }
private void SearchTarget() { var battleSys = CBattleEntityMgr.Instance.GetSystem <CBattleEntitySys>(); var target = battleSys.FindTargetOfEntity(this.Entity); if (null != target) { var attackCom = Entity.GetComponent <CAttackCom>(); attackCom.TargetID = target.GetComponent <CAttributeCom>().ID; //check distance if (CBattleHelper.CheckTargetInAttackRange(Entity, target)) { StateTransite((int)E_RoleState.Attack); } else { StateTransite((int)E_RoleState.Walking); } } }