void OnTriggerEnter(Collider theCollider) { if (!theCollider.CompareTag("Bullet")) { return; } if (--enemyHealth <= 0) { Destroy(gameObject); BulletImpactPool.PlayBulletImpact(transform.position); } }
protected override void OnUpdate() { Entities.ForEach((Entity entity, ref Health health, ref Translation pos) => { if (health.Value <= 0) { if (EntityManager.HasComponent(entity, typeof(PlayerTag))) { Settings.PlayerDied(); } else if (EntityManager.HasComponent(entity, typeof(EnemyTag))) { PostUpdateCommands.DestroyEntity(entity); BulletImpactPool.PlayBulletImpact(pos.Value); } } }); }
protected override void OnUpdate() { Entities.ForEach((Entity entity, ref Health health, ref Translation translation) => { if (health.Value > 0f) { return; } if (EntityManager.HasComponent(entity, typeof(PlayerTag))) { PlayerSettings.PlayerDied(); } else if (EntityManager.HasComponent(entity, typeof(EnemyTag))) { PostUpdateCommands.DestroyEntity(entity); BulletImpactPool.PlayBulletImpact(translation.Value); var instantiated = PostUpdateCommands.Instantiate(PlayerSettings.Coin); PostUpdateCommands.SetComponent(instantiated, new Translation { Value = translation.Value }); } else if (EntityManager.HasComponent <BulletTag>(entity)) { PostUpdateCommands.DestroyEntity(entity); } }); var count = _enemies.CalculateEntityCount(); if (count == 0 && GameManager.Instance.GameStatus == GameManager.Status.Play) { GameManager.Instance.Success(); } }