Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 public static FighterHealTick GetFighterHealTick(this IHeal heal)
 {
     return(new FighterHealTick()
     {
         Fighter = heal.Actor.AsStruct(),
         Target = heal.Target.AsStruct(),
         HealSkill = heal.Skill,
     });
 }
Ejemplo n.º 3
0
    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;
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public void heal(IHeal healer)
        {
            float amount = healer.getAmount();

            healthContainer.add(amount);
        }
 public HealCommand(IHeal healer)
 {
     this.healer = healer;
 }
Ejemplo n.º 8
0
 public static int GetHealValue(this IHeal heal, EngineCalculationValues calculationValues)
 {
     return(heal.Skill.Heal * (1 + (int)(heal.Actor.GetAdjustedStats().HealingPower *calculationValues.HealingPowerFactor)));
 }
Ejemplo n.º 9
0
 public static float GetDistance(this IHeal heal)
 {
     return(heal.Actor.GetDistanceAbs(heal.Target));
 }
Ejemplo n.º 10
0
 public static bool IsInRange(this IHeal heal)
 {
     return(heal.GetDistance() <= heal.Skill.Range);
 }
Ejemplo n.º 11
0
        public void Heal(IHeal heal)
        {
            _health = Mathf.Clamp(_health += heal.Amount, MIN_HEALTH, MAX_HEALTH);

            OnHeal?.Invoke(heal);
        }