예제 #1
0
        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));
        }
예제 #2
0
        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));
        }