void OnTriggerEnter2D(Collider2D coll) { if (coll.tag == Tags.LEFTBORDER) { _movement.TouchedRight = false; _movement.TouchedLeft = true; } if (coll.tag == Tags.RIGHTBORDER) { _movement.TouchedLeft = false; _movement.TouchedRight = true; } if (coll.tag == Tags.PICKUP) { IPickUp pickUp = coll.GetComponent <IPickUp>(); pickUp.PickUp(); } if (coll.tag == Tags.FLOOR) { PlayerDeath gameOver = coll.GetComponent <PlayerDeath>(); gameOver.GameOver(); Destroy(this.gameObject); } }
void OnTriggerEnter(Collider other) { IPickUp pickUp = other.gameObject.GetComponent <IPickUp>(); if (pickUp != null) { pickUp.OnPull(gameObject); } }
protected virtual void OnTriggerEnter2D(Collider2D other) { IPickUp pickUp = other.gameObject.GetComponent <IPickUp> (); if (pickUp != null) { pickUp.PickUpBehaviour(this); pickUpSound.Play(); } }
void Interact() { Ray ray = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2)); RaycastHit hit; if (Physics.Raycast(ray, out hit, maxReach)) { //Debug.DrawLine(ray.origin, hit.point, Color.red, 10); IInteractible interactible = hit.transform.gameObject.GetComponent <IInteractible>(); IPickUp iPickUp = hit.transform.gameObject.GetComponent <IPickUp>(); if (interactible != null) { interactible.Interact(); } else if (iPickUp != null) { iPickUp.Interact(this); } } }
public void OnTriggerEnter2D(Collider2D other) { IPickUp pickUp = other.GetComponent <IPickUp>(); pickUp?.PickUp(parent); }
public PickUpController(IPickUp pickUp) { _pickUp = pickUp; }