Example #1
0
    //// Functions:

    public void StartGame()
    {
        AudioManager.instance.PlayMusic(AudioID.GAME_MUSIC);
        Menu_C.SetActive(false);
        UI_C.SetActive(true);

        missilesForShip = missiles > 9 ? 9 : missiles;
        missiles       -= missilesForShip;

        energyForShip = energy > 9 ? 9 : energy;
        energy       -= energyForShip;

        Instantiate(Ship_Prefab, new Vector3(0f, 0f, 0f), new Quaternion(0f, 0f, 0f, 1f), MainGame).GetComponent <Ship>().StartShip(missilesForShip, energyForShip);

        meteorCount     = 0;
        meteorMaxNumber = 5;

        stars = 0;
        score = 0;

        UpdateStars();
        UpdateScore();

        StartCoroutine(MeteorCreator());
        StartCoroutine(PointsCounter());

        Pause(false);
        StartCoroutine(ShowHint());
    }
Example #2
0
    public void ReturnToMenu()
    {
        StopAllCoroutines();

        this.energy   += energyForShip;
        this.missiles += missilesForShip;

        for (int i = MainGame.childCount - 1; i >= 0; i--)
        {
            Destroy(MainGame.GetChild(i).gameObject);
        }
        Menu_C.SetActive(true);
        UI_C.SetActive(false);

        AudioManager.instance.PlayMusic(AudioID.MENU_MUSIC);
        ShowMenu(GAME_MENU);
    }
Example #3
0
    public void EndGame(int energy, int missiles)
    {
        StopAllCoroutines();

        this.energy   += energy;
        this.missiles += missiles;

        for (int i = MainGame.childCount - 1; i >= 0; i--)
        {
            Destroy(MainGame.GetChild(i).gameObject);
        }
        Menu_C.SetActive(true);
        UI_C.SetActive(false);

        totalStars += stars;
        highScores.Add(score);
        highScores.Sort();
        highScores.RemoveAt(0);

        Save();

        AudioManager.instance.PlayMusic(AudioID.MENU_MUSIC);
        ShowMenu(GAME_MENU);
    }