Пример #1
0
    private IEnumerator Stun(float timeToStun)
    {
        StopCoroutine("Stun");

        GameObject dmgTxt = (GameObject)Instantiate(globalPrefabs.floatingDamageText);

        dmgTxt.transform.parent = this.transform;
        FloatingTextGUI dmgText = dmgTxt.GetComponent <FloatingTextGUI>();

        dmgText.SetDmgInfo(ToolTipStyle.Purple + "Stunned!" + ToolTipStyle.EndColor, transform.position);

        isStunned = true;
        yield return(new WaitForSeconds(timeToStun));

        isStunned = false;
    }
Пример #2
0
    private IEnumerator DoDot(string dotName, int damage, int ticks, float timeBetweenTicks)
    {
        currentDots.Add(dotName);
        for (int i = 0; i < ticks; i++)
        {
            this.GetComponent <Health>().CurrentHealth -= damage;

            GameObject dmgTxt = Instantiate(globalPrefabs.floatingDamageText) as GameObject;
            dmgTxt.transform.parent = this.transform;
            FloatingTextGUI dmgText = dmgTxt.GetComponent <FloatingTextGUI>();
            dmgText.SetDmgInfo(ToolTipStyle.Purple + damage.ToString() + ToolTipStyle.EndColor, transform.position);


            yield return(new WaitForSeconds(timeBetweenTicks));
        }
        currentDots.Remove(dotName);
    }
Пример #3
0
    private IEnumerator KnockBack()
    {
        StopCoroutine("KnockBack");
        isUseless     = true;
        isKnockedBack = true;

        GameObject dmgTxt = (GameObject)Instantiate(globalPrefabs.floatingDamageText);

        dmgTxt.transform.parent = this.transform;
        FloatingTextGUI dmgText = dmgTxt.GetComponent <FloatingTextGUI>();

        dmgText.SetDmgInfo(ToolTipStyle.Purple + "Knockback!" + ToolTipStyle.EndColor, transform.position);

        yield return(new WaitForSeconds(0.5f));

        isKnockedBack = false;
        isUseless     = false;
    }
Пример #4
0
    void DealDamage(Transform target)
    {
        Health hp = (Health)target.transform.GetComponent("Health");

        if (hp)
        {
            GameObject dmgTxt = (GameObject)Instantiate(globalPrefabs.floatingDamageText);
            dmgTxt.transform.parent = target;
            FloatingTextGUI ftg = dmgTxt.GetComponent <FloatingTextGUI>();
            ftg.SetDmgInfo("", target.position);
            MonsterAI fa = (MonsterAI)target.GetComponent <MonsterAI>();
            physicalDamageDealt = 0;
            int DamageDealt = CalculateWeaponDamage(ftg, fa);
            ProcHandler(fa);
            fa.inCombat           = true;
            hp.CurrentHealth      = hp.CurrentHealth - Damage;
            playerNew.playerState = PlayerState.Combat;
            playerNew.CheckForExitCombat();
        }
    }
Пример #5
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;
        }
    }
Пример #6
0
    private void ProcHandler(MonsterAI fa)
    {
        Weapon wep = playerNew.EquipedWeapon as Weapon;

        if (wep != null)
        {
            if (wep.Proc == ProcType.Slow || wep.Proc == ProcType.Poison ||
                wep.Proc == ProcType.Knockback || wep.Proc == ProcType.Stun)
            {
                int randomNum = Random.Range(0, 100 + 1);
                if (randomNum < (wep.ProcModifier * 100))
                {
                    switch (wep.Proc)
                    {
                    case ProcType.Slow:
                        fa.SlowAttackSpeed(0.3f);
                        break;

                    case ProcType.Poison:
                        int damageToDeal = (int)(fa.MonsterHealth * 0.01);
                        fa.UseDot("Poison", damageToDeal, 5, 0.5f);
                        break;

                    case ProcType.Knockback:
                        fa.KnockBackSelf();
                        break;

                    case ProcType.Stun:
                        fa.StunSelf(3.0f);
                        break;
                    }
                }
            }
            else
            {
                switch (wep.Proc)
                {
                case ProcType.GainLifeOnHit:
                    playerNew.GetVital((int)VitalName.Health).CurValue += (int)wep.ProcModifier;
                    GameObject infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    FloatingTextGUI ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    var             info = ToolTipStyle.Green + "+" + ((int)wep.ProcModifier).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.GainEnergyOnHit:
                    playerNew.GetVital((int)VitalName.Energy).CurValue += (int)wep.ProcModifier;
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Yellow + "+" + ((int)wep.ProcModifier).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.GainManaOnHit:
                    playerNew.GetVital((int)VitalName.Mana).CurValue += (int)wep.ProcModifier;
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Blue + "+" + ((int)wep.ProcModifier).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.ConvertToLife:
                    playerNew.GetVital((int)VitalName.Health).CurValue += (int)(wep.ProcModifier * physicalDamageDealt);
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Green + "+" + ((int)(wep.ProcModifier * physicalDamageDealt)).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.ConvertToEnergy:
                    playerNew.GetVital((int)VitalName.Energy).CurValue += (int)(wep.ProcModifier * physicalDamageDealt);
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Yellow + "+" + ((int)(wep.ProcModifier * physicalDamageDealt)).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                case ProcType.ConvertToMana:
                    playerNew.GetVital((int)VitalName.Mana).CurValue += (int)(wep.ProcModifier * physicalDamageDealt);
                    infoTxt = (GameObject)Instantiate(globalPrefabs.floatingBuffText);
                    infoTxt.transform.parent = this.transform;
                    ftg  = infoTxt.GetComponent <FloatingTextGUI>();
                    info = ToolTipStyle.Blue + "+" + ((int)(wep.ProcModifier * physicalDamageDealt)).ToString() + ToolTipStyle.EndColor;
                    ftg.SetInfo(info, transform.position);
                    break;

                default:
                    break;
                }
            }
        }
    }