Beispiel #1
0
 /// <summary>
 /// Define Singleton
 /// </summary>
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #2
0
    /// <summary>
    /// Switches level options
    /// </summary>
    public void NextLevel()
    {
        if (LevelOptions.NextLevel != null)
        {
            _levelGamescore = 0;
            LevelOptions    = LevelOptions.NextLevel;
            Spawner.GetComponent <EnemySpawner>().SetLevelSettings(LevelOptions);


            Spawner.SetActive(false);
            PlayerObject.SetActive(false);
            if (StartGameBtn != null && !StartGameBtn.activeSelf)
            {
                StartGameBtn.SetActive(true);
            }
            if (ControlsUI != null)
            {
                ControlsUI.SetActive(true);
            }
            if (WinnerUI != null)
            {
                if (NextTargetUI != null)
                {
                    NextTargetUI.GetComponent <Text>().text = LevelOptions.Score.ToString();
                    WinnerUI.SetActive(true);
                }
            }
        }
    }
Beispiel #3
0
    public void HandlePause()
    {
        if (Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.Joystick1Button7))
        {
            if (IsPaused == false)
            {
                G4.LogEvent("PressedStart", "Paused", "HasPaused", 1);

                // Builder Hit with all Event parameters.
                G4.LogEvent(new EventHitBuilder()
                            .SetEventCategory("PressButton")
                            .SetEventAction("Paused")
                            .SetEventLabel("HasPressed")
                            .SetEventValue(1));

                Debug.Log("Sent");
                Time.timeScale = 0;
                PauseMenuUI.SetActive(true);
                MainPauseUI.SetActive(true);
                QuitToMainUI.SetActive(false);
                ControlsUI.SetActive(false);
                IsPaused = true;
            }
            else
            {
                Time.timeScale = 1;
                QuitToMainUI.SetActive(false);
                ControlsUI.SetActive(false);
                MainPauseUI.SetActive(true);
                PauseMenuUI.SetActive(false);
                IsPaused = false;
            }
        }
    }
Beispiel #4
0
 private void ButtonClickControllerControls()
 {
     keyBordAndMouse = false;
     controller      = true;
     KeysPanel.SetActive(false);
     ControllerPanel.SetActive(true);
     ControlsUI.SetActive(false);
     ControllerBack.Select();
 }
Beispiel #5
0
 void Start()
 {
     PauseMenuUI.SetActive(false);
     CountdownUI.SetActive(true);
     ControlsUI.SetActive(false);
     MenuCheckUI.SetActive(false);
     GameOverUI.SetActive(false);
     StartCoroutine(GameCountDown());
     GameIsPaused = false;
     gameStarted  = false;
 }
Beispiel #6
0
 private void Start()
 {
     keyBordAndMouse = false;
     controller      = false;
     ControlsUI.SetActive(true);
     KeysPanel.SetActive(false);
     ControllerPanel.SetActive(false);
     back.onClick.AddListener(ButtonClickBack);
     KeysBack.onClick.AddListener(ChooseControlles);
     ControllerBack.onClick.AddListener(ChooseControlles);
     KeysControls.onClick.AddListener(ButtonClickKeyBordAndMouseControls);
     ControllerControls.onClick.AddListener(ButtonClickControllerControls);
     back.Select();
 }
Beispiel #7
0
 /// <summary>
 /// Restart button click event listener. Starts game
 /// </summary>
 public void Restart()
 {
     ControlsUI.SetActive(false);
     WinnerUI.SetActive(false);
     PlayerObject.GetComponent <Player>().Restart();
     Spawner.GetComponent <EnemySpawner>().Restart();
     BackgroundUI.GetComponent <Image>().sprite = LevelOptions.Background;
     StartGameBtn.SetActive(false);
     if (_playerDead)
     {
         GameOverUI.SetActive(false);
         _playerDead = false;
     }
     OnHealthsUpdate(PlayerObject.GetComponent <Player>().hPoints);
 }
