Beispiel #1
0
 private void cancelAction()
 {
     if (inOuterMenu)
     {
         if (Actions.Count > 0)
         {
             ThinkAction lastAction = Actions[Actions.Count - 1];
             Actions.RemoveAt(Actions.Count - 1);
             CurrentPartyMember = lastAction.Actor;
             if (!ThinkMenuOption.IsDefaultOptionName(lastAction.OptionName))
             {
                 Inventory inventory = getInventoryFromThinkActionType(lastAction.Type, CurrentPartyMember);
                 if (inventory != null)
                 {
                     inventory.AddItem(lastAction.OptionName, CurrentPartyMember);
                 }
             }
             repopulateMenuOptions();
             Logger.Log("Back to action selection for party member " + (Actions.Count + 1).ToString());
         }
     }
     else
     {
         hideOpenMenu();
     }
 }
Beispiel #2
0
        private void pushStateForThinkAction(ThinkAction thinkAction)
        {
            if (thinkAction == null)
            {
                return;
            }

            if (!statusEffectsCompleteForAction && thinkAction.Actor.Alive)
            {
                PushState(new HandleStatusEffects(Battle, StatusEffectEvent.BeforeAct, thinkAction: thinkAction));
                return;
            }

            if (!thinkAction.Actor.Alive || !thinkAction.Active)
            {
                if (!ThinkMenuOption.IsDefaultOptionName(thinkAction.OptionName))
                {
                    Inventory inventory = getInventoryFromThinkActionType(thinkAction.Type, thinkAction.Actor);
                    if (inventory != null)
                    {
                        inventory.AddItem(thinkAction.OptionName, thinkAction.Actor);
                    }
                }
                getNextThinkAction();
                return;
            }

            if (thinkAction.Target.Alive)
            {
                if (thinkAction.Type == ThinkActionType.Attack)
                {
                    PushState(new Attack(Battle, thinkAction));
                }
                else
                {
                    PushState(new UseItem(Battle, thinkAction));
                }
            }
            else
            {
                if (Battle.PlayerParty.Count > 0 && Battle.EnemyParty.Count > 0)
                {
                    PushState(new SelectTarget(Battle, thinkAction));
                }
                else
                {
                    Finish();
                }
            }
        }
Beispiel #3
0
        private void selectAction()
        {
            if (MenuOptions[CurrentOptionNameIndex].Disabled)
            {
                return;
            }

            ThinkMenuOption option = MenuOptions[CurrentOptionNameIndex];

            currentThinkAction = new ThinkAction(CurrentThinkActionType, option.Name, CurrentPartyMember);
            if (CurrentThinkActionType == ThinkActionType.Defend)
            {
                finishThinkForCurrentPartyMember();
            }
            else
            {
                currentThinkAction.InfiniteInInventory = option.Amount < 0;
                PushState(new SelectTarget(Battle, currentThinkAction));
            }
        }
Beispiel #4
0
        private void equipCurrentOption()
        {
            ThinkMenuOption option = MenuOptions[CurrentOptionNameIndex];

            if (CurrentThinkActionType == ThinkActionType.Attack)
            {
                CurrentPartyMember.EquipWeapon(option.Name);
                Logger.Log(CurrentPartyMember.Data.Name + " equipped '" + option.Name + "' weapon");
            }
            else if (CurrentThinkActionType == ThinkActionType.Defend)
            {
                CurrentPartyMember.EquipShield(ThinkMenuOption.IsDefaultOption(option) ? null : option.Name);
                Logger.Log(CurrentPartyMember.Data.Name + " equipped '" + option.Name + "' shield");
            }
            else
            {
                CurrentPartyMember.EquipWeapon(null);
                CurrentPartyMember.EquipShield(null);
            }
        }
Beispiel #5
0
        private void checkUsabilityOfWeaponMenuOptions()
        {
            foreach (CharacterClass characterClass in Enum.GetValues(typeof(CharacterClass)))
            {
                if (characterClass == CharacterClass.Enemy)
                {
                    continue;
                }

                foreach (ThinkMenuOption menuOption in weaponMenuOptions[characterClass])
                {
                    if (ThinkMenuOption.IsDefaultOption(menuOption))
                    {
                        menuOption.Disabled = false;
                        continue;
                    }
                    WeaponData weaponData = ResourceManager.GetWeaponData(menuOption.Name);
                    menuOption.Disabled = weaponData == null || (weaponData.WeaponType == WeaponType.Melee && !Battle.PlayerPartyLayout.PartyMemberInFrontLine(CurrentPartyMember));
                }
            }
        }
        private void drawOptionNamesText(Renderer renderer)
        {
            float   fontHeight      = renderer.Font.MeasureString("I", subMenuFontSize).Y;
            Vector2 scale           = Game1.ScreenScaleFactor;
            Vector2 fontScale       = new Vector2(subMenuFontSize / Font.DefaultSize) * Game1.ScreenScaleFactor.X;
            Vector2 position        = new Vector2(subMenuX + subMenuPadding, subMenuY);
            float   measureFontSize = Font.DefaultSize * fontScale.Y;
            Vector2 upArrowPosition = (position * scale) + new Vector2(subMenuWidth * Game1.ScreenScaleFactor.X * 0.5f, 0.0f);

            int startIndex;
            int finishIndex;

            battleState.Battle.CalculateStartAndFinishIndexesForMenuList(battleState.MenuOptions.Count, maxVisibleSubMenuOptions, battleState.CurrentOptionNameIndex, out startIndex, out finishIndex);

            for (int i = startIndex; i <= finishIndex; ++i)
            {
                ThinkMenuOption menuOption = battleState.MenuOptions[i];

                if (i == battleState.CurrentOptionNameIndex)
                {
                    Vector2 arrowPosition = (position - new Vector2(subMenuPadding, 0.0f)) * scale;
                    renderer.DrawText(">", arrowPosition, Color.White, 0.0f, Vector2.Zero, fontScale);
                    Vector2 arrowSize      = renderer.Font.MeasureString(">", measureFontSize);
                    Vector2 buttonSize     = new Vector2(renderer.Font.MeasureString("I", measureFontSize).Y);
                    Vector2 buttonPosition = arrowPosition - new Vector2(buttonSize.X + (arrowSize.X * 0.2f), (buttonSize.Y - (arrowSize.Y * 0.8f)) / 2.0f);
                    battleState.Battle.DrawButtonWithText(InputButton.A, null, buttonPosition, menuOption.Disabled ? Color.Gray : Color.White, renderer);
                    Vector2 containerSize     = renderer.Font.MeasureString(menuOption.Description, measureFontSize) / scale;
                    Vector2 containerPosition = position + new Vector2(subMenuWidth + (borderTextureData[Battle.E].Width * 0.5f), 0.0f);
                    drawContainer(containerPosition.X, containerPosition.Y, containerSize.X, containerSize.Y, renderer);
                    renderer.DrawText(menuOption.Description, containerPosition * scale, Color.White, 0.0f, Vector2.Zero, fontScale);
                }

                renderer.DrawText(menuOption.Name.Replace('-', ' '), position * scale, menuOption.Disabled ? Color.Gray : Color.White, 0.0f, Vector2.Zero, fontScale);

                string  amountString = menuOption.Amount < 0 ? "~" : menuOption.Amount.ToString();
                Vector2 amountSize   = renderer.Font.MeasureString(amountString, subMenuFontSize);
                renderer.DrawText(amountString, (position + new Vector2(subMenuWidth - (subMenuPadding * 2) - amountSize.X, 0.0f)) * scale, menuOption.Disabled ? Color.Gray : Color.White, 0.0f, Vector2.Zero, fontScale);

                position.Y += fontHeight * fontHeightScale;
            }

            float   arrowFontSize   = measureFontSize * 1.5f;
            Vector2 arrowFontScale  = fontScale * 1.5f;
            Vector2 scrollArrowSize = renderer.Font.MeasureString("^", arrowFontSize);

            scrollArrowSize = new Vector2(scrollArrowSize.Y, scrollArrowSize.X);
            float yOffset = 10.0f * scale.Y;

            if (arrowMoveTimer <= arrowMoveTime)
            {
                yOffset *= arrowMoveTimer / arrowMoveTime;
            }
            else
            {
                yOffset *= 1.0f - ((arrowMoveTimer - arrowMoveTime) / arrowMoveTime);
            }
            if (startIndex > 0)
            {
                renderer.DrawText("^", new Vector2(upArrowPosition.X, upArrowPosition.Y - (scrollArrowSize.Y / 2.0f) - yOffset), Color.White, 0.0f, scrollArrowSize / 2.0f, arrowFontScale);
            }
            if (finishIndex < battleState.MenuOptions.Count - 1)
            {
                renderer.DrawText("^", new Vector2(upArrowPosition.X, (position.Y * scale.Y) + (scrollArrowSize.Y / 2.0f) + yOffset), Color.White, 0.0f, scrollArrowSize / 2.0f, new Vector2(arrowFontScale.X, -arrowFontScale.Y));
            }
        }
Beispiel #7
0
 public static bool IsDefaultOption(ThinkMenuOption option)
 {
     return(IsDefaultOptionName(option.Name));
 }
Beispiel #8
0
 static ThinkMenuOption()
 {
     NoWeapon = new ThinkMenuOption("No weapon", null, -1, false);
     NoShield = new ThinkMenuOption("No shield", "Meatshields. Yum.", -1, false);
 }
 public static bool IsDefaultOption(ThinkMenuOption option)
 {
     return IsDefaultOptionName(option.Name);
 }
 static ThinkMenuOption()
 {
     NoWeapon = new ThinkMenuOption("No weapon", null, -1, false);
     NoShield = new ThinkMenuOption("No shield", "Meatshields. Yum.", -1, false);
 }