public void Add(AgentRemote agentRemote) { if (!agentRemotes.ContainsKey(agentRemote.AgentID)) { agentRemotes[agentRemote.AgentID] = agentRemote; NotifyAll(); } }
public void StopAttackEffect() { if (effect != null) { VfxPooling.Release(Type, effect); targetAgent = null; effect = null; } }
//only main thread private void EmitMoveEvent(NavAgent agent, bool isFound, AgentRemote enemy) { if (isFound) { MovementListener.Move( agent.GetMovePath(), agent.GetTimes(), agent.CurrentPosition, agent.Remote, enemy); } }
// Decision making public AgentRemote GetEnemyAt(Vector3Int position) { AgentNodes.GetInfo(position, out NodeInfo info); if (info == null) { return(null); } else { AgentRemote otherAgent = info.GameObject.GetComponent <AgentRemote>(); // is enemy bool isEnemy = otherAgent.UserInfo.ID_User != CurrentAgent.Remote.UserInfo.ID_User; return(isEnemy == true ? otherAgent : null); } }
public void AsyncStartMove(Vector3Int start, Vector3Int end, AgentRemote targetEnemy) { StartPosition = start; EndPosition = end; currentEnemy = targetEnemy; if (curMoveStep >= maxMoveStep || (path != null && path.Count == 0)) { curMoveStep = 0; } AStarAlgorithm.FindInfo info = new AStarAlgorithm.FindInfo() { StartPosition = start, EndPosition = end, DoneCallback = FindPathDone_Callback }; AStar.FindPath(info); }
private void CheckAttack() { if (!string.IsNullOrEmpty(UnitInfo.Attack_Unit_ID) && UnitInfo.Attack_Unit_ID.ToLower() != "null") { string[] strs = UnitInfo.Attack_Unit_ID.Split('_'); int otherID = int.Parse(strs[3]); AgentRemote other = AgentRemoteManager.GetAgentRemote(otherID); targetAgent = other; if (other != null && !IsMoving()) { transform.forward = (other.transform.position - transform.position).normalized; Animator.Play(AnimState.Attack1); AttackTarget = other.transform; if (effect == null) { Debugger.Log("call attack effect"); effect = VfxPooling.GetItem(Type); effect.transform.position = transform.position; effect?.Attack(AttackTarget); } else { effect.Attack(AttackTarget); } } } else { AnimatorController.StateInfo attackState = Animator.GetStateInfo(AnimState.Attack1); if (attackState != null && attackState.IsPlaying) { attackState.Stop(); StopAttackEffect(); } } }
private void MoveActiveAgent(Vector3Int start, Vector3Int end, AgentRemote enemy) { MoveAgent(CurrentAgent, start, end, enemy); }
public void MoveAgent(NavAgent agent, Vector3Int start, Vector3Int end, AgentRemote enemy) { agent.AsyncStartMove(start, end, enemy); }