private void InformScoreAdded()
    {
        int scoreAdded = GetScoreAddedForMissileDestruction();
        HUDInventoryAndScoreController controller = (HUDInventoryAndScoreController)Object.FindObjectOfType(typeof(HUDInventoryAndScoreController));

        controller.AddScore(scoreAdded);
    }
    public void OnEnterNewHighScore()
    {
        string initials = GetComponent <InputField>().text;

        if (initials == null || initials.Length == 0)
        {
            AccessDeniedSound.Play();
            return;
        }

        HUDInventoryAndScoreController scoreController = (HUDInventoryAndScoreController)Object.FindObjectOfType(typeof(HUDInventoryAndScoreController));
        int score = scoreController.GetCurrentScore();

        HighScoreUtils.AddHighScore(initials, score);

        SceneManager.LoadScene("HighScoreScene");
    }
    private bool IsNewHighScore()
    {
        HUDInventoryAndScoreController scoreController = (HUDInventoryAndScoreController)Object.FindObjectOfType(typeof(HUDInventoryAndScoreController));
        int score = scoreController.GetCurrentScore();
        SortedList <int, HighScore> highScores = HighScoreUtils.GetHighScores();

        if (highScores.Count < 10)
        {
            return(true);
        }

        foreach (HighScore highScore in highScores.Values)
        {
            if (score >= highScore.Score)
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 4
0
    public IEnumerator ShowPointsTextInAndOut(float t, int missilesLeft)
    {
        // Don't show for first level.
        if (Level.GetCurrentLevel() != 1)
        {
            int lastLevel = Level.GetCurrentLevel() - 1;
            LevelCompleteText.text = "LEVEL " + lastLevel + " COMPLETE";

            HUDInventoryAndScoreController controller =
                (HUDInventoryAndScoreController)Object.FindObjectOfType(typeof(HUDInventoryAndScoreController));

            int citiesNotDestroyed = CitiesNotDestroyed();
            CitiesLeft.text = "" + citiesNotDestroyed;
            int pointsPerCity = GetPointsPerCity();
            PointsPerCity.text = pointsPerCity + " POINTS";
            // Add cities score
            controller.AddScore(citiesNotDestroyed * pointsPerCity);

            MissilesLeft.text = "" + missilesLeft;
            int pointsPerMissile = GetPointsPerMissile();
            PointsPerMissile.text = pointsPerMissile + " POINTS";
            // Add missiles score
            controller.AddScore(missilesLeft * pointsPerMissile);

            PointInfoGroup.SetActive(true);
            yield return(new WaitForSeconds(t));

            PointInfoGroup.SetActive(false);
        }
        yield return(null);

        int newLevel = Level.GetCurrentLevel();

        LevelText.gameObject.SetActive(true);
        LevelText.text = string.Format(LEVEL_TEXT, newLevel);

        AirRaidSiren.Play();
        StartCoroutine(FadeLevelTextInAndOut(2f));
    }
Esempio n. 5
0
    private int GetMissilesLeft()
    {
        HUDInventoryAndScoreController controller = (HUDInventoryAndScoreController)Object.FindObjectOfType(typeof(HUDInventoryAndScoreController));

        return(controller.GetNumMissilesLeft());
    }