Ejemplo n.º 1
0
    public string Heal(string[] args)
    {
        var healerName          = args[0];
        var healingReceiverName = args[1];

        var healer = this.party.FirstOrDefault(c => c.Name == healerName);

        if (healer == null)
        {
            throw new ArgumentException($"Character {healerName} not found!");
        }
        var receiver = this.party.FirstOrDefault(c => c.Name == healingReceiverName);

        if (receiver == null)
        {
            throw new ArgumentException($"Character {healingReceiverName} not found!");
        }
        IHealable healeable = null;

        try
        {
            healeable = (IHealable)healer;
        }
        catch (Exception)
        {
            throw new ArgumentException($"{healerName} cannot heal!");
        }

        healeable.Heal(receiver);

        return($"{healer.Name} heals {receiver.Name} for {healer.AbilityPoints}! {receiver.Name} has {receiver.Health} health now!");
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider col)
    {
        if (!col.gameObject.TryGetComponent(out PlayerStatus pstats))
        {
            Physics.IgnoreCollision(myCollider, col);
            return;
        }

        IHealable applyHeal = col.gameObject.GetComponent <IHealable>();

        if (applyHeal != null)
        {
            switch (buffType)
            {
            case 0:
                applyHeal.AddBuff(new DamageUpStatus(100000f));
                break;

            case 1:
                applyHeal.AddBuff(new DefenseUpStatus(100000f));
                break;

            case 2:
                applyHeal.AddBuff(new SpeedUpStatus(100000f));
                break;
            }
            Destroy(gameObject);
        }
    }
        public string Heal(string[] args)
        {
            string healerName          = args[0];
            string healingReceiverName = args[1];

            Character healer          = this.GetCharacter(healerName);
            Character healingReceiver = this.GetCharacter(healingReceiverName);

            if (!healer.GetType()
                .GetInterfaces()
                .Contains(typeof(IHealable)))
            {
                throw new ArgumentException($"{healerName} cannot heal!");
            }

            IHealable healableCharacter = (IHealable)healer;

            healableCharacter.Heal(healingReceiver);

            string result = string.Format("{0} heals {1} for {2}! {3} has {4} health now!",
                                          healer.Name,
                                          healingReceiverName,
                                          healer.AbilityPoints,
                                          healingReceiverName,
                                          healingReceiver.Health);

            return(result);
        }
Ejemplo n.º 4
0
 public void AddListener(IHealable _iHealable)
 {
     if (_iHealable != null)
     {
         iHealableInterfaces.Add(_iHealable);
     }
 }
        public string Heal(string[] args)
        {
            string healerName   = args[0];
            string receiverName = args[1];

            CheckIfCharacterExist(healerName);
            CheckIfCharacterExist(receiverName);

            Character healer   = GetCharacter(healerName);
            Character receiver = GetCharacter(receiverName);

            if (!typeof(IHealable).IsAssignableFrom(healer.GetType()))
            {
                throw new ArgumentException($"{healer.Name} cannot heal!");
            }

            IHealable tempHealer = (IHealable)healer;

            tempHealer.Heal(receiver);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"{healer.Name} heals {receiver.Name} for {healer.AbilityPoints}! {receiver.Name} has {receiver.Health} health now!");


            return(sb.ToString().TrimEnd('\n', '\r'));
        }
Ejemplo n.º 6
0
        public string Heal(string[] args)
        {
            string healerName          = args[0];
            string healingReceiverName = args[1];

            Character healer = this.party.FirstOrDefault(x => x.Name == healerName);

            if (healer == null)
            {
                throw new ArgumentException($"Character {healerName} not found!");
            }

            Character receiver = this.party.FirstOrDefault(x => x.Name == healingReceiverName);

            if (receiver == null)
            {
                throw new ArgumentException($"Character {healingReceiverName} not found!");
            }

            if (!(healer is IHealable) && receiver is IAttackable && healer.IsAlive && receiver.IsAlive)
            {
                throw new ArgumentException($"{healerName} cannot heal!");
            }

            IHealable healer1 = healer;

            healer1.Heal(receiver);

            return($"{healer.Name} heals {receiver.Name} for {healer.AbilityPoints}! {receiver.Name} has {receiver.Health} health now!");
        }