Beispiel #8
0
    public void HandleControl()
    {
        G4.LogEvent("PressButton", "ControlButton", "HasPressed", 1);

        // Builder Hit with all Event parameters.
        G4.LogEvent(new EventHitBuilder()
                    .SetEventCategory("PressButton")
                    .SetEventAction("ControlButton")
                    .SetEventLabel("HasPressed")
                    .SetEventValue(1));

        Debug.Log("Sent");
        MainPauseUI.SetActive(false);
        ControlsUI.SetActive(true);
    }
Beispiel #9
0
    public void HandleBack()
    {
        G4.LogEvent("ResumeGame", "Unpaused", "Back", 1);

        // Builder Hit with all Event parameters.
        G4.LogEvent(new EventHitBuilder()
                    .SetEventCategory("ResumeGame")
                    .SetEventAction("Unpaused")
                    .SetEventLabel("Back")
                    .SetEventValue(1));

        Debug.Log("Sent");
        Time.timeScale = 1;
        QuitToMainUI.SetActive(false);
        ControlsUI.SetActive(false);
        MainPauseUI.SetActive(true);
        PauseMenuUI.SetActive(false);
        IsPaused = false;
    }
Beispiel #10
0
    /// <summary>
    /// OnPlayerDead event listener
    /// </summary>
    private void GameOver()
    {
        if (!_playerDead)
        {
            _playerDead = true;
            if (StartGameBtn != null && !StartGameBtn.activeSelf)
            {
                StartGameBtn.SetActive(true);
            }

            if (GameOverUI != null)
            {
                GameOverUI.SetActive(true);
            }

            if (ControlsUI != null)
            {
                ControlsUI.SetActive(true);
            }
        }
    }
Beispiel #11
0
    private void ChooseControlles()
    {
        if (keyBordAndMouse == true)
        {
            keyBordAndMouse = false;
            controller      = false;
            KeysPanel.SetActive(false);
            ControllerPanel.SetActive(false);
            ControlsUI.SetActive(true);
            back.Select();
        }

        if (controller == true)
        {
            keyBordAndMouse = false;
            controller      = false;
            KeysPanel.SetActive(false);
            ControllerPanel.SetActive(false);
            ControlsUI.SetActive(true);
            back.Select();
        }
    }
 public void ShowControls()
 {
     MainUI.SetActive(false);
     ControlsUI.SetActive(true);
     controlsActive = true;
 }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("StartButton") && gameStarted == true)
        {
            if (GameIsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }

        if (Input.GetButtonDown("Cancel"))
        {
            ControlsUI.SetActive(false);
            MenuCheckUI.SetActive(false);
            myInputField.Select();
        }

        if ((P1Slider.value == MaxPoints || P2Slider.value == MaxPoints || P3Slider.value == MaxPoints || P4Slider.value == MaxPoints))
        {
            GameIsPaused = true;
            checkWinner();
            GameOverUI.SetActive(true);
            GameOverText.GetComponent <Text>().text = "Game Over\n\nThe " + role + " has been promoted";
            StartCoroutine(gameOver());
        }

        switch (PowerUp.pointPowerUp) //If a player collects a point power up
        {
        case 1:                       //Player 1
            P1Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;

        case 2:     //Player 2
            P2Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;

        case 3:     //Player 3
            P3Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;

        case 4:     //Player 4
            P4Slider.value      += 0.25f;
            PowerUp.pointPowerUp = 0;
            break;
        }

        switch (TripWires.playerNum)
        {
        case 1:
            P1Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;

        case 2:
            P2Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;

        case 3:
            P3Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;

        case 4:
            P4Slider.value     -= 0.25f;
            TripWires.playerNum = 0;
            break;
        }

        switch (Dynamite.dynaPlayerNum)
        {
        case 1:
            P1Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;

        case 2:
            P2Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;

        case 3:
            P3Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;

        case 4:
            P4Slider.value        -= 0.25f;
            Dynamite.dynaPlayerNum = 0;
            break;
        }
    }
Beispiel #14
0
 public void Controls()
 {
     ControlsUI.SetActive(true);
 }