Пример #1
0
 public override void OnInteracted(Collider2D hit, Interact_Base self)
 {
     if (hit.gameObject.GetComponent <PlayerController>())
     {
         self.interactKey.enabled = true;
         hit.GetComponent <PlayerController>().InteractableItem(self.gameObject);
     }
 }
Пример #2
0
    //Code for interacting with the object in front.
    //Object needs a boxcollider.
    public void InteractForward()
    {
        int xMod = 0;
        int yMod = 0;

        if (curDir == Direction.South)
        {
            yMod = -1;
        }
        else if (curDir == Direction.North)
        {
            yMod = 1;
        }
        else if (curDir == Direction.East)
        {
            xMod = -1;
        }
        else
        {
            xMod = 1;
        }

        //Vector3 checkPos = tlmp.CellToWorld(a);
        Vector3 checkPos = transform.position;

        checkPos.z += yMod * tileSize;
        checkPos.x += xMod * tileSize;
        Collider[] x = Physics.OverlapSphere(checkPos, 0.2f);

        //check if theres a door
        if (x.Length > 0 && x[0].tag == "Interactable")
        {
            print("toggled itneractable");
            Interact_Base bs = x[0].gameObject.GetComponent <Interact_Base>();
            bs.Toggle();
        }
    }
 public abstract void OnInteracted(Collider2D hit, Interact_Base interactable);