Пример #1
0
        // Assign new held Item, then grab the item into our hand / controller
        public void GrabGrabbable(Grabbable item)
        {
            // We are trying to grab something else
            if (flyingGrabbable != null && item != flyingGrabbable)
            {
                return;
            }

            // Make sure we aren't flying an object at us still
            resetFlyingGrabbable();

            // Drop whatever we were holding
            if (HeldGrabbable != null && HeldGrabbable)
            {
                Debug.Log("Try release:" + HeldGrabbable.name);
                TryRelease();
            }

            // Assign new grabbable
            HeldGrabbable = item;

            // Just grabbed something, no longer fresh.
            FreshGrip = false;
            Debug.Log("Grabbb in grabber: " + item.name);
            // Let item know it's been grabbed
            item.GrabItem(this);
            Grab?.Invoke(new GrabbableEventArgs(item, this));
        }
Пример #2
0
        public GrabOptionsGump(Mobile m)
            : base(10, 10)
        {
            GrabOptions options = Grab.GetOptions(m);

            AddPage(1);
            AddBackground(0, 0, 330, 405, 9250);
            AddLabel(120, 15, LabelHue, "Grab Options");
            AddImageTiled(15, 35, 300, 4, 9151);

            AddAlphaRegion(15, 45, 160, 20);
            AddLabel(15, 45, LabelHue, "Loot to Grab");
            AddAlphaRegion(180, 45, 135, 20);
            AddLabel(180, 45, LabelHue, "Placement Container");

            string[] types = Enum.GetNames(typeof(GrabFlag));

            for (int i = 0, y = 75; i < types.Length; i++, y += 25)
            {
                GrabFlag flag = (GrabFlag)Enum.Parse(typeof(GrabFlag), types[i], true);

                AddCheck(15, y, 210, 211, options.GetFlag(flag), (i + 1));
                AddLabel(40, y, LabelHue, types[i]);

                AddLabelCropped(185, y, 100, 20, LabelHue, Grab.GetContainerName(m, flag));
                AddButton(295, y, 9762, 9763, (i + 1), GumpButtonType.Reply, 0);
            }

            AddButton(15, 370, 4020, 4022, 100, GumpButtonType.Reply, 0);
            AddLabel(50, 370, LabelHue, "Cancel");
            AddButton(285, 370, 4023, 4025, 105, GumpButtonType.Reply, 0);
            AddLabel(190, 370, LabelHue, "Apply Changes");
        }
        public static void GrabWindow(Window window)
        {
            window.GrabFocus();

            Grab.Add(window);

            Gdk.GrabStatus grabbed =
                Gdk.Pointer.Grab(window.GdkWindow, true,
                                 Gdk.EventMask.ButtonPressMask
                                 | Gdk.EventMask.ButtonReleaseMask
                                 | Gdk.EventMask.PointerMotionMask, null, null, CURRENT_TIME);

            if (grabbed == Gdk.GrabStatus.Success)
            {
                grabbed = Gdk.Keyboard.Grab(window.GdkWindow, true, CURRENT_TIME);

                if (grabbed != Gdk.GrabStatus.Success)
                {
                    Grab.Remove(window);
                    window.Destroy();
                }
            }
            else
            {
                Grab.Remove(window);
                window.Destroy();
            }
        }
            public bool Interact(int x, int y, Interaction interaction)
            {
                if (pixels.Contains(new Point(x, y)))
                {
                    switch (interaction)
                    {
                    case Interaction.Eye:
                        Look?.Invoke();
                        break;

                    case Interaction.Hand:
                        Grab?.Invoke();
                        break;

                    case Interaction.Mouth:
                        Talk?.Invoke();
                        break;

                    default:
                        return(false);
                    }
                }

                return(true);
            }
Пример #5
0
 void GrabStart(CustomHand hand)
 {
     SetInteractibleVariable(hand);
     hand.SkeletonUpdate();
     hand.grabType = CustomHand.GrabType.Select;
     Grab.Invoke();
 }
