Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider other)
    {
        IPickUp pickUp = other.gameObject.GetComponent <IPickUp>();

        if (pickUp != null)
        {
            pickUp.OnPull(gameObject);
        }
    }
Ejemplo n.º 3
0
    protected virtual void OnTriggerEnter2D(Collider2D other)
    {
        IPickUp pickUp = other.gameObject.GetComponent <IPickUp> ();

        if (pickUp != null)
        {
            pickUp.PickUpBehaviour(this);
            pickUpSound.Play();
        }
    }
Ejemplo n.º 4
0
    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);
            }
        }
    }
Ejemplo n.º 5
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        IPickUp pickUp = other.GetComponent <IPickUp>();

        pickUp?.PickUp(parent);
    }
Ejemplo n.º 6
0
 public PickUpController(IPickUp pickUp)
 {
     _pickUp = pickUp;
 }