Exemple #1
0
    //MENU BUTTON CODE
    public void StartGame()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        playerObj.transform.position = PlayerInitialPosition;

        SetCameraParent("Player");

        Countdown.StartAnimation();

        MainMenuPanel.SetActive(false);
        ScorePanel.SetActive(true);
        PulsePanel.SetActive(true);

        for (int i = 0; i < GameObject.FindGameObjectsWithTag("wall").Length; i++)
        {
            Destroy(GameObject.FindGameObjectsWithTag("wall") [i].gameObject);
        }
        for (int i = 0; i < GameObject.FindGameObjectsWithTag("Point").Length; i++)
        {
            Destroy(GameObject.FindGameObjectsWithTag("Point") [i].gameObject);
        }
        SpawnController.SpawnPointSphere();
    }
    // Use this for initialization
    void Start()
    {
        ispaused = false;
        Timer    = 0;
        ScorePanel.SetActive(true);
        isActive                 = true;
        countEnemyScore          = 0;
        countSpider              = 0;
        lifeNum                  = 5;
        score                    = 0;
        textCurrentScore.enabled = true;
        switch (LevelController.levelName)
        {
        case "BtnZen":
            levelName = "Zen";
            break;

        case "BtnClassic":
            levelName = "Classic";
            break;

        case "BtnInsane":
            levelName = "Insane";
            break;

        case "BtnTimeAttack":
            levelName = "TimeAttack";
            break;

        default:
            levelName = "Insane";
            break;
        }
        spawner = Instantiate(SpawnerObject, SpawnerObject.transform.position, Quaternion.identity);
    }
    public void showGameOverPanel()
    {
        if (MainAudioSource.isPlaying && MainAudioSource.clip != bgGameOverClip)
        {
            MainAudioSource.Stop();
            audioSource.PlayOneShot(gameoverClip);
            MainAudioSource.clip = bgGameOverClip;
            MainAudioSource.Play();
        }

        //MainAudioSource.clip = backgroundGameOver;
        GameOverPanel.SetActive(true);
        textScoreLast.text = score.ToString();

        if (score > highscore)
        {
            highscore = score;
        }

        textScoreBest.text = highscore.ToString();

        PlayerPrefs.SetInt("highscore", highscore);

        pauseButton.SetActive(false);
        continueButton.SetActive(false);
        textCurrentScore.enabled = false;
        ScorePanel.SetActive(false);
    }
Exemple #4
0
 public void BackToMainMenu()
 {
     ScorePanel.SetActive(false);
     InfoPanel.SetActive(false);
     WinnerPanel.SetActive(false);
     PausePanel.SetActive(false);
     MenuCam.CameraMode = 1;
     OpenMainMenu();
     Main.PrepareBackground();
 }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        if (GameStartBtnPressed && !Winner)
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                InfoPanel.SetActive(false);
                ScorePanel.SetActive(true);
                Main.StartGame(GameMode);
                if (GameMode == 1 || GameMode == 2)
                {
                    Player2Score.SetActive(true);
                }
                else if (GameMode == 3)
                {
                    Player2Score.SetActive(false);
                }
                GameStartBtnPressed = false;
                GamePaused          = false;
                GameStarted         = true;
            }
            if (Input.GetKey(KeyCode.Escape))
            {
                GameStartBtnPressed = false;
                Winner = false;
                BackToMainMenu();
            }
        }

        if (GameStarted && !GamePaused)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                GamePaused = true;
                PausePanelCtrl(GamePaused);
                Time.timeScale = 0;
            }
        }

        if (GamePaused)
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                GamePaused = false;
                PausePanelCtrl(GamePaused);
                Time.timeScale = 1;
            }
            if (Input.GetKeyDown(KeyCode.Space))
            {
                GamePaused  = false;
                GameStarted = false;
                PausePanelCtrl(GamePaused);
                Time.timeScale = 1;
                BackToMainMenu();
            }
        }

        if (Winner)
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                WinnerPanel.SetActive(false);
                Main.StartGame(GameMode);
                GameStarted = true;
                Winner      = false;
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                WinnerPanel.SetActive(false);
                GameStarted        = false;
                Winner             = false;
                MenuCam.CameraMode = 1;
                BackToMainMenu();
            }
        }
    }