Пример #6
0
    //
    public void GrabStart(CustomHand hand)
    {
        // power steering stuff
        PowerSteeringActive = false;
        //
        SetInteractibleVariable(hand);
        hand.SkeletonUpdate();
        hand.PivotUpdate();
        Transform tempPoser      = GetMyGrabPoserTransform(hand);
        Vector3   HandTolocalPos = transform.InverseTransformPoint(hand.PivotPoser.position);

        HandTolocalPos.z        = 0;
        tempPoser.localPosition = HandTolocalPos;
        if (hand.handType == SteamVR_Input_Sources.LeftHand)
        {
            oldPosLeft = new Vector2(HandTolocalPos.x, HandTolocalPos.y);
        }
        else
        {
            if (hand.handType == SteamVR_Input_Sources.RightHand)
            {
                oldPosRight = new Vector2(HandTolocalPos.x, HandTolocalPos.y);
            }
        }
        ReversHand = Vector3.Angle(transform.forward, hand.PivotPoser.forward) < 90;
        Grab.Invoke();
    }
Пример #7
0
    public void interact()
    {
        Grab      grabber   = myPlayer.grabber;
        Inventory inventory = myPlayer.inventory;

        if (grabber.hasObject())
        {
            grabber.dropObject();
        }
        else
        {
            Vector3    point;
            GameObject nearest = getTarget(out point);
            if (nearest != null && !inventory.take(nearest))
            {
                Label trgt;
                bool  canInteract = hasInteractable(nearest, out trgt);
                if (canInteract)
                {
                    InteractTrigger trig = new InteractTrigger();
                    trig.setPoint(point);
                    trgt.sendTrigger(nearest, trig);
                }
                else
                {
                    grabber.grabObject(nearest, point);
                }
            }
        }
    }
        protected override bool OnButtonPressEvent(EventButton evnt)
        {
            if (evnt.Button != 1 || evnt.IsContextMenuButton())
            {
                return(base.OnButtonPressEvent(evnt));
            }

            if (IsOverIndicator(evnt.Y))
            {
                parentStrip.GotoTask(parentStrip.SearchNextTask(GetHoverMode()));
                return(base.OnButtonPressEvent(evnt));
            }

            var hoverTask = GetHoverTask(evnt.Y);

            if (hoverTask != null)
            {
                MoveToTask(hoverTask);
            }

            if (IsInsideBar(evnt.X, evnt.Y))
            {
                Grab.Add(this);
                grabCenter = GetSliderCenter();
                grabY      = evnt.Y;
            }
            else
            {
                MovePosition(evnt.Y);
            }

            return(base.OnButtonPressEvent(evnt));
        }
Пример #9
0
 private void Awake()
 {
     rb             = GetComponent <Rigidbody2D>();
     anim           = GetComponent <Animator>();
     spriteRenderer = transform.GetChild(0).GetComponent <SpriteRenderer>();
     grab           = GetComponent <Grab>();
 }
Пример #10
0
        void ButtonPressEventHandler(object o, ButtonPressEventArgs a)
        {
            if (a.Event.Type != Gdk.EventType.ButtonPress)
            {
                return;
            }

            if (a.Event.Button == 1)
            {
                is_dragging = true;
            }

            HasFocus = true;
            Gdk.EventButton pos          = a.Event;
            int             new_selected = HitTest(pos.Y);

            int double_click_time = Settings.DoubleClickTime;

            if ((new_selected == Selected) && (a.Event.Time - last_click_time <= double_click_time))
            {
                Selected = new_selected;
                Grab.Remove(this);
                if (ItemActivated != null)
                {
                    ItemActivated(Selected);
                }
            }
            else
            {
                Selected = new_selected;
            }

            last_click_time = a.Event.Time;
            a.RetVal        = true;
        }
