示例#1
0
 void Start()
 {
     //Sets starting Health variable to calculate later on the actual health that player has.
     FindPlayer();
     if (player != null)
     {
         startHealth = player.GetComponent <Stats>().currentHP;
     }
 }
示例#2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            instance.UserProfile.deaths++;
            instance.SaveUserProfile();
            SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
        }
        enemiesInStage     = GetComponent <scr_WaveSystem>().enemiesInStage;
        totalEnemiesKilled = enemiesKilled / enemiesInStage;

        if (gameOver)
        {
            gameOverText.SetActive(true);
            if (Input.GetKeyDown(KeyCode.Space))
            {
                instance.UserProfile.deaths++;
                instance.SaveUserProfile();
                SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
            }
        }
        if (bossKill)
        {
            if (!HUDFade.active)
            {
                HUDFade.SetActive(true);
            }

            instance.UpdateHighscoresFile(instance.UserProfile.ProfileName, SceneManager.GetActiveScene().name, instance.UserProfile.playerStats.ScoreValue);
            instance.UserProfile.CurrentLevelName = SceneManager.GetActiveScene().name;
            instance.SaveUserProfile();
            HUDcharacter.Play("bossWin");
            player.locked = true;
            player.GetComponent <Rigidbody>().velocity = transform.forward * leaveSpeed;
            leaveSpeed += 2 * Time.deltaTime;
            if (boundary.GetComponent <scr_Dest_Boundary>().playerExit)
            {
                player.GetComponent <Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
                transition = true;
                bossKill   = false;
            }
            //levelUI.SetActive(true);
            //TransitionCam.SetActive (true);
        }

        if (transition)
        {
            player.locked = true;
            clearScreen.SetActive(true);
            Debug.Log(totalEnemiesKilled);
            gameClearTexts[0].text         = "500";
            gameClearTexts[1].text         = (Math.Round(totalEnemiesKilled, 2) * 100).ToString() + "%";
            gameClearTexts[2].text         = "x" + player.stats.difficulty.ToString();
            gameClearTexts[3].text         = Math.Round((500 * player.stats.difficulty * totalEnemiesKilled), 0).ToString();
            gameClearTexts[4].text         = instance.UserProfile.playerStats.ScoreValue.ToString();
            instance.UserProfile.Crystals += (int)Math.Round((500 * player.stats.difficulty * totalEnemiesKilled), 0);
            CarryStats();
            if (Input.GetKeyDown(KeyCode.Space))
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1, LoadSceneMode.Single);
            }
        }
        UpdateHealthText();
    }