Пример #1
0
 public override void Interact(PlayerController pc)
 {
     if (bevent)
     {
         bevent.Interact(pc, this);
     }
 }
Пример #2
0
    /// <summary>
    /// The <paramref name="pc"/> just dropped this item.
    /// </summary>
    /// <param name="pc"></param>
    public void Drop(PlayerController pc)
    {
        rigidbody.velocity        = Vector3.zero;
        rigidbody.angularVelocity = Vector3.zero;
        rigidbody.useGravity      = true;

        gameObject.layer = LayerMask.NameToLayer("Item");

        if (pickupEvent)
        {
            dropEvent.Interact(pc, this);
        }
    }
Пример #3
0
    /// <summary>
    /// The <paramref name="pc"/> just picked up this item.
    /// </summary>
    /// <param name="pc"></param>
    public void Pickup(PlayerController pc)
    {
        rigidbody.velocity        = Vector3.zero;
        rigidbody.angularVelocity = Vector3.zero;
        rigidbody.useGravity      = false;

        gameObject.layer = LayerMask.NameToLayer("ItemPickup");

        if (pickupEvent)
        {
            pickupEvent.Interact(pc, this);
        }

        if (bounce != null)
        {
            StopCoroutine(bounce);
        }
    }
Пример #4
0
 public override void Interact(PlayerController pc)
 {
     if (status)
     {
         status = false;
         if (offevent)
         {
             offevent.Interact(pc, this);
         }
     }
     else
     {
         status = true;
         if (onevent)
         {
             onevent.Interact(pc, this);
         }
     }
 }
Пример #5
0
    private void FixedUpdate()
    {
        if (disabled)
        {
            return;
        }

        IWeight act     = null;
        float   actDist = float.MaxValue;
        float   temp;

        // Check collisions
        foreach (Item item in GlobalTypeList <Interactive> .GetTypeList(typeof(Item)))
        {
            if (item.Bounds.Intersect(CylinderBounds, out temp))
            {
                if (temp < actDist)
                {
                    act     = item;
                    actDist = temp;
                }
            }
        }

        // Items have priority
        if (act == null)
        {
            foreach (var player in GlobalList <PlayerController> .GetList)
            {
                if (player.interactiveBounds.Intersect(CylinderBounds, out temp))
                {
                    if (temp < actDist)
                    {
                        act     = player;
                        actDist = temp;
                    }
                }
            }
        }

        if (focus != null && focus != act)
        {
            focus.Exit(this);
        }

        focus = act;

        if (focus != null)
        {
            focus.Enter(this);
        }

        var statusEvent = focus != null;

        if (statusEvent ^ selected)
        {
            selected = statusEvent;
            if (bevent)
            {
                bevent.Interact(null, this);
            }
        }
    }