Пример #1
0
    private void Initialize()
    {
        if (type == Type.Enemy)
        {
            //Debug.Log("Enemy initialized. (call second)");
            EnemyInfo ei = EnemyManager.em.FindEnemyInfo(name, level);
            size      = ei.size;
            maxHealth = (int)(ei.maxHealth * (1f + (level / 10) * 0.5f));
            weapons   = new List <Weapon> {
                ei.weapon.Clone()
            };
            armor = ei.armor.Clone();
            weapons[0].element += ei.weaponDelta * (level - 1);
            armor.element      += ei.armorDelta * (level - 1);
            bonusMaxHealth      = 0;

            if (ei.name.Equals("Fire golem"))
            {
                armor.activeArmorEffects.Add(new KeyValuePair <string, int>("Disguise", 1));
            }
            else if (ei.name.Equals("Ice golem"))
            {
                armor.activeArmorEffects.Add(new KeyValuePair <string, int>("Disguise", 2));
            }
            else if (ei.name.Equals("Nature golem"))
            {
                armor.activeArmorEffects.Add(new KeyValuePair <string, int>("Disguise", 0));
            }

            ((EnemyMover)mover).distanceType  = ei.distanceType;
            ((EnemyMover)mover).sightDistance = ei.sightDistance;
            ((EnemyMover)mover).leaveDistance = ei.leaveDistance;
        }
        else
        {
            weapons        = GameManager.gm.GetComponent <DataReader>().playerWeapons;
            armor          = GameManager.gm.GetComponent <DataReader>().playerArmor;
            bonusMaxHealth = GameManager.gm.GetComponent <DataReader>().playerBonusMaxHealth;
        }
        currentHealth = MaxHealth;
        if (healthBar != null)
        {
            healthBar.maxValue = MaxHealth;
            healthBar.value    = currentHealth;
        }
        oldHealth     = currentHealth;
        trueOldHealth = currentHealth;
        poisonDamage  = 0;
        gustDamage    = 0;
        reflectDamage = 0;
        attackSum     = 0;
        hasStuned     = false;
        hasReflected  = false;
        ToggleWeapon();

        if (statusUI != null)
        {
            statusUI.UpdateAll(this, currentHealth);
        }
    }
Пример #2
0
    public IEnumerator ReflectedAnimation(int oldHealth, Slider healthBar = null, StatusUI statusUI = null, Vector3 direction = new Vector3())
    {
        isMoving = true;
        int     frame            = 25;
        Vector3 originalPosition = GetComponent <Transform>().position;
        Color   originalColor    = GetComponent <SpriteRenderer>().color;

        GameObject g = Instantiate(damageNumber, c.canvas.GetComponent <Transform>());

        g.GetComponent <DamageNumber>().Initialize(oldHealth - c.currentHealth, DamageNumber.DamageType.Reflect);

        for (int i = 0; i < frame; i++)
        {
            if (i < frame / 2)
            {
                GetComponent <SpriteRenderer>().color = Color.Lerp(originalColor, new Color(0.7f, 0.7f, 0f, 0.8f), (float)i / frame * 2);
                if (!direction.Equals(new Vector3()))
                {
                    GetComponent <Transform>().position = Vector3.Lerp(originalPosition, originalPosition + 0.2f * direction, (float)i / frame * 2);
                }
            }
            else
            {
                GetComponent <SpriteRenderer>().color = Color.Lerp(originalColor, new Color(0.7f, 0.7f, 0f, 0.8f), (float)(frame - i) / frame * 2);
                if (!direction.Equals(new Vector3()))
                {
                    GetComponent <Transform>().position = Vector3.Lerp(originalPosition, originalPosition + 0.2f * direction, (float)(frame - i) / frame * 2);
                }
            }

            float f = Mathf.Lerp(c.currentHealth, oldHealth, Mathf.Pow(1 - ((float)i / frame), 2f));
            if (healthBar != null)
            {
                healthBar.value = f;
            }
            if (statusUI != null)
            {
                statusUI.UpdateAll(c, (int)f);
            }

            yield return(null);
        }
        if (healthBar != null)
        {
            healthBar.value = c.currentHealth;
        }
        if (statusUI != null)
        {
            statusUI.UpdateAll(c, c.currentHealth);
        }
        GetComponent <SpriteRenderer>().color = originalColor;
        if (!direction.Equals(new Vector3()))
        {
            GetComponent <Transform>().position = originalPosition;
        }

        isMoving = false;
    }
Пример #3
0
    public IEnumerator PoisonedAnimation(int oldHealth, Slider healthBar = null, StatusUI statusUI = null)
    {
        isMoving = true;
        int   frame    = 10;
        Color original = GetComponent <SpriteRenderer>().color;

        GameObject g = Instantiate(damageNumber, c.canvas.GetComponent <Transform>());

        g.GetComponent <DamageNumber>().Initialize(oldHealth - c.currentHealth, DamageNumber.DamageType.Poison);

        for (int i = 0; i < frame; i++)
        {
            if (i < frame / 2)
            {
                GetComponent <SpriteRenderer>().color = Color.Lerp(original, new Color(0.7f, 0f, 0.7f, 0.6f), (float)i / frame * 2);
            }
            else
            {
                GetComponent <SpriteRenderer>().color = Color.Lerp(new Color(1f, 1f, 1f, 1f), new Color(0.7f, 0f, 0.7f, 0.6f), (float)(frame - i) / frame * 2);
            }

            float f = Mathf.Lerp(c.currentHealth, oldHealth, Mathf.Pow(1 - ((float)i / frame), 2f));
            if (healthBar != null)
            {
                healthBar.value = f;
            }
            if (statusUI != null)
            {
                statusUI.UpdateAll(c, (int)f);
            }

            yield return(null);
        }
        if (healthBar != null)
        {
            healthBar.value = c.currentHealth;
        }
        if (statusUI != null)
        {
            statusUI.UpdateAll(c, c.currentHealth);
        }
        GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f);
        isMoving = false;
    }
Пример #4
0
    public IEnumerator RegeneratedAnimation(int oldHealth, Slider healthBar = null, StatusUI statusUI = null)
    {
        isMoving = true;
        int frame = 6;

        if (c.currentHealth == oldHealth)
        {
            isMoving = false;

            // 여기서도 코루틴이 종료될 수 있음에 주의!
            yield break;
        }

        GameObject g = Instantiate(damageNumber, c.canvas.GetComponent <Transform>());

        g.GetComponent <DamageNumber>().Initialize(c.currentHealth - oldHealth, DamageNumber.DamageType.Heal);

        for (int i = 0; i < frame; i++)
        {
            float f = Mathf.Lerp(c.currentHealth, oldHealth, Mathf.Pow(1 - ((float)i / frame), 2f));
            if (healthBar != null)
            {
                healthBar.value = f;
            }
            if (statusUI != null)
            {
                statusUI.UpdateAll(GetComponent <Character>(), (int)f);
            }

            yield return(null);
        }
        if (healthBar != null)
        {
            healthBar.value = c.currentHealth;
        }
        if (statusUI != null)
        {
            statusUI.UpdateAll(GetComponent <Character>(), c.currentHealth);
        }
        isMoving = false;
    }
Пример #5
0
    public override IEnumerator DamagedAnimation(int oldHealth, Slider healthBar = null, StatusUI statusUI = null, Vector3 direction = new Vector3(), bool isCritical = false)
    {
        isMoving = true;
        float         frame = 16, frame2 = 0, frame3 = 10;
        Vector3       originalPosition = t.position;
        Color         originalColor    = GetComponent <SpriteRenderer>().color;
        DamagedScreen damagedScreen    = GameManager.gm.Canvas.GetComponent <UIInfo>().DamagedPanel;

        DamageNumber.DamageType dt = DamageNumber.DamageType.Normal;
        if (isCritical)
        {
            dt = DamageNumber.DamageType.Critical;
        }

        if (!direction.Equals(new Vector3()))
        {
            GameObject g = Instantiate(damageNumber, c.canvas.GetComponent <Transform>());
            g.GetComponent <DamageNumber>().Initialize(oldHealth - c.currentHealth, dt);
        }

        for (int i = 0; i < frame + frame2; i++)
        {
            if (i < frame / 2)
            {
                GetComponent <SpriteRenderer>().color = Color.Lerp(originalColor, new Color(0.7f, 0f, 0f, 0.6f), i / frame * 2);
                if (!direction.Equals(new Vector3()))
                {
                    t.position = Vector3.Lerp(originalPosition, originalPosition + 0.2f * direction, i / frame * 2);
                }
            }
            else
            {
                GetComponent <SpriteRenderer>().color = Color.Lerp(originalColor, new Color(0.7f, 0f, 0f, 0.6f), (frame + frame2 - i) / (frame / 2 + frame2));
                if (!direction.Equals(new Vector3()))
                {
                    t.position = Vector3.Lerp(originalPosition, originalPosition + 0.2f * direction, (frame + frame2 - i) / (frame / 2 + frame2));
                }
            }

            if (c.currentHealth <= c.MaxHealth / 6)
            {
                damagedScreen.StartEffect(true);
            }
            else if (c.currentHealth <= c.MaxHealth / 3)
            {
                damagedScreen.StartEffect(false);
            }

            if (i < frame)
            {
                float f = Mathf.Lerp(c.currentHealth, oldHealth, Mathf.Pow(1 - (i / frame), 2f));
                if (healthBar != null)
                {
                    healthBar.value = f;
                }
                if (statusUI != null)
                {
                    statusUI.UpdateAll(c, (int)f);
                }
            }

            yield return(null);
        }
        if (healthBar != null)
        {
            healthBar.value = c.currentHealth;
        }
        if (statusUI != null)
        {
            statusUI.UpdateAll(c, c.currentHealth);
        }
        GetComponent <SpriteRenderer>().color = originalColor;
        if (!direction.Equals(new Vector3()))
        {
            t.position = originalPosition;
        }

        for (int i = 0; i < frame3; i++)
        {
            yield return(null);
        }

        isMoving = false;
    }
Пример #6
0
    public IEnumerator HealedAnimation(int oldHealth, Slider healthBar = null, StatusUI statusUI = null, bool isDrain = false)
    {
        isMoving = true;
        int frame = 25;

        if (isDrain)
        {
            frame = 6;
        }
        Color original   = GetComponent <SpriteRenderer>().color;
        Color afterColor = new Color(1f, 1f, 1f, 1f);

        if (isDrain)
        {
            afterColor = original;
        }

        if (c.currentHealth == oldHealth)
        {
            GetComponent <SpriteRenderer>().color = afterColor;
            isMoving = false;

            // 여기서도 코루틴이 종료될 수 있음에 주의!
            yield break;
        }

        GameObject g = Instantiate(damageNumber, c.canvas.GetComponent <Transform>());

        g.GetComponent <DamageNumber>().Initialize(c.currentHealth - oldHealth, DamageNumber.DamageType.Heal);

        for (int i = 0; i < frame; i++)
        {
            if (!isDrain)
            {
                if (i < frame / 2)
                {
                    GetComponent <SpriteRenderer>().color = Color.Lerp(original, new Color(0f, 0.7f, 0.2f, 0.6f), (float)i / frame * 2);
                }
                else
                {
                    GetComponent <SpriteRenderer>().color = Color.Lerp(afterColor, new Color(0f, 0.7f, 0.2f, 0.6f), (float)(frame - i) / frame * 2);
                }
            }

            float f = Mathf.Lerp(c.currentHealth, oldHealth, Mathf.Pow(1 - ((float)i / frame), 2f));
            if (healthBar != null)
            {
                healthBar.value = f;
            }
            if (statusUI != null)
            {
                statusUI.UpdateAll(GetComponent <Character>(), (int)f);
            }

            yield return(null);
        }
        if (healthBar != null)
        {
            healthBar.value = c.currentHealth;
        }
        if (statusUI != null)
        {
            statusUI.UpdateAll(GetComponent <Character>(), c.currentHealth);
        }
        GetComponent <SpriteRenderer>().color = afterColor;
        isMoving = false;
    }