Пример #1
0
        public Game1()
        {
            Window.AllowUserResizing = true;
            Console.WriteLine(Window.ClientBounds);

            _graphics = new GraphicsDeviceManager(this);
            GraphicsDevice.Viewport = new Viewport(0,0, 1280, 720);
            _graphics.IsFullScreen = false;
            //#if WINDOWS
            _graphics.PreferredBackBufferHeight = 720;
            _graphics.PreferredBackBufferWidth = 1280;
            //#endif
            keyboardManager = new KeyboardManager(this);
        }
        public void Update(GameTime gameTime, KeyboardManager keyboardManager)
        {
            keyOld = keyNew;
            keyNew = Keyboard.GetState();
            keyTest.Update();
            keyboardManager.Update(gameTime);
            chatString = keyboardManager.Text;
            chatString = keyTest.output;
            if(keyNew.IsKeyDown(Keys.Enter) && keyOld.IsKeyUp(Keys.Enter))
            {
                if(ChatMode)
                {
                    ChatMode = false;
                    keyboardManager.Text = ": ";
                    keyTest.output = ": ";
                    string chatMessage = chatString.Substring(2);
                    if(chatMessage.Length > 0)
                    {
                        if(chatMessage.Substring(0, 1) == ".")
                        {
                            //commands
                            if(chatMessage.Length > 2)
                            {
                                switch(chatMessage.Substring(1).ToUpper())
                                {
                                    case "POKEMON":
                                        IsAdmin = true;
                                        AddCommandChatMessage("Admin mode activated");
                                        return;
                                    case "START":
                                        if(IsAdmin)
                                        {
                                            AddCommandChatMessage("Starting Game");
                                            NetManager.SendMessageParams(NetDeliveryMethod.ReliableOrdered,
                                                                        (int)DataType.StartGame
                                            );
                                        }
                                        else
                                            AddCommandChatMessage("You are not Admin...");

                                        break;

                                }
                            }

                        }
                        NetManager.SendMessageParamsStringsOnly(NetDeliveryMethod.ReliableOrdered,
                                                                              (int)DataType.ChatMessage,
                                                                              DataStorage.GetLocalPlayerConfig().UserName,
                                                                              chatMessage
                        );

                        AddChatMessage(DataStorage.GetLocalPlayerConfig().UserName, chatMessage);
                        //NetOutgoingMessage oMsg = NetManager.CreateMessage();
                        //oMsg.Write((int)DataType.ChatMessage);
                        //oMsg.Write(chatMessage);
                        //NetManager.SendMessage(NetDeliveryMethod.ReliableOrdered, oMsg);
                    }
                    else
                    {
                        keyboardManager.Text = ": ";
                        keyTest.output = ": ";
                    }
                }
                else
                {
                    ChatMode = true;
                    keyboardManager.Text = ": ";
                    keyTest.output = ": ";
                }
            }
        }