Example #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            //access the player
            Unikitty unikitty = other.GetComponent <Unikitty>();
            //enable power up
            if (unikitty != null)
            {
                unikitty.CandyPowerOn();
            }

            //destroy orself
            Destroy(this.gameObject);
        }
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            //access the player
            Unikitty unikitty = other.GetComponent <Unikitty>();
            //enable power up
            if (unikitty != null)
            {
                unikitty.PresentShieldOn();
            }

            //destroy orself
            Destroy(this.gameObject);
            Destroy(Instantiate(presentShieldEnabledPrefab, transform.position + new Vector3(0, 0, 0), Quaternion.identity), 0.8f);
        }
    }
Example #3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "CandyShot")
     {
         if (other.transform.parent != null)
         {
             Destroy(other.transform.parent.gameObject);
         }
         Destroy(other.gameObject);
         Destroy(this.gameObject);
         Destroy(Instantiate(_explosionPrefab, transform.position + new Vector3(0, 0, 0), Quaternion.identity), 0.5f);
         _uiManager.UpdateScore();
         bool isFliped = Unikitty.facingLeft;
         if (isFliped == true)
         {
             Destroy(Instantiate(_rightEnemyBoxExplosion, transform.position + new Vector3(0, 3, 0), Quaternion.Euler(0, 0, 0)), 0.94f);
         }
         else
         {
             Destroy(Instantiate(_rightEnemyBoxExplosion, transform.position + new Vector3(0, 3, 0), Quaternion.Euler(0, 180f, 0)), 0.94f);
         }
     }
     else if (other.tag == "Player")
     {
         Unikitty unikitty = other.GetComponent <Unikitty>();
         if (unikitty != null)
         {
             unikitty.Damage();
         }
         Destroy(this.gameObject);
         Destroy(Instantiate(_explosionPrefab, transform.position + new Vector3(0, 0, 0), Quaternion.identity), 0.5f);
         _uiManager.UpdateScore();
         bool isFliped = Unikitty.facingLeft;
         if (isFliped == true)
         {
             Destroy(Instantiate(_rightEnemyBoxExplosion, transform.position + new Vector3(0, 3, 0), Quaternion.Euler(0, 0, 0)), 0.94f);
         }
         else
         {
             Destroy(Instantiate(_rightEnemyBoxExplosion, transform.position + new Vector3(0, 3, 0), Quaternion.Euler(0, 180f, 0)), 0.94f);
         }
     }
 }