public static bool IsOnCooldown(this IHeal heal, IEnumerable <EngineRoundTick> roundTicks) { return(heal.Skill.Cooldown > 0 && roundTicks .GetLastRounds(heal.Skill.Cooldown) .OfType <FighterHealTick>() .Where(o => o.Fighter.Id == heal.Actor.Id) .Any(o => o.Skill.Id == heal.Skill.Id)); }
public static FighterHealTick GetFighterHealTick(this IHeal heal) { return(new FighterHealTick() { Fighter = heal.Actor.AsStruct(), Target = heal.Target.AsStruct(), HealSkill = heal.Skill, }); }
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Transform objectHit = hit.transform; MonoBehaviour[] mono; mono = objectHit.gameObject.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour item in mono) { if (item is IDamage) { IDamage temp = item as IDamage; temp.TakeDamage(); return; } if (item is IExplode) { IExplode temp = item as IExplode; temp.Explode(); return; } } } } if (Input.GetMouseButtonDown(1)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Transform objectHit = hit.transform; MonoBehaviour[] mono; mono = objectHit.gameObject.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour item in mono) { if (item is IHeal) { IHeal temp = item as IHeal; temp.Heal(); return; } } } } }
public string Heal() { ISlot healingItemSlot = this.inventory.BackPack.SlotList .FirstOrDefault(s => !s.IsEmpty && s.Item.GetType().BaseType.Name == HealthPotion); if (healingItemSlot != null) { IHeal potion = healingItemSlot.Item as IHeal; this.health += potion.HealingPoints; healingItemSlot.IsEmpty = true; healingItemSlot.Item = null; return(string.Format(Message.SuccessRestoreHealth, potion.HealingPoints)); } return(Message.NoHealingItemsLeft); }
public static IEnumerable <EngineTick> Handle( this IHeal heal, Dictionary <Guid, IFighterStats> fighters, IEnumerable <EngineRoundTick> roundTicks, EngineCalculationValues calculationValues) { var ticks = new List <EngineTick>(); var healTick = heal.GetFighterHealTick(); ticks.Add(healTick); if (heal.IsOnCooldown(roundTicks)) { healTick.OnCooldown = true; return(ticks); } if (!heal.IsInRange()) { healTick.OutOfRange = true; return(ticks); } healTick.PotentialHealing = heal.GetHealValue(calculationValues); var target = fighters[heal.Target.Id]; healTick.AppliedHealing = target.Heal(healTick.PotentialHealing); target.DamageTaken -= healTick.AppliedHealing; var additionalTicks = heal.Skill.Perform(heal.Actor, heal.Target, calculationValues); foreach (var tick in additionalTicks.OfType <FighterTick>()) { tick.Handle(fighters); } ticks.AddRange(additionalTicks); return(ticks); }
public void heal(IHeal healer) { float amount = healer.getAmount(); healthContainer.add(amount); }
public HealCommand(IHeal healer) { this.healer = healer; }
public static int GetHealValue(this IHeal heal, EngineCalculationValues calculationValues) { return(heal.Skill.Heal * (1 + (int)(heal.Actor.GetAdjustedStats().HealingPower *calculationValues.HealingPowerFactor))); }
public static float GetDistance(this IHeal heal) { return(heal.Actor.GetDistanceAbs(heal.Target)); }
public static bool IsInRange(this IHeal heal) { return(heal.GetDistance() <= heal.Skill.Range); }
public void Heal(IHeal heal) { _health = Mathf.Clamp(_health += heal.Amount, MIN_HEALTH, MAX_HEALTH); OnHeal?.Invoke(heal); }