Пример #11
0
        private void OnContainerSelect(Mobile from, object target, object state)
        {
            if (target is Container)
            {
                Container cont = (Container)target;

                if (!cont.IsChildOf(from.Backpack) && cont != from.Backpack)
                {
                    from.SendMessage("You may only drop grabbed loot into containers in your pack.");
                }
                else
                {
                    GrabOptions options       = Grab.GetOptions(from);
                    GrabFlag    containerFlag = Grab.ParseInt32((int)state);

                    options.SetPlacementContainer(containerFlag, cont);

                    from.SendMessage("You have selected a new container for '{0}'.", Enum.GetName(typeof(GrabFlag), containerFlag));
                }
            }
            else
            {
                from.SendMessage("Loot can only be dropped into containers.");
            }

            from.SendGump(new GrabOptionsGump(from));
        }
Пример #12
0
    // Initialize player information
    void OnGameBegin(CharacterInfo player1, CharacterInfo player2, StageOptions stage)
    {
        p1 = player1;
        p2 = player2;

        // Get all of the moves' SkillTree handlers
        basic = GetComponent <Basic>();
        basic.GetTree(p1, true);
        basic.GetTree(p2, false);
        handlers[Constants.BASIC] = basic.Resolve;

        strong = GetComponent <Strong>();
        strong.GetTree(p1, true);
        strong.GetTree(p2, false);
        handlers[Constants.STRONG] = strong.Resolve;

        evade = GetComponent <Evade>();
        evade.GetTree(p1, true);
        evade.GetTree(p2, false);
        handlers[Constants.EVADE] = evade.Resolve;

        grab = GetComponent <Grab>();
        grab.GetTree(p1, true);
        grab.GetTree(p2, false);
        handlers[Constants.GRAB] = evade.Resolve;
    }
Пример #13
0
    //Grab event callback
    void OnMADHGGrabEvent(Grab grab)
    {
        string logTime    = getLogTime();
        var    grabStatus = grab.status;

        switch (grabStatus)
        {
        case Grab.GrabStatus.START:
            Debug.Log("HandGestureSample: DemoHandGesture: onGrab: START - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "] logTime : " + logTime);
            eventGrabStr = "GrabEvent: onGrab: START - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "] logTime : " + logTime + " \n";
            break;

        case Grab.GrabStatus.HOLDING:
            Debug.Log("HandGestureSample: DemoHandGesture: onGrab: HOLDING - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "]  different: [" + grab.dx + ", " + grab.dy + "] logTime : " + logTime);
            eventGrabStr = "GrabEvent: onGrab: HOLDING - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "]  different: [" + grab.dx + ", " + grab.dy + "] logTime : " + logTime + " \n";
            break;

        case Grab.GrabStatus.RELEASE:
            Debug.Log("HandGestureSample: DemoHandGesture: onGrab: RELEASE - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "]  different: [" + grab.dx + ", " + grab.dy + "] logTime : " + logTime);
            eventGrabStr = "GrabEvent: onGrab: RELEASE - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "]  different: [" + grab.dx + ", " + grab.dy + "] logTime : " + logTime + " \n";
            break;

        case Grab.GrabStatus.CANCEL:
            Debug.Log("HandGestureSample: DemoHandGesture: onGrab: CANCEL - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "]  different: [" + grab.dx + ", " + grab.dy + "] logTime : " + logTime);
            eventGrabStr = "GrabEvent: onGrab: CANCEL - Hand[" + grab.index + "] position[" + grab.x + ", " + grab.y + "]  different: [" + grab.dx + ", " + grab.dy + "] logTime : " + logTime + " \n";
            break;

        default:
            Debug.Log("HandGestureSample: DemoHandGesture: onGrab: OTHER DEFAULT CASE");
            eventGrabStr = "GrabEvent: onGrab: onGrab: OTHER DEFAULT CASE logTime : " + logTime + " \n";
            break;
        }
    }
