private void OnTriggerEnter2D(Collider2D collision) { if (Player.Instance == null) { return; } if (collision.attachedRigidbody.gameObject != Player.Instance.gameObject) { return; } if (Player.Instance.life < 5) { Player.Instance.life += 1; updateUI.EarnUIheart(); Destroy(transform.gameObject); } }
private void ItemEffect(ITEM item) { switch (item) { case ITEM.FasterAttack: Player.Instance.attackCooldown = 0.15f; itemImage.sprite = fasterAttack; break; case ITEM.SlowerAttack: Player.Instance.attackCooldown = 0.45f; itemImage.sprite = slowerAttack; break; case ITEM.SpeedUp: Player.Instance.defaultMovement.speedMax = 4.0f; itemImage.sprite = speedUp; break; case ITEM.SpeedDown: Player.Instance.defaultMovement.speedMax = 1.0f; itemImage.sprite = speedDown; break; case ITEM.LifeTouch: if (Player.Instance.life < 5) { Player.Instance.life += 1; updateUI.EarnUIheart(); } itemImage.sprite = lifeTouch; break; case ITEM.DeathTouch: Player.Instance.ApplyHit(null); itemImage.sprite = deathTouch; break; } }