예제 #1
0
 /// <summary>
 /// Initializes the object.
 /// </summary>
 protected virtual void Start()
 {
     ResetBaseValues();
     RespawnPosition = transform.position;
     _characterSize  = _characterBody.GetComponent <Collider>().bounds.size;
     _groundCollider = _characterBody.GetComponent <GroundCollider>();
 }
예제 #2
0
        /// <summary>
        /// Checks debugging input.
        /// </summary>
        private void CheckDebugInput()
        {
            // Change scene
            LoadLevel();

            // Pause play mode
            if (Input.GetKeyDown(KeyCode.P))
            {
                Debug.Break();
            }

            if (_players != null)
            {
                // Respawn players
                if (Input.GetKeyDown(KeyCode.U))
                {
                    foreach (PlayerCharacter player in _players)
                    {
                        player.Respawn();
                    }
                }

                // Toggle noclip
                if (Input.GetKeyDown(KeyCode.I))
                {
                    bool noclip = false;
                    foreach (PlayerCharacter player in _players)
                    {
                        WallCollider   wc = player.GetComponentInChildren <WallCollider>();
                        GroundCollider gc = player.GetComponentInChildren <GroundCollider>();
                        noclip     = wc.enabled;
                        wc.enabled = !noclip;
                        gc.enabled = !noclip;
                    }
                    Debug.Log("Noclip: " + noclip);
                }

                // Toggle god mode
                if (Input.GetKeyDown(KeyCode.L))
                {
                    bool godMode = false;
                    foreach (PlayerCharacter player in _players)
                    {
                        godMode = !player.IsInvulnerable;
                        player.IsInvulnerable = godMode;
                    }
                    Debug.Log("God mode: " + godMode);
                }

                // Change player count
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    GameManager.Instance.ActivatePlayers(1);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    GameManager.Instance.ActivatePlayers(2);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    GameManager.Instance.ActivatePlayers(3);
                }
                else if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    GameManager.Instance.ActivatePlayers(4);
                }

                // First-person mode
                if (Input.GetKeyDown(KeyCode.O))
                {
                    _camera.SetFirstPersonPlayer(_camera.firstPersonMode ? null : _players[0]);
                }

                // Save game
                if (Input.GetKeyDown(KeyCode.F5))
                {
                    GameManager.Instance.SaveGame();
                }

                // Load game
                if (Input.GetKeyDown(KeyCode.F9))
                {
                    GameManager.Instance.LoadGame();
                }
            }
        }