Ejemplo n.º 1
0
    public override void update()
    {
        // Get the angles at which the enemies will come at their target
        float angle = 360 / m_EnemyGroup.Length;

        float currentAngle = 0;

        for (int i = 0; i < m_EnemyGroup.Length; i++)
        {
            if (m_EnemyGroup[i] != null)
            {
                // Choose the enemies surrond location
                Vector3 surroundLocation = SurroundPoint(m_Target.transform.position, currentAngle);

                Instantiate(Resources.Load("Cube"), surroundLocation, Quaternion.identity);

                EnemyWithMovement temp = m_EnemyGroup[i] as EnemyWithMovement;
                if (temp != null)
                {
                    NavMeshAgent agent = temp.GetAgent;
                    agent.stoppingDistance = 2.0f;
                    agent.SetDestination(surroundLocation);
                }
                currentAngle += angle;
            }
        }
    }
Ejemplo n.º 2
0
    // Returns the path nodes used for patrolling
    public Transform[] getPathNodes()
    {
        // If the enemy ai is an enemy ai with movement return the pathnodes
        EnemyWithMovement temp = m_EnemyAI as EnemyWithMovement;

        if (temp != null)
        {
            return(temp.m_PathNodes);
        }
        // else it shouldn't have any so return null
        else
        {
                        #if DEBUG || UNITY_EDITOR
            Debug.Log("Invalid Type");
                        #endif
            return(null);
        }
    }
Ejemplo n.º 3
0
    //Returns the navmesh agent
    public NavMeshAgent GetAgent()
    {
        // If the enemy Ai is an enemy ai with movement return the navmesh agent
        EnemyWithMovement temp = m_EnemyAI as EnemyWithMovement;

        if (temp != null)
        {
            return(temp.GetAgent);
        }
        // else the enemy shouldn't have a navmesh agent so return null
        else
        {
                        #if DEBUG || UNITY_EDITOR
            Debug.Log("Invalid Type");
                        #endif
            return(null);
        }
    }