public void GameSuccess() { if (LevelState == EnumLevelState.Gameover) { return; } if (CurrentLevelIndex == NONE_LEVEL_INDEX) { Log.Error("Gameover Only heppen in level"); return; } if (LevelState != EnumLevelState.Normal) { Log.Error("Gameover Only heppen when level is in Normal State,now is {0}", LevelState.ToString()); return; } DataPlayer dataPlayer = GameEntry.Data.GetData <DataPlayer>(); int hp = dataPlayer.HP; int starCount = 0; for (int i = 0; i < starScore.Length; i++) { if (hp >= starScore[i]) { starCount = i + 1; } else { starCount = i; break; } } SetLevelRecord(CurrentLevelIndex, starCount); ChangeLevelState(EnumLevelState.Gameover); GameEntry.Event.Fire(this, GameoverEventArgs.Create(EnumGameOverType.Success, starCount)); }
public void GameFail() { if (LevelState == EnumLevelState.Gameover) { return; } if (CurrentLevelIndex == NONE_LEVEL_INDEX) { Log.Error("Gameover Only heppen in level"); return; } if (LevelState != EnumLevelState.Normal) { Log.Error("Gameover Only heppen when level is in Normal State,now is {0}", LevelState.ToString()); return; } ChangeLevelState(EnumLevelState.Gameover); GameEntry.Event.Fire(this, GameoverEventArgs.Create(EnumGameOverType.Fail, 0)); }