private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Player") &&
         CanBeGrabbedBy(collision.gameObject))
     {
         //HACK: this is just about the worst code I have ever written
         PlayerInteraction pickUpper = collision.gameObject.GetComponent <PlayerInteraction>();
         pickUpper.GetComponent <PlayerEnergy>().AddEnergy(m_energy);
         Destroy(gameObject);
         if (m_onPickUpAudio)
         {
             AudioSource audioSource = OurUtility.GetOrAddComponent <AudioSource>(pickUpper.gameObject);
             audioSource.PlayOneShot(m_onPickUpAudio);
         }
     }
 }
 public virtual void NotifyPickUp(PlayerInteraction pickUpper)
 {
     if (m_collider != null)
     {
         m_collider.enabled = false;
     }
     if (m_rigidbody)
     {
         m_rigidbody.velocity  = Vector3.zero;
         m_rigidbody.simulated = false;
     }
     if (m_onPickUpAudio)
     {
         AudioSource audioSource = OurUtility.GetOrAddComponent <AudioSource>(pickUpper.gameObject);
         audioSource.PlayOneShot(m_onPickUpAudio);
     }
     HeldBy = pickUpper;
 }
示例#3
0
 private void Awake()
 {
     m_health      = GetComponent <GhostHealth>();
     m_rigidbody   = GetComponent <Rigidbody2D>();
     m_audioSource = OurUtility.GetOrAddComponent <AudioSource>(gameObject);
 }
示例#4
0
 private void Awake()
 {
     m_audioSource = OurUtility.GetOrAddComponent <AudioSource>(gameObject);
 }
 private void Awake()
 {
     m_audioSource = OurUtility.GetOrAddComponent <AudioSource>(gameObject);
     m_collider    = GetComponent <CircleCollider2D>();
 }