Beispiel #1
0
    public void DealFallDamage(int damage)
    {
        GameObject dmgTxt = (GameObject)Instantiate(globalPrefabs.floatingDamageText);

        dmgTxt.transform.parent = this.transform;
        FloatingTextGUI dmgText      = dmgTxt.GetComponent <FloatingTextGUI>();
        string          damageString = ToolTipStyle.Bold + ToolTipStyle.Red + "-" + damage.ToString() + ToolTipStyle.EndColor + ToolTipStyle.EndBold;

        dmgText.PlayerDamage(damageString, this.transform.position, 1.5f);
        _pc.GetVital((int)VitalName.Health).CurValue -= damage;
    }
Beispiel #2
0
    public void DealDamage(int damage)
    {
        int damageToDeal = (int)Random.Range(damage * 0.3f, damage + 1);
        int baseDamage   = (int)(damageToDeal * Random.Range(0.1f, 0.2f));

        damageToDeal -= baseDamage;
        if (!Invincible)
        {
            //Armor blocks it
            damageToDeal -= _pc.PlayerArmor;


            GameObject dmgTxt = Instantiate(globalPrefabs.floatingDamageText, transform.position, Quaternion.identity) as GameObject;
            dmgTxt.transform.parent = this.transform;
            FloatingTextGUI dmgText = dmgTxt.GetComponent <FloatingTextGUI>();
            dmgText.PlayerDamage("", _pc.transform.position, 0.5f);

            //Chance to block (damage blocked always equal to Pc.DamageBlocked)
            int blockRandom = Random.Range(0, 100 + 1);

            if (blockRandom < (_pc.PlayerChanceToBlock * 100))
            {
                damageToDeal -= _pc.PlayerDamageBlocked;

                dmgText.AddToText(ToolTipStyle.Italic + "\t" + ToolTipStyle.Small + "Block!" + ToolTipStyle.EndSize + ToolTipStyle.EndItalic);
            }

            //deal the damage
            if (damageToDeal < 0)
            {
                damageToDeal = 0;
            }

            damageToDeal += baseDamage;             //will always do some damage

            dmgText.AddToText(ToolTipStyle.Break + ToolTipStyle.Brown + "-" + damageToDeal.ToString() + ToolTipStyle.EndColor);
            _pc.GetVital((int)VitalName.Health).CurValue -= damageToDeal;
        }
    }