Пример #14
0
        static async void MainAsync(string[] args)
        {
            List <HtmlNode> articles  = Grab.GrabArticles();
            int             articleNo = 0;

            foreach (HtmlNode a in articles)
            {
                articleNo++;
                Console.Write($"Beginning scrapping article {articleNo}. ");
                PostMessage post;
                try
                {
                    Interpreter.Interpret(a, out post);
                    var json = JsonConvert.SerializeObject(post, new IsoDateTimeConverter()
                    {
                        DateTimeFormat = "yyyy-MM-dd"
                    });
                    Console.WriteLine($"Post article {articleNo} API result: ");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(await PostArticle.Post(json));
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("-------------------------------------------------------");
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"{articleNo} articles scrapped. Press any key to exit.");
            Console.ReadLine();
        }
Пример #15
0
 internal Grab(Grab next, long address, long limit, long nextPointer, MemoryAllocationTracker memoryTracker)
 {
     this.NextConflict  = next;
     this.Address       = address;
     this.Limit         = limit;
     this.NextPointer   = nextPointer;
     this.MemoryTracker = memoryTracker;
 }
Пример #16
0
 // Use this for initialization
 void Start()
 {
     anim       = GetComponent <Animator>();
     rb         = GetComponent <Rigidbody2D>();
     enemHealth = FindObjectOfType <EnemyHealth>();
     grabClass  = FindObjectOfType <Grab>();
     grounded   = FindObjectOfType <GroundCheck>();
 }
Пример #17
0
    // Start is called before the first frame update
    void Start()
    {
        this.collision = GetComponent <Collision>();
        this.grab      = GetComponent <Grab>();
        this.jumping   = GetComponent <Jumping>();

        this.rigidbody = GetComponent <Rigidbody2D>();
    }
Пример #18
0
 private void Awake()
 {
     rb             = GetComponent <Rigidbody2D>();
     anim           = GetComponent <Animator>();
     grab           = GetComponent <Grab>();
     groundLayer    = LayerMask.GetMask("Ground");
     remainingJumps = extraJumps;
 }
 void ClearGrab()
 {
     if (IsInGrab())
     {
         Grab.Remove(this);
         grabY = -1;
     }
 }
Пример #20
0
 internal Grab(Grab next, long size, MemoryAllocationTracker memoryTracker)
 {
     this.NextConflict  = next;
     this.Address       = UnsafeUtil.allocateMemory(size, memoryTracker);
     this.Limit         = Address + size;
     this.MemoryTracker = memoryTracker;
     NextPointer        = Address;
 }
Пример #21
0
        private static void GrabLoot(Mobile from, Container cont)
        {
            if (!from.Alive || cont == null)
            {
                return;
            }

            if (cont is Corpse && from == ((Corpse)cont).Owner)
            {
                Corpse corpse = (Corpse)cont;

                if (corpse.Killer == null || corpse.Killer is BaseCreature)
                {
                    corpse.Open(from, true);
                }
                else
                {
                    corpse.Open(from, false);
                }
            }
            else
            {
                bool        fullPack = false;
                List <Item> items    = new List <Item>(cont.Items);
                GrabOptions options  = Grab.GetOptions(from);

                for (int i = 0; !fullPack && i < items.Count; i++)
                {
                    Item item = items[i];

                    if (options.IsLootable(item))
                    {
                        Container dropCont = options.GetPlacementContainer(Grab.ParseType(item));

                        if (dropCont == null || dropCont.Deleted || !dropCont.IsChildOf(from.Backpack))
                        {
                            dropCont = from.Backpack;
                        }

                        if (!item.DropToItem(from, dropCont, new Point3D(-1, -1, 0)))
                        {
                            fullPack = true;
                        }
                    }
                }

                if (fullPack)
                {
                    from.SendMessage("You grabbed as many of the items as you could. The rest remain {0}.", (cont is Corpse ? "on the corpse" : "in the container"));
                }
                else
                {
                    from.SendMessage("You retrieve all of the items from the {0}.", (cont is Corpse ? "body" : "container"));
                }

                from.RevealingAction();
            }
        }
Пример #22
0
 static public void AddGrab(GameObject gameObject, ActionSequence sequence)
 {
     Grab action = new Grab();
     action.source = gameObject;
     action.range = 2.0f;
     action.duration = 0.2f;
     QueuePop(sequence,3);
     sequence.actions.Add(action);
 }
Пример #23
0
    Vector3 oldDir;                  //old hands rotation

    public void GrabStart(CustomHand hand)
    {
        SetInteractibleVariable(hand);
        hand.SkeletonUpdate();
        GetMyGrabPoserTransform(hand).rotation = Quaternion.LookRotation(transform.forward, hand.PivotPoser.up);
        oldDir = transform.InverseTransformDirection(hand.PivotPoser.up);
        GetMyGrabPoserTransform(hand).transform.position = hand.PivotPoser.position;
        Grab.Invoke();
    }
 protected override void OnMapped()
 {
     base.OnMapped();
     Gdk.Pointer.Grab(GdkWindow, true, Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask, null, null, Global.CurrentEventTime);
     Grab.Add(this);
     GrabBrokenEvent += delegate {
         Destroy();
     };
 }
Пример #25
0
        protected override bool OnButtonPressEvent(EventButton evnt)
        {
            int px = (int)evnt.X - x_offset;
            int py = (int)evnt.Y - y_offset;

            if (px < 0)
            {
                px = 0;
            }
            if (px > width - 1)
            {
                px = width - 1;
            }
            if (py < 0)
            {
                py = 0;
            }
            if (py > height - 1)
            {
                py = height - 1;
            }

            //find the closest point
            float closest_x = MinX - 1;
            var   distance  = int.MaxValue;

            foreach (var point in points)
            {
                int cx = Project(point.Key, MinX, MaxX, width);
                if (Math.Abs(px - cx) < distance)
                {
                    distance  = Math.Abs(px - cx);
                    closest_x = point.Key;
                }
            }

            Grab.Add(this);
            CursorType = CursorType.Tcross;
            switch (CurveType)
            {
            case CurveType.Linear:
            case CurveType.Spline:
                if (distance > min_distance)
                {
                    //insert a new control point
                    AddPoint((closest_x = Unproject(px, MinX, MaxX, width)), MaxY - Unproject(py, MinY, MaxY, height));
                    QueueDraw();
                }
                grab_point = closest_x;
                break;

            case CurveType.Free:
                throw new NotImplementedException();
            }

            return(true);
        }
Пример #26
0
        protected virtual void OnGrabHit(int i, bool grab)
        {
            Grab?.Invoke(i, grab);

            if (CanResetOntrigger && Input.GrabLState && Input.GrabRState)
            {
                Reset();
            }
        }
Пример #27
0
        protected override bool OnButtonReleaseEvent(EventButton evnt)
        {
            Grab.Remove(this);
            //FIXME: remove inactive points

            CursorType = CursorType.Fleur;
            grab_point = null;
            return(true);
        }
Пример #28
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.name == "Trigger")
     {
         Grab       c       = grab.GetComponent <Grab>();
         GameObject chicken = c.currchicken;
         Destroy(chicken);
         chickenDestroyed++;
     }
 }
Пример #29
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Grab accessory = (Grab)target;

        if (GUILayout.Button("Force Equip"))
        {
            FindObjectOfType <Example>().EquipAccessoryWithForce(accessory);
        }
    }
Пример #30
0
 public void LeaveDragMode(uint time)
 {
     if (DragInProgress)
     {
         Pointer.Ungrab(time);
         Grab.Remove(this);
     }
     MotionNotifyEvent -= new MotionNotifyEventHandler(OnMotionNotify);
     DragInProgress     = false;
 }
Пример #31
0
 public void Grab(Grab aGrabber)
 {
     grabber          = aGrabber;
     myRigidbody.drag = 20;
     myRigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
     force = 20 / myRigidbody.mass;
     if (force > 20)
     {
         force = 20;
     }
 }