Exemplo n.º 1
0
    public Vector3 RequestTacticalPosition(AIController controller)
    {
        Player target = controller.Target;

        if (target == null)
        {
            target = RequestTarget();
        }

        Vector3 currentPosition = controller.transform.position;

        AITacticalPosition tacticalPosition = m_TacticalPositions[target.ID - 1];

        AITacticalPosition.Space freeSpace = tacticalPosition.GetFreeSpace();

        Vector3 targetPosition = Vector3.zero;

        switch (freeSpace)
        {
        case AITacticalPosition.Space.LEFT:
        {
            targetPosition = -Vector3.right;
            break;
        }

        case AITacticalPosition.Space.RIGHT:
        {
            targetPosition = Vector3.right;
            break;
        }

        case AITacticalPosition.Space.BOTH:
        {
            if (currentPosition.x >= target.transform.position.x)
            {
                targetPosition = Vector3.right;
                freeSpace      = AITacticalPosition.Space.RIGHT;
            }
            else
            {
                targetPosition = -Vector3.right;
                freeSpace      = AITacticalPosition.Space.LEFT;
            }

            break;
        }
        }

        float random = Random.Range(-0.3f, 0.3f);

        targetPosition.z = random;
        targetPosition.Normalize();

        tacticalPosition.AddAI(controller, freeSpace);

        return(targetPosition);
    }
Exemplo n.º 2
0
    void InitTacticalPosition()
    {
        m_TacticalPositions = new AITacticalPosition[2];

        int nbTargets = m_TacticalPositions.Length;

        for (int i = 0; i < nbTargets; i++)
        {
            Player target = m_PlayerManager.GetPlayer(i + 1);

            if (target)
            {
                m_TacticalPositions[i] = new AITacticalPosition(target);
            }
        }
    }