Пример #1
0
    // When the Raycast has hit a 'Cover' Type object (Tag)
    private void CoverCommands(Vector3 _hit)
    {
        if (Input.GetButtonDown("SquadOneAction"))
        {
            cover_manager.ClearSquadOnePositions();
            formation_manager.ClearSquadOnePositions();
            SquadGetCover(_hit, squad_1);

            squad_one_following = false;
        }

        else if (Input.GetButtonDown("SquadTwoAction"))
        {
            cover_manager.ClearSquadTwoPositions();
            formation_manager.ClearSquadTwoPositions();
            SquadGetCover(_hit, squad_2);
            squad_two_following = false;
        }

        else if (Input.GetButtonDown("TeamAction"))
        {
            cover_manager.ClearSquadOnePositions();
            cover_manager.ClearSquadTwoPositions();
            formation_manager.ClearSquadOnePositions();
            formation_manager.ClearSquadTwoPositions();

            squad_one_following = false;
            squad_two_following = false;

            float squad_one_avg_dist = 0;
            float squad_two_avg_dist = 0;

            for (int i = 0; i < squad_one.Count; i++)
            {
                squad_one_avg_dist += Vector3.Distance(squad_one[i].GetComponent <Transform>().position, _hit);
            }

            for (int i = 0; i < squad_two.Count; i++)
            {
                squad_two_avg_dist += Vector3.Distance(squad_two[i].GetComponent <Transform>().position, _hit);
            }

            // Check Which Squad Memebr is closest
            if (squad_one_avg_dist < squad_two_avg_dist)
            {
                // If Squadie One is closest...
                SquadGetCover(_hit, squad_1);
                StartCoroutine(SquadGetCoverDelay(_hit, squad_2));
            }

            else
            {
                // if Squadie Two is closest...
                SquadGetCover(_hit, squad_2);
                StartCoroutine(SquadGetCoverDelay(_hit, squad_1));
            }
        }
    }