private void OnEvent(GameEvent ev) { switch (ev.Type()) { case GameEventType.EVENT_BULLET_HITS_PLAYER: { EventBulletHitsPlayer r_ev = (EventBulletHitsPlayer)ev; ItemManager.Instance.DestroyItem(r_ev.hit.GetGrabbedItem()); break; } } }
private void OnTriggerEnter2D(Collider2D collision) { PlayerStats stats = collision.GetComponent <PlayerStats>(); if (stats != null) { if (shooter != null) { if (stats != shooter) { if (stats.GetHasGrabbedItem()) { Item it = stats.GetGrabbedItem(); if (!it.GetIndestructible()) { EventBulletHitsPlayer ev = new EventBulletHitsPlayer(shooter, stats); EventManager.Instance.SendEvent(ev); Destroy(gameObject); } } } } return; } BulletWall wall = collision.GetComponent <BulletWall>(); if (wall != null) { Destroy(gameObject); return; } }