Пример #1
0
        private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            bool isSuppress = false;

            if (nCode >= 0)
            {
                switch (wParam.ToInt64())
                {
                case WM_RBUTTONUP:
                    if (OnRightClick != null)
                    {
                        isSuppress = OnRightClick.Invoke();
                    }
                    break;

                case WM_LBUTTONUP:
                    if (OnLeftClick != null)
                    {
                        isSuppress = OnLeftClick.Invoke();
                    }
                    break;
                }
            }

            if (isSuppress)
            {
                return(new IntPtr(-1));
            }
            else
            {
                return(NativeMethods.CallNextHookEx(hMouseHook, nCode, wParam, lParam));
            }
        }
Пример #2
0
 protected override void RightClick()
 {
     if (Input.GetKeyDown(keys.rightClick))
     {
         OnRightClick?.Invoke();
     }
 }
Пример #3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Right)
     {
         OnRightClick?.Invoke(Item);
     }
 }
Пример #4
0
 void Control_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         OnRightClick.Invoke(this, e);
     }
 }
Пример #5
0
 private void InternalMouseUpEvent(MouseEventArgs args)
 {
     if (args.Button == 2)
     {
         OnRightClick?.Invoke();
     }
 }
Пример #6
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.pointerId == -1)
     {
         OnLeftClick.Invoke();
         if (isToggle && ToggleClick == toggleClick.left)
         {
             Toggle();
         }
     }
     else if (eventData.pointerId == -2)
     {
         OnRightClick.Invoke();
         if (isToggle && ToggleClick == toggleClick.right)
         {
             Toggle();
         }
     }
     else if (eventData.pointerId == -3)
     {
         OnMiddleClick.Invoke();
         if (isToggle && ToggleClick == toggleClick.middle)
         {
             Toggle();
         }
     }
     img.color = press;
     tweenToNormal();
 }
 public NodeDataInfoPanel()
 {
     Active = false;
     OnMouseClick.Add(UseEvent);
     OnRightClick.Add(UseEvent);
     OnMouseDown.Add(UseEvent);
 }
Пример #8
0
 public void OnMouseButtonRight()
 {
     if (Input.GetMouseButton(1))
     {
         OnRightClick.Invoke();
     }
 }
Пример #9
0
 public virtual void MouseRightClick(UIMouseEvent e)
 {
     //Main.NewText("点击");
     OnRightClick?.Invoke(e, this);
     if (PropagationRule.HasFlag(PropagationFlags.MouseRightClick))
     {
         Parent?.MouseRightClick(e);
     }
 }
        private void OnRightMouseClick()
        {
            if (IsMouseOverUI())
            {
                return;
            }

            OnRightClick?.Invoke(_floorPos);
        }
Пример #11
0
 public void fireRightClickedEvent(InputAction.CallbackContext context)
 {
     if (!context.performed)
     {
         return;
     }
     OnRightClick?.Invoke(this, new OnRightClickArgs {
         context = context, clickPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition)
     });;
 }
 private void listView1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         ListViewItem i = listView1.GetItemAt(e.X, e.Y);
         if (i != null && OnRightClick != null)
         {
             OnRightClick.Invoke(PointToClient(listView1.PointToScreen(e.Location)));
         }
     }
 }
Пример #13
0
    public void OnPointerClick(PointerEventData eventData)
    {
        switch (eventData.button)
        {
        case PointerEventData.InputButton.Right:
            OnRightClick?.Invoke();
            break;

        case PointerEventData.InputButton.Left:
            OnLeftClick?.Invoke();
            break;
        }
    }
Пример #14
0
    private void Update()
    {
        // Left Click event:
        if (Input.GetMouseButtonDown(0))
        {
            OnLeftClick?.Invoke();
        }

        // Right Click event:
        if (Input.GetMouseButtonDown(2))
        {
            OnRightClick?.Invoke();
        }
    }
Пример #15
0
 private void ClickOrNot(MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Left)
     {
         if (_left_up.Subtract(_left_down) < _click_threshold)
         {
             OnLeftClick?.Invoke(this, e);
         }
     }
     else if (e.ChangedButton == MouseButton.Right)
     {
         if (_right_up.Subtract(_right_down) < _click_threshold)
         {
             OnRightClick?.Invoke(this, e);
         }
     }
     _left_up    = DateTime.MaxValue;
     _left_down  = DateTime.MinValue;
     _right_up   = DateTime.MaxValue;
     _right_down = DateTime.MinValue;
 }
