// Use this for initialization void Awake() { if (OnTakeDamage == null) { OnTakeDamage = new TakeDamageEvent(); } if (OnHeal == null) { OnHeal = new HealEvent(); } if (OnAddHealth == null) { OnAddHealth = new AddHealthEvent(); } if (OnSubtractHeath == null) { OnSubtractHeath = new SubtractHealthEvent(); } if (OnNoHealth == null) { OnNoHealth = new NoHealthEvent(); } maxHealth = startingHealth; currentHealth = maxHealth; }
private void ProcessHealEvent(HealEvent kEvent) { KVector2 healerPosition = kEvent.source; GameObject attacker = FruitonsGrid[healerPosition.x, healerPosition.y]; attacker.GetComponentInChildren <BoyFighterBattleAnimator>().Cast(() => AfterHealAnimation(kEvent)); }
public override void Execute(Vector2Int value, int level) { HealEvent e = Instantiate(heal, BattleEventManager.Instance.transform); e.heal = GetValue(value, level); e.target = EnemyArea.Instance.enemy; }
public void AddHealEvent(HealEvent healEvent) { if (healEvent.Source != Source || healEvent.Target != Target) { throw new ArgumentException($"This heal info is for {Source} and {Target}," + $" but you're adding an event for {healEvent.Source} and {healEvent.Target}."); } switch (healEvent.HealType) { case HealType.PotentialHealth: PotentialHealing += healEvent.Amount.Value; break; case HealType.RealizedHealth: RealizedHealing += healEvent.Amount.Value; if (healEvent.StartEvent != null) { Overhealing += healEvent.StartEvent.Amount.Value - healEvent.Amount.Value; } else // No corresponding potential, so adding realized is best we can do (happens when owner heals themselves). { PotentialHealing += healEvent.Amount.Value; } break; case HealType.Nano: NanoHealing += healEvent.Amount.Value; break; default: throw new NotImplementedException(); } }
public override void Execute(Vector2Int value, int power, CardDisplay cardDisplay) { HealEvent e = Instantiate(healEvent, BattleEventManager.Instance.transform); e.heal = GetFinalValue(value, power); e.target = PlayerArea.Instance.player; }
private void AfterHealAnimation(HealEvent kEvent) { KVector2 kEventPosition = kEvent.target; var clientFruiton = FruitonsGrid[kEventPosition.x, kEventPosition.y].GetComponent <ClientFruiton>(); clientFruiton.ReceiveHeal(kEvent.heal); ShowFloatingText(clientFruiton.transform.position, kEvent.heal); }
/// <summary> /// Lets object be healed. Negative values not allowed. /// Raises and healEvent when object is healed. /// </summary> /// <param name="amount"></param> The amount healed. public void Heal(int amount) { if (amount < 0) { return; } int newHealth = Mathf.Min((currentHealth + amount), maxHealth); HealEvent?.Invoke(newHealth - currentHealth); currentHealth = newHealth; Debug.Log("Healing current health with " + amount + " to " + currentHealth); }
public override void Enter(BEnemy owner) { //turn off FOV visualization owner.GetComponent <EnemyVision>().enabled = false; owner.pathFinder.isStopped = true; //drop item if (owner.itemDrop != null) { GameObject.Instantiate(owner.itemDrop, owner.transform.position, Quaternion.identity); } //play animation owner.transform.Find("Texture").GetComponent <SpriteRenderer>().enabled = false; //Give 1 health to player var giveHealth = new HealEvent(1); giveHealth.addListener(GameObject.Find("Player")); EventManager.Instance.addEvent(giveHealth); }
public int Heal(int heal) { if (!isServer) { return(0); } HealEvent e = GetEventSystem <HealEvent>().CallListners(new HealEvent(gameObject, heal)); if (e.IsCancel) { return(0); } int preHealth = HealthValue; HealthValue += e.Heal; if (HealthValue > (int)MaxHealth.GetCalculated()) { HealthValue = (int)MaxHealth.GetCalculated(); } return(HealthValue - preHealth); }
public void Heal(int heal) { this.health = GetHeal(this.health, heal); HealEvent?.Invoke(heal); }