private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Coin")) { GameplayEvents.CoinCollected(); Destroy(other.gameObject); } if (other.CompareTag("Exit")) { GameEvents.LevelPassed(); } if (other.CompareTag("Heart")) { GameplayEvents.HeartCollected(); Destroy(other.gameObject); } if (other.CompareTag("Death")) { if (_immune) { return; } GameplayEvents.Damaged(3); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Enemy")) { GameplayEvents.EnemyKilled(other.transform.position); Destroy(other.gameObject); } }
private void OnCollisionEnter2D(Collision2D other) { if (_immune) { return; } if (other.gameObject.CompareTag("Damage") || other.gameObject.CompareTag("Enemy")) { _immune = true; GameplayEvents.Damaged(1); } }
private void Damaged(int amount) { if (GameEvents.gameOver) { return; } GameplayEvents.EnemyKilled(_player.transform.position); if (PrefsManager.Player.Lifes - amount < 1) { GameEvents.GameOver(); _player.gameObject.SetActive(false); } _immuneTimer = 0f; PrefsManager.Player.RemoveLifes(amount); _player.visual.Damaged(); }
public override void OnAttack() { _muzzleFlesh.transform.localScale = Vector3.one * 0.5f; _timer = _time; _muzzleFlesh.NextFrame(); RaycastHit2D hit = Physics2D.Raycast(gameObject.transform.position + transform.right * 2, transform.right, 100); if (hit.transform != null) { if (hit.collider.CompareTag("Enemy")) { GameplayEvents.EnemyKilled(hit.transform.position); Destroy(hit.transform.gameObject); } } }
private void UpdateInput() { if (Input.GetKeyDown(_fire1)) { GameplayEvents.MeleeAttack(); } if (Input.GetKeyDown(_fire2)) { GameplayEvents.RangeAttack(); } if (Input.GetKey(_left)) { GameplayEvents.Move(Vector2.left); _interaction = true; } else { if (Input.GetKey(_right)) { GameplayEvents.Move(Vector2.right); _interaction = true; } else { _interaction = false; } } if (Input.GetKeyDown(_jump)) { GameplayEvents.Jump(); } if (_interaction == false) { GameplayEvents.Stop(); } GameplayEvents.FocusOnPoint(Input.mousePosition); }