示例#1
0
    /// Called every frame the user is still looking at a valid GameObject. This
    /// can be a 3D or UI element.
    ///
    /// The camera is the event camera, the target is the object the user is
    /// looking at, and the intersectionPosition is the intersection point of the
    /// ray sent from the camera on the object.
    public void OnGazeStay(Camera camera, GameObject targetObject, Vector3 intersectionPosition,
                           bool isInteractive)
    {
        SetGazeTarget(intersectionPosition, isInteractive);
        ///-////

        if (gazedAt != null && gazeStartTime > 0f)
        {
            if (Time.time - gazeStartTime > 2.5f && ExecuteEvents.CanHandleEvent <timeinputhandler> (gazedAt))
            {
                gazeStartTime = -1f;
                ExecuteEvents.Execute(gazedAt, null, (timeinputhandler handler, BaseEventData Data) => handler.HandleTimeInput());
                Debug.Log("gvrReticle1");
            }
        }

        ///-/////
    }
    public static int CanHandleEvent_s(IntPtr l)
    {
        int result;

        try
        {
            GameObject go;
            LuaObject.checkType <GameObject>(l, 1, out go);
            bool b = ExecuteEvents.CanHandleEvent <IEventSystemHandler>(go);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, b);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
示例#3
0
    // Use this for initialization
    //void Start () {

    //}

    //// Update is called once per frame
    //void Update () {

    //}

    public override void StartAction(GameObject obj, GameObject actionObj)
    {
        base.StartAction(obj);

        //StopAction
        // 相手側にイベントがなければ返す
        if (!ExecuteEvents.CanHandleEvent <IOrderEvent>(obj))
        {
            return;
        }
        // 実行(命令の変更)
        ExecuteEvents.Execute <IOrderEvent>(
            obj,
            null,
            (e, d) => { e.stopOrder(); });

        // 空の状態に変更する
        //ChangeOrder(obj, OrderStatus.NULL);
        EndOrder(obj);
    }
示例#4
0
    private void HandleHover(float restartValue)
    {
        if (ExecuteEvents.CanHandleEvent <ITimedEventHandler>(this.GazeAt) == true)
        {
            float currentTime = Time.time - this.GazeStartTime;

            if (currentTime > 3.0f)
            {
                this.GazeStartTime = restartValue;
                this.CreateReticleVertices(1.0f);

                ExecuteEvents.Execute(this.GazeAt, null,
                                      (ITimedEventHandler handler, BaseEventData data) => handler.HandleTimedInput());
            }
            else
            {
                this.CreateReticleVertices(currentTime / 3.0f);
            }
        }
    }
示例#5
0
        public void Process(PointerEventData pointerData, List <RaycastResult> raycastResults, SteamVR_Controller.Device device)
        {
            bool showWheel = false;

            foreach (RaycastResult raycast in raycastResults)
            {
                if (ExecuteEvents.CanHandleEvent <IScrollHandler>(raycast.gameObject))
                {
                    showWheel = true;
                }
                if (pointerData.scrollDelta != Vector2.zero)
                {
                    GameObject targetGO = ExecuteEvents.ExecuteHierarchy(raycast.gameObject, pointerData, ExecuteEvents.scrollHandler);
                    if (targetGO != null)
                    {
                        showWheel = true;
                    }
                }
            }
            m_showWheel(showWheel);
        }
示例#6
0
    private void SendObject(GameObject obj)
    {
        // シーンにいる全部のロボットを入れる
        var robotList = GameObject.FindGameObjectsWithTag("Robot");

        // 全部のロボットにオーダーを出す
        foreach (var robot in robotList)
        {
            // IRobotEventが実装されていなければreturn
            if (!ExecuteEvents.CanHandleEvent <IOrderEvent>(robot))
            {
                Debug.Log("IOrderEvent未実装");
                return;
            }

            ExecuteEvents.Execute <IOrderEvent>(
                robot,
                null,
                (receive, y) => receive.setObject(obj));
        }
    }
示例#7
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        foreach (string weaknessTag in weaknessTags)
        {
            if (collision.tag.Equals(weaknessTag))
            {
                //Debug.Log("weakness touched: " + collision.tag);
                //Debug.Log(collision.gameObject.name)

                //if none of the gameobject's script can handle IWeaknessMessenger, destroy gameobject by default
                if (!ExecuteEvents.CanHandleEvent <IWeaknessMessenger>(gameObject))
                {
                    Destroy(gameObject);
                }
                else //implement your own functionality once weakness by some object is triggered
                {
                    ExecuteEvents.Execute <IWeaknessMessenger>(gameObject, null, (x, y) => x.OnWeaknessReceived(collision));
                }

                break;
            }
        }
    }
