Esempio n. 1
0
        public static void Update(GameTime gameTime)
        {
            var keyboardState = Keyboard.GetState();
            var mouseState    = Mouse.GetState();

            MouseInterface.Update(gameTime);
            ColumnInterface.Update(gameTime);

            //check mouse state
            if (
                IsMouseStateEated &&
                (
                    mouseState.LeftButton == ButtonState.Pressed ||
                    mouseState.RightButton == ButtonState.Pressed ||
                    mouseState.MiddleButton == ButtonState.Pressed
                )
                )
            {
                IsMouseStateEated = true;
            }
            else
            {
                IsMouseStateEated = false;
            }

            if (SaveLoadInterface.IsShow)
            {
                //Temporaty enable input
                Globals.EnableInputTemporary();
                SaveLoadInterface.Update(gameTime);
                if (IsKeyPressedAndCanInput(keyboardState, Keys.Escape))
                {
                    ShowSaveLoad(false);
                }
                //Restore input
                Globals.RestoreInputDisableState();
            }
            else if (TitleInterface.IsShow)
            {
                //Temporaty enable input
                Globals.EnableInputTemporary();
                TitleInterface.Update(gameTime);
                //Restore input
                Globals.RestoreInputDisableState();
            }
            else if (SystemInterface.IsShow)
            {
                //Temporaty enable input
                Globals.EnableInputTemporary();
                SystemInterface.Update(gameTime);
                if (IsKeyPressedAndCanInput(keyboardState, Keys.Escape))
                {
                    ShowSystem(false);
                }
                //Restore input
                Globals.RestoreInputDisableState();
            }
            else if (LittleMapInterface.IsShow)
            {
                //Temporaty enable input
                Globals.EnableInputTemporary();
                LittleMapInterface.Update(gameTime);
                if (IsShowLittleMapKeyPressed(keyboardState) ||
                    IsKeyPressedAndCanInput(keyboardState, Keys.Escape))
                {
                    LittleMapInterface.IsShow = false;
                }
                //Restore input
                Globals.RestoreInputDisableState();
            }
            else if (SelectionInterface.IsShow)
            {
                //Temporaty enable input
                Globals.EnableInputTemporary();

                IsMouseStateEated = true;
                SelectionInterface.Update(gameTime);

                //Restore input
                Globals.RestoreInputDisableState();
            }
            else if (DialogInterface.IsShow)
            {
                //Temporaty enable input
                Globals.EnableInputTemporary();

                IsMouseStateEated = true;
                if (DialogInterface.IsInSelecting)
                {
                    DialogInterface.Update(gameTime);
                    //Check wheathe selection ended after updated
                    if (!DialogInterface.IsInSelecting)
                    {
                        DialogInterface.IsShow = false;
                    }
                }
                else
                {
                    DialogInterface.Update(gameTime);
                    if (IsTalkNext())
                    {
                        if (!DialogInterface.NextPage())
                        {
                            DialogInterface.IsShow = false;
                        }
                    }
                }
                //Restore input
                Globals.RestoreInputDisableState();
            }
            else
            {
                if (BuyInterface.IsShow)
                {
                    //Temporaty enable input
                    Globals.EnableInputTemporary();

                    BuyInterface.Update(gameTime);
                    GoodsInterface.Update(gameTime);
                    BottomInterface.Update(gameTime);
                    IsMouseStateEated = true;

                    if (IsKeyPressedAndCanInput(keyboardState, Keys.Escape))
                    {
                        EndBuyGoods();
                    }
                    //Restore input
                    Globals.RestoreInputDisableState();
                }
                else
                {
                    if (IsShowLittleMapKeyPressed(keyboardState))
                    {
                        ShowAllPanels(false);
                        LittleMapInterface.IsShow = true;
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.Escape))
                    {
                        if (HasPanelsShow())
                        {
                            ShowAllPanels(false);
                        }
                        else
                        {
                            ShowSystem();
                        }
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.F1))
                    {
                        ToggleStateGuiShow();
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.F2))
                    {
                        ToggleEquipGuiShow();
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.F3))
                    {
                        ToggleXiuLianGuiShow();
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.F5))
                    {
                        ToggleGoodsGuiShow();
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.F6))
                    {
                        ToggleMagicGuiShow();
                    }
                    else if (IsKeyPressedAndCanInput(keyboardState, Keys.F7))
                    {
                        ToggleMemoGuiShow();
                    }

                    TopInterface.Update(gameTime);
                    BottomInterface.Update(gameTime);
                    MagicInterface.Update(gameTime);
                    XiuLianInterface.Update(gameTime);
                    GoodsInterface.Update(gameTime);
                    MemoInterface.Update(gameTime);
                    StateInterface.Update(gameTime);
                    EquipInterface.Update(gameTime);
                    ToolTipInterface.Update(gameTime);
                }

                if (!Globals.TheGame.IsGamePlayPaused)
                {
                    TimerInterface.Update(gameTime);
                }

                if (IsDropped)
                {
                    IsDropped = false;
                    if (DragDropSourceItem != null)
                    {
                        DragDropSourceItem.IsShow = true;
                    }
                    if (DragDropSourceTexture != null &&
                        DragDropSourceTexture.Data != null)
                    {
                        _dropSound.Play();
                    }
                    DragDropSourceItem    = null;
                    DragDropSourceTexture = null;
                }
            }

            MessageInterface.Update(gameTime);

            _lastMouseState    = mouseState;
            _lastKeyboardState = keyboardState;
        }