void Start()
    {
        skillShot = GetComponent <CharacterSkillShot>();
        //get initial damage of this shot
        //because this is a range-damage shot, get the damage from the explosion particle
        GameObject explosionParticle = GetComponent <CharacterSkillShot>().explodeParticlePref;

        damage     = explosionParticle.GetComponent <RadiantDamage>();
        initDamage = damage.GetDamage();
    }
Exemple #2
0
    //---------------------------------------------------------------
    void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject collidingObject = collision.gameObject;

        if (collidingObject.GetComponent <RadiantDamage> ())
        {
            RadiantDamage radiantDamage   = collidingObject.GetComponent <RadiantDamage>();
            int           inflictedDamage = radiantDamage.GetDamage();
            health = health - inflictedDamage;
            CheckLife();
        }
    }
Exemple #3
0
    //---------------------------------------------------------------
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (GetComponent <Enemy>() || GetComponent <BlockOfStage>())
        {
            if (collider.GetComponent <RadiantDamage> ())
            {
                RadiantDamage radiantDamage = collider.GetComponent <RadiantDamage>();

                int inflictedDamage = radiantDamage.GetDamage();
                print("inflictedDamage :" + inflictedDamage);
                health = health - inflictedDamage;
                print("health :" + health);
                if (health <= 0)
                {
                    Instantiate(DieEffectPrefab, transform.position, Quaternion.identity);

                    if (GetComponent <BlockOfStage>())
                    {
                        GetComponent <BlockOfStage>().BlockDestroy();
                        return;
                    }

                    if (GetComponent <Enemy>())
                    {
                        GetComponent <Enemy>().EnemyDestroy();
                        return;
                    }
                }

                if (lostHeathToChangeSprite != 0)
                {
                    ChangeSpriteFollowHealth();
                }
            }
        }
    }