Пример #1
0
    // Update is called once per frame
    void Update()
    {
        // Make sure the Audio Souce follows the Player
        transform.position = player.position;

        if (health == null)
        {
            health = sC.GetStatOfType(StatType.HealthStat) as HealthStat;
            if (health.PrecentValue <= 0.3)
            {
                FX.clip = heartBeat;
                FX.Play();
                StartCoroutine(StartFade(100, 0.025f, FX));
                FX.loop = true;
            }
            else if (FX.isPlaying)
            {
                StartCoroutine(StartFade(50, 0.0f, FX));
                FX.Stop();
            }
        }

        Debug.Log(string.Format("Slime Status: {0}", GameObject.Find("slime_VFP(Clone)")));
        if (GameObject.Find("slime_VFP(Clone)") && !SlimeFX.isPlaying)
        {
            SlimeFX.Play();
            Debug.Log("Slime Playing");
        }
        else if (!GameObject.Find("slime_VFP(Clone)") && SlimeFX.isPlaying)
        {
            SlimeFX.Stop();
            Debug.Log("Slime Stop Playing");
        }
    }
Пример #2
0
    // do something on collision
    public override void onCollision(GameObject projectile, Collision2D collision)
    {
        Collider2D collider = collision.GetContact(0).collider;

        //Debug.Log(User.name + " hit " + collider.name);


        if (collider.gameObject == User)
        {
            return;
        }


        if (breakWalls)
        {
            Vector2 hitPos = collision.GetContact(0).point - collision.relativeVelocity.normalized * .1f;

            if (collision.GetContact(0).collider.name == "Walls")
            {
                FindObjectsOfType <Map.MapManager>()[0].DamageTile(hitPos.x, hitPos.y, damage);
                Destroy(projectile);
            }
        }

        StatControler sC;
        StatControler sCUser = User.GetComponent <StatControler>();

        if ((sC = collision.GetContact(0).collider.gameObject.GetComponent <StatControler>()) != null)
        {
            int finalDamage = 0;
            finalDamage += damage;

            HealthStat health      = sC.GetStatOfType(StatType.HealthStat) as HealthStat;
            ArmorStat  armor       = sC.GetStatOfType(StatType.ArmorStat) as ArmorStat;
            DamageStat damageBonus = sCUser.GetStatOfType(StatType.DamageStat) as DamageStat;

            if (armor != null)
            {
                finalDamage -= (int)armor.CalculateFinalValue();
            }
            if (damageBonus != null)
            {
                finalDamage += (int)damageBonus.CalculateFinalValue();
            }

            //Debug.Log(health);

            if (health != null)
            {
                //Debug.Log(finalDamage);
                health.addValue(-finalDamage);
                Destroy(projectile);
            }
        }
    }
Пример #3
0
    public void JoinNextLevel()
    {
        animator.SetBool("Falling", false);
        Map.MapManager.instance.JoinNextLevel();
        HealthStat h = statControler?.GetStatOfType(StatType.HealthStat) as HealthStat;

        if (h != null)
        {
            h.addValue(-1 * h.BaseValue * .5f);
        }
    }
Пример #4
0
    private void Update()
    {
        if (health == null)
        {
            health = sC.GetStatOfType(StatType.HealthStat) as HealthStat;
            health.OnStatDepletedCallBack += Die;
        }


        this.updateBar(health.PrecentValue);
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (stat == null)
        {
            stat = statControler.GetStatOfType(statType) as ConsumableStat;
            if (stat != null)
            {
                stat.OnStatDepletedCallBack += Die;
            }
        }

        if (transform.position != target)
        {
            target = player.position + new Vector3(attackRange / 2, attackRange / 2, 0);

            var norm = target;
            norm.Normalize();
            var angle = Mathf.Atan2(norm.x, norm.y);
            //Debug.Log(angle);

            if (angle < ThreePiOverFour && angle > -PiOverFour)
            {
                mageAni.SetInteger("WalkState", (int)DIR.UP);
            }
            else if (angle < PiOverFour && angle > -PiOverFour)
            {
                mageAni.SetInteger("WalkState", (int)DIR.RIGHT);
            }

            else if (angle < -PiOverFour && angle > -ThreePiOverFour)
            {
                mageAni.SetInteger("WalkState", (int)DIR.DOWN);
            }
            else if (angle > ThreePiOverFour || angle < -ThreePiOverFour)
            {
                mageAni.SetInteger("WalkState", (int)DIR.LEFT);
            }

            //transform.position = Vector3.MoveTowards(transform.position, target, Time.deltaTime * speed);
        }
        else
        {
            mageAni.SetInteger("WalkState", (int)DIR.IDLE);
        }

        if (Vector3.Distance(player.position, transform.position) <= attackRange)
        {
            UseItem();
        }

        Vector2 dir = target.normalized;

        rb.MovePosition(rb.position + dir * speed * Time.fixedDeltaTime);
    }
Пример #6
0
    private void Update()
    {
        if (stat == null)
        {
            stat = statControler.GetStatOfType(statType) as ConsumableStat;

            if (stat != null)
            {
                stat.OnStatDepletedCallBack += Die;
            }
        }
    }
