void OnTriggerEnter2D(Collider2D hit) { GameObject otherObj = hit.gameObject; MedicineBullet bullet = otherObj.GetComponent <MedicineBullet>(); if (bullet) { Destroy(bullet.gameObject); } }
public bool NotifyHitByBullet(MedicineBullet bullet) { if (bullet == null) { return(false); } if ((int)bullet.BulletType == (int)this.EnemyType) { Destroy(this.gameObject); return(true); } else { this.MySpeed *= this.MoveSpeedMultiplier; return(true); } }
public void Fire() { if (this.AmmoCount <= 0) { return; } if (this.EquippedMedicine == null) { return; } this.AmmoCount--; GameObject medThrow = Instantiate(this.EquippedMedicine, this.Doc.position, this.Doc.rotation); MedicineBullet bulletComp = medThrow.GetComponent <MedicineBullet>(); if (bulletComp) { bulletComp.InitializeBullet(this.Doc); } }