/// <summary> /// Sets the ItemAction's properties based on the item it has. /// <para>The default behavior is to check the item's properties and set its MoveInfo, DamageInfo, and HealingInfo accordingly.</para> /// </summary> protected virtual void SetActionProperties() { Name = ItemUsed.Name; //NOTE: Refactor and make cleaner in some way IHPHealingItem hpHealing = ItemUsed as IHPHealingItem; IFPHealingItem fpHealing = ItemUsed as IFPHealingItem; IDamagingItem damageItem = ItemUsed as IDamagingItem; IStatusHealingItem statusHealing = ItemUsed as IStatusHealingItem; IStatusInflictingItem statusInflicting = ItemUsed as IStatusInflictingItem; IDamageEffectItem damageEffectItem = ItemUsed as IDamageEffectItem; EntityTypes[] otherEntityTypes = ItemUsed.OtherEntTypes; //Check if we should replace all instances of Enemy EntityTypes with opposing ones if (ItemUsed.GetOpposingIfEnemy == true && otherEntityTypes != null && otherEntityTypes.Length > 0) { //Create a new array so we don't modify the item's information otherEntityTypes = new EntityTypes[ItemUsed.OtherEntTypes.Length]; for (int i = 0; i < ItemUsed.OtherEntTypes.Length; i++) { EntityTypes entitytype = ItemUsed.OtherEntTypes[i]; //If we found Enemy, change it if (entitytype == EntityTypes.Enemy) { entitytype = User.GetOpposingEntityType(); } //Set the value otherEntityTypes[i] = entitytype; } } MoveInfo = new MoveActionData(ItemUsed.Icon, ItemUsed.Description, MoveResourceTypes.FP, 0, CostDisplayTypes.Hidden, ItemUsed.MoveAffectionType, ItemUsed.SelectionType, false, ItemUsed.HeightsAffected, otherEntityTypes); //Set the damage data if (damageItem != null || statusInflicting != null) { int damage = damageItem != null ? damageItem.Damage : 0; Elements element = damageItem != null ? damageItem.Element : Elements.Normal; StatusChanceHolder[] statuses = statusInflicting != null ? statusInflicting.StatusesInflicted : null; DamageEffects damageEffects = damageEffectItem != null ? damageEffectItem.InducedDamageEffects : DamageEffects.None; DamageInfo = new DamageData(damage, element, true, ContactTypes.None, ContactProperties.Ranged, statuses, damageEffects); } //Set the healing data if (hpHealing != null || fpHealing != null || statusHealing != null) { int hpHealed = hpHealing != null ? hpHealing.HPRestored : 0; int fpHealed = fpHealing != null ? fpHealing.FPRestored : 0; StatusTypes[] statusesHealed = statusHealing != null ? statusHealing.StatusesHealed : null; HealingInfo = new HealingData(hpHealed, fpHealed, statusesHealed); } }
public DamageEffects DamEffect(DamageEffects DamEff) { switch (DamEff) { case DamageEffects.FireEffect: FireEffect.SetActive(true); StartCoroutine(EffectTimer()); break; case DamageEffects.ElectricEffect: ElectricEffect.SetActive(true); StartCoroutine(EffectTimer()); break; } return(DamEff); }
/// <summary> /// Sets the ItemAction's properties based on the item it has. /// </summary> protected void SetActionProperties() { Name = ItemUsed.Name; //NOTE: Refactor and make cleaner in some way IHPHealingItem hpHealing = ItemUsed as IHPHealingItem; IFPHealingItem fpHealing = ItemUsed as IFPHealingItem; IDamagingItem damageItem = ItemUsed as IDamagingItem; IStatusHealingItem statusHealing = ItemUsed as IStatusHealingItem; IStatusInflictingItem statusInflicting = ItemUsed as IStatusInflictingItem; IDamageEffectItem damageEffectItem = ItemUsed as IDamageEffectItem; MoveAffectionTypes moveAffectionType = ItemUsed.EntityType == User.EntityType ? MoveAffectionTypes.Ally : MoveAffectionTypes.Enemy; if (ItemUsed.TargetsSelf == true) { moveAffectionType = MoveAffectionTypes.Self; } MoveInfo = new MoveActionData(null, ItemUsed.Description, MoveResourceTypes.FP, 0, CostDisplayTypes.Hidden, moveAffectionType, ItemUsed.SelectionType, false, ItemUsed.HeightsAffected); //Set the damage data if (damageItem != null || statusInflicting != null) { int damage = damageItem != null ? damageItem.Damage : 0; Elements element = damageItem != null ? damageItem.Element : Elements.Normal; StatusChanceHolder[] statuses = statusInflicting != null ? statusInflicting.StatusesInflicted : null; DamageEffects damageEffects = damageEffectItem != null ? damageEffectItem.InducedDamageEffects : DamageEffects.None; DamageInfo = new DamageData(damage, element, true, ContactTypes.None, statuses, damageEffects); } //Set the healing data if (hpHealing != null || fpHealing != null || statusHealing != null) { int hpHealed = hpHealing != null ? hpHealing.HPRestored : 0; int fpHealed = fpHealing != null ? fpHealing.FPRestored : 0; StatusTypes[] statusesHealed = statusHealing != null ? statusHealing.StatusesHealed : null; HealingInfo = new HealingData(hpHealed, fpHealed, statusesHealed); } }
protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult) { //If the attack didn't hit, don't factor in DamageEffects if (StepResult.VictimResult.Hit == false) { StepResult.VictimResult.DamageEffect = DamageEffects.None; } //If the current result has no DamageEffects (whether the move didn't have any or a Defensive Action removed them) //or if the BattleEntity isn't vulnerable to any DamageEffects, then don't bother doing anything else if (StepResult.VictimResult.DamageEffect == DamageEffects.None || StepResult.VictimResult.Entity.EntityProperties.HasDamageEffectVulnerabilities() == false) { return; } //The DamageEffects stored in the result DamageEffects resultEffects = DamageEffects.None; //Get all the DamageEffects DamageEffects[] damageEffects = UtilityGlobals.GetEnumValues <DamageEffects>(); //Start at index 1, as 0 is the value of None indicating no DamageEffects for (int i = 1; i < damageEffects.Length; i++) { DamageEffects curEffect = damageEffects[i]; //If the move has the DamageEffect and the entity is affected by it, add it to the result //This approach is easier and more readable than removing effects if (UtilityGlobals.EnumHasFlag(StepResult.VictimResult.DamageEffect, curEffect) == true && StepResult.VictimResult.Entity.EntityProperties.IsVulnerableToDamageEffect(curEffect) == true) { resultEffects |= curEffect; } } //Set the result StepResult.VictimResult.DamageEffect = resultEffects; }
public override BattleGlobals.DefensiveActionHolder HandleSuccess(int damage, StatusChanceHolder[] statusEffects, DamageEffects damageEffects) { int newDamage = damage - 1; StatusChanceHolder[] newStatuses = FilterStatuses(statusEffects); BattleManager.Instance.battleEventManager.QueueBattleEvent((int)BattleGlobals.BattleEventPriorities.Damage, new BattleManager.BattleState[] { BattleManager.BattleState.Turn }, new WaitForAnimBattleEvent(User, AnimationGlobals.PlayerBattleAnimations.GuardName, true)); BattleObjManager.Instance.AddBattleObject(new ActionCommandVFX(ActionCommand.CommandRank.Nice, User.Position, new Vector2(-15, -15))); SoundManager.Instance.PlaySound(SoundManager.Sound.ActionCommandSuccess); return(new BattleGlobals.DefensiveActionHolder(newDamage, newStatuses, Enumerations.DamageEffects.None, DefensiveActionType)); }
/// <summary> /// What happens when the Defensive Action is successfully performed. /// <para>This can be called for only one Defensive Action at a time (Ex. You can't both Guard and Superguard). /// Whichever is successful first in the BattleEntity's DefensiveAction list is the one that gets called.</para> /// </summary> /// <param name="damage">The original damage that would be dealt to the BattleEntity</param> /// <param name="statusEffects">The original StatusEffects that would be inflicted on the BattleEntity</param> /// <param name="damageEffects">The original DamageEffects that would affect the BattleEntity.</param> /// <returns>A DefensiveActionHolder containing the modified damage dealt and a filtered set of StatusEffects inflicted</returns> public abstract BattleGlobals.DefensiveActionHolder HandleSuccess(int damage, StatusChanceHolder[] statusEffects, DamageEffects damageEffects);
public override BattleGlobals.DefensiveActionHolder HandleSuccess(int damage, StatusChanceHolder[] statusEffects, DamageEffects damageEffects) { int newDamage = 0; StatusChanceHolder[] newStatuses = FilterStatuses(statusEffects); BattleManager.Instance.battleEventManager.QueueBattleEvent((int)BattleGlobals.BattleEventPriorities.Damage, new BattleManager.BattleState[] { BattleManager.BattleState.Turn }, new WaitForAnimBattleEvent(User, AnimationGlobals.PlayerBattleAnimations.SuperguardName, true)); BattleObjManager.Instance.AddBattleObject(new ActionCommandVFX(ActionCommand.CommandRank.Great, User.Position, new Vector2(-15, -15))); SoundManager.Instance.PlaySound(SoundManager.Sound.ActionCommandSuccess); StatusGlobals.PaybackHolder paybackData = new StatusGlobals.PaybackHolder(StatusGlobals.PaybackTypes.Constant, PhysicalAttributes.None, Elements.Normal, new ContactTypes[] { ContactTypes.SideDirect, ContactTypes.TopDirect }, new ContactProperties[] { ContactProperties.None, ContactProperties.Protected, ContactProperties.WeaponDirect }, ContactResult.Failure, ContactResult.Failure, 1, null); return(new BattleGlobals.DefensiveActionHolder(newDamage, newStatuses, DamageEffects.None, DefensiveActionType, paybackData)); }
/// <summary> /// Gets the result of the first successful Defensive Action performed. /// </summary> /// <param name="damage">The original damage of the attack.</param> /// <param name="statusesInflicted">The original set of StatusEffects inflicted.</param> /// <param name="damageEffects">The original DamageEffects that would affect the BattleEntity.</param> /// <param name="defensiveOverrides">The types of Defensive Actions to override.</param> /// <returns>A nullable DefensiveActionHolder? with a DefensiveAction's result if successful, otherwise null.</returns> public BattleGlobals.DefensiveActionHolder?GetDefensiveActionResult(int damage, StatusChanceHolder[] statusesInflicted, DamageEffects damageEffects, DefensiveActionTypes defensiveOverrides) { //Handle Defensive Actions for (int i = 0; i < DefensiveActions.Count; i++) { //Check if there are any overrides for this type of Defensive Action if (defensiveOverrides != DefensiveActionTypes.None && UtilityGlobals.DefensiveActionTypesHasFlag(defensiveOverrides, DefensiveActions[i].DefensiveActionType)) { Debug.Log($"{defensiveOverrides} overrode {DefensiveActions[i].DefensiveActionType}!"); continue; } if (DefensiveActions[i].IsSuccessful == true) { BattleGlobals.DefensiveActionHolder holder = DefensiveActions[i].HandleSuccess(damage, statusesInflicted, damageEffects); return(holder); } } return(null); }
/// <summary> /// Entity-specific logic for handling DamageEffects. /// </summary> /// <param name="damageEffects">The bit field of DamageEffects.</param> protected virtual void HandleDamageEffects(DamageEffects damageEffects) { }
void Start() { effects = GetComponent <DamageEffects>(); source = GetComponent <AudioSource>(); }
public override BattleGlobals.DefensiveActionHolder HandleSuccess(int damage, StatusChanceHolder[] statusEffects, DamageEffects damageEffects) { int newDamage = damage - 1; StatusChanceHolder[] newStatuses = FilterStatuses(statusEffects); BattleEventManager.Instance.QueueBattleEvent((int)BattleGlobals.StartEventPriorities.Damage, new BattleManager.BattleState[] { BattleManager.BattleState.Turn }, new WaitForAnimBattleEvent(User, AnimationGlobals.PlayerBattleAnimations.GuardName, true)); return(new BattleGlobals.DefensiveActionHolder(newDamage, newStatuses, Enumerations.DamageEffects.None)); }
/// <summary> /// Gets the result of the first successful Defensive Action performed. /// </summary> /// <param name="damage">The original damage of the attack.</param> /// <param name="statusesInflicted">The original set of StatusEffects inflicted.</param> /// <param name="damageEffects">The original DamageEffects that would affect the BattleEntity.</param> /// <returns>A nullable DefensiveActionHolder? with a DefensiveAction's result if successful, otherwise null.</returns> public BattleGlobals.DefensiveActionHolder?GetDefensiveActionResult(int damage, StatusChanceHolder[] statusesInflicted, DamageEffects damageEffects) { //Handle Defensive Actions for (int i = 0; i < DefensiveActions.Count; i++) { if (DefensiveActions[i].IsSuccessful == true) { BattleGlobals.DefensiveActionHolder holder = DefensiveActions[i].HandleSuccess(damage, statusesInflicted, damageEffects); return(holder); } } return(null); }
/// <summary> /// Tells whether the BattleEntity is vulnerable to any DamageEffect in a set of DamageEffects. /// </summary> /// <param name="damageEffects">The DamageEffects to check vulnerability to.</param> /// <returns>true if the BattleEntity is vulnerable to any of the DamageEffects, otherwise false.</returns> public bool IsVulnerableToDamageEffect(DamageEffects damageEffects) { DamageEffects vulnerableTest = (VulnerableDamageEffects & damageEffects); return(vulnerableTest != 0); }
/// <summary> /// Sets the BattleEntity's vulnerability to DamageEffects. /// <para>IMPORTANT: Make sure the BattleEntity implements the interfaces associated with each effect it's vulnerable to.</para> /// </summary> /// <param name="damageEffects">The DamageEffects value to set. This is a bit field.</param> public void SetVulnerableDamageEffects(DamageEffects damageEffects) { VulnerableDamageEffects = damageEffects; }