Example #1
0
        public void Add(AgentRemote agentRemote)
        {
            if (!agentRemotes.ContainsKey(agentRemote.AgentID))
            {
                agentRemotes[agentRemote.AgentID] = agentRemote;

                NotifyAll();
            }
        }
Example #2
0
        public void StopAttackEffect()
        {
            if (effect != null)
            {
                VfxPooling.Release(Type, effect);

                targetAgent = null;
                effect      = null;
            }
        }
Example #3
0
 //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);
     }
 }
Example #4
0
        // 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);
            }
        }
Example #5
0
        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);
        }
Example #6
0
        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();
                }
            }
        }
Example #7
0
 private void MoveActiveAgent(Vector3Int start, Vector3Int end, AgentRemote enemy)
 {
     MoveAgent(CurrentAgent, start, end, enemy);
 }
Example #8
0
 public void MoveAgent(NavAgent agent, Vector3Int start, Vector3Int end, AgentRemote enemy)
 {
     agent.AsyncStartMove(start, end, enemy);
 }