예제 #1
0
    IEnumerator DeathSequence()
    {
        float scale = 1;

        while (scale >= 0.01f)
        {
            TimeShifter.Shift(0.2f);
            scale -= 2f * Time.deltaTime;
            transform.localScale = new Vector3(scale, scale, scale);
            yield return(null);
        }
        Destroy(gameObject);
    }
예제 #2
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (!friendly)
     {
         if (collision.collider.gameObject.layer == 8)
         {
             SoundSystem.PlaySound(transform.position, 1, true);
             friendly         = true;
             gameObject.layer = 9;
             transform.GetChild(0).gameObject.layer              = 9;
             GetComponentInChildren <SpriteRenderer>().color     = Color.green;
             GetComponentInChildren <TrailRenderer>().startColor = Color.green;
             GetComponentInChildren <TrailRenderer>().endColor   = Color.green;
             Instantiate(friendlyP, transform.position, transform.rotation);
             TimeShifter.Shift(0.1f, 0.8f);
         }
         if (collision.collider.gameObject.layer == 13)
         {
             SoundSystem.PlaySound(transform.position, 0);
             Instantiate(particle, transform.position, transform.rotation);
             HealthController.Damage(playerDmg + 0.03f);
             TimeShifter.Shift(0.15f, 0.3f);
             Destroy(gameObject);
         }
     }
     if (friendly)
     {
         if (collision.collider.gameObject.layer == 11)
         {
             Instantiate(friendlyP, transform.position, transform.rotation);
             TimeShifter.Shift();
             DetachTrail();
             SoundSystem.PlaySound(transform.position, 2);
             collision.collider.GetComponent <ObjectHP>().Damage(enemyDmg);
             Destroy(gameObject);
         }
         hitCounter++;
         if (hitCounter > 3)
         {
             Instantiate(friendlyP, transform.position, transform.rotation);
             if (GetComponentInChildren <TrailRenderer>() != null)
             {
                 DetachTrail();
             }
             Destroy(gameObject);
         }
     }
 }