private void OnTriggerExit(Collider other) { if (other.attachedRigidbody && other.attachedRigidbody.CompareTag("Player")) { OnPlayerExit.Invoke(); } }
private void OnTriggerExit(Collider other) { if (other.tag == "Player") { OnPlayerExit.Invoke(); } }
void OnTriggerExit(Collider other) { If(other.GetComponent <PlayerController>()) { OnPlayerExit?.Invoke(gridPosition); } }
private void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) { OnPlayerExit?.Invoke(); } }
private void OnTriggerExit2D(Collider2D collider) { if (collider.tag == "Player") { Debug.Log("Player is leaving the zone"); OnPlayerExit?.Invoke(this, EventArgs.Empty); } }
private void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) { Debug.Log("Player left area"); OnPlayerExit?.Invoke(); } }
/// <summary> /// When player exit, disable teleporters and kill ennemies (if any) to reduce lag and remove events /// </summary> public void PlayerExit() { TeleporterManager tpm = teleportersExit.GetComponent <TeleporterManager>(); tpm.SetPlayerHere(false); OnPlayerExit?.Invoke(this, EventArgs.Empty); }
private void AddDebugCalls() { OnShotFired.AddListener(() => { Debug.Log("Shot fired detected in " + transform.parent.parent.name); }); OnEnemyDamage.AddListener(() => { Debug.Log("Enemy damaged detected in " + transform.parent.parent.name); }); OnPlayerEnter.AddListener(() => { Debug.Log("Player entered " + GetComponentInParent <Room>().name); }); OnPlayerExit.AddListener(() => { Debug.Log("Player exited " + GetComponentInParent <Room>().name); }); }
public void Update() { var lastplayerrect = new Rectangle(Main.player.lastPosition.ToPoint(), new Point(50, 50)); if (Main.player.rect.Intersects(bounds)) { OnPlayerInside?.Invoke(); } if (Main.player.rect.Intersects(bounds) && !lastplayerrect.Intersects(bounds)) { OnPlayerEnter?.Invoke(); } if (!Main.player.rect.Intersects(bounds) && lastplayerrect.Intersects(bounds)) { OnPlayerExit?.Invoke(); } }
protected virtual void OnDestroy() { OnPlayerExit?.Invoke(); }
private void Awake() { AddDebugCalls(); EnemyBase[] enemies = GetComponentsInChildren <EnemyBase>(true); foreach (EnemyBase enemy in enemies) { // When hyperseed is grabbed - all enemies turn aggressive GrabHyperseed.AddListener(() => { if (enemy) { enemy.TurnAggressiveHyperseed.Invoke(); } }); // Testing - all enemies turn aggressive TurnGroupAggressive.AddListener(() => { if (enemy) { enemy.TurnAggressive.Invoke(); } }); // Testing - all enemies turn passive TurnGroupPassive.AddListener(() => { if (enemy) { enemy.ForceIdle(); } }); // Aggro when enemy is damaged OnEnemyDamage.AddListener(() => { if (enemy) { enemy.TurnAggressive.Invoke(); } }); // Stop/resume aggro when player exits/enters a room OnPlayerExit.AddListener(() => { if (enemy) { enemy.ForceIdle(); } }); OnPlayerEnter.AddListener(() => { if (enemy) { enemy.ResetEnemy(); } }); } // Brawlers all aggro when an attack/ability is used in the room enemies = GetComponentsInChildren <Brawler>(true); foreach (Brawler enemy in enemies) { OnShotFired.AddListener(() => { if (enemy) { enemy.TurnAggressive.Invoke(); } }); } // Remove listeners after events are called to prevent chain-calling // Once enemies turn aggressive they stay that way for ever, so no need for re-calling anyways GrabHyperseed.AddListener(() => { OnEnemyDamage.RemoveAllListeners(); OnShotFired.RemoveAllListeners(); OnPlayerEnter.RemoveAllListeners(); OnPlayerExit.RemoveAllListeners(); }); OnEnemyDamage.AddListener(() => { OnEnemyDamage.RemoveAllListeners(); }); OnShotFired.AddListener(() => { OnShotFired.RemoveAllListeners(); }); }