Пример #16
0
 private void StartSwipeTapDetect()
 {
     // create object to detect swipe
     swipeTapDetect = GameObject.Instantiate(Resources.Load <SwipeTapDetect>(GameUIData.SWIPE_TAP_DETECT_PREFAB_PATH));
     // subscripe finger detection
     swipeTapDetect.OnLeftSwipe += () =>
     {
         OnLeftClick?.Invoke();
     };
     swipeTapDetect.OnRightSwipe += () =>
     {
         OnRightClick?.Invoke();
     };
     swipeTapDetect.OnUpSwipe += () =>
     {
         OnUpClick?.Invoke();
     };
     swipeTapDetect.OnDownSwipe += () =>
     {
         OnDownClick?.Invoke();
     };
 }
Пример #17
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject[LeftChannel] != null)
            {
                StatusLeft = jObject[LeftChannel].Value <string>();
                if (StatusLeft == "click")
                {
                    OnLeftClick?.Invoke(this, new WallSwitchEventArgs(StatusLeft));
                }
                else if (StatusLeft == "double_click")
                {
                    OnLeftDoubleClick?.Invoke(this, new WallSwitchEventArgs(StatusLeft));
                }
                else if (StatusLeft == "long_click")
                {
                    OnLeftLongClick?.Invoke(this, new WallSwitchEventArgs(StatusLeft));
                }
            }

            if (jObject[RightChannel] != null)
            {
                StatusRight = jObject[RightChannel].Value <string>();
                if (StatusRight == "click")
                {
                    OnRightClick?.Invoke(this, new WallSwitchEventArgs(StatusRight));
                }
                else if (StatusRight == "double_click")
                {
                    OnRightDoubleClick?.Invoke(this, new WallSwitchEventArgs(StatusRight));
                }
                else if (StatusRight == "long_click")
                {
                    OnRightLongClick?.Invoke(this, new WallSwitchEventArgs(StatusRight));
                }
            }
        }
Пример #18
0
        public override void Update(Vector2 windowSize)
        {
            UpdateChildren(windowSize);

            if (Enabled && (!clicked && MouseOver(windowSize) && MouseLeftDown && !mouseDown ||
                            (ui.Input.KeyPress(Shortcut) && !ui.ignoreShortcuts)))
            {
                OnLeftClick?.Invoke(this);
            }
            if (Enabled && MouseOver(windowSize) && MouseRightClick)
            {
                OnRightClick?.Invoke(this);
            }

            if (ChangeState)
            {
                if (MouseOver(windowSize))
                {
                    if (mouseDown)
                    {
                        State = 2;
                    }
                    else
                    {
                        State = 1;
                    }
                }
                else
                {
                    State = 0;
                }
            }

            clicked = (MouseOver(windowSize) && !mouseDown && MouseLeftDown) || (ui.Input.KeyPress(Shortcut) && !ui.ignoreShortcuts);

            mouseDown = MouseLeftDown;
        }
Пример #19
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject[LeftChannel] != null)
            {
                if (jObject[LeftChannel].Value <string>() == "click")
                {
                    OnLeftClick?.Invoke(new EventArgs());
                }
                else if (jObject[LeftChannel].Value <string>() == "double_click")
                {
                    OnLeftDoubleClick?.Invoke(new EventArgs());
                }
                else if (jObject[LeftChannel].Value <string>() == "long_click")
                {
                    OnLeftLongClick?.Invoke(new EventArgs());
                }
            }

            if (jObject[RightChannel] != null)
            {
                if (jObject[RightChannel].Value <string>() == "click")
                {
                    OnRightClick?.Invoke(new EventArgs());
                }
                else if (jObject[RightChannel].Value <string>() == "double_click")
                {
                    OnRightDoubleClick?.Invoke(new EventArgs());
                }
                else if (jObject[RightChannel].Value <string>() == "long_click")
                {
                    OnRightLongClick?.Invoke(new EventArgs());
                }
            }
        }
Пример #20
0
 private void RightClick()
 {
     OnRightClick?.Invoke(this, EventArgs.Empty);
 }
