Пример #1
0
    public void SelectMidPlayer(KeyCode key)
    {
        if (Input.GetKeyDown(key))
        {
            if (!midPlayer.GetComponent <PlayerHealth>().playerIsDead)
            {
                DeactivatePresentPlayerComponents();

                midPlayer.GetComponent <ActionRecorder>().playerHUD.SetActive(true);
                midPlayer.GetComponent <MeshRenderer>().enabled           = false;
                midPlayer.GetComponentInChildren <MouseLook>().enabled    = true;
                midPlayer.GetComponent <FPSController>().enabled          = true;
                midPlayer.GetComponentInChildren <Camera>().enabled       = true;
                midPlayer.GetComponentInChildren <Rigidbody>().useGravity = false;
                midPlayer.GetComponentInChildren <GunControl>().enabled   = true;
                midPlayer.GetComponent <ActionRecorder>().enabled         = true;

                presentPlayer       = midPlayer;
                presentPlayerStatic = presentPlayer;
                playerIsNow         = PresentPlayer.MID;
            }
            else
            {
                Debug.Log("Mid player is dead!");
            }
        }
    }
Пример #2
0
    public void SelectLeftPlayer(KeyCode key)
    {
        if (Input.GetKeyDown(key))
        {
            if (!leftPlayer.GetComponent <PlayerHealth>().playerIsDead) //first check if player you want to switch to is still alive
            {
                DeactivatePresentPlayerComponents();

                leftPlayer.GetComponent <MeshRenderer>().enabled = false;
                leftPlayer.GetComponent <ActionRecorder>().playerHUD.SetActive(true);
                leftPlayer.GetComponentInChildren <MouseLook>().enabled    = true;
                leftPlayer.GetComponent <FPSController>().enabled          = true;
                leftPlayer.GetComponentInChildren <Camera>().enabled       = true;
                leftPlayer.GetComponentInChildren <Rigidbody>().useGravity = false;
                leftPlayer.GetComponentInChildren <GunControl>().enabled   = true;
                leftPlayer.GetComponent <ActionRecorder>().enabled         = true;

                presentPlayer       = leftPlayer;
                presentPlayerStatic = presentPlayer;
                playerIsNow         = PresentPlayer.LEFT;
            }

            else
            {
                Debug.Log("Left player is dead!");
            }
        }
    }
Пример #3
0
    public void SelectGodPlayer(KeyCode key)
    {
        if (Input.GetKeyDown(key))
        {
            if (presentPlayer != godPlayer)
            {
                presentPlayer.GetComponentInChildren <MouseLook>().enabled     = false;
                presentPlayer.GetComponent <FPSController>().enabled           = false;
                presentPlayer.GetComponentInChildren <Camera>().enabled        = false;
                presentPlayer.GetComponentInChildren <Rigidbody>().useGravity  = false;
                presentPlayer.GetComponentInChildren <Rigidbody>().isKinematic = true;
                presentPlayer.GetComponentInChildren <GunControl>().enabled    = false;
                presentPlayer.GetComponent <ActionRecorder>().playerHUD.SetActive(false);
                presentPlayer.GetComponent <MeshRenderer>().enabled = true;


                ReactivateActionRecorders();

                //godPlayer.GetComponentInChildren<MouseLook>().enabled = true;
                //godPlayer.GetComponent<FPSController>().enabled = true;
                godPlayer.GetComponentInChildren <Camera>().enabled = true;
                godPlayer.GetComponent <GodControl>().godIsSelected = true;
                //godPlayer.GetComponentInChildren<Rigidbody>().useGravity = false;
                //godPlayer.GetComponentInChildren<GunControl>().enabled = true;

                presentPlayer       = godPlayer;
                presentPlayerStatic = presentPlayer;
                playerIsNow         = PresentPlayer.GOD;
            }
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        currentlySelectedPlayer = playerIsNow;

        SelectMidPlayer(midPlayerKey);
        SelectLeftPlayer(leftPlayerKey);
        SelectRightPlayer(rightPlayerKey);
        SelectGodPlayer(godPlayerKey);

        if (presentPlayer != godPlayer)
        {
            godPlayer.GetComponent <GodControl>().godIsSelected = false;
        }
    }