예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     sC              = transform.parent.GetComponent <StatControler>();
     bar             = transform.Find("Bar");
     barSprite       = bar.Find("BarSprite").gameObject.GetComponent <SpriteRenderer>();
     barSprite.color = maxHealth;
 }
예제 #2
0
 public void Equip(StatControler statControler)
 {
     foreach (modInfo mod in modifiers)
     {
         statControler.AddModifier(new StatModifier(mod.value, mod.type, mod.statType, this));
     }
 }
예제 #3
0
 private void Update()
 {
     if (Input.GetButtonDown("Equipment"))
     {
         equipmentUI.SetActive(!equipmentUI.activeSelf);
     }
     statController = player.GetComponent <StatControler>();
 }
예제 #4
0
 // Start is called before the first frame update
 void Start()
 {
     heldItem      = Instantiate(heldItem);
     curDirection  = DIR.IDLE;
     player        = GameObject.Find("Player").transform;
     statControler = GetComponent <StatControler>();
     rb            = GetComponent <Rigidbody2D>();
 }
예제 #5
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);
            }
        }
    }
예제 #6
0
    void Start()
    {
        heldItem = Instantiate(heldItem);

        sprite        = GetComponent <SpriteRenderer>();
        rb            = GetComponent <Rigidbody2D>();
        statControler = GetComponent <StatControler>();
        playerObj     = GameObject.Find("Player_v2");

        sprite.color = Color.Lerp(a, b, 0);

        StartCoroutine(SetHealth());
    }
예제 #7
0
    void Start()
    {
        // hack: works for now - ask isaac
        heldItem = Instantiate(heldItem);

        sprite        = GetComponent <SpriteRenderer>();
        statControler = GetComponent <StatControler>();
        //rb = GetComponent<Rigidbody2D>();
        playerObj = GameObject.FindGameObjectWithTag("Player");
        if (health == null)
        {
            health = GetComponent <StatControler>().GetStatOfType(StatType.HealthStat) as HealthStat;
        }
        //StartCoroutine(EnemyFSM());
    }
예제 #8
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Sound Manager Setup");
        sC         = player.GetComponent <StatControler>();
        BGM.volume = 0.05f;
        FX.volume  = 0.005f;
        StartCoroutine(BGM_Manager());

        /**/
        GameObject SlimeAS = new GameObject();

        SlimeAS.transform.parent = transform;
        SlimeAS.AddComponent <AudioSource>();
        SlimeFX        = SlimeAS.GetComponent <AudioSource>();
        SlimeFX.loop   = true;
        SlimeFX.volume = 0.1f;
        SlimeFX.clip   = SlimeAudio;
    }
예제 #9
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);
            }
        }
    }
예제 #10
0
 // Start is called before the first frame update
 void Start()
 {
     player         = GameObject.Find("Player_v2");
     playerCollider = player.GetComponent <CapsuleCollider2D>();
     playerSC       = player.GetComponent <StatControler>();
 }
예제 #11
0
 private void Start()
 {
     statControler = GetComponentInParent <StatControler>();
 }
예제 #12
0
 public void Unequip(StatControler statControler)
 {
     statControler.RemoveAllModifiersFromSource(this);
 }
예제 #13
0
 // Start is called before the first frame update
 void Start()
 {
     //Debug.Log("Starting");
     sprite        = GetComponent <SpriteRenderer>();
     statControler = GetComponent <StatControler>();
 }
예제 #14
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);
            }
        }
    }