Пример #21
0
        /// <summary>
        /// Handles the logic of Dragging/Dropping/Zooming the map.
        /// This is basically said the logic handler of the control.
        /// It is called quite a lot of times, the delta of two calls may be calculated out of the passed GameTime parameter.
        /// </summary>
        /// <param name="time">The time passed since the game started.</param>
        public void Update(GameTime time, InputArgs input)
        {
            // Clean up icon texture cache...
            var keys = _markerTextures.Keys;

            foreach (string key in keys)
            {
                if (Markers.All(m => m.TextureIdentifier != key))
                {
                    _markerTextures[key].Dispose();
                    _markerTextures.Remove(key);
                }
            }

            // drag&drop handling
            MouseState currentState = input.MouseState;

            MapVector mousePos = new MapVector()
            {
                X = currentState.X, Y = currentState.Y
            };

            if (_dragging && CanMove)
            {
                MapVector oldVector = new MapVector()
                {
                    X = _oldMouseState.X, Y = _oldMouseState.Y
                };

                MapVector offset = (oldVector - mousePos) / _map.CoordinateScale;

                MapVector centerMapVector    = _map.LatLonToMapPoint(_map.Position);
                MapVector newCenterMapVector = centerMapVector + offset;

                // real a mod b:
                // a mod b = (a % b + b) % b
                // https://de.wikipedia.org/wiki/Division_mit_Rest#Modulo
                // We do this to allow scrollen over the maps borders.
                newCenterMapVector.X = ((newCenterMapVector.X % _map.MapCoordinatesWidth) + _map.MapCoordinatesWidth) % _map.MapCoordinatesWidth;
                newCenterMapVector.Y = ((newCenterMapVector.Y % _map.MapCoordinatesHeight) + _map.MapCoordinatesHeight) % _map.MapCoordinatesHeight;


                MapPointLatLon newCenterGeoPoint = _map.MapPointToLatLon(newCenterMapVector);

                _map.Position = newCenterGeoPoint;

                OnMoved?.Invoke(this, _map.Position);
            }

            int wheel = _oldMouseState.ScrollWheelValue - currentState.ScrollWheelValue;

            bool zoom    = false;
            int  newZoom = 0;

            if (wheel < 0)
            {
                if (_map.Zoom < _map.MaxZoom)
                {
                    zoom    = true;
                    newZoom = _map.Zoom + 1;
                }
            }
            else if (wheel > 0)
            {
                if (_map.Zoom > _map.MinZoom)
                {
                    zoom    = true;
                    newZoom = _map.Zoom - 1;
                }
            }

            if (zoom && CanZoom)
            {
                switch (ZoomMode)
                {
                case ZoomingType.Center:
                    SetZoomCenter(newZoom);
                    break;

                case ZoomingType.Mouse:
                    MapVector viewPos = mousePos -
                                        _map.ViewBounds.Location;
                    SetZoomMouse(newZoom, viewPos);
                    break;
                }

                OnZoomed?.Invoke(this, _map.Zoom);
            }

            if ((_oldMouseState.LeftButton == ButtonState.Pressed) && currentState.LeftButton == ButtonState.Released)
            {
                // Mouse up
                _dragging = false;
            }
            else if ((_oldMouseState.LeftButton == ButtonState.Released) && currentState.LeftButton == ButtonState.Pressed)
            {
                // Mouse down
                _dragging = true;
            }

            if (_oldMouseState.RightButton == ButtonState.Pressed && currentState.RightButton == ButtonState.Released)
            {
                OnRightClick?.Invoke(this, _map.ViewPointToLatLon(mousePos));
            }

            _oldMouseState = currentState;
        }
        // Update is called once per frame
        void FixedUpdate()
        {
            OnRightClick rc = plane.GetComponent <OnRightClick>();

            if (rc.clicked_off)
            {
                foreach (GameObject task in construction_tasks.Values)
                {
                    SelectTask selections = task.GetComponent <SelectTask>();
                    selections.rightClickAndSelected = false;
                }

                foreach (GameObject task in transport_tasks.Values)
                {
                    SelectTask selections = task.GetComponent <SelectTask>();
                    selections.rightClickAndSelected = false;
                }

                if (selectAgent.currentlySelected.Count != 0)
                {
                    selectAgent.DeselectAll();
                }
                rc.clicked_off = false;
            }

            if (!start_recieved)
            {
                rosSocket.Publish(updateID, message);
            }

            // Update agents through the update function
            if (agent_message != null)
            {
                if (!agents.ContainsKey(agent_message.name))
                {
                    GameObject addingAgent = new GameObject();
                    try
                    {
                        if (agent_message.agent_type == "ConstructionAgent")
                        {
                            addingAgent = Instantiate(contructionAgentModel, getVectFromMessage(agent_message.pose), getQuadFromMsg(agent_message.pose));
                        }
                        else
                        {
                            addingAgent = Instantiate(transportAgentModel, getVectFromMessage(agent_message.pose), getQuadFromMsg(agent_message.pose));
                        }
                        selectAgent menu = addingAgent.AddComponent <selectAgent>();
                        menu.agentType = agent_message.agent_type;
                        BoxCollider box = addingAgent.AddComponent <BoxCollider>();
                        box.size = box.size * 1.3f;
                        NameDisplay name_display = addingAgent.AddComponent <NameDisplay>();
                        if (agent_message.agent_type == "ConstructionAgent")
                        {
                            name_display.colour = red;
                        }
                        else
                        {
                            name_display.colour = blue;
                        }
                        AgentInfo agent_info = addingAgent.AddComponent <AgentInfo>();
                        name_display.name      = agent_message.name;
                        menu.agentName         = agent_message.name;
                        menu.agentCurrentTask  = agent_message.current_task;
                        menu.currentAction     = agent_message.current_action;
                        menu.agentCapabilities = getStringCompatibilities(agent_message.capabilities);
                        menu.movementSpeed     = agent_message.movement_speed.ToString();
                        menu.isAtTask          = agent_message.is_at_task.ToString();
                        agents.Add(agent_message.name, addingAgent);
                    } catch (ArgumentException e)
                    {
                        print("Some reason, the agent has already been added... " + e);
                        Destroy(addingAgent);
                        agents.Remove(agent_message.name);
                    }
                }
                else
                {
                    GameObject currentAgent;
                    agents.TryGetValue(agent_message.name, out currentAgent);
                    currentAgent.transform.position      = getVectFromMessage(agent_message.pose);
                    currentAgent.transform.localRotation = getQuadFromMsg(agent_message.pose);
                    selectAgent menu = currentAgent.GetComponent <selectAgent>();
                    menu.agentCurrentTask  = agent_message.current_task;
                    menu.currentAction     = agent_message.current_action;
                    menu.agentCapabilities = getStringCompatibilities(agent_message.capabilities);
                    menu.movementSpeed     = agent_message.movement_speed.ToString();
                    menu.isAtTask          = agent_message.is_at_task.ToString();
                }
                agent_message = null;
            }

            if (construction_task_message != null)
            {
                string PERM_CONTRUCTION_NAME = String.Copy(construction_task_message.name);
                if ((!construction_tasks.ContainsKey(construction_task_message.name)))
                {
                    try
                    {
                        if (!construction_task_message.is_complete)
                        {
                            GameObject addingConstructionTask = Instantiate(contructionTaskModel, getVectFromMessage(construction_task_message.pose, new Vector3(0, 1f, 0)), getQuadFromMsg(construction_task_message.pose));
                            construction_tasks.Add(PERM_CONTRUCTION_NAME, addingConstructionTask);
                            NameDisplay name_display = addingConstructionTask.AddComponent <NameDisplay>();
                            name_display.name   = PERM_CONTRUCTION_NAME;
                            name_display.colour = offRed;
                            BoxCollider box = addingConstructionTask.AddComponent <BoxCollider>();
                            box.size = box.size * 1.3f;
                            SelectTask taskSelect = addingConstructionTask.AddComponent <SelectTask>();
                            taskSelect.taskName = PERM_CONTRUCTION_NAME;
                            taskSelect.taskType = "Construction";
                        }
                    }
                    catch (ArgumentException e)
                    {
                        print("Some reason, the contruction task has already been added... " + e);
                    }
                }
                else
                {
                    GameObject currentConstructionTask;
                    construction_tasks.TryGetValue(construction_task_message.name, out currentConstructionTask);
                    if (construction_task_message.is_complete)
                    {
                        construction_tasks.Remove(construction_task_message.name);
                        Destroy(currentConstructionTask);
                    }
                }
                construction_task_message = null;
            }

            if (transport_task_message != null)
            {
                if (!transport_tasks.ContainsKey(transport_task_message.name))
                {
                    if (!transport_task_message.is_complete)
                    {
                        GameObject addingTransportTask    = Instantiate(transportTaskModel, getVectFromMessage(transport_task_message.pose, new Vector3(0, 0.47f, 0)), getQuadFromMsg(transport_task_message.pose));
                        GameObject addingTransportTaskEnd = Instantiate(dartModel, getVectFromMessage(transport_task_message.end_pose, new Vector3(0, 1.252f, 0)), Quaternion.Euler(90, 0, 0));
                        addingTransportTaskEnd.transform.localScale = new Vector3(200, 200, 200);
                        // Makes the transport task end a child of the adding transport task.
                        // addingTransportTaskEnd.transform.parent = addingTransportTask.transform;
                        transport_tasks.Add(transport_task_message.name, addingTransportTask);
                        LineRenderer line = addingTransportTask.AddComponent <LineRenderer>();
                        line.material = lineMaterial;
                        NameDisplay name_display = addingTransportTask.AddComponent <NameDisplay>();
                        name_display.colour = offBlue;
                        line.SetPositions(new Vector3[2] {
                            new Vector3(addingTransportTask.transform.position.x, 0.01f, addingTransportTask.transform.position.z),
                            new Vector3(addingTransportTaskEnd.transform.position.x, 0.01f, addingTransportTaskEnd.transform.position.z)
                        });
                        line.startWidth   = 0.05f;
                        line.endWidth     = 0.5f;
                        name_display.name = transport_task_message.name;
                        BoxCollider box = addingTransportTask.AddComponent <BoxCollider>();
                        box.size = box.size * 1.3f;
                        SelectTask taskSelect = addingTransportTask.AddComponent <SelectTask>();
                        taskSelect.taskName = transport_task_message.name;
                        taskSelect.taskType = "Transport";
                    }
                }
                else
                {
                    GameObject currentTransportTask;
                    transport_tasks.TryGetValue(transport_task_message.name, out currentTransportTask);
                    try
                    {
                        currentTransportTask.transform.position = getVectFromMessage(transport_task_message.pose, new Vector3(0, 0.47f, 0));
                        LineRenderer line = currentTransportTask.GetComponent <LineRenderer>();
                        line.SetPosition(0, new Vector3(currentTransportTask.transform.position.x, 0.01f, currentTransportTask.transform.position.z));
                        if (transport_task_message.is_complete)
                        {
                            transport_tasks.Remove(transport_task_message.name);
                            Destroy(currentTransportTask);
                        }
                    } catch (MissingReferenceException e)
                    {
                        print("Transport task was destroyed, the task is still in the dictionary for some reasons... Deleting it again.");
                        transport_tasks.Remove(transport_task_message.name);
                    }
                }
                transport_task_message = null;
            }



            if (construction_tasks.Count != 0)
            {
                foreach (GameObject task in construction_tasks.Values)
                {
                    task.transform.localEulerAngles = new Vector3(45, task.transform.localEulerAngles.y + 1f, 90);
                }
            }
        }
