private void Victory()
    {
        victory.SetActive(true);
        points_victory.text = "Points: " + coins;

        JSONLevel l = HandleJSON.GetLevels()[0];

        if (coins > l.player_score)
        {
            JSONPlayer player = HandleJSON.GetPlayer();
            player.coins += coins - l.player_score;
            HandleJSON.WriteJsonPlayer(player);
            l.player_score = coins;
            HandleJSON.WriteJsonLevel(l);
        }

        if (coins >= l.gold)
        {
            trophy.text = "Gold";
        }
        else if (coins >= l.silver)
        {
            trophy.text = "Silver";
        }
        else if (coins >= l.bronze)
        {
            trophy.text = "Bronze";
        }
        else
        {
            trophy.text = "";
        }
    }
Exemple #2
0
 public void OpenLevelSelect()
 {
     levelSelectPanel.SetActive(true);
     menu.SetActive(false);
     if (prefabSpawn.childCount == 0)
     {
         JSONLevel[] levels = HandleJSON.GetLevels();
         for (int i = 0; i < levels.Length; i++)
         {
             if (levels[i].player_score < levels[i].bronze)
             {
                 break;
             }
             LevelSelectUIItem p = Instantiate <LevelSelectUIItem>(prefab, prefabSpawn);
             p.SetItem(levels[i].level_name, levels[i].GetTrophy(), levels[i].player_score);
         }
     }
 }
Exemple #3
0
 public void NextLevel()
 {
     if (endless)
     {
         progress++;
         Setup();
     }
     else
     {
         int length = HandleJSON.GetLevels().Length;
         if (progress < length - 1)
         {
             JSONPlayer p = HandleJSON.GetPlayer();
             p.current_level = progress;
             HandleJSON.WriteJsonPlayer(p);
             progress++;
             Setup();
         }
         else
         {
             SceneManager.LoadScene("Scene_Main_Menu");
         }
     }
 }
Exemple #4
0
    void Setup()
    {
        if (!endless)
        {
            progress = HandleJSON.GetPlayer().current_level;
            JSONLevel[] levels = HandleJSON.GetLevels();
            if (progress > levels.Length)
            {
                progress = levels.Length - 1;
            }
            JSONWave[] jws      = levels[progress].waves;
            Wave[]     fromJSON = new Wave[jws.Length];
            for (int i = 0; i < jws.Length; i++)
            {
                fromJSON[i] = new Wave(jws[i]);
            }

            WaveManager wM = GetComponentInChildren <WaveManager>();
            wM.SetWaves(fromJSON);
        }
        else
        {
            Wave[] w = new Wave[progress];
            for (int i = 0; i < w.Length; i++)
            {
                int[] units = new int[progress];
                for (int x = 0; x < units.Length; x++)
                {
                    units[x] = Random.Range(0, 3);
                }
                w[i] = new Wave(units, Random.Range(2, 8), (progress % 10 == 0) ? 1 : 0);
            }
            WaveManager wM = GetComponentInChildren <WaveManager>();
            wM.SetWaves(w);
        }
    }