Пример #1
0
 public static void InputControl()
 {
     new Thread(() =>
     {
         while (true)
         {
             if (Console.KeyAvailable)
             {
                 currentKey = Console.ReadKey();
                 if (currentKey.Key.IsOneOf(ConsoleKey.UpArrow, ConsoleKey.DownArrow))
                 {
                     currentPlateDirection = arrowDirection[currentKey.Key.ToString()];
                 }
                 if (currentKey.Key == ConsoleKey.Escape)
                 {
                     Program.IsExit = false;
                 }
             }
             else
             {
                 currentPlateDirection = PlateDirection.no;
             }
             Thread.Sleep(1);
         }
     }).Start();
 }
Пример #2
0
 public static void GameIterating()
 {
     if (Program.IsServer)
     {
         opponentPlateBuffer = (PlateDirection)ServerСonnection.TransferGameData((int)currentPlateDirection);
         opponentPlate.Move(playingField, PlateSide.right, opponentPlateBuffer);
         userPlate.Move(playingField, PlateSide.left, currentPlateDirection);
         ball.Move(playingField);
         ServerСonnection.TransferGameData(ball.GetBallData());
     }
     else
     {
         opponentPlateBuffer = (PlateDirection)ClientСonnection.TransferGameData((int)currentPlateDirection);
         opponentPlate.Move(playingField, PlateSide.left, opponentPlateBuffer);
         userPlate.Move(playingField, PlateSide.right, currentPlateDirection);
         ball.SetBallData(ClientСonnection.TransferGameData());
         ball.RenderingBall(playingField);
     }
 }
Пример #3
0
        public char[,] Move(char[,] playingField, PlateSide plateSide, PlateDirection plateDirection)
        {
            switch (plateDirection)
            {
            case PlateDirection.up:
                if (position > minimumPosition)
                {
                    position -= 1;
                }
                break;

            case PlateDirection.down:
                if (position < maximumPosition)
                {
                    position += 1;
                }
                break;
            }
            return(plateSide switch
            {
                PlateSide.left => RenderingLeftPlate(playingField),
                PlateSide.right => RenderingRightPlate(playingField),
                _ => playingField,
            });