static public void Update(GameTime gt)
        {
            CheckMouse();
            // selectedSprite.position = new Vector2(400,300);
            anyButtonsPressed = false;
            mouseState        = Mouse.GetState();
            keyboardState     = Keyboard.GetState();
            //var wot = keyboardState.GetPressedKeys();
            //String test = "";
            //foreach (var item in wot)
            //{
            //    test += item;
            //    test += " + ";
            //}
            //Console.WriteLine(test);

            if (!KeyboardMouseUtility.AnyButtonsPressed() && Keyboard.GetState().IsKeyDown(Keys.LeftAlt) && Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                // ResolutionUtility.AdjustResolution(Game1.monitorSize.X, Game1.monitorSize.Y, Game1.graphics);
                ResolutionUtility.toggleFullscreen();
                KeyboardMouseUtility.bPressed = true;
            }



            if (keyboardState.GetPressedKeys().Length > 1)
            {
                foreach (var key in Game1.actionKeyList)
                {
                    if (keyboardState.GetPressedKeys()[keyboardState.GetPressedKeys().Length - 1] == (key.assignedActionKey))
                    {
                        lastPressedKey = key;
                    }
                }
            }
            else
            {
                foreach (var key in Game1.actionKeyList)
                {
                    if (keyboardState.IsKeyDown(key.assignedActionKey))
                    {
                        lastPressedKey = key;
                        //selectedSprite.MoverMustUpdateHitboxes = true;
                    }
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.NumPad8))
            {
            }

            //if (keyboardState.GetPressedKeys().Length >= 1)
            //{
            //    foreach (var key in Game1.actionKeyList)
            //    {
            //        if (keyboardState.IsKeyDown(key.assignedActionKey))
            //        {
            //            lastPressedKey = key;
            //            break;
            //        }

            //    }
            //}



            List <Actions.ActionKey> pressedKeys = new List <Actions.ActionKey>();

            foreach (var key in Game1.actionKeyList)
            {
                if (keyboardState.IsKeyDown(key.assignedActionKey))
                {
                    #region EDITOR PLAYTEST FUNCTION
                    if (MapBuilder.bPlayTest && Game1.bIsDebug)
                    {
                        if (key.actionIndentifierString.Equals(Game1.cancelString) && Keyboard.GetState().IsKeyDown(Keys.LeftShift) && MapBuilder.bPlayTest)
                        {
                            ReturnToEditorAction();
                            break;
                        }
                    }
                    #endregion

                    pressedKeys.Add(key);
                }
            }


            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                // KeyboardMouseUtility.bPressed = true;
                pressedKeys.Add(Game1.actionKeyList.Find(key => key.actionIndentifierString.Equals(Game1.confirmString, StringComparison.OrdinalIgnoreCase)));
                KeyboardMouseUtility.bMouseButtonPressed = true;
            }


            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                // KeyboardMouseUtility.bPressed = true;
                pressedKeys.Add(Game1.actionKeyList.Find(key => key.actionIndentifierString.Equals(Game1.cancelString, StringComparison.OrdinalIgnoreCase)));
                KeyboardMouseUtility.bMouseButtonPressed = true;
            }

            if (Mouse.GetState().RightButton != ButtonState.Pressed && Mouse.GetState().LeftButton != ButtonState.Pressed)
            {
                KeyboardMouseUtility.bMouseButtonPressed = false;
            }

            if (KeyboardMouseUtility.ScrollingDown() || KeyboardMouseUtility.ScrollingUp())
            {
                pressedKeys.Add(new Actions.ActionKey());
                pressedKeys.Last().actionIndentifierString = "Scroll";
            }

            #region NON EDITOR PLAYER CONTROLS
            if (pressedKeys.Count != 0)
            {
                // GameProcessor.bUpdateShadows = true;
                GameProcessor.bUpdateOnceMore = true;
                anyButtonsPressed             = true;
                //  GameProcessor.GenerateCamera(GameProcessor.cameraFollowTarget, .06f, GameProcessor.zoom);
                if (LUA.LuaExecutionList.DemandOverride())
                {
                    LUA.LuaExecutionList.ControlOverride(pressedKeys);
                }

                switch (currentController)
                {
                case Controllers.NonCombat:
                    NonCombatCtrl.Update(pressedKeys);
                    break;

                case Controllers.Combat:
                    CombatCtrl.Update(pressedKeys);
                    break;

                case Controllers.Menu:
                    MenuCtrl.Update(pressedKeys);
                    break;

                case Controllers.Dialogue:
                    DialogueCtrl.Update(pressedKeys);
                    break;

                case Controllers.SoloCombat:
                    SoloCombatCtrl.Update(pressedKeys);
                    break;

                case Controllers.EXPGainScreen:
                    ExpGainCtrl.Update(pressedKeys);
                    break;

                case Controllers.StartScreen:
                    ContextControllers.StartScreenCtrl.Update(pressedKeys);
                    break;

                case Controllers.ScriptProcessor:
                    ScriptProcessorCtrl.Update(pressedKeys);
                    break;

                case Controllers.GameSettingsMenu:
                    if (!SettingsMenu.bIsRunning)
                    {
                        currentController = Controllers.NonCombat;
                    }
                    GameSettingsMenuCtrl.Update(pressedKeys);
                    break;

                case Controllers.GameOptions:
                    if (!OptionsMenu.bIsRunning)
                    {
                        currentController = Controllers.NonCombat;
                    }
                    GameOptionsMenuCtrl.Update(pressedKeys);
                    break;

                default:
                    break;
                }
            }
            else if (KeyboardMouseUtility.bMouseMoved)
            {
                switch (currentController)
                {
                case Controllers.NonCombat:
                    break;

                case Controllers.Combat:
                    break;

                case Controllers.Menu:
                    MenuCtrl.MouseMove();
                    break;

                case Controllers.Dialogue:
                    break;

                case Controllers.SoloCombat:
                    break;

                case Controllers.EXPGainScreen:
                    break;

                case Controllers.StartScreen:
                    ContextControllers.StartScreenCtrl.MouseMove();
                    break;

                case Controllers.ScriptProcessor:
                    ScriptProcessorCtrl.HandleMouseMove();
                    break;

                case Controllers.GameSettingsMenu:
                    GameSettingsMenuCtrl.HandleMouseMove();
                    break;

                case Controllers.GameOptions:
                    GameOptionsMenuCtrl.HandleMouseMove();
                    break;

                default:
                    break;
                }
            }
            else if (selectedSprite != null && !CombatProcessor.bIsRunning)
            {
                selectedSprite.animationIndex = (int)BaseCharacter.CharacterAnimations.Idle;
            }

            #endregion
            if (selectedSprite != null && (!CombatProcessor.bStartPhase1 && !CombatProcessor.bMainCombat && !CombatProcessor.bIsRunning) && !ScriptProcessor.bIsRunning)
            {
                selectedSprite.Update(gt);
            }

            stop : { }
        }
