示例#1
0
        void Draw(int playerIndex, Game.Core.Interfaces.Location.Models.ILocation location, MoveDirection direction)
        {
            Console.Clear();

            // Raise IDrawingObject's event before the object is drawn.
            var handler = OnDrawHandler;

            if (handler != null && playerIndex > 0)
            {
                //direction
                handler(playerIndex, direction);
                Console.WriteLine("Player moved " + playerIndex.ToString());
            }
            else
            {
                Console.WriteLine("Press any key to start");
            }
            for (int i = 0; i < location.Height; i++)
            {
                for (int j = 0; j < location.Width; j++)
                {
                    var layouts = location.GetFields(i, j).ToArray();
                    Console.Write(" | " + (int)layouts.Last().Type);
                }
                Console.WriteLine(" |");
            }
        }
示例#2
0
        public void DrawLocation(Game.Core.Interfaces.Location.Models.ILocation location)
        {
            Draw(0, location, MoveDirection.None);
            ConsoleKeyInfo info = Console.ReadKey();

            while (info.Key != ConsoleKey.Escape)
            {
                for (int playerIndex = 1; playerIndex <= location.PlayerCount; playerIndex++)
                {
                    var direction = getMoveDirection(info.Key);
                    Console.WriteLine("Pressed: " + info.Key + ", Move Direction: " + direction);
                    Draw(playerIndex, location, direction);                   //event
                    info = Console.ReadKey();
                }
            }
        }