示例#8
0
 public static void HandleEventToObj(GameObject gameObject)
 {
     if (ExecuteEvents.CanHandleEvent<IBeginDragHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.beginDragHandler);
     if (ExecuteEvents.CanHandleEvent<ICancelHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.cancelHandler);
     if (ExecuteEvents.CanHandleEvent<IDeselectHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.deselectHandler);
     if (ExecuteEvents.CanHandleEvent<IDragHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.dragHandler);
     if (ExecuteEvents.CanHandleEvent<IDropHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.dropHandler);
     if (ExecuteEvents.CanHandleEvent<IEndDragHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.endDragHandler);
     if (ExecuteEvents.CanHandleEvent<IInitializePotentialDragHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.initializePotentialDrag);
     ////if (ExecuteEvents.CanHandleEvent<IMoveHandler>(gameObject))
     ////    ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.moveHandler);
     if (ExecuteEvents.CanHandleEvent<IPointerClickHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
     if (ExecuteEvents.CanHandleEvent<IPointerDownHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerDownHandler);
     if (ExecuteEvents.CanHandleEvent<IPointerEnterHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerEnterHandler);
     if (ExecuteEvents.CanHandleEvent<IPointerExitHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerExitHandler);
     if (ExecuteEvents.CanHandleEvent<IPointerUpHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerUpHandler);
     if (ExecuteEvents.CanHandleEvent<IScrollHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.scrollHandler);
     if (ExecuteEvents.CanHandleEvent<ISelectHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.selectHandler);
     if (ExecuteEvents.CanHandleEvent<ISubmitHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.submitHandler);
     if (ExecuteEvents.CanHandleEvent<IUpdateSelectedHandler>(gameObject))
         ExecuteEvents.Execute(gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.updateSelectedHandler);
 }
示例#9
0
    private void SimulateMouseEvents(SimulatedFingerStateType p_gestureStateType, Vector3 p_screenPosition, List <RaycastResult> p_listRaycastResult)
    {
        PointerEventData __newPointerEventData = new PointerEventData(null);

        __newPointerEventData.position      = p_screenPosition;
        __newPointerEventData.pressPosition = p_screenPosition;
        for (int i = 0; i < p_listRaycastResult.Count; i++)
        {
            GameObject __go = (ExecuteEvents.CanHandleEvent <ISelectHandler>(p_listRaycastResult[i].gameObject) == true) ? p_listRaycastResult[i].gameObject : p_listRaycastResult[i].gameObject.transform.parent.gameObject;
            __newPointerEventData.pointerPressRaycast = p_listRaycastResult[i];

            switch (p_gestureStateType)
            {
            case SimulatedFingerStateType.BEGIN:
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.selectHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.pointerEnterHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.pointerDownHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.initializePotentialDrag);
                break;

            case SimulatedFingerStateType.UPDATE:
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.dragHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.scrollHandler);
                break;

            case SimulatedFingerStateType.FINISH:
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.pointerClickHandler);

                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.pointerExitHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.pointerUpHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.endDragHandler);
                ExecuteEvents.Execute(__go, __newPointerEventData, ExecuteEvents.deselectHandler);
                break;
            }
        }
    }