Ejemplo n.º 7
0
        public int DoHeal(IHealable target, int healAmount)
        {
            var dmgHealed = target.TakeHeal(this, healAmount);

            OnDoneHeal(this, target, healAmount);
            return(dmgHealed);
        }
    public override void Apply(MonoBehaviour client)
    {
        // Make sure the client can be healed
        bool intHealable   = client as IHealable <int> != null;
        bool floatHealable = client as IHealable <float> != null;

        bool canHealClient = intHealable || floatHealable;

        if (canHealClient)
        {
            if (intHealable)
            {
                IHealable <int> toHeal = client as IHealable <int>;
                toHeal.TakeHealing(healAmount);
            }
            else if (floatHealable)
            {
                IHealable <float> toHeal = client as IHealable <float>;
                toHeal.TakeHealing(healAmount);
            }
        }
        else
        {
            // Report being unable to heal the client
            string format = "Healing effect {0} could not be applied on {1}; {1} does " +
                            "not implement IHealable in a way that {0} supports.";
            string errMessage = string.Format(format, this.name, client.name);
            throw new System.ArgumentException(errMessage);
        }
    }
Ejemplo n.º 9
0
 public static void HealEntity(IHealable obj, int val)
 {
     if (obj != null)
     {
         obj.OnHeal(val);
     }
 }
Ejemplo n.º 10
0
 OnTriggerEnter(Collider other)
 {
     if (HealAmount > 0)
     {
         IHealable isHealable = other.GetComponent <IHealable>();
         if (isHealable != null)
         {
             isHealable.Heal(HealAmount);
             timeLeft = respawnTimer;
             GetComponent <Renderer>().enabled = false;
             GetComponent <Collider>().enabled = false;
             _audioSource.Play();
         }
     }
     else if (HealAmount < 0)
     {
         IDamageable isDamagable = other.GetComponent <IDamageable>();
         if (isDamagable != null)
         {
             isDamagable.Damage(-HealAmount);
             timeLeft = respawnTimer;
             GetComponent <Renderer>().enabled = false;
             GetComponent <Collider>().enabled = false;
             _audioSource.Play();
         }
     }
 }
Ejemplo n.º 11
0
 public void HealTarget(IHealable h)
 {
     if (isActive)
     {
         h.Heal(healAmt);
         StartCoroutine(Cooldown());
     }
 }
        public override void Init(GameObject caster, GameObject target, Element element, StatusEffectData data)
        {
            base.Init(caster, target, element, data);

            healPerTick = data.DamagePerFrame;

            targetHealthSys = target.GetComponent <IHealable>();
        }
    protected override void React(Collider other)
    {
        IHealable target = other.GetComponent <IHealable>();

        Assert.IsNotNull(target, $"{other.gameObject.name} doesn't implement IHealable interface");

        healBehaviour.Heal(target);
    }
Ejemplo n.º 14
0
    public override void UseItem(Transform user)
    {
        IHealable userHealable = user.GetComponent <IHealable>();

        if (userHealable != null)
        {
            userHealable.Heal(healthRestoration);
        }
    }
Ejemplo n.º 15
0
    public void OnTriggerStay(Collider other)
    {
        IHealable healable = other.GetComponent <IHealable>();

        if (healable != null)
        {
            healable.Heal(_settings.HealingValue);
        }
    }
Ejemplo n.º 16
0
    OnTriggerEnter(Collider other)
    {
        IHealable isHealable = other.GetComponent <IHealable> ();

        if (isHealable != null)
        {
            isHealable.Heal(100);
        }
    }
Ejemplo n.º 17
0
    public void HealTarget(IHealable ih)
    {
        ih.HealHealth(healAmount);

        //Wouter BossSkillGeyser

        FMODUnity.RuntimeManager.PlayOneShotAttached("event:/Player/PlayerPickupHP", this.gameObject);
        Destroy(gameObject);
    }