Beispiel #2
0
        private static void SpecificEquipPageControls(Actions.ActionKey key)
        {
            if (key.actionIndentifierString.Equals(Game1.cameraMoveDownString) && ((float)((float)-GameMenuHandler.verticalModifier / (float)GameMenuHandler.maxVertical)) <= 1)
            {
                GameMenuHandler.verticalModifier -= 4;
            }

            if (key.actionIndentifierString.Equals(Game1.cameraMoveUpString) && ((float)((float)-GameMenuHandler.verticalModifier / (float)GameMenuHandler.maxVertical)) >= 0)
            {
                GameMenuHandler.verticalModifier += 4;
            }

            if (KeyboardMouseUtility.bMouseButtonPressed && key.actionIndentifierString.Equals(Game1.cancelString) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                GameMenuHandler.EquipmentTabRightClick();
                KeyboardMouseUtility.bPressed = true;
            }

            if (KeyboardMouseUtility.bMouseButtonPressed && key.actionIndentifierString.Equals(Game1.confirmString) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                GameMenuHandler.EquipmentTabLeftClick();
            }

            if (!GameMenuHandler.bDisplayOptions && GameMenuHandler.selectedEquipmentPieceCharacterPanel == null)
            {
                int  index   = PlayerSaveData.heroParty.IndexOf(GameMenuHandler.selectedCharacterEquipment);
                bool bChange = false;

                if (key.actionIndentifierString.Equals(Game1.moveUpString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    index  -= 1;
                    bChange = true;
                }

                if (key.actionIndentifierString.Equals(Game1.moveDownString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    index  += 1;
                    bChange = true;
                }


                if (key.actionIndentifierString.Equals(Game1.cancelString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.selectedCharacterEquipment = null;
                    KeyboardMouseUtility.bPressed = true;
                }



                if (bChange)
                {
                    if (index <= -1)
                    {
                        GameMenuHandler.selectedCharacterEquipment = PlayerSaveData.heroParty[PlayerSaveData.heroParty.Count - 1];
                        GameMenuHandler.verticalModifier           = (-GameMenuHandler.maxVertical / PlayerSaveData.heroParty.Count) * (PlayerSaveData.heroParty.Count - 1);
                    }
                    else if (index >= PlayerSaveData.heroParty.Count)
                    {
                        GameMenuHandler.selectedCharacterEquipment = null;
                    }
                    else
                    {
                        GameMenuHandler.selectedCharacterEquipment = PlayerSaveData.heroParty[index];
                        GameMenuHandler.verticalModifier           = (-GameMenuHandler.maxVertical / PlayerSaveData.heroParty.Count) * index;
                    }
                }
            }

            if (!GameMenuHandler.bDisplayOptions && GameMenuHandler.selectedCharacterEquipment != null && GameMenuHandler.selectedEquipmentPiece == null)
            {
                if (!KeyboardMouseUtility.bMouseButtonPressed && key.actionIndentifierString.Equals(Game1.tabKeyString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    if (GameMenuHandler.selectedCharacterEquipment.weapon != GameMenuHandler.selectedEquipmentPieceCharacterPanel)
                    {
                        GameMenuHandler.selectedEquipmentPieceCharacterPanel = GameMenuHandler.selectedCharacterEquipment.weapon;
                        GameMenuHandler.bWeaponTab                    = true;
                        GameMenuHandler.EquipmentCurrentPage          = 1;
                        GameMenuHandler.bDisplayOptions               = false;
                        GameMenuHandler.equipmentOptionSelectionIndex = 0;
                        GameMenuHandler.selectedEquipmentPiece        = null;
                        GameMenuHandler.RegenerateEquipList();
                    }
                    else
                    {
                        GameMenuHandler.selectedEquipmentPieceCharacterPanel = GameMenuHandler.selectedCharacterEquipment.armour;
                        GameMenuHandler.bWeaponTab                    = false;
                        GameMenuHandler.EquipmentCurrentPage          = 1;
                        GameMenuHandler.bDisplayOptions               = false;
                        GameMenuHandler.equipmentOptionSelectionIndex = 0;
                        GameMenuHandler.selectedEquipmentPiece        = null;
                        GameMenuHandler.RegenerateEquipList();
                    }
                }

                if (key.actionIndentifierString.Equals(Game1.cancelString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.selectedEquipmentPieceCharacterPanel = null;
                    KeyboardMouseUtility.bPressed = true;
                }
            }

            if (!GameMenuHandler.bDisplayOptions && GameMenuHandler.selectedCharacterEquipment != null && GameMenuHandler.selectedEquipmentPieceCharacterPanel != null ||
                (!GameMenuHandler.bDisplayOptions && GameMenuHandler.selectedCharacterEquipment != null && GameMenuHandler.bWeaponTab && GameMenuHandler.selectedCharacterEquipment.weapon == null) ||
                (!GameMenuHandler.bDisplayOptions && GameMenuHandler.selectedCharacterEquipment != null && !GameMenuHandler.bWeaponTab && GameMenuHandler.selectedCharacterEquipment.armour == null))
            {
                if (key.actionIndentifierString.Equals(Game1.cancelString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.selectedEquipmentPiece = null;
                    KeyboardMouseUtility.bPressed          = true;
                }

                if (!KeyboardMouseUtility.bMouseButtonPressed && key.actionIndentifierString.Equals(Game1.confirmString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.EquipmentShowChoices(GameMenuHandler.equipmentItems.IndexOf(GameMenuHandler.selectedEquipmentPiece));
                    KeyboardMouseUtility.bPressed = true;
                }

                int  index   = GameMenuHandler.equipmentItems.IndexOf(GameMenuHandler.selectedEquipmentPiece);
                bool bChange = false;

                if (key.actionIndentifierString.Equals(Game1.moveUpString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    index  -= 6;
                    bChange = true;
                }

                if (key.actionIndentifierString.Equals(Game1.moveDownString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    index  += 6;
                    bChange = true;
                }

                if (key.actionIndentifierString.Equals(Game1.moveLeftString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    index--;
                    bChange = true;
                }

                if (key.actionIndentifierString.Equals(Game1.moveRightString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    index++;
                    bChange = true;
                }

                if (bChange)
                {
                    if (index < 0)
                    {
                        if (GameMenuHandler.EquipmentMaxPage != 0 && GameMenuHandler.EquipmentCurrentPage >= 0)
                        {
                            GameMenuHandler.EquipmentCurrentPage--;
                            index = GameMenuHandler.equipmentItems.Count - 1;
                            if (GameMenuHandler.EquipmentCurrentPage == 0 - 1)
                            {
                                GameMenuHandler.EquipmentCurrentPage = GameMenuHandler.EquipmentMaxPage;
                                GameMenuHandler.RegenerateItemList();
                                index = GameMenuHandler.equipmentItems.Count - 1;
                            }
                        }
                        else
                        {
                            GameMenuHandler.EquipmentCurrentPage = 0;
                            GameMenuHandler.RegenerateItemList();
                            index = GameMenuHandler.equipmentItems.Count - 1;
                        }
                    }
                    else if (index >= GameMenuHandler.equipmentItems.Count)
                    {
                        if (GameMenuHandler.EquipmentMaxPage != 0 && GameMenuHandler.EquipmentCurrentPage != GameMenuHandler.EquipmentMaxPage)
                        {
                            GameMenuHandler.EquipmentCurrentPage++;
                            GameMenuHandler.RegenerateItemList();
                            index = 0;
                        }
                        else
                        {
                            GameMenuHandler.EquipmentCurrentPage = 0;
                            GameMenuHandler.RegenerateItemList();

                            index = 0;
                        }
                    }

                    if (bChange && GameMenuHandler.equipmentItems.Count != 0)
                    {
                        GameMenuHandler.selectedEquipmentPiece = GameMenuHandler.equipmentItems[index];
                        GameMenuHandler.selectedItemHighlighterPosition.Location = GameMenuHandler.equipmentItemBoxes[index].Location;
                        GameMenuHandler.equipmentDisplay.Generate(index);
                        //GameMenuHandler.SelectItemViaKeyboard(GameMenuHandler.itemPageSelectedItem, index);
                    }
                }
            }

            if (GameMenuHandler.bDisplayOptions && GameMenuHandler.selectedCharacterEquipment != null && GameMenuHandler.selectedEquipmentPiece != null)
            {
                if (key.actionIndentifierString.Equals(Game1.moveUpString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.equipmentOptionSelectionIndex--;
                }

                if (key.actionIndentifierString.Equals(Game1.moveDownString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.equipmentOptionSelectionIndex++;
                }


                if (GameMenuHandler.equipmentOptionSelectionIndex == EquipmentOptionDisplay.choiceBoxes.Count)
                {
                    GameMenuHandler.equipmentOptionSelectionIndex = 0;
                }

                if (GameMenuHandler.equipmentOptionSelectionIndex < 0)
                {
                    GameMenuHandler.equipmentOptionSelectionIndex = EquipmentOptionDisplay.choiceBoxes.Count - 1;
                }

                if (!KeyboardMouseUtility.bMouseButtonPressed && key.actionIndentifierString.Equals(Game1.cancelString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.bDisplayOptions = false;
                    KeyboardMouseUtility.bPressed   = true;
                }

                if (!KeyboardMouseUtility.bMouseButtonPressed && key.actionIndentifierString.Equals(Game1.confirmString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.EquipChoiceConfirm();
                }
            }

            if (GameMenuHandler.selectedCharacterEquipment == null && GameMenuHandler.selectedCharacterEquipment == null)
            {
                if (key.actionIndentifierString.Equals(Game1.tabKeyString) && !KeyboardMouseUtility.AnyButtonsPressed())
                {
                    GameMenuHandler.TabClick();
                }
            }
        }