Exemple #1
0
 //object pooling
 public void getAttackObj(ExploreCat enemyCat, float damage)
 {
     if (attackObjs.Count == 0)
     {
         CreateAttackObject(enemyCat, damage);
         return;
     }
     cAttack = attackObjs.Dequeue();
     cAttack.setOnHit(true);
     cAttack.setDamage(damage);
 }
Exemple #2
0
    private void CreateAttackObject(ExploreCat enemyCat, float damage)
    {
        cAttack = Instantiate(Resources.Load <GameObject>("miscPrefabs/" + cat.getCatAsset().attackType.ToString())).GetComponent <AttackObj>();
        Sprite secondarySprite = Resources.Load <Sprite>("fightUI/" + this.cat.getCatAsset().secondaryType.ToString());

        if (cat.getCatAsset().attackType == AttackType.Melee)
        {
            ((Melee)cAttack).Init(this);
            ((Melee)cAttack).getSprite().sprite = secondarySprite;
        }
        else if (cat.getCatAsset().attackType == AttackType.Ranged)
        {
            cAttack.GetComponent <SpriteRenderer>().sprite = secondarySprite;
            ((Projectile)cAttack).Init(this, this.realizedStats.projectileSpeed, cat.getCatAsset().secondaryType);
        }
        cAttack.setDamage(damage);
    }