Ejemplo n.º 18
0
    private void RestoreHealth()
    {
        IHealable healable = _player.GetComponent <IHealable>();

        if (healable != null)
        {
            healable.Heal(1.0f);
        }
    }
Ejemplo n.º 19
0
        void IDoHeal.OnHeal(IHealer source, IHealable target, int amount)
        {
            var player = target as IPlayer;

            if (player.Seat == Ui.Seat)
            {
                StartCoroutine(Play());
            }
        }
Ejemplo n.º 20
0
        protected override void OnCollisionEnter(Collision Collision)
        {
            IHealable healable = Collision.gameObject.GetComponent <IHealable>();

            if (healable != null && healable.CanHeal)
            {
                healable.Heal(new FHeal(_amount));
                Destroy(gameObject);
            }
        }
Ejemplo n.º 21
0
        public void Use(GameObject consumer)
        {
            IHealable target = consumer.GetComponent <IHealable>();

            if (target != null)
            {
                target.Heal(HealthRestored);
                Logger.LogFormat("Used health potion to restore {0} health.", HealthRestored);
            }
        }
Ejemplo n.º 22
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        IHealable healComponent = collider.GetComponent <IHealable>();

        if (healComponent != null)
        {
            healComponent.Heal(healthRestore);
            Destroy(this.gameObject);
        }
    }
Ejemplo n.º 23
0
 internal void TakeCare(IHealable healable)
 {
     if (healable.HealthStatus <= 80)
     {
         healable.Heal(40);
     }
     else if (healable.HealthStatus <= 100)
     {
         healable.Heal(30);
     }
 }
Ejemplo n.º 24
0
    public float healing = 0;       // Сила хила аптечки



    protected override void OnCollisionEnter2D(Collision2D collision)
    {
        IHealable healableObj = collision.gameObject.GetComponent <IHealable>();

        if (healableObj != null)
        {
            healableObj.Heal(healing);

            base.OnCollisionEnter2D(collision);
        }
    }
Ejemplo n.º 25
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == tag)
     {
         IHealable otherHealth = other.GetComponent <IHealable>();
         if (otherHealth != null)
         {
             otherHealth.Heal(otherHealth.GetMaxHealth() * healthPerSecond * Time.deltaTime);
         }
     }
 }
Ejemplo n.º 26
0
        public override void BeginEffect(Transform target)
        {
            IHealable healable = target.GetComponent <IHealable>();

            if (healable != null)
            {
                healable.Heal(_value);
            }

            PlayParticles(target);
        }
Ejemplo n.º 27
0
        void TryApplyHeal(IHealable target, int amount)
        {
            var targetChar = (IRuntimeCharacter)target;

            if (MyChar.Data.RuntimeData != targetChar)
            {
                return;
            }

            var notf  = UiNotificationTextPooler.Instance.Get();
            var final = transform.position + new Vector3(0, HeightNotification, 0);

            notf.Write(transform.position, final, amount + Heal, SpeedNotification, Color.green);
        }
Ejemplo n.º 28
0
    void OnTriggerEnter2D(Collider2D col)
    {
        IHealable i = Lib.FindInHierarchy <IHealable>(col.gameObject);

        if (i == null)
        {
            return;
        }
        this.enabled = true;
        if (!inside.Contains(i))
        {
            inside.Add(i);
        }
    }
Ejemplo n.º 29
0
    void OnTriggerExit2D(Collider2D col)
    {
        IHealable i = Lib.FindInHierarchy <IHealable>(col.gameObject);

        if (i == null)
        {
            return;
        }
        inside.Remove(i);
        if (inside.Count <= 0)
        {
            this.enabled = false;
        }
    }
Ejemplo n.º 30
0
 public DefendingCharacterState(
     IStateController controller,
     ISubject <AttackArgs> attackSubject,
     ISubject <DefendArgs> defendSubject,
     ISubject <HealArgs> healSubject,
     IDamageable damageable,
     IHealable healable
     ) : base(controller,
              attackSubject,
              defendSubject,
              healSubject,
              damageable,
              healable)
 {
 }