Пример #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);
        }
    }
Пример #2
0
    void OnTriggerEnter(Collider other)
    {
        IPickUp pickUp = other.gameObject.GetComponent <IPickUp>();

        if (pickUp != null)
        {
            pickUp.OnPull(gameObject);
        }
    }
Пример #3
0
    protected virtual void OnTriggerEnter2D(Collider2D other)
    {
        IPickUp pickUp = other.gameObject.GetComponent <IPickUp> ();

        if (pickUp != null)
        {
            pickUp.PickUpBehaviour(this);
            pickUpSound.Play();
        }
    }
Пример #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);
            }
        }
    }
Пример #5
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        IPickUp pickUp = other.GetComponent <IPickUp>();

        pickUp?.PickUp(parent);
    }
Пример #6
0
 public PickUpController(IPickUp pickUp)
 {
     _pickUp = pickUp;
 }