/// <summary> /// Updates the current set of Battle Events. /// </summary> public void UpdateBattleEvents() { //There are no more BattleEvents to update if (HasBattleEvents == false) { return; } //Update all Battle Events for (int i = 0; i < BattleEvents[CurHighestPriority].Count; i++) { BattleEvent battleEvent = BattleEvents[CurHighestPriority][i]; //Start the Battle Event if it hasn't started already if (battleEvent.HasStarted == false) { battleEvent.Start(); } battleEvent.Update(); if (battleEvent.IsDone == true) { //Remove the BattleEvent if it's finished BattleEvents[CurHighestPriority].RemoveAt(i); i--; } } //If we're done with all Battle Events with this priority, remove the priority and find the next highest priority to update if (BattleEvents[CurHighestPriority].Count == 0) { BattleEvents.Remove(CurHighestPriority); CurHighestPriority = FindNextHighestBattleEventPriority(); } }
public override void Combine(BattleEvent other) { HealHPBattleEvent hpEvent = other as HealHPBattleEvent; if (hpEvent != null) { //Add the hp heal amount onto this one HPHeal += hpEvent.HPHeal; } }
public override void Combine(BattleEvent other) { HealFPBattleEvent fpEvent = other as HealFPBattleEvent; if (fpEvent != null) { //Add the fp heal amount onto this one FPHeal += fpEvent.FPHeal; } }
public override bool AreContentsEqual(BattleEvent other) { if (base.AreContentsEqual(other) == true) { return(true); } DeathBattleEvent deathEvent = other as DeathBattleEvent; return(deathEvent != null && deathEvent.Entity == Entity); }
public override bool AreContentsEqual(BattleEvent other) { if (base.AreContentsEqual(other) == true) { return(true); } RevivedBattleEvent revivedEvent = other as RevivedBattleEvent; return(revivedEvent != null && revivedEvent.RevivedEntity == RevivedEntity); }
public override bool AreContentsEqual(BattleEvent other) { if (base.AreContentsEqual(other) == true) { return(true); } MessageBattleEvent messageEvent = other as MessageBattleEvent; return(messageEvent != null && messageEvent.BattleMessage == BattleMessage); }
public override bool AreContentsEqual(BattleEvent other) { if (base.AreContentsEqual(other) == true) { return(true); } WaitForAnimBattleEvent waitForAnimEvent = other as WaitForAnimBattleEvent; //Don't compare the animation. In cases where two or more of this event have the same priority and same entity, //we don't want a latter animation to override this one return(waitForAnimEvent != null && waitForAnimEvent.Entity == Entity); }
public override bool AreContentsEqual(BattleEvent other) { if (base.AreContentsEqual(other) == true) { return(true); } //Compare the Duplighost references RemoveDisguiseBattleEvent disguiseEvent = other as RemoveDisguiseBattleEvent; if (disguiseEvent == null || disguiseEvent.DuplighostRef != DuplighostRef) { return(false); } return(true); }
/// <summary> /// Adds a Battle Event to occur. /// </summary> /// <param name="priority">The priority the Battle Event has. Must be greater than or equal to 0.</param> /// <param name="battleEvent">The Battle Event to add.</param> private void AddBattleEvent(int priority, BattleEvent battleEvent) { if (priority < 0) { Debug.LogError($"Not adding BattleEvent because the priority's value is {priority} which is less than 0!"); return; } if (battleEvent == null) { Debug.LogError($"Trying to add null BattleEvent with priority of {priority}! Not adding BattleEvent"); return; } //If the battle event is unique, check if one with the same contents exist if (battleEvent.IsUnique == true) { if (BattleEvents.ContainsKey(priority) == true) { bool sameContents = BattleEvents[priority].Exists((evt) => (evt.AreContentsEqual(battleEvent) == true)); if (sameContents == true) { Debug.Log($"Not adding BattleEvent {battleEvent} with Priority {priority} as it has the same contents as another and is a unique event."); return; } } } //Set the current highest priority to the priority if there are no Battle Events if (HasBattleEvents == false) { CurHighestPriority = priority; } if (BattleEvents.ContainsKey(priority) == false) { BattleEvents.Add(priority, new List <BattleEvent>()); } BattleEvents[priority].Add(battleEvent); Debug.Log($"Added BattleEvent {battleEvent} with Priority {priority} to take effect"); }
/// <summary> /// Places a Battle Event on the pending list. /// <para>If the current BattleState matches a BattleState the Battle Event takes effect in, it will take effect immediately. /// Otherwise, it will wait and take effect once the current BattleState matches.</para> /// </summary> /// <param name="priority">The priority the Battle Event has. Must be greater than or equal to 0.</param> /// <param name="battleStates">The BattleStates the Battle Event takes effect in. If none are specified, the event isn't added.</param> /// <param name="battleEvent">The Battle Event to add.</param> public void QueueBattleEvent(int priority, BattleGlobals.BattleState[] battleStates, BattleEvent battleEvent) { if (priority < 0) { Debug.LogError($"Not queueing BattleEvent because the priority's value is {priority} which is less than 0!"); return; } if (battleEvent == null) { Debug.LogError($"Trying to queue null BattleEvent with priority of {priority}! Not queueing BattleEvent"); return; } if (battleStates == null || battleStates.Length == 0) { Debug.LogError($"BattleEvent {battleEvent} with Priority {priority} was queued, but no BattleStates were specified. Not queueing."); return; } //Add the Battle Event directly if the current state is the state to add it in if (battleStates.Contains(BManager.State) == true) { AddBattleEvent(priority, battleEvent); } //Otherwise put it in the pending list else { PendingBattleEvents.Add(new PendingBattleEventHolder(priority, battleStates, battleEvent)); Debug.Log($"Queued BattleEvent {battleEvent} with Priority {priority}"); } }
/// <summary> /// Adds a Battle Event to occur. /// </summary> /// <param name="priority">The priority the Battle Event has. Must be greater than or equal to 0.</param> /// <param name="battleEvent">The Battle Event to add.</param> private void AddBattleEvent(int priority, BattleEvent battleEvent) { if (priority < 0) { Debug.LogError($"Not adding BattleEvent because the priority's value is {priority} which is less than 0!"); return; } if (battleEvent == null) { Debug.LogError($"Trying to add null BattleEvent with priority of {priority}! Not adding BattleEvent"); return; } List <BattleEvent> bEventList = null; //If the battle event is combineable, find one of the same type if (battleEvent.IsCombineable == true) { if (BattleEvents.TryGetValue(priority, out bEventList) == true) { //NOTE: Checking for same type isn't ideal; find a better way to do this sort of thing //and allow possibilities of combining values with other types of Battle Events as well BattleEvent combinedEvent = bEventList.Find((evt) => (evt.GetType() == battleEvent.GetType())); //If we found it, combine the newly added event's contents into the existing one if (combinedEvent != null) { Debug.Log($"Combined BattleEvent {battleEvent} with Priority {priority} as one it can combine with was found in the queue!"); combinedEvent.Combine(battleEvent); //Return since we already combined the data from the battle event return; } } } //If the battle event is unique, check if one with the same contents exist else if (battleEvent.IsUnique == true) { if (BattleEvents.TryGetValue(priority, out bEventList) == true) { bool sameContents = bEventList.Exists((evt) => (evt.AreContentsEqual(battleEvent) == true)); if (sameContents == true) { Debug.Log($"Not adding BattleEvent {battleEvent} with Priority {priority} as it has the same contents as another and is a unique event."); return; } } } //Set the current highest priority to the priority if there are no Battle Events if (HasBattleEvents == false) { CurHighestPriority = priority; } //If null, check if an entry exists exists if (bEventList == null) { //If the entry doesn't exist, add a new list if (BattleEvents.TryGetValue(priority, out bEventList) == false) { bEventList = new List <BattleEvent>(); BattleEvents.Add(priority, bEventList); } } //Add the Battle Event bEventList.Add(battleEvent); Debug.Log($"Added BattleEvent {battleEvent} with Priority {priority} to take effect"); }
/// <summary> /// Combines the contents of this Battle Event with the contents of another Battle Event instance of the same type. /// </summary> /// <param name="other">The Battle Event to combine into this one.</param> public virtual void Combine(BattleEvent other) { }
/// <summary> /// Tells if this Battle Event's contents are equal to another Battle Event's contents. /// <para>The base behavior is to compare this Battle Event to the Battle Event passed in.</para> /// </summary> /// <param name="other">The Battle Event to compare this one to.</param> /// <returns>true if the contents are equal, otherwise false.</returns> public virtual bool AreContentsEqual(BattleEvent other) { return(this == other); }
public PendingBattleEventHolder(int priority, BattleGlobals.BattleState[] battleStates, BattleEvent battleEvent) { Priority = priority; States = battleStates; PendingBattleEvent = battleEvent; }
public WaitForBattleEventSeqAction(BattleEvent battleEvent) { BEvent = battleEvent; }