Пример #23
0
 public virtual void RightClick(UIMouseEvent evt)
 {
     OnRightClick?.Invoke(evt, this);
     Parent?.RightClick(evt);
 }
Пример #24
0
 internal void CallRightClick()
 {
     OnRightClick?.Invoke();
 }
        // Update is called once per frame
        void FixedUpdate()
        {
            SteamVR_LaserPointer rLaserPointer = rightController.GetComponent <SteamVR_LaserPointer>();
            SteamVR_LaserPointer lLaserPointer = leftController.GetComponent <SteamVR_LaserPointer>();

            if (rLaserPointer.hit_game_object != null)
            {
                GameObject hitObject = rLaserPointer.hit_game_object;
                if (agent_ids.Contains(hitObject.GetInstanceID()))
                {
                    print("Hit an agent!");
                    selectAgent_vr hitAgent = hitObject.GetComponent <selectAgent_vr>();
                    if (rLaserPointer.triggered)
                    {
                        hitAgent.OnMouseDown();
                    }
                }

                if (task_ids.Contains(hitObject.GetInstanceID()))
                {
                    print("Hit a task");
                    SelectTask_vr selectedTask = hitObject.GetComponent <SelectTask_vr>();
                    if (rLaserPointer.triggered)
                    {
                        if (selectedTask.OnTrigged())
                        {
                            rLaserPointer.hit_target = true;
                        }
                    }
                }

                /*if (hitObject.Equals(plane))
                 * {
                 *  selectAgent_vr.DeselectAll();
                 * }*/
            }
            if (lLaserPointer.hit_game_object != null)
            {
                print(lLaserPointer.hit_game_object);
            }


            OnRightClick rc = plane.GetComponent <OnRightClick>();

            if (rc.clicked_off)
            {
                foreach (GameObject task in construction_tasks.Values)
                {
                    SelectTask_vr selections = task.GetComponent <SelectTask_vr>();
                    selections.rightClickAndSelected = false;
                }

                foreach (GameObject task in transport_tasks.Values)
                {
                    SelectTask_vr selections = task.GetComponent <SelectTask_vr>();
                    selections.rightClickAndSelected = false;
                }

                if (selectAgent_vr.currentlySelected.Count != 0)
                {
                    selectAgent_vr.DeselectAll();
                }
                rc.clicked_off = false;
            }

            if (!start_recieved)
            {
                rosSocket.Publish(updateID, message);
            }

            // Update agents through the update function
            if (agent_message != null)
            {
                if (!agents.ContainsKey(agent_message.name))
                {
                    GameObject addingAgent = new GameObject();
                    try
                    {
                        if (agent_message.agent_type == "ConstructionAgent")
                        {
                            addingAgent = Instantiate(contructionAgentModel, getVectFromMessage(agent_message.pose), getQuadFromMsg(agent_message.pose));
                        }
                        else
                        {
                            addingAgent = Instantiate(transportAgentModel, getVectFromMessage(agent_message.pose), getQuadFromMsg(agent_message.pose));
                        }
                        selectAgent_vr menu = addingAgent.AddComponent <selectAgent_vr>();
                        agent_ids.Add(addingAgent.GetInstanceID());
                        menu.agentType = agent_message.agent_type;
                        BoxCollider box = addingAgent.AddComponent <BoxCollider>();
                        box.size = box.size * 1.3f;
                        GameObject textObject = new GameObject();
                        textObject.transform.position = addingAgent.transform.position;
                        textObject.transform.LookAt(camera.transform);
                        Vector3 rot = textObject.transform.eulerAngles;
                        rot = new Vector3(rot.x, rot.y + 180, rot.z);
                        textObject.transform.rotation = Quaternion.Euler(rot);
                        TextMesh text_name = textObject.AddComponent <TextMesh>();
                        text_name.text     = agent_message.name;
                        text_name.fontSize = text_size;
                        //TextMesh agent_name = addingAgent.AddComponent<TextMesh>();
                        if (agent_message.agent_type == "ConstructionAgent")
                        {
                            text_name.color = red;
                        }
                        else
                        {
                            text_name.color = blue;
                        }
                        textValues.Add(agent_message.name, textObject);
                        AgentInfo agent_info = addingAgent.AddComponent <AgentInfo>();
                        //name_display.name = agent_message.name;
                        menu.agentName         = agent_message.name;
                        menu.agentCurrentTask  = agent_message.current_task;
                        menu.currentAction     = agent_message.current_action;
                        menu.agentCapabilities = getStringCompatibilities(agent_message.capabilities);
                        menu.movementSpeed     = agent_message.movement_speed.ToString();
                        menu.isAtTask          = agent_message.is_at_task.ToString();
                        agents.Add(agent_message.name, addingAgent);
                    } catch (ArgumentException e)
                    {
                        print("Some reason, the agent has already been added... " + e);
                        Destroy(addingAgent);
                        agents.Remove(agent_message.name);
                    }
                }
                else
                {
                    GameObject currentAgent;

                    agents.TryGetValue(agent_message.name, out currentAgent);
                    currentAgent.transform.position      = getVectFromMessage(agent_message.pose);
                    currentAgent.transform.localRotation = getQuadFromMsg(agent_message.pose);
                    selectAgent_vr menu = currentAgent.GetComponent <selectAgent_vr>();
                    menu.agentCurrentTask  = agent_message.current_task;
                    menu.currentAction     = agent_message.current_action;
                    menu.agentCapabilities = getStringCompatibilities(agent_message.capabilities);
                    menu.movementSpeed     = agent_message.movement_speed.ToString();
                    menu.isAtTask          = agent_message.is_at_task.ToString();
                    GameObject objText;
                    textValues.TryGetValue(agent_message.name, out objText);
                    objText.transform.position = currentAgent.transform.position;
                }
                agent_message = null;
            }

            if (construction_task_message != null)
            {
                string PERM_CONTRUCTION_NAME = String.Copy(construction_task_message.name);
                if ((!construction_tasks.ContainsKey(construction_task_message.name)))
                {
                    try
                    {
                        if (!construction_task_message.is_complete)
                        {
                            GameObject addingConstructionTask = Instantiate(contructionTaskModel, getVectFromMessage(construction_task_message.pose, new Vector3(0, 1f, 0)), getQuadFromMsg(construction_task_message.pose));
                            construction_tasks.Add(PERM_CONTRUCTION_NAME, addingConstructionTask);
                            //NameDisplay name_display = addingConstructionTask.AddComponent<NameDisplay>();
                            //name_display.name = PERM_CONTRUCTION_NAME;
                            task_ids.Add(addingConstructionTask.GetInstanceID());
                            BoxCollider box = addingConstructionTask.AddComponent <BoxCollider>();
                            box.size = box.size * 1.3f;
                            SelectTask_vr taskSelect = addingConstructionTask.AddComponent <SelectTask_vr>();
                            taskSelect.taskName = PERM_CONTRUCTION_NAME;
                            taskSelect.taskType = "Construction";

                            GameObject textObject = new GameObject();
                            textObject.transform.position = addingConstructionTask.transform.position;
                            textObject.transform.LookAt(camera.transform);
                            Vector3 rot = textObject.transform.eulerAngles;
                            rot = new Vector3(rot.x, rot.y + 180, rot.z);
                            textObject.transform.rotation = Quaternion.Euler(rot);
                            TextMesh text_name = textObject.AddComponent <TextMesh>();
                            text_name.text     = construction_task_message.name;
                            text_name.fontSize = text_size;
                            text_name.color    = offRed;
                            textValues.Add(construction_task_message.name, textObject);
                        }
                    }
                    catch (ArgumentException e)
                    {
                        print("Some reason, the contruction task has already been added... " + e);
                    }
                }
                else
                {
                    GameObject currentConstructionTask;
                    construction_tasks.TryGetValue(construction_task_message.name, out currentConstructionTask);
                    GameObject objText;
                    textValues.TryGetValue(construction_task_message.name, out objText);
                    objText.transform.position = currentConstructionTask.transform.position;
                    if (construction_task_message.is_complete)
                    {
                        construction_tasks.Remove(construction_task_message.name);
                        Destroy(currentConstructionTask);
                        textValues.Remove(construction_task_message.name);
                        Destroy(objText);
                    }
                }
                construction_task_message = null;
            }

            if (transport_task_message != null)
            {
                if (!transport_tasks.ContainsKey(transport_task_message.name))
                {
                    if (!transport_task_message.is_complete)
                    {
                        GameObject addingTransportTask    = Instantiate(transportTaskModel, getVectFromMessage(transport_task_message.pose, new Vector3(0, 0.47f, 0)), getQuadFromMsg(transport_task_message.pose));
                        GameObject addingTransportTaskEnd = Instantiate(dartModel, getVectFromMessage(transport_task_message.end_pose, new Vector3(0, 1.252f, 0)), Quaternion.Euler(90, 0, 0));
                        addingTransportTaskEnd.transform.localScale = new Vector3(200, 200, 200);
                        task_ids.Add(addingTransportTask.GetInstanceID());
                        // Makes the transport task end a child of the adding transport task.
                        // addingTransportTaskEnd.transform.parent = addingTransportTask.transform;
                        transport_tasks.Add(transport_task_message.name, addingTransportTask);
                        LineRenderer line = addingTransportTask.AddComponent <LineRenderer>();
                        line.material = lineMaterial;
                        //NameDisplay name_display = addingTransportTask.AddComponent<NameDisplay>();
                        //name_display.colour = offBlue;
                        line.SetPositions(new Vector3[2] {
                            new Vector3(addingTransportTask.transform.position.x, 0.01f, addingTransportTask.transform.position.z),
                            new Vector3(addingTransportTaskEnd.transform.position.x, 0.01f, addingTransportTaskEnd.transform.position.z)
                        });
                        line.startWidth = 0.05f;
                        line.endWidth   = 0.5f;
                        //name_display.name = transport_task_message.name;
                        BoxCollider box = addingTransportTask.AddComponent <BoxCollider>();
                        box.size = box.size * 1.3f;
                        SelectTask_vr taskSelect = addingTransportTask.AddComponent <SelectTask_vr>();
                        taskSelect.taskName = transport_task_message.name;
                        taskSelect.taskType = "Transport";

                        GameObject textObject = new GameObject();
                        textObject.transform.position = addingTransportTask.transform.position;
                        textObject.transform.LookAt(camera.transform);
                        Vector3 rot = textObject.transform.eulerAngles;
                        rot = new Vector3(rot.x, rot.y + 180, rot.z);
                        textObject.transform.rotation = Quaternion.Euler(rot);
                        TextMesh text_name = textObject.AddComponent <TextMesh>();
                        text_name.text     = transport_task_message.name;
                        text_name.fontSize = text_size;
                        text_name.color    = offBlue;
                        textValues.Add(transport_task_message.name, textObject);
                    }
                }
                else
                {
                    GameObject currentTransportTask;
                    transport_tasks.TryGetValue(transport_task_message.name, out currentTransportTask);

                    GameObject objText;
                    textValues.TryGetValue(transport_task_message.name, out objText);
                    objText.transform.position = currentTransportTask.transform.position;

                    try
                    {
                        currentTransportTask.transform.position = getVectFromMessage(transport_task_message.pose, new Vector3(0, 0.47f, 0));
                        LineRenderer line = currentTransportTask.GetComponent <LineRenderer>();
                        line.SetPosition(0, new Vector3(currentTransportTask.transform.position.x, 0.01f, currentTransportTask.transform.position.z));
                        if (transport_task_message.is_complete)
                        {
                            transport_tasks.Remove(transport_task_message.name);
                            Destroy(currentTransportTask);
                            textValues.Remove(transport_task_message.name);
                            Destroy(objText);
                        }
                    } catch (MissingReferenceException e)
                    {
                        print("Transport task was destroyed, the task is still in the dictionary for some reasons... Deleting it again.");
                        transport_tasks.Remove(transport_task_message.name);
                    }
                }
                transport_task_message = null;
            }

            if (textValues.Count > 0)
            {
                List <string> keys = new List <string>(textValues.Keys);
                foreach (string k in keys)
                {
                    textValues[k].transform.LookAt(Camera.main.transform);
                    Vector3 rot = textValues[k].transform.eulerAngles;
                    rot = new Vector3(-rot.x, rot.y + 180, rot.z);
                    textValues[k].transform.rotation = Quaternion.Euler(rot);
                }
            }

            if (construction_tasks.Count != 0)
            {
                foreach (GameObject task in construction_tasks.Values)
                {
                    task.transform.localEulerAngles = new Vector3(45, task.transform.localEulerAngles.y + 1f, 90);
                }
            }
        }
