/// <summary> /// Applies an effect in a square. Ignores LOS. /// </summary> /// <param name="radius">How many blocks out to effect. EG: radius of 1 is a 3x3 effect.</param> /// <param name="center">coords for the center of the AOE effect.</param> /// <param name="player">coords for where the player is.</param> /// <param name="hitMiddle">Should we apply the effect to the middle tile?</param> /// <param name="appliedEffect">What effect to apply</param> /// <param name="hitEmpty">Apply the effect even if no creature is there?</param> /// <returns>Returns the number of targets hit. Note that if you have hit empty enabled, this will just count tiles.</returns> public static int SquareAOE(int radius, Vector2Int center, Vector2Int player, bool hitMiddle, IEffect appliedEffect, bool hitEmpty) { // Want to apply bonus damage once Strike s = appliedEffect as Strike; int oldDamage = 0; if (s != null) { oldDamage = s.Damage; s.Damage = (int)((s.Damage + BattleManager.cardResolveStack.GetMomentumBonus()) * BattleManager.cardResolveStack.GetInsightBonus()); } int targetsHit = 0; for (int xOffset = -radius; xOffset <= radius; xOffset++) { for (int yOffset = -radius; yOffset <= radius; yOffset++) { if (!(xOffset == 0 && yOffset == 0) || hitMiddle) { try { if (hitEmpty || BattleManager.instance.map.map[center.x + xOffset, center.y + yOffset].IsCreatureOnTile()) { targetsHit++; Debug.Log("AOE effect triggered. Offset = " + xOffset + ", " + yOffset + ". Hitmiddle: " + hitMiddle); appliedEffect.Activate(player, new Vector2Int(center.x + xOffset, center.y + yOffset)); } } catch (Exception) { // Outside of map. Do nothing. } } } } if (s != null) { s.Damage = oldDamage; } return(targetsHit); }
public void ApplyEffect(GameObject target, IEffect effect, BaseAsyncSkillEfector.EffectType type) { bool overrided = false; if (type == BaseAsyncSkillEfector.EffectType.Overwrite) { var effectInstance = _activeEffectList.FirstOrDefault(e => e.EffectName == effect.GetType().Name); var index = _activeEffectList.IndexOf(effectInstance); if (index > -1) { _activeEffectList[index] = new EffectInfo(effect); _activeEffectList[index].Effect.Activate(target); overrided = true; } } if (!overrided) { effect.Activate(target); _activeEffectList.Add(new EffectInfo(effect)); } }