コード例 #1
0
 public ShowHighScoresState(IHighScoreList ScoreList, GameState ReversionState = null, int[] HighlightPositions = null)
 {
     _ScoreList = ScoreList;
     hs         = _ScoreList.GetScores().ToList();
     HighlightedScorePositions = HighlightPositions ?? new int[] { };
     SelectedScorePosition     = HighlightPositions == null || HighlightPositions.Length == 0 ? 1 : HighlightPositions.First() - 1;
     RevertState = ReversionState;
     double xpoint = 1 + TetrisGame.rgen.NextDouble() * 2;
     double ypoint = 1 + TetrisGame.rgen.NextDouble() * 2;
     //var sib = StandardImageBackgroundGDI.GetStandardBackgroundDrawer(new PointF((float)xpoint, (float)ypoint));
 }
コード例 #2
0
        public override void HandleGameKey(IStateOwner pOwner, GameKeys g)
        {
            GameKeys[] handledKeys = new GameKeys[] { GameKeys.GameKey_Down, GameKeys.GameKey_Drop, GameKeys.GameKey_RotateCW };
            if (!ScrollCompleted)
            {
                IncrementTimediff = new TimeSpan(0, 0, 0, 0, 50);
            }

            else if (ScrollCompleted && handledKeys.Contains(g))
            {
                if (g == GameKeys.GameKey_Drop)
                {
                    //move up...
                    SelectedScorePosition--;
                    if (SelectedScorePosition < 0)
                    {
                        SelectedScorePosition = _ScoreList.MaximumSize;
                    }
                }
                else if (g == GameKeys.GameKey_Down)
                {
                    SelectedScorePosition++;
                    if (SelectedScorePosition > _ScoreList.MaximumSize)
                    {
                        SelectedScorePosition = 0;
                    }
                }
                else if (g == GameKeys.GameKey_RotateCW)
                {
                    //This is where we will enter a "HighscoreDetails" state passing along this one specific high score.
                    var SelectedScore         = _ScoreList.GetScores().ToArray()[SelectedScorePosition];
                    ViewScoreDetailsState vsd = new ViewScoreDetailsState(this, SelectedScore, _BG, SelectedScorePosition + 1);
                    pOwner.CurrentState = vsd;
                }
            }

            else if (RevertState != null)
            {
                pOwner.CurrentState = RevertState;
            }
        }