Beispiel #1
0
 public void ReleaseGrabbedElement()
 {
     if (grabbedElement != null)
     {
         grabbedElement.Release();
         grabbedElement = null;
         return;
     }
 }
    protected override void GrabbableTriggerExit(GrabbableElement p)
    {
        if (controller == null)
        {
            return;
        }

        controller.ObjectExitTrigger(this, p);
    }
 protected override void GrabbableTriggerExit(GrabbableElement p)
 {
     base.GrabbableTriggerExit(p);
     --entityIn;
     if (entityIn == 0)
     {
         SetState(eInteruptorState.Up);
     }
 }
Beispiel #4
0
 public override void ObjectEnterTrigger(InteractableElement ie, Object o)
 {
     if (o is GrabbableElement)
     {
         GrabbableElement c = o as GrabbableElement;
         Player           p = c.GetComponentInParent <Player> ();
         if (p != null)
         {
             p.ReleaseGrabbedElement();
         }
         c.transform.position = new Vector3(-8.5f, 3.5f, 0f);
     }
 }
Beispiel #5
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        Player           player = collision.gameObject.GetComponent <Player>();
        GrabbableElement ge     = collision.gameObject.GetComponent <GrabbableElement>();

        if (player != null)
        {
            PlayerTriggerExit(player);
            player.RemoveInteraction(this);
        }
        if (ge != null)
        {
            GrabbableTriggerExit(ge);
        }
    }
Beispiel #6
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Player           player = collision.gameObject.GetComponent <Player>();
        GrabbableElement ge     = collision.gameObject.GetComponent <GrabbableElement>();

        if (player != null)
        {
            PlayerTriggerEnter(player);
            if (!string.IsNullOrEmpty(InteractText))
            {
                player.SetInteraction(this);
            }
        }
        if (ge != null)
        {
            GrabbableTriggerEnter(ge);
        }
    }
Beispiel #7
0
    private void Interact()
    {
        // first check if something is held
        if (grabbedElement != null)
        {
            grabbedElement.Throw();
            grabbedElement = null;
            return;
        }

        // Next check if an interaction is available
        if (nearestInteraction != null)
        {
            GameElement elem = nearestInteraction;
            try
            {
                elem.Interact(this);
            }
            catch (Exception e)
            {
            }

            if (elem is GrabbableElement)
            {
                grabbedElement = elem as GrabbableElement;
                HideIndicator(true);
            }
            if (elem is CollectableElement)
            {
                if (heldElement == null)
                {
                    heldElement = elem as CollectableElement;
                    Socket.SendMessage(new UpdateItemMessage(heldElement.ItemID, heldElement.ItemDescription, heldElement.ItemName));
                }
                else
                {
                    (elem as CollectableElement).Throw();
                }
            }
            nearestInteraction = null;
            return;
        }
    }
 protected override void GrabbableTriggerEnter(GrabbableElement p)
 {
     base.GrabbableTriggerEnter(p);
     ++entityIn;
     SetState(eInteruptorState.Down);
 }
Beispiel #9
0
 protected virtual void GrabbableTriggerExit(GrabbableElement p)
 {
 }