示例#10
0
 private bool CannotHandlDragAnymore(GameObject handler)
 {
     return(!ExecuteEvents.CanHandleEvent <IColliderEventDragStartHandler>(handler));
 }
        private bool ExecuteEvent()
        {
            go = agent;

            var handlerType = eventHandler.value;

            switch (handlerType)
            {
            case EventHandlers.Submit:
                if (!ExecuteEvents.CanHandleEvent <ISubmitHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.submitHandler);
                break;

            case EventHandlers.beginDrag:
                if (!ExecuteEvents.CanHandleEvent <IBeginDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.beginDragHandler);
                break;

            case EventHandlers.cancel:
                if (!ExecuteEvents.CanHandleEvent <ICancelHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.cancelHandler);
                break;

            case EventHandlers.deselectHandler:
                if (!ExecuteEvents.CanHandleEvent <IDeselectHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.deselectHandler);
                break;

            case EventHandlers.dragHandler:
                if (!ExecuteEvents.CanHandleEvent <IDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.dragHandler);
                break;

            case EventHandlers.dropHandler:
                if (!ExecuteEvents.CanHandleEvent <IDropHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.dropHandler);
                break;

            case EventHandlers.endDragHandler:
                if (!ExecuteEvents.CanHandleEvent <IEndDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.endDragHandler);
                break;

            case EventHandlers.initializePotentialDrag:
                if (!ExecuteEvents.CanHandleEvent <IInitializePotentialDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.initializePotentialDrag);
                break;

            case EventHandlers.pointerClickHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerClickHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
                break;

            case EventHandlers.pointerDownHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerDownHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerDownHandler);
                break;

            case EventHandlers.pointerUpHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerUpHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerUpHandler);
                break;

            case EventHandlers.pointerEnterHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerEnterHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerEnterHandler);
                break;

            case EventHandlers.pointerExitHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerExitHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerExitHandler);
                break;

            case EventHandlers.scrollHandler:
                if (!ExecuteEvents.CanHandleEvent <IScrollHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.scrollHandler);
                break;

            case EventHandlers.updateSelectedHandler:
                if (!ExecuteEvents.CanHandleEvent <IUpdateSelectedHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.updateSelectedHandler);
                break;
            }

            return(true);
        }
        private bool ExecuteEvent()
        {
            go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                LogError("Missing GameObject ");
                return(false);
            }

            var handlerType = (EventHandlers)eventHandler.Value;

            switch (handlerType)
            {
            case EventHandlers.Submit:
                if (!ExecuteEvents.CanHandleEvent <ISubmitHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.submitHandler);
                break;

            case EventHandlers.beginDrag:
                if (!ExecuteEvents.CanHandleEvent <IBeginDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.beginDragHandler);
                break;

            case EventHandlers.cancel:
                if (!ExecuteEvents.CanHandleEvent <ICancelHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.cancelHandler);
                break;

            case EventHandlers.deselectHandler:
                if (!ExecuteEvents.CanHandleEvent <IDeselectHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.deselectHandler);
                break;

            case EventHandlers.dragHandler:
                if (!ExecuteEvents.CanHandleEvent <IDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.dragHandler);
                break;

            case EventHandlers.dropHandler:
                if (!ExecuteEvents.CanHandleEvent <IDropHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.dropHandler);
                break;

            case EventHandlers.endDragHandler:
                if (!ExecuteEvents.CanHandleEvent <IEndDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.endDragHandler);
                break;

            case EventHandlers.initializePotentialDrag:
                if (!ExecuteEvents.CanHandleEvent <IInitializePotentialDragHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.initializePotentialDrag);
                break;

            case EventHandlers.pointerClickHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerClickHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
                break;

            case EventHandlers.pointerDownHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerDownHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerDownHandler);
                break;

            case EventHandlers.pointerUpHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerUpHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerUpHandler);
                break;

            case EventHandlers.pointerEnterHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerEnterHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerEnterHandler);
                break;

            case EventHandlers.pointerExitHandler:
                if (!ExecuteEvents.CanHandleEvent <IPointerExitHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.pointerExitHandler);
                break;

            case EventHandlers.scrollHandler:
                if (!ExecuteEvents.CanHandleEvent <IScrollHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.scrollHandler);
                break;

            case EventHandlers.updateSelectedHandler:
                if (!ExecuteEvents.CanHandleEvent <IUpdateSelectedHandler>(go))
                {
                    return(false);
                }
                ExecuteEvents.Execute(go, new BaseEventData(EventSystem.current), ExecuteEvents.updateSelectedHandler);
                break;
            }

            return(true);
        }
示例#13
0
 public bool CanHandleEvent(GameObject go)
 {
     return(ExecuteEvents.CanHandleEvent <T>(go));
 }
 protected bool CanExecute <Event>(GameObject go) where Event : IEventSystemHandler
 {
     return(ExecuteEvents.CanHandleEvent <Event>(go));
 }