Beispiel #1
0
        static void Main()
        {
            Console.Title = "2048 Game. Keys - Up, Down, Right, Left.";
            DR game = new DR();

            game.Run();
        }
Beispiel #2
0
        private bool Update(Direction dir)
        {
            ulong score;
            bool  isUpdated = DR.Update(this.Board, dir, out score);

            this.Score += score;
            return(isUpdated);
        }
Beispiel #3
0
        private bool IsDead()
        {
            ulong score;

            foreach (Direction dir in new Direction[] { Direction.Down, Direction.Up, Direction.Left, Direction.Right })
            {
                ulong[,] clone = (ulong[, ])Board.Clone();
                if (DR.Update(clone, dir, out score))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #4
0
 private void Display()
 {
     Console.Clear();
     Console.WriteLine();
     for (int i = 0; i < nRows; i++)
     {
         for (int j = 0; j < nCols; j++)
         {
             using (new ColorOutput(DR.GetNumberColor(Board[i, j])))
             {
                 Console.Write(string.Format("{0,6}", Board[i, j]));
             }
         }
         Console.WriteLine();
         Console.WriteLine();
     }
     Console.WriteLine("Score: {0}", this.Score);
     Console.WriteLine();
 }