示例#1
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (!collected)
     {
         if (canBeCollectedByEntitesTagged.Contains(collision.gameObject.tag))
         {
             GameManager.instance.GetComponent <TutorialManager> ().SetTrigger(TutorialManager.TutorialTriggers.PickupCollected);
             UpgradeSystem upSys = collision.gameObject.GetComponent <UpgradeSystem> ();
             //Grant Upgrade , If the reciever has an UpgradeSystem
             if (upSys != null)                   // if it's players
             {
                 collected = true;
                 sound.Collect();
                 body.bodyType = RigidbodyType2D.Kinematic;
                 if (!grantOneAtRandom)
                 {
                     foreach (Upgrade u in upgradesToGrant)
                     {
                         upSys.Add(u);
                     }
                 }
                 else
                 {
                     Upgrade toGrant = upgradesToGrant [Random.Range(0, upgradesToGrant.Count)];
                     upSys.Add(toGrant);
                 }
             }
             animator.SetTrigger("Collected");
         }
         this.enabled = false;
     }
 }