/// <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); } }
/// <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); } }