Beispiel #1
0
    private void ShowDamageBurst(HitStatus status, int damage = 0)
    {
        var             clone      = (GameObject)Instantiate(this.damageNumbers, this.gameObject.transform.position, Quaternion.Euler(Vector3.zero));
        FloatingNumbers damageText = clone.GetComponent <FloatingNumbers>();

        damageText.SetDamageDone(damage);
        damageText.SetHitStatus(status);
    }
Beispiel #2
0
    public void TryAttack(StatsManager other)
    {
        bool canReceiveAttack = true;

        if (other.gameObject.tag == "Enemy")
        {
            var enemy = other.gameObject.GetComponent <EnemyController>();
            canReceiveAttack = enemy.CanReceiveAttack();
        }
        if (canReceiveAttack)
        {
            int       damage = 0;
            string    messageWhenTryingAttack = string.Empty;
            HitStatus status = this.DidHit(other);
            switch (status)
            {
            case HitStatus.EpicFail:
                damage = this.EpicFail();
                break;

            case HitStatus.FacePalm:
                // Missed
                UIManager.outputMessages.Add(string.Format("{0} missed {1}", this.GetName(), other.GetName()));
                break;

            case HitStatus.NotBad:
                messageWhenTryingAttack += string.Format("{0} hit {1}", this.GetName(), other.GetName());
                UIManager.outputMessages.Add(messageWhenTryingAttack);
                damage = this.RollDamage(other);
                if (("" + UIManager.outputMessages[UIManager.outputMessages.Count - 1]).Contains("experience"))
                {
                    UIManager.outputMessages[UIManager.outputMessages.Count - 2] += string.Format(" by {0}", damage);
                }
                else
                {
                    UIManager.outputMessages[UIManager.outputMessages.Count - 1] += string.Format(" by {0}", damage);
                }
                break;

            case HitStatus.YoureAwesome:
                messageWhenTryingAttack += string.Format("{0} critically hit {1}", this.GetName(), other.GetName());
                UIManager.outputMessages.Add(messageWhenTryingAttack);
                damage  = this.RollDamage(other);
                damage += this.RollDamage(other);
                if (("" + UIManager.outputMessages[UIManager.outputMessages.Count - 1]).Contains("experience"))
                {
                    UIManager.outputMessages[UIManager.outputMessages.Count - 2] += string.Format(" by {0}", damage);
                }
                else
                {
                    UIManager.outputMessages[UIManager.outputMessages.Count - 1] += string.Format(" by {0}", damage);
                }
                break;
            }
            this.ShowDamageBurst(status, damage);
            if (damage > 0)
            {
                other.flashAfterTakingDamage        = true;
                other.flashAfterTakingDamageCounter = other.flashAfterTakingDamageLength;
                if (other.gameObject.tag == "Player")
                {
                    this.sfxManager.playerHurt.Play();
                }

                this.sceneManager.SetObjectsThatTouch(this.gameObject, other.gameObject);

                // DB: Save who took damage
            }
        }
        else
        {
            UIManager.outputMessages.Add("INVULNERABLE!");
            var             clone      = (GameObject)Instantiate(this.damageNumbers, this.gameObject.transform.position, Quaternion.Euler(Vector3.zero));
            FloatingNumbers damageText = clone.GetComponent <FloatingNumbers>();
            damageText.SetHitStatus(HitStatus.Invulnerable);
        }
    }