Exemplo n.º 1
0
    void UserInput()
    {
        if (Input.GetButtonDown("TeamFormUp") && command_input == true)
        {
            formation_manager.ClearSquadOnePositions();
            formation_manager.ClearSquadTwoPositions();
            squad_one_following = true;
            squad_two_following = true;
            TeamFollowCommand();

            command_input = false;
        }

        if (Input.GetButtonDown("CycleFormation") && command_input == true)
        {
            formation_manager.ClearSquadOnePositions();
            formation_manager.ClearSquadTwoPositions();

            formation_manager.CycleFormation();

            if (squad_one_following == true && squad_two_following == true)
            {
                TeamFollowCommand();
            }

            if (squad_one_following == true && squad_two_following == false)
            {
                SquadFollowCommand(squad_1);
            }

            if (squad_one_following == false && squad_two_following == true)
            {
                SquadFollowCommand(squad_2);
            }

            command_input = false;
        }

        if ((Input.GetButtonDown("SquadOneAction") && command_input == true) ||
            (Input.GetButtonDown("SquadTwoAction") && command_input == true) ||
            (Input.GetButtonDown("TeamAction") && command_input == true))
        {
            RaycastHit hit;
            Ray        ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));

            // if the Ray hits something & is within range
            if (Physics.Raycast(ray, out hit, distance, cover_mask))
            {
                if (hit.collider.tag == "Ground")
                {
                    DistanceToCoverCheck(ref hit);
                }

                // Set TargetIndicator Hit Pos
                SetTargetIndicator(hit.point);

                Vector3 hit_pos = new Vector3(hit.point.x, 0.0f, hit.point.z);

                // Identify object hit
                if (hit.collider.tag == "Full Cover" || hit.collider.tag == "Low Cover")
                {
                    CoverCommands(hit_pos);
                }

                else if (hit.collider.tag == "Low Cover")
                {
                    // Low Cover Commands to go here!
                }

                else if (hit.collider.tag == "Ground")
                {
                    MoveCommands(hit_pos);
                }
            }

            command_input = false;
        }

        if (command_input == false)
        {
            command_timer += Time.deltaTime;
        }
    }