示例#1
0
    void Update()
    {
        if (Input.GetButtonDown("Pause") && !TextFieldEnabled)
        {
            Pause();
        }

        /*
         * if(Input.GetKeyDown(KeyCode.I)){
         *      deathCanvas.SetActive (true);
         * }
         * if (Input.GetKeyDown(KeyCode.O)) {
         *      GameObject obj = ObjectPooler.current.GetObject ();
         *      obj.SetActive (true);
         *      obj.transform.position = GameObject.FindGameObjectWithTag ("Player").transform.position;
         * }
         */

        if (Input.anyKeyDown)
        {
            if (Input.GetKeyDown(cheatCode[cheatindex]))
            {
                cheatindex++;
            }
            else
            {
                cheatindex = 0;
            }
        }
        if (cheatindex == cheatCode.Length)
        {
            cheatindex = 0;
            Debug.Log("hoch die hande!");
            cheat = !cheat;

            if (!achievements.cheats_unlocked)
            {
                achievements.cheatsAchievement();
            }
        }

        if (Input.GetKeyDown(KeyCode.H) && cheat == true && !TextFieldEnabled)
        {
            if (DebuggerPanel != null)
            {
                if (DebuggerPanel.activeInHierarchy)
                {
                    DebuggerPanel.SetActive(false);
                }
                else
                {
                    DebuggerPanel.SetActive(true);
                }
            }
        }

        //Cheatcode to spawn all weapons around the torch
        if (Input.GetKeyDown(KeyCode.N) && cheat && !TextFieldEnabled)
        {
            SpawnAllWeapons();
        }
        //Cheatcode to spawn all powerups around the torch
        if (Input.GetKeyDown(KeyCode.B) && cheat && !TextFieldEnabled)
        {
            SpawnAllPowerUps();
        }
        //Cheatcode to proceed to the next level
        if (Input.GetKeyDown(KeyCode.L) && cheat && !TextFieldEnabled)
        {
            Proceed();
        }
        //Cheatcode to get full health
        if (Input.GetKeyDown(KeyCode.K) && torch != null && cheat && !TextFieldEnabled)
        {
            torch.HealToStartingHealth();
        }
        //Cheatcode to toggle if the torch is damagable or not
        if (Input.GetKeyDown(KeyCode.J) && torch != null && cheat && !TextFieldEnabled)
        {
            torch.ToggleDamagable();
        }
        //Cheatcode to kill all active enemies
        if (Input.GetKeyDown(KeyCode.LeftBracket) && cheat && !TextFieldEnabled)
        {
            KillAllEnemies();
        }
        //Cheatcode to spawn a key
        if (Input.GetKeyDown(KeyCode.O) && cheat && !TextFieldEnabled)
        {
            SpawnKey();
        }
        //Cheatcode to spawn to highscores
        if (Input.GetKeyDown(KeyCode.Alpha0) && cheat && !TextFieldEnabled)
        {
            TeleportToHighScores();
        }
        //Cheatcode to get 1000 coins
        if (Input.GetKeyDown(KeyCode.Backslash) && cheat && !TextFieldEnabled)
        {
            data.coins += 1000;
        }
        //Cheatcode to reveal the whole minimap
        if (Input.GetKeyDown(KeyCode.V) && cheat && !TextFieldEnabled)
        {
            RevealMinimap();
        }
        //MASTER CHEATCODE
        if (Input.GetKeyDown(KeyCode.Alpha9) && cheat && !TextFieldEnabled)
        {
            SpawnAllWeapons();
            SpawnAllPowerUps();
            torch.HealToStartingHealth();
            torch.ToggleDamagable();
            KillAllEnemies();
            RevealMinimap();
            spawner.ToggleSpawner();
        }

        //Toggle minimap
        if (Input.GetButtonDown("ToggleMinimap") && !TextFieldEnabled)
        {
            ToggleMiniMap();
        }

        //Add second player
        if (Input.GetButtonDown("ToggleSecondPlayer") && !TextFieldEnabled)
        {
            int newNumberOfPlayers;
            if (numberOfPlayers == 1)
            {
                newNumberOfPlayers = 2;
            }
            else
            {
                newNumberOfPlayers = 1;
            }
            SetNumberOfPlayers(newNumberOfPlayers);
        }
    }