Esempio n. 1
0
 private void OnTriggerExit(Collider other)
 {
     if (other.attachedRigidbody && other.attachedRigidbody.CompareTag("Player"))
     {
         OnPlayerExit.Invoke();
     }
 }
Esempio n. 2
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == "Player")
     {
         OnPlayerExit.Invoke();
     }
 }
Esempio n. 3
0
 void OnTriggerExit(Collider other)
 {
     If(other.GetComponent <PlayerController>())
     {
         OnPlayerExit?.Invoke(gridPosition);
     }
 }
Esempio n. 4
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         OnPlayerExit?.Invoke();
     }
 }
Esempio n. 5
0
 private void OnTriggerExit2D(Collider2D collider)
 {
     if (collider.tag == "Player")
     {
         Debug.Log("Player is leaving the zone");
         OnPlayerExit?.Invoke(this, EventArgs.Empty);
     }
 }
Esempio n. 6
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         Debug.Log("Player left area");
         OnPlayerExit?.Invoke();
     }
 }
Esempio n. 7
0
    /// <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);
    }
Esempio n. 8
0
    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);
        });
    }
Esempio n. 9
0
        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();
 }
Esempio n. 11
0
    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();
        });
    }