Ejemplo n.º 1
0
    public void Damage(float dmg, Effect.AbilityEffect effect, bool crit, GameObject abilityOwner)
    {
        if (crit)
        {
            dmg *= 1.25f;
        }

        health -= dmg;                       // remove damage from health
        health  = health < 0 ? 0f : health;  // do not allow below 0

        if (health <= 0 && !isDead)
        {
            // inform player that it was killed
            abilityOwner.GetComponent <Player>().AddExperience(1200000); // TODO
            int experience = 1200000;
            print("Killed " + name + ": Gained " + experience + " experience");

            Kill();
        }

        damageTaken?.Invoke(dmg, new Effect.AbilityEffect(), crit); // inform subscribers that HP has changed
        healthChanged?.Invoke();
        _behaviorManager.Damaged(abilityOwner, dmg);

        if (effect.effectType != Effect.EffectType.Basic)
        {
            ApplyEffect(effect, abilityOwner);
        }
    }
Ejemplo n.º 2
0
 private void ShowCombatText(float damage, Effect.AbilityEffect effect, bool crit)
 {
     if (UISettings.instance.CombatActive)
     {
         // show the combat text
         initCBT(damage, effect, crit);
     }
 }
Ejemplo n.º 3
0
    public void SetVars(int damage_, float range, Effect.AbilityEffect effect_, GameObject owner, Ability.AbilityType aType)
    {
        damage      = damage_;
        maxRange    = range;
        effect      = effect_;
        _owner      = owner;
        abilityType = aType;

        startPosition = transform.position;
    }
Ejemplo n.º 4
0
    IEnumerator ApplyDamageEffect(Effect.AbilityEffect effect, GameObject abilityOwner)
    {
        int ticksRemaining = effect.numTicks;

        while (ticksRemaining > 0)
        {
            SubsequentDamage(effect, abilityOwner);
            ticksRemaining--;
            yield return(new WaitForSeconds(1));
        }
    }
Ejemplo n.º 5
0
    public void ApplyEffect(Effect.AbilityEffect effect, GameObject abilityOwner)
    {
        switch (effect.effectType)
        {
        case Effect.EffectType.Bleed:
        case Effect.EffectType.Burn:
        case Effect.EffectType.Poison:
        {
            StartCoroutine(ApplyDamageEffect(effect, abilityOwner));
        }
        break;

        case Effect.EffectType.Root:
            break;
        }
    }
Ejemplo n.º 6
0
    void initCBT(float damage, Effect.AbilityEffect effect, bool crit)
    {
        GameObject temp = Instantiate(combatText) as GameObject;

        temp.GetComponent <CombatTextDestroy>().SetParentWorldTransform(transform);
        RectTransform tempRect = temp.GetComponent <RectTransform>();


        temp.transform.SetParent(damageCanvas);
        tempRect.transform.localPosition = Vector3.zero;
        tempRect.transform.localScale    = combatText.transform.localScale;

        switch (effect.effectType)
        {
        case Effect.EffectType.Basic:
            temp.GetComponent <TMPro.TextMeshProUGUI>().color = textColors[0];
            break;

        case Effect.EffectType.Bleed:
            temp.GetComponent <TMPro.TextMeshProUGUI>().color = textColors[1];
            break;

        case Effect.EffectType.Burn:
            temp.GetComponent <TMPro.TextMeshProUGUI>().color = textColors[2];
            break;

        case Effect.EffectType.Poison:
            temp.GetComponent <TMPro.TextMeshProUGUI>().color = textColors[3];
            break;
        }

        if (crit)
        {
            temp.GetComponent <TMPro.TextMeshProUGUI>().fontSize *= 1.2f;
        }


        temp.GetComponent <TMPro.TextMeshProUGUI>().text = ((int)damage).ToString();

        temp.GetComponent <Animator>().SetTrigger("Hit");
    }
Ejemplo n.º 7
0
    void SubsequentDamage(Effect.AbilityEffect effect, GameObject abilityOwner)
    {
        if (isDead)
        {
            return;
        }

        int damage = effect.value;

        health -= damage;                    // remove damage from health
        health  = health < 0 ? 0f : health;  // do not allow below 0

        if (health <= 0)
        {
            Kill();
        }

        damageTaken?.Invoke(damage, effect, false); // inform subscribers that HP has changed
        healthChanged?.Invoke();
        _behaviorManager.Damaged(abilityOwner, damage);
    }
Ejemplo n.º 8
0
    public void Damage(float damage, Effect.AbilityEffect effect, bool crit, GameObject abilityOwner)
    {
        if (damage >= _health)
        {
            _health -= _health;
            TriggerDeath();
        }
        else
        {
            _health -= (int)damage;
            D_HealthChanged?.Invoke();

            switch (effect.effectType)
            {
            case Effect.EffectType.Basic:
            {
            }
            break;
            }
        }
    }
Ejemplo n.º 9
0
 public void ApplyEffect(Effect.AbilityEffect effect, GameObject abilityOwner)
 {
     throw new NotImplementedException();
 }