Пример #26
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            if (TBARInputs.UIAdjustmentMode.JustPressed)
            {
                TBAR.IsAdjustingUI = !TBAR.IsAdjustingUI;
            }

            if (TBARInputs.SummonStand.JustPressed && IsStandUser)
            {
                if (!PlayerStand.IsActive)
                {
                    PlayerStand.TryActivate(player);
                }

                if (player.HeldItem.GetDamageData(player).DPS > damageCaps[(int)PlayerStand.StandDamageType])
                {
                    damageCaps[(int)PlayerStand.StandDamageType] = player.HeldItem.GetDamageData(player).DPS;
                }
            }

            if (TBARInputs.OpenStandAlbum.JustPressed)
            {
                if (IsStandUser)
                {
                    UIManager.Instance.StandAlbumLayer.ToggleVisibility();
                }
            }

            if (IsStandUser)
            {
                if (TBARInputs.ComboButton1.JustPressed)
                {
                    OnInput(ComboInput.Action1);
                }

                if (TBARInputs.ComboButton2.JustPressed)
                {
                    OnInput(ComboInput.Action2);
                }

                if (TBARInputs.ComboButton3.JustPressed)
                {
                    OnInput(ComboInput.Action3);
                }

                if (HasPressedUp)
                {
                    OnInput(ComboInput.Up);
                }

                if (HasPressedDown)
                {
                    OnInput(ComboInput.Down);
                }

                if (HasPressedLeftClick)
                {
                    OnLeftClick?.Invoke(player);
                    PlayerStand.HandleImmediateInputs(player, ImmediateInput.LeftClick);
                }

                if (HasPressedRightClick)
                {
                    OnRightClick?.Invoke(player);
                    PlayerStand.HandleImmediateInputs(player, ImmediateInput.RightClick);
                }

                OldUpButtonState   = player.controlUp;
                OldDownButtonState = player.controlDown;
                OldLeftClickState  = player.controlUseItem;
                OldRightClickState = player.controlUseTile;
            }
        }
Пример #27
0
 public virtual void RightClick(UIMouseEventArgs e)
 {
     OnRightClick?.Invoke(this, e);
     Parent?.RightClick(e);
 }