//====================================================== void OnTriggerEnter2D(Collider2D other) { PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>(); if (playerReference != null && playerReference.player != null) { if (onPlayerDetected != null) { onPlayerDetected(playerReference.player, this); } } }
//====================================================== void OnTriggerEnter2D(Collider2D other) { PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>(); if (playerReference != null && playerReference.player != null) { playerReference.player.InstaDeath(); } SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>(); if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null) { PatrollingEnemy patrollingEnemy = swappableEntityReference.swappableEntity as PatrollingEnemy; if (patrollingEnemy != null) { patrollingEnemy.InstaDeath(); } } }
//====================================================== protected override void OnTriggerEnter2D(Collider2D other) { PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>(); if (playerReference != null && playerReference.player != null) { playerReference.player.InstaDeath(); } SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>(); if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null) { PatrollingEnemy patrollingEnemy = swappableEntityReference.swappableEntity as PatrollingEnemy; if (patrollingEnemy != null) { patrollingEnemy.InstaDeath(); } } //Do something Destroy(gameObject); }
//====================================================== protected virtual void OnTriggerEnter2D(Collider2D other) { PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>(); if (playerReference != null && playerReference.player == owner) { Destroy(gameObject); return; } SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>(); if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null) { owner.Swap(swappableEntityReference.swappableEntity); } else { SoundManager.instance.PlaySound(SoundManager.SoundType.NoSwap); } //Do something Destroy(gameObject); }
// ===================================== private void OnTriggerStay2D(Collider2D other) { PlayerHitboxReference playerReference = other.GetComponent <PlayerHitboxReference>(); if (playerReference != null && playerReference.player != null && !playerReference.player.isDead) { PlayerController player = playerReference.player; Vector2 direction = transform.TransformDirection(localSpikeDirection).normalized; if (Vector2.Dot(direction, player.currentSpeed - currentSpeed) >= -0.1f) { return; } SoundManager.instance.PlaySound(SoundManager.SoundType.Spikes); player.InstaDeath(); return; } SwappableEntityHitboxReference swappableEntityReference = other.GetComponent <SwappableEntityHitboxReference>(); if (swappableEntityReference != null && swappableEntityReference.swappableEntity != null) { PatrollingEnemy enemy = swappableEntityReference.swappableEntity as PatrollingEnemy; if (enemy != null) { Vector2 direction = transform.TransformDirection(localSpikeDirection).normalized; if (Vector2.Dot(direction, enemy.currentSpeed - currentSpeed) >= -0.1f) { return; } SoundManager.instance.PlaySound(SoundManager.SoundType.Spikes); enemy.InstaDeath(); return; } } }