Beispiel #1
0
    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();
    }
Beispiel #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();
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        transform.localScale = new Vector3(
            transform.localScale.x + Time.deltaTime * scaleSpeed,
            transform.localScale.y + Time.deltaTime * scaleSpeed,
            transform.localScale.z);

        float growingDamage = initDamage * transform.transform.localScale.x;

        skillShot.SetShotPower((int)growingDamage);
        if (damage.GetDamage() >= (initDamage * 3))
        {
            GameObject damager = Instantiate(GetComponent <CharacterSkillShot>().explodeParticlePref, transform.position, Quaternion.identity);

            //damager.GetComponent<RadiantDamage>().SetDamage(growingDamage);
            Destroy(gameObject);
        }
    }
Beispiel #4
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();
                }
            }
        }
    }