//Event handler when the ally who is in Veil starts their next turn //Ignore its turn as it needs to wait for the entity that initiated it to finish //We don't simply set turn count to 0, as we need to make the ally's turn start right before ending it //This allows commands like Defend to end on the ally's next turn even if it can't move yet private void AllyAffectedTurnStartHandler() { Debug.Log($"Skipped {AllyAffected.Name}'s turn for {nameof(VeilAction)} as it's being protected by {EntityUsing.Name}!"); //Clear the menu stack - the ally can't move yet AllyAffected.BManager.battleUIManager.ClearMenuStack(); //Make the ally do nothing on each of its turns AllyAffected.StartAction(new NoAction(AllyAffected), true, null); }
//Event handler when the ally who is hidden starts their next turn //Ignore its turn as it needs to wait for the entity that hid them to finish //We don't simply set turn count to 0, as we need to make the ally's turn start right before ending it //This allows commands like Defend to end on the ally's next turn even if it can't move yet private void AllyAffectedTurnStartHandler() { Debug.Log($"Skipped {AllyAffected.Name}'s turn for {nameof(OuttaSight)} as it's being protected by {EntityUsing.Name}!"); //Clear the menu stack - the ally can't move yet BattleUIManager.Instance.ClearMenuStack(); //Make the ally do nothing on each of its turns AllyAffected.StartAction(new NoAction(), true, null); AllyAffected.AnimManager.PlayAnimation(AnimationGlobals.PlayerBattleAnimations.GuardName); }
private void OnChooseYes() { User.BManager.battleUIManager.ClearMenuStack(); //Remove any remaining item turns from the BattleEntity and make it do nothing if it no longer wants to use items User.EntityProperties.RemoveAdditionalProperty(Enumerations.AdditionalProperty.DipItemTurns); //Make the entity perform the NoAction //It does this instead of directly ending the entity's turn since choosing not to use an item is affected by Confusion User.StartAction(new NoAction(User), false, null); }
//Event handler when the user's next turn is started private void OnUserTurnStart() { EntityUsing.TurnStartEvent -= OnUserTurnStart; Debug.Log($"Using {ItemChosen.Name} for {EntityUsing.Name}, which was received via Mystery!"); //Clear the menu stack as the action will be selected automatically EntityUsing.BManager.battleUIManager.ClearMenuStack(); //Immediately start using the item ItemAction itemChosenAction = ItemChosen.GetActionAssociated(User); //Special case: if the item chosen is a Mystery, initialize it //We can't do this earlier in Initialize, otherwise we run into an infinite loop if (itemChosenAction is MysteryAction) { itemChosenAction.Initialize(); } //1. Find out if this item targets enemies or allies //2. If it targets allies, only use it on the entity using it //3. If it targets enemies, use it on the first enemy if it targets only one, otherwise use it on all enemies List <BattleEntity> entitiesAffected = new List <BattleEntity>(); itemChosenAction.GetEntitiesMoveAffects(entitiesAffected); if (itemChosenAction.MoveProperties.SelectionType == Enumerations.EntitySelectionType.Single || itemChosenAction.MoveProperties.SelectionType == Enumerations.EntitySelectionType.First) { //If this selects the first or a single entity and it's an ally, make sure it always targets the entity using the Mystery //Examples include a Mushroom or Honey Syrup if (UtilityGlobals.MoveAffectionTypesHasFlag(itemChosenAction.MoveProperties.MoveAffectionType, MoveAffectionTypes.Self | MoveAffectionTypes.Ally)) { entitiesAffected.Clear(); entitiesAffected.Add(EntityUsing); } //If it affects a first or single entity and we have more in the list, remove all but the first one //If this is a single target damaging item that targets enemies, it'll choose the first enemy (Ex. Egg Bomb) if (entitiesAffected.Count > 1) { entitiesAffected.RemoveRange(1, entitiesAffected.Count - 1); } } //Start the second half of the sequence EntityUsing.StartAction(itemChosenAction, true, entitiesAffected.ToArray()); EntityUsing = null; ItemChosen = null; }
//Event handler when the user's next turn is started private void OnUserTurnStart() { AllyAffected.TurnStartEvent -= AllyAffectedTurnStartHandler; EntityUsing.TurnStartEvent -= OnUserTurnStart; Debug.Log($"Starting second phase of {nameof(VeilAction)} for {EntityUsing.Name}!"); //Clear the menu stack as the action will be selected automatically User.BManager.battleUIManager.ClearMenuStack(); //Immediately start the second half of the sequence MoveAction veilSecondHalf = new MoveAction(User, "Veil Second Half", new MoveActionData(null, "Second half of Veil", Enumerations.MoveResourceTypes.FP, 0, Enumerations.CostDisplayTypes.Shown, Enumerations.MoveAffectionTypes.None, Enumerations.EntitySelectionType.First, false, null), new VeilSecondHalfSequence(null, ScaleVal)); //Start the second half of the sequence EntityUsing.StartAction(veilSecondHalf, true, AllyAffected); }
//Event handler when the user's next turn is started private void OnUserTurnStart() { AllyAffected.TurnStartEvent -= AllyAffectedTurnStartHandler; EntityUsing.TurnStartEvent -= OnUserTurnStart; Debug.Log($"Starting second phase of {nameof(OuttaSight)} for {EntityUsing.Name}!"); //Clear the menu stack as the action will be selected automatically BattleUIManager.Instance.ClearMenuStack(); //Immediately start the second half of the sequence MoveAction outtaSightSecondHalf = new MoveAction("Outta Sight Second Half", new MoveActionData(null, "Second half of Outta Sight", Enumerations.MoveResourceTypes.FP, 0, Enumerations.CostDisplayTypes.Shown, Enumerations.MoveAffectionTypes.None, TargetSelectionMenu.EntitySelectionType.First, false, null), new OuttaSightSecondHalfSequence(null, AlphaVal)); //Start the second half of the sequence EntityUsing.StartAction(outtaSightSecondHalf, true, AllyAffected); }