Esempio n. 1
0
    public void End()   // If player reaches end
    {
        goldCoins = score / scorePerGold;
        SoundManScript.PlaySound("win", false, false, Vector2.zero, 0.6f);
        endCoinObj.GetComponent <GoldSpawner>().SetSpawnLimit(goldCoins);
        persistentDataScript.AddVacation();
        persistentDataScript.SetScore(score);
        for (int i = 0; i < achievements.Count; i++)    // Update achievements
        {
            switch (achievements[i].GetReq())
            {
            case "beattime":
                if (persistentDataScript.GetTime() == 1000)
                {
                    achievements[i].StaticValue(timer);
                    achievements[i].StaticStageReq((int)timer);
                    persistentDataScript.SetTime((int)timer);
                }
                else if (timer < persistentDataScript.GetTime())
                {
                    achievements[i].SetValue(timer);
                    persistentDataScript.SetTime((int)timer);
                }
                break;

            case "beatourtime":
                if (timer < persistentDataScript.GetDevTime())
                {
                    achievements[i].SetValue(timer);
                    List <int> achieve10Reqs = new List <int>();
                    achieve10Reqs.Add(0);
                    achievements[i].SetAchievement(0, "Beat The Devs!", "beatourtime", "You beat our time! \n(" + persistentDataScript.GetDevTime() + ")", achieve10Reqs);
                }
                break;

            case "goldget":
                achievements[i].SetValue(goldCoins);
                break;

            case "complete":
                achievements[i].AddValue(1);
                break;
            }
        }
        for (int i = 0; i < endAnimAnimators.Count; i++)
        {
            endAnimAnimators[i].enabled = true;
        }
        SoundManScript.PlaySound("chestopen", false, false, Vector3.zero, 0.7f);
        persistentDataScript.SetAchievements(achievements);
        END = true;
    }