コード例 #1
0
 //trigger detection for enemy ships and coins.
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "UpgradeCoin")
     {
         //Debug.Log ("Trigger Collision: " + col.tag);
         CoinValue value = col.gameObject.GetComponent <CoinValue> ();
         PlayerStatsManager.SetPlayerScore(value.GetCoinValue());
         value.PassUpgradeValue();
         Destroy(col.gameObject);
     }
     if (col.tag == "Enemy Ship" || col.tag == "EliteEnemyShip")
     {
         PlayerStatsManager.SetPlayerHealth(-enemyCollisionDamage);
         EnemyAI collide = col.gameObject.GetComponent <EnemyAI> ();
         if (col.tag == "EliteEnemyShip")
         {
             collide.SetDamage(5f);
         }
         else
         {
             collide.SetDamage(100f);
         }
         hurtSound.Play();
     }
 }