private void EndLevelSaves(int newScore) { Debug.Log("Save"); var level = _playerState.level; SettingHelper.SetLevelAsCompleted(level); var oldScore = SettingHelper.GetLevelScore(level) .GetOrDefault(0); Debug.Log($"oldScore {oldScore}"); Debug.Log($"newScore: {newScore}"); if (newScore > oldScore) { SettingHelper.SetLevelScore(level, newScore); } for (var i = 1; i <= _playerState.UnlockNext; i++) { SettingHelper.SetLevelAsUnlocked(level + i); } }
private void Awake() { ResourcesHelper.SetFeaturesFromTextFile( string.Format(PlayerFeaturesFile, level.ToString("00")), SetFeature ); _initialCoin = _coin; _gameManager = FindObjectOfType <GameManager>(); Debug.Log($"initial health: {Health}"); Messenger <int> .AddListener(GameEvent.ENEMY_REACH_TARGET, OnDamage); Messenger <int> .AddListener(GameEvent.ENEMY_KILLED, OnEnemyKilled); Messenger <int> .AddListener(GameEvent.TOWER_CREATED, OnTowerCreated); Messenger <int> .AddListener(GameEvent.TOWER_SELLED, OnTowerSelled); Debug.Log($"isLevelCompleted: {SettingHelper.IsLevelCompleted(level).GetOrDefault(false)}"); Debug.Log($"levelScore: {SettingHelper.GetLevelScore(level).GetOrDefault(0)}"); }