Ejemplo n.º 1
0
    private void GameOver()
    {
        // Player Won the level
        if (IsLevelClear())
        {
            PlayerInfo playerInfo = PlayerInfoManager.GetCurrentPlayerInfo();

            TimeSpan time    = TimeSpan.FromSeconds(timer.totalTime);
            TimeSpan oldTime = playerInfo.Levels[levelIndex].time;

            //Actualizar récord si se ha batido o si no existia(oldTime == 0)
            if (time < oldTime || Math.Abs(oldTime.TotalSeconds) < float.Epsilon)
            {
                playerInfo.Levels[levelIndex].time = time;
            }

            // Desbloquear siguiente nivel si es necesario  si quedan niveles por desbloquear
            if ((levelIndex + 1) < GameManager.GetLevelsCount())
            {
                playerInfo.Levels[levelIndex + 1].unlocked = true;
            }
            PlayerInfoManager.SetCurrentPlayerInfo(playerInfo);
            GameManager.Save();
        }
        //Ir a la pantalla de selección de nivel
        GameManager.ChangeScene(Scene.SELECT_LEVEL);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Set panel whit all player´s info
 /// </summary>
 /// <param name="status"></param>
 public void UpdateHUD()
 {
     Camera.main.GetComponent <SoundEffectsMenu>().PlayEffect(pageBook);
     close.gameObject.SetActive(true);
     panel.SetActive(true);
     info.gameObject.SetActive(true);
     nameTxt.gameObject.SetActive(true);
     playerName = string.IsNullOrEmpty(PlayerInfoManager.GetCurrentPlayerInfo().Name) ? "Player": PlayerInfoManager.GetCurrentPlayerInfo().Name;
     TextName();
     BestTime(PlayerInfoManager.GetCurrentPlayerInfo().Levels[levelSelector.CurrentLevelIndex].time);
     //record.gameObject.SetActive(status);
     //TextRecord(GameManager.instancia.BestRecord(GameManager.instancia.currLevel),GameManager.instancia.BestRecordMan(GameManager.instancia.currLevel));
 }
Ejemplo n.º 3
0
    private void Start()
    {
        CurrentLevelIndex = 0;
        soundEffects      = Camera.main.GetComponent <SoundEffectsMenu>();
        levelsInfo        = PlayerInfoManager.GetCurrentPlayerInfo().Levels;
        Assert.IsNotNull(levelsInfo, "Error: Couldn't find the levelsInfo in LevelSelector\n<color=yellow>Tip: is PlayerInfoManager initialized?(Have you used/created GameManager?)</color>");

        int index = 0;

        for (int i = 1; i < levelsInfo.Length; i++)
        {
            if (levelsInfo[i].unlocked)
            {
                activateLevels.FastActiveSprite(index++);
            }
        }

        hud.UpdateHUD();
    }