示例#1
0
        /// <summary>
        /// Finds the next node in the path
        /// </summary>
        public virtual void GetNextNode(NodeYfb currentlyEnteredNode)
        {
            // Don't do anything if the calling node is the same as the m_CurrentNode
            if (m_CurrentNode != currentlyEnteredNode)
            {
                return;
            }
            if (m_CurrentNode == null)
            {
                Debug.LogError("Cannot find current node");
                return;
            }

            NodeYfb nextNode = m_CurrentNode.GetNextNode();

            if (nextNode == null)
            {
                if (m_NavMeshAgent.enabled)
                {
                    m_NavMeshAgent.isStopped = true;
                }
                HandleDestinationReached();
                return;
            }

            Debug.Assert(nextNode != m_CurrentNode);
            SetNode(nextNode);
            MoveToNode();
        }
示例#2
0
        /// <summary>
        /// Stops the attack on the home base
        /// </summary>
        //void OnDied(DamageableBehaviour damageableBehaviour)
        //{
        //	m_IsChargingHomeBaseAttack = false;
        //}

        /// <summary>
        /// Fired then the agent reached its final node,
        /// Starts the attack timer
        /// </summary>
        /// <param name="homeBase"></param>
        void OnDestinationReached(NodeYfb homeBase)
        {
            //m_FinalDestinationDamageableBehaviour = homeBase.GetComponent<DamageableBehaviour>();
            // start timer
            if (m_HomeBaseAttackTimer == null)
            {
                m_HomeBaseAttackTimer = new Timer(homeBaseAttackChargeTime, AttackHomeBase);
            }
            else
            {
                m_HomeBaseAttackTimer.Reset();
            }
            m_IsChargingHomeBaseAttack = true;
        }
示例#3
0
        /// <summary>
        /// Spawns the agent
        /// </summary>
        /// <param name="agentConfig">The agent to spawn</param>
        /// <param name="node">The starting node that the agent uses</param>
        protected virtual void SpawnAgent(AgentConfigurationYfb agentConfig, NodeYfb node)
        {
            Vector3 spawnPosition = node.GetRandomPointInNodeArea();

            var poolable = Poolable.TryGetPoolable <Poolable>(agentConfig.agentPrefab.gameObject);

            if (poolable == null)
            {
                return;
            }
            var agentInstance = poolable.GetComponent <AgentYfb>();

            agentInstance.transform.position = spawnPosition;
            agentInstance.Initialize();
            agentInstance.SetNode(node);
            agentInstance.transform.rotation = node.transform.rotation;
        }
示例#4
0
 /// <summary>
 /// Sets the node to navigate to
 /// </summary>
 /// <param name="node">The node that the agent will navigate to</param>
 public virtual void SetNode(NodeYfb node)
 {
     m_CurrentNode = node;
 }