void ApplyAbility() { BaseAbilityEffect[] effects = turn.ability.GetComponentsInChildren <BaseAbilityEffect>(); for (int i = 0; i < turn.targets.Count; ++i) { Tile target = turn.targets[i]; for (int j = 0; j < effects.Length; ++j) { BaseAbilityEffect effect = effects[j]; AbilityEffectTarget targeter = effect.GetComponent <AbilityEffectTarget>(); if (targeter.IsTarget(target)) { //calculate actual hit rate HitRate rate = effect.GetComponent <HitRate>(); int chance = rate.Calculate(target); if (UnityEngine.Random.Range(0, 101) > chance) { // A Miss! Debug.Log("Action Missed!"); continue; } //apply damage/effect on hit effect.Apply(target); } } } }
void ApplyAbility() { BaseAbilityEffect[] effects = turn.ability.GetComponentsInChildren <BaseAbilityEffect>(); for (int i = 0; i < turn.targets.Count; ++i) { Tile target = turn.targets[i]; for (int j = 0; j < effects.Length; ++j) { BaseAbilityEffect effect = effects[j]; AbilityEffectTarget targeter = effect.GetComponent <AbilityEffectTarget>(); if (targeter.IsTarget(target)) { HitRate rate = effect.GetComponent <HitRate>(); int chance = rate.Calculate(target); if (UnityEngine.Random.Range(0, 101) > chance) { Debug.Log(turn.actor.name + " missed!"); // Swing and a miss! continue; } effect.Apply(target); } } } }
private void UpdateHitSuccessIndicator() { int chance = 0; int amount = 0; Tile target = turn.targets[index]; Transform obj = turn.ability.transform; for (int i = 0; i < obj.childCount; ++i) { AbilityEffectTarget targeter = obj.GetChild(i).GetComponent <AbilityEffectTarget>(); if (targeter.IsTarget(target)) { HitRate hitRate = targeter.GetComponent <HitRate>(); chance = hitRate.Calculate(target); BaseAbilityEffect effect = targeter.GetComponent <BaseAbilityEffect>(); if (effect == null) { throw new Exception("Missing AbilityEffect component."); } amount = effect.Predict(target); break; } } hitIndicatorPanelController.SetStats(chance, amount); }
void Perform(Tile target) { for (int i = 0; i < transform.childCount; ++i) { Transform child = transform.GetChild(i); BaseAbilityEffect effect = child.GetComponent <BaseAbilityEffect>(); effect.Apply(target); } }
void UpdateHitSuccessIndicator() { int chance = 0; int amount = 0; Tile target = turn.targets[index]; for (int i = 0; i < targeters.Length; ++i) { if (targeters[i].IsTarget(target)) { HitRate hitRate = targeters[i].GetComponent <HitRate>(); chance = hitRate.Calculate(target); BaseAbilityEffect effect = targeters[i].GetComponent <BaseAbilityEffect>(); amount = effect.Predict(target); break; } } hitSuccessIndicator.SetStats(chance, amount); }
void UpdateHitSuccessIndicator() { int chance = 0; int amount = 0; WorldTile target = turn.targets[index]; Transform obj = turn.ability.transform; for (int i = 0; i < obj.childCount; ++i) { AbilityEffectTarget targeter = obj.GetChild(i).GetComponent <AbilityEffectTarget>(); if (targeter.IsTarget(target)) { HitRate hitRate = targeter.GetComponent <HitRate>(); chance = hitRate.Calculate(target); BaseAbilityEffect effect = targeter.GetComponent <BaseAbilityEffect>(); amount = effect.Predict(target); break; } } hitSuccessIndicator.SetStats(chance, amount); }
public void Load(CardRecipe data) { AbilityManaCost abilityManaCost = GetComponent <AbilityManaCost>(); if (abilityManaCost == null) { abilityManaCost = gameObject.AddComponent <AbilityManaCost>(); } AbilityEffectTarget abilityEffectTarget = GetComponent <AbilityEffectTarget>(); if (abilityEffectTarget != null) { DestroyImmediate(abilityEffectTarget, true); } BaseAbilityEffect abilityEffect = GetComponent <BaseAbilityEffect>(); if (abilityEffect != null) { DestroyImmediate(abilityEffect, true); } BaseAbilityPower power = GetComponent <BaseAbilityPower>(); if (power != null) { DestroyImmediate(power, true); } AbilityRange range = GetComponent <AbilityRange>(); if (range != null) { DestroyImmediate(range, true); } if (data == null) { Name = ""; Desc = ""; abilityManaCost.amount = 0; abilityEffectTarget = gameObject.AddComponent <DefaultAbilityEffectTarget>(); abilityEffect = gameObject.AddComponent <DamageAbilityEffect>(); power = gameObject.AddComponent <PhysicalAbilityPower>(); power.Power = 0; range = gameObject.AddComponent <ConstantAbilityRange>(); range.horizontal = 0; this.data = Resources.Load("Recipes/CardRecipes/Empty Card Data") as CardRecipe; ID = GetInstanceID(); visualEffect = null; return; } Name = data.Name; Desc = data.Description; abilityManaCost.amount = data.AbilityManaCost; abilityEffectTarget = gameObject.AddComponent(Type.GetType(data.AbilityEffectTarget)) as AbilityEffectTarget; if (data.AbilityEffect.Contains("InflictStatus")) { string ae = "InflictStatusAbilityEffect"; string status = string.Format("{0}StatusEffect", data.AbilityEffect.Substring(13, data.AbilityEffect.Length - 26)); InflictStatusAbilityEffect effect = gameObject.AddComponent(Type.GetType(ae)) as InflictStatusAbilityEffect; effect.statusName = status; abilityEffect = effect; } else { abilityEffect = gameObject.AddComponent(Type.GetType(data.AbilityEffect)) as BaseAbilityEffect; } power = gameObject.AddComponent(Type.GetType(data.AbilityPower)) as BaseAbilityPower; power.Power = data.BasePower; range = gameObject.AddComponent(Type.GetType(data.AbilityRange)) as AbilityRange; range.horizontal = data.AbilityRangeHorizontal; this.data = data; ID = GetInstanceID(); visualEffect = data.ParticleEffect; }
void Perform(Tile target) { BaseAbilityEffect effect = transform.GetComponentInChildren <BaseAbilityEffect>(); effect.OnApply(target); }
void Awake() { effect = GetTrackedEffect(); }
private void AddEffect(IFighter aTarget) { BaseAbilityEffect abilityEffect = (BaseAbilityEffect)aTarget.GetFighterGameObject().AddComponent(System.Type.GetType(m_EffectScript)); abilityEffect.InitEffect(aTarget, m_EffectLifeSpan, m_EffectPower); }
void Awake() { _activeEffect = GetComponentInChildren <BaseAbilityEffect>(); }