protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titlescreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height),
                                 Color.White);
            }
            if (gameState == GameStates.GameLobby)
            {
                GameLobby.Draw(spriteBatch, sf);
                ChatManager.Draw(spriteBatch, sf, chatBackground);
            }
            if (gameState == GameStates.PlayingState)
            {
                if (currentMap == "SnowMap")
                {
                    spriteBatch.Draw(snowMountainBackground,
                                     new Rectangle(0, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height),
                                     Color.White);
                    collisionManager.Draw(spriteBatch, snowy4block, snowy8block);
                }
                if (currentMap == "ForestMap")
                {
                    spriteBatch.Draw(greenForestBackground,
                                     new Rectangle(0, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height),
                                     Color.White);
                    collisionManager.Draw(spriteBatch, forest4block, forest8block);
                }
                Player.Draw(spriteBatch);
                shotManager.Draw(spriteBatch);
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.Title = "Client";
            Console.WriteLine("EnterIp");
            var a = Console.ReadLine();

            Console.WriteLine("Подключение к серверу...");
            socket.Connect(a, 2048);
            Console.WriteLine("Подключено");
            Thread.Sleep(1000);
            Console.Clear();

            Console.WriteLine("Введите спрайт");
            char spr = Convert.ToChar(Console.ReadLine());

            Console.Clear();

            Console.WriteLine("Выберите цвет");
            for (int i = 0; i <= 14; i++)
            {
                Console.ForegroundColor = (ConsoleColor)i;
                Console.WriteLine(i);
            }
            Console.ResetColor();
            ConsoleColor clr = (ConsoleColor)int.Parse(Console.ReadLine());

            Console.Clear();

            int x = random.Next(1, 19);
            int y = random.Next(1, 19);

            Console.WriteLine("Получение идентификатора");
            SendPacket(PacketInfo.ID);
            int id = ReceivePacket();

            Console.WriteLine("Получен ID :" + id);
            Thread.Sleep(1000);
            Console.Clear();

            player = new Player(x, y, spr, clr, id);
            SendPacket(PacketInfo.Position);

            Task.Run(() => { while (true)
                             {
                                 ReceivePacket();
                             }
                     });

            while (true)
            {
                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.LeftArrow: player.Remove(); player.X = Math.Max(player.X - 1, 0); player.Draw();
                    SendPacket(PacketInfo.Position);
                    break;

                case ConsoleKey.RightArrow: player.Remove(); player.X = Math.Min(player.X + 1, 19); player.Draw();
                    SendPacket(PacketInfo.Position);
                    break;

                case ConsoleKey.UpArrow: player.Remove(); player.Y = Math.Max(player.Y - 1, 0); player.Draw();
                    SendPacket(PacketInfo.Position);
                    break;

                case ConsoleKey.DownArrow: player.Remove(); player.Y = Math.Min(player.Y + 1, 19); player.Draw();
                    SendPacket(PacketInfo.Position);
                    break;
                }

                if (check() != -1)
                {
                    Console.SetCursorPosition(1, 22);
                    Console.Write("Last Winner: Player" + id);
                }
            }
        }