예제 #1
0
    private IEnumerator DeathDelayAndReload()
    {
        UpdateUI();

        yield return(new WaitForSeconds(deathDelay));

        numberCoins -= coinsThisLevel;
        ResetCoinsFromThisLevel();

        UpdateUI();

        if (playerLives <= 0)
        {
            GameOverScreen gameOverScreen = Resources.FindObjectsOfTypeAll <GameOverScreen>()[0];

            gameOverScreen.SetActive();
        }
        else
        {
            int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            SceneManager.LoadScene(currentSceneIndex);
        }

        initialUIUpdated = false;
    }
예제 #2
0
    public void GameOver()
    {
        SetHighScore();

        Text GameOverMessage = GameOverScreen.transform.GetChild(1).GetComponent <Text>();

        if (PlayerScore == PlayerPrefs.GetInt("High Score") && PlayerScore != 0)
        {
            GameOverMessage.text = "HIGH SCORE!";
        }
        else
        {
            if (PlayerScore >= 500 && PlayerScore < 1500)
            {
                GameOverMessage.text = "Not bad";
            }
            else if (PlayerScore >= 1500 && PlayerScore < 3000)
            {
                GameOverMessage.text = "Pshttt you got lucky";
            }
            else if (PlayerScore >= 3000)
            {
                GameOverMessage.text = "DAMN SON!";
            }
        }

        PauseMenuScreen.SetActive(false);
        GameUIScreen.SetActive(false);
        GameOverScreen.SetActive(true);
        GameOverFlag = true; //possibly useless. Check if removing break game.
    }
예제 #3
0
    public void RestartGame()
    {
        Debug.Log("Starting game...");
        Time.timeScale = 1;
        VictoryScreen.SetActive(false);
        GameOverScreen.SetActive(false);

        Money = GetComponent <ConfiguraionLoader>().DefaultMoney;
        Lives = GetComponent <ConfiguraionLoader>().DefaultLives;

        foreach (Transform child in EnemiesParent.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        foreach (Transform child in ProjectileParent.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        foreach (Transform child in TowersParent.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        GetComponent <WaveController>().ResetGame();
    }
예제 #4
0
    private void GameSetup()
    {
        GameOverScreen.SetActive(false);

        GameTimer -= Time.deltaTime;
        GameTimerText.SetText("GAME START IN: " + GameTimer.ToString("F0"));
        if (GameTimer < 0)
        {
            if (Client.PlayerNum == 1)
            {
                playerUI = UIs[0];
                playerUI.SetActive(true);
                Turn = true;
            }
            else if (Client.PlayerNum == 2)
            {
                playerUI = UIs[1];
                playerUI.SetActive(true);
                Turn = false;
            }

            GameTimer         = gameTime;
            ScoreText.enabled = true;
            TurnText.SetActive(true);
            GameReady = true;
        }
    }
예제 #5
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        mainMenu.SetActive(true);
        hud.SetActive(false);
        gameOverScreen.SetActive(false);
        gameBeingPlayed = false;
    }
예제 #6
0
 public void desactiveAllScreen()
 {
     UIScreen.SetActive(false);
     GameOverScreen.SetActive(false);
     LogoScreen.SetActive(false);
     MenuScreen.SetActive(false);
     CronomeScreen.SetActive(false);
     creditScreen.SetActive(false);
 }
 void Start()
 {
     cardMan            = gameObject.GetComponent <CardsManager>();
     p1But.interactable = false;
     p2But.interactable = false;
     MainMenuScreen.SetActive(true);
     GameScreen.SetActive(false);
     GameOverScreen.SetActive(false);
     CamAnim.SetBool("GameStarted", false);
 }
예제 #8
0
    private void GameOver()
    {
        GameOverScreen.transform.GetChild(0).GetComponent <TextMeshProUGUI>().SetText("Score: " + Score);
        GameOverScreen.SetActive(true);
        Client.SendActionToServer((uint)DataCodes.END_GAME);

        // turn off the client component.
        Client.enabled = false;

        runOnce = true;
    }
예제 #9
0
 //Initialize after each another rebirth
 public void NextPlay()
 {
     IsGameOver = false;
     GameOverScreen.SetActive(false);
     cam.backgroundColor = Random.ColorHSV();
     StartButton.gameObject.SetActive(true);
     ShopButton.gameObject.SetActive(true);
     Logo.gameObject.SetActive(true);
     Hits = 0;
     enemies.StartCoroutine(enemies.Generate());
     if (!StartButton.IsActive() || !ShopButton.IsActive())
     {
         this.gameObject.SetActive(true);
     }
 }
예제 #10
0
    // refresh all boxes and lines, and local score
    public override void NewGame()
    {
        FirstScore  = 0;
        SecondScore = 0;

        GameOverScreen.SetActive(false);
        MyHUD.SetActive(true);

        foreach (S_Box b in MyBoxes)
        {
            b.Refresh();
        }

        foreach (S_Line l in MyLines)
        {
            l.HardOccupy(false);
        }
    }
예제 #11
0
    //Implements death after falling for too long
    public IEnumerator DeadByFall()
    {
        if (IsFalling() && !Jump())
        {
            yield return(new WaitForSeconds(1.5f));

            CloudsDestroyer();
            EnemiesDestroyer();
            IsGameOver = true;
            PointsForGameOverScreen         = CurrentPoints;
            cam.gameObject.transform.parent = null;
            cam.transform.position          = new Vector2(0f, 0f);
            this.gameObject.SetActive(false);
            gameObject.transform.position = new Vector3(0.0f, -4.3f, 0.0f);
            enemies.StopAllCoroutines();
            CurrentPointsText.canvasRenderer.gameObject.SetActive(false);
            CloudsGenerator.transform.position  = new Vector2(0f, 2f);
            EnemiesGenerator.transform.position = new Vector2(0f, 2f);
            if (PlayerPrefs.HasKey("All points"))
            {
                Points = CurrentPoints + PlayerPrefs.GetInt("All points");
            }
            else
            {
                Debug.Log("Error, no key");
            }
            PlayerPrefs.SetInt("All points", Points);
            sm.points     = Points;
            CurrentPoints = 0;
            Hits          = 0;
            DiedByFall    = true;

            int range = Random.Range(0, 2);
            if (range == 1)
            {
                ShowAd();
            }

            if (IsGameOver)
            {
                GameOverScreen.SetActive(true);
            }
        }
    }
 public void GameOver()
 {
     TurnText.text      = "Game Over";
     p1But.interactable = false;
     p2But.interactable = false;
     if (cardMan.p1Cards.Count > cardMan.p2Cards.Count)
     {
         GameOverText.text = "Player 1 Wins!";
     }
     else if (cardMan.p1Cards.Count < cardMan.p2Cards.Count)
     {
         GameOverText.text = "Player 2 Wins!";
     }
     else if (cardMan.p1Cards.Count == cardMan.p2Cards.Count)
     {
         GameOverText.text = "Game Draw!";
     }
     GameOverScreen.SetActive(true);
 }
예제 #13
0
 //Implements death after collision
 public void DeadByCollision(Collision2D col)
 {
     Hits++;
     if (Hits == 2 || this.gameObject.transform.position.y <= -4.5f || col.gameObject.tag == "Enemy")
     {
         //Gamepley stuff
         IsGameOver = true;
         PointsForGameOverScreen         = CurrentPoints;
         gameObject.transform.position   = new Vector3(0.0f, -4.3f, 0.0f);
         cam.gameObject.transform.parent = null;
         cam.gameObject.SetActive(true);
         gameObject.SetActive(false);
         enemies.StopAllCoroutines();
         CloudsGenerator.transform.position  = new Vector2(0f, 2f);
         EnemiesGenerator.transform.position = new Vector2(0f, 2f);
         cam.transform.position = new Vector2(0f, 0f);
         Hits = 0;
         CloudsDestroyer();
         EnemiesDestroyer();
         //Saving stuff
         if (PlayerPrefs.HasKey("All points"))
         {
             Points = CurrentPoints + PlayerPrefs.GetInt("All points");
         }
         else
         {
             Debug.Log("error, no key");
         }
         PlayerPrefs.SetInt("All points", Points);
         sm.points     = Points;
         CurrentPoints = 0;
         //UI stuff
         CurrentPointsText.canvasRenderer.gameObject.SetActive(false);
         if (IsGameOver)
         {
             GameOverScreen.SetActive(true);
         }
     }
 }
예제 #14
0
    //Class Methods
    private void Start()
    {
        Time.timeScale = 1f;

        PlayerScore        = 0;
        AsteroidShootScore = 10;
        AsteroidsPool      = new GameObject[20];
        MusicSource        = GetComponent <AudioSource>();

        GameOverFlag = PauseFlag = Muted = false;

        MusicSource.Play();

        GameUIScreen.SetActive(true);
        GameOverScreen.SetActive(false);
        PauseMenuScreen.SetActive(false);

        //SelectBackground();

        SetHighScore();

        AsteroidPool();
    }
예제 #15
0
 private void GameOver()
 {
     Debug.Log("Game Over");
     Time.timeScale = 0;
     GameOverScreen.SetActive(true);
 }
예제 #16
0
 //controlls which screen is online
 private void ScreenController(int i)
 {
     arrowScreen.SetActive(0 == i);
     InstructionScreen.SetActive(1 == i);
     GameOverScreen.SetActive(2 == i);
 }
예제 #17
0
 protected override void GameOver()
 {
     GameOverScreen.SetActive(true);
     MyHUD.SetActive(false);
 }