コード例 #1
0
ファイル: MyAgentRemoteManager.cs プロジェクト: dqtoy/Assets
        public void Add(AgentRemote agentRemote)
        {
            if (!agentRemotes.ContainsKey(agentRemote.AgentID))
            {
                agentRemotes[agentRemote.AgentID] = agentRemote;

                NotifyAll();
            }
        }
コード例 #2
0
ファイル: AgentRemote.cs プロジェクト: dqtoy/Assets
        public void StopAttackEffect()
        {
            if (effect != null)
            {
                VfxPooling.Release(Type, effect);

                targetAgent = null;
                effect      = null;
            }
        }
コード例 #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);
     }
 }
コード例 #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);
            }
        }
コード例 #5
0
ファイル: NavAgent.cs プロジェクト: dqtoy/Assets
        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);
        }
コード例 #6
0
ファイル: AgentRemote.cs プロジェクト: dqtoy/Assets
        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();
                }
            }
        }
コード例 #7
0
 private void MoveActiveAgent(Vector3Int start, Vector3Int end, AgentRemote enemy)
 {
     MoveAgent(CurrentAgent, start, end, enemy);
 }
コード例 #8
0
 public void MoveAgent(NavAgent agent, Vector3Int start, Vector3Int end, AgentRemote enemy)
 {
     agent.AsyncStartMove(start, end, enemy);
 }