Пример #7
0
    public void addItem(Item item)
    {
        Debug.Log("This got called");

        StatModifier armorMod = new StatModifier(item.armor, item.statModType, item.armorType);;

        StatModifier healthMod = new StatModifier(item.health, item.statModType, item.healthType);

        StatModifier damageMod = new StatModifier(item.damage, item.statModType, item.damageType);

        HealthStat health = statController.GetStatOfType(StatType.HealthStat) as HealthStat;
        ArmorStat  armor  = statController.GetStatOfType(StatType.ArmorStat) as ArmorStat;
        DamageStat damage = statController.GetStatOfType(StatType.DamageStat) as DamageStat;

        statController.AddModifier(healthMod);
        statController.AddModifier(armorMod);
        statController.AddModifier(damageMod);

        Debug.Log("Health total is " + health.CalculateFinalValue());
        Debug.Log("Damage total is " + damage.CalculateFinalValue());
        Debug.Log("Armor total is " + armor.CalculateFinalValue());


        items[(int)item.equipmentSlot] = item;

        for (int i = 0; i < equipmentUISlots.Length; i++)
        {
            if (item.equipmentSlot == equipmentUISlots[i].equipmentSlot)
            {
                equipmentUISlots[i].addItem(item);
            }
        }
    }
Пример #8
0
    IEnumerator SetHealth()
    {
        yield return(new WaitForEndOfFrame());

        if (health == null)
        {
            health = statControler.GetStatOfType(statType) as ConsumableStat;

            if (health != null)
            {
                health.OnStatDepletedCallBack += Die;
            }

            StartCoroutine(SetHealth());
        }
        else
        {
            StartCoroutine(EnemyFSM());
        }
    }
Пример #9
0
    private void Update()
    {
        //Debug.Log(target);
        rb.MovePosition(rb.position + dir * speed * Time.fixedDeltaTime);

        if (health == null)
        {
            health = GetComponent <StatControler>().GetStatOfType(StatType.HealthStat) as HealthStat;
        }

        if (stat == null)
        {
            stat = statControler.GetStatOfType(statType) as ConsumableStat;

            if (stat != null)
            {
                stat.OnStatChangeCallBack   += UpdateColor;
                stat.OnStatDepletedCallBack += Die;
            }
        }
    }
Пример #10
0
    // do something on collision
    public override void onCollision(GameObject attack, Collision2D collider)
    {
        //Debug.Log(User.name + " hit " + collider.gameObject.name);

        if (collider.gameObject == User)
        {
            return;
        }

        StatControler sC;
        StatControler sCUser = User.GetComponent <StatControler>();

        if ((sC = collider.gameObject.GetComponent <StatControler>()) != null)
        {
            int finalDamage = 0;
            finalDamage += damage;

            HealthStat health      = sC.GetStatOfType(StatType.HealthStat) as HealthStat;
            ArmorStat  armor       = sC.GetStatOfType(StatType.ArmorStat) as ArmorStat;
            DamageStat damageBonus = sCUser.GetStatOfType(StatType.DamageStat) as DamageStat;

            if (armor != null)
            {
                finalDamage -= (int)armor.CalculateFinalValue();
            }
            if (damageBonus != null)
            {
                finalDamage += (int)damageBonus.CalculateFinalValue();
            }

            //Debug.Log(health);

            if (health != null)
            {
                health.addValue(-finalDamage);
                //Debug.Log("Players health is = " + health.CurrentValue);
            }
        }
    }
Пример #11
0
    // do something on collision
    public override void onCollision(GameObject projectile, Collision2D collision)
    {
        Collider2D collider = collision.GetContact(0).collider;

        //Debug.Log(User.name + " hit " + collider.name);


        if (collider.gameObject == User)
        {
            return;
        }


        if (breakWalls)
        {
            Vector2 hitPos = collision.GetContact(0).point - collision.relativeVelocity.normalized * .1f;

            if (collision.GetContact(0).collider.name == "Walls")
            {
                Instantiate(explosion, hitPos, new Quaternion());

                for (float i = -explosionRaidius; i <= explosionRaidius; ++i)
                {
                    for (float j = -explosionRaidius; j <= explosionRaidius; ++j)
                    {
                        var d = i * i + j * j;
                        if (d <= sqrR)
                        {
                            Map.MapManager.instance.DamageTile(hitPos.x + i, hitPos.y + j, damage / d);
                        }
                    }
                }

                Destroy(projectile);
            }
        }

        StatControler sC;
        StatControler sCUser = User.GetComponent <StatControler>();

        if ((sC = collision.GetContact(0).collider.gameObject.GetComponent <StatControler>()) != null)
        {
            int finalDamage = 0;
            finalDamage += damage;

            HealthStat health      = sC.GetStatOfType(StatType.HealthStat) as HealthStat;
            ArmorStat  armor       = sC.GetStatOfType(StatType.ArmorStat) as ArmorStat;
            DamageStat damageBonus = sCUser.GetStatOfType(StatType.DamageStat) as DamageStat;

            if (armor != null)
            {
                finalDamage -= (int)armor.CalculateFinalValue();
            }
            if (damageBonus != null)
            {
                finalDamage += (int)damageBonus.CalculateFinalValue();
            }

            //Debug.Log(health);

            if (health != null)
            {
                //Debug.Log(finalDamage);
                health.addValue(-finalDamage);
                Destroy(projectile);
            }
        }
    }