Example #1
0
    void Update()
    {
        if (Health.Value == 3f)
        {
            Heart3.SetActive(true);
            Heart2.SetActive(true);
            Heart1.SetActive(true);
        }

        if (Health.Value == 2f)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(true);
            Heart1.SetActive(true);
        }

        if (Health.Value == 1f)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(true);
        }
        if (Health.Value <= 0f)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(false);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if (scoreIncreasing) {
        //    scoreCounts += pointPerSecond * Time.deltaTime;
        //}
        //extra heart indicator
        if ((heartCounterText != null) && (HeartCount > 3))
        {
            //heartCounterText.GetComponent<Text>().enabled = true;
            heartCounterText.GetComponent <Text>().text = "x" + HeartCount;
        }
        else
        {
            heartCounterText.GetComponent <Text>().text = "";
        }

        if (scoreCounts > highScoreCounts)
        {
            highScoreCounts = scoreCounts;
            PlayerPrefs.SetFloat("HighScores", highScoreCounts);
        }

        scoreText.text     = "Coins: " + Mathf.Round(scoreCounts);
        highScoreText.text = "High Score: " + Mathf.Round(highScoreCounts);
        gameScore.text     = "" + Mathf.Round(gameScoreCounts);

        if (HeartCount == 3)
        {
            Heart3.SetActive(true);
            Heart2.SetActive(false);
            Heart1.SetActive(false);
            Heart0.SetActive(false);
        }
        else if (HeartCount == 2)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(true);
            Heart1.SetActive(false);
            Heart0.SetActive(false);
        }
        else if (HeartCount == 1)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(true);
            Heart0.SetActive(false);
        }
        else if (HeartCount == 0)
        {
            HeartCount = 3;
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(false);
            Heart0.SetActive(true);

            gameManager.RestartGame();
        }
    }
Example #3
0
        public void Play_Start_Click(object sender, EventArgs e) // Function switches on a game
        {
            LevelUpGif.BringToFront();
            if (firstPlane)
            {
                Heart1.Visible = true;
                Heart2.Visible = true;
                Heart3.Visible = true;
            }
            else if (secondPlane)
            {
                this.Controls.Remove(Heart1);
                Heart1.Dispose();
                Heart2.Visible = true;
                Heart3.Visible = true;
            }
            else if (thirdPlane)
            {
                this.Controls.Remove(Heart1);
                Heart1.Dispose();
                this.Controls.Remove(Heart2);
                Heart2.Dispose();
                Heart3.Visible = true;
            }


            if (isstarted)
            {
                if (paused)
                {
                    StartTimers();
                    Menu_Off();
                }
            }
            if (!isstarted)
            {
                isstarted = true;
                Menu_Off();
                Player.Visible      = true;
                Change_Off.Visible  = false;
                PointsLabel.Visible = true;
                StarsMoveTimer.Start();

                for (int i = 0; i < stars.Length; i++)
                {
                    stars[i].Visible = true;
                }


                enemyMoveTimer.Start();
            }
        }
Example #4
0
        public void EnemyBulletsCollision()
        {
            for (int i = 0; i < enemies.Count; i++)
            {
                if (thirdPlane && enemies[i].EnemyBullet.EnemyBulletPicture != null && enemies[i].EnemyBullet.EnemyBulletPicture.Bounds.IntersectsWith(Player.Bounds))
                {
                    //destruction of the third heart
                    //gameover
                    enemies[i].EnemyBullet.death();
                    this.Controls.Remove(Heart3);
                    Heart3.Dispose();
                    gameover();
                }
                else if (secondPlane && enemies[i].EnemyBullet.EnemyBulletPicture != null && enemies[i].EnemyBullet.EnemyBulletPicture.Bounds.IntersectsWith(Player.Bounds))
                {
                    HeatCount++;
                    Player.Location = new Point(313, 570);
                    enemies[i].EnemyBullet.death();
                    if (HeatCount == 1)
                    {
                        //destruction of the second heart
                        this.Controls.Remove(Heart2);
                        Heart2.Dispose();
                    }
                    else if (HeatCount == HP)
                    {
                        //destruction of the Third heart
                        //gameover
                        this.Controls.Remove(Heart3);
                        Heart3.Dispose();
                        gameover();
                    }
                }
                else if (firstPlane && enemies[i].EnemyBullet.EnemyBulletPicture != null && enemies[i].EnemyBullet.EnemyBulletPicture.Bounds.IntersectsWith(Player.Bounds))
                {
                    HeatCount++;
                    Player.Location = new Point(313, 570);

                    enemies[i].EnemyBullet.death();

                    if (HeatCount == 1)
                    {
                        //destruction of the first heart
                        this.Controls.Remove(Heart1);
                        Heart1.Dispose();
                    }
                    else if (HeatCount == 2)
                    {
                        //destruction of the second heart
                        this.Controls.Remove(Heart2);
                        Heart2.Dispose();
                    }
                    else if (HeatCount == HP)
                    {
                        //destruction of the third heart
                        //gameover
                        this.Controls.Remove(Heart3);
                        Heart3.Dispose();
                        gameover();
                    }
                }
            }
        }