// Player Death. void OnTriggerEnter2D(Collider2D other) { string otherTag = other.tag; // Enemy bullet or Enemy if (!m_playerProperty.m_tgm) { switch (otherTag) { case "Enemy": PlayerDeath(); break; case "EnemyBullet": PlayerProperty.PlayerStateType bulletType = other.transform.parent.name.Contains("Black") ? PlayerProperty.PlayerStateType.Black : PlayerProperty.PlayerStateType.White; DamagePlayerByState(bulletType, other.transform.parent.GetComponent <UbhBullet>()); break; case "EnemyLaser": PlayerDeath(); break; case "EnemyBullet_DontDestoryOutBound": PlayerDeath(); break; } } }
void DamagePlayerByState(PlayerProperty.PlayerStateType enemyType, UbhBullet enemyBullet) { if (enemyBullet == null) { return; } Debug.Log(enemyType); if (enemyType == m_playerProperty.m_playerState) { m_playerProperty.m_playerHealth--; if (m_playerProperty.m_playerHealth <= 0) { PlayerDeath(); } UbhObjectPool.Instance.ReleaseGameObject(enemyBullet.gameObject); } else { PlayerDeath(); } }