예제 #1
0
        private void HandleHMDWearing()
        {
            EDeviceActivityLevel level = OpenVR.System.GetTrackedDeviceActivityLevel(0);

            switch (level)
            {
            case EDeviceActivityLevel.k_EDeviceActivityLevel_Unknown:
            case EDeviceActivityLevel.k_EDeviceActivityLevel_Idle:
            case EDeviceActivityLevel.k_EDeviceActivityLevel_Idle_Timeout:
            case EDeviceActivityLevel.k_EDeviceActivityLevel_Standby:

                if (!isWearingHeadset)
                {
                    break;
                }
                isWearingHeadset = false;
                onHeadsetStateChanged.Invoke(false);
                break;


            case EDeviceActivityLevel.k_EDeviceActivityLevel_UserInteraction:
                if (isWearingHeadset)
                {
                    break;
                }
                isWearingHeadset = true;
                onHeadsetStateChanged.Invoke(true);
                break;
            }
        }
        public void CheckInteraction(Collider collider)
        {
            if (collider)
            {
                var old = target;
                if (collider.TryGetComponent(out target) && target.enabled)
                {
                    if (old && old != target)
                    {
                        old.SetFocus(false);
                    }

                    if (old != target)
                    {
                        target.SetFocus(true);
                        onCanInteract.Invoke(true);
                    }
                }
                else
                {
                    ClearTarget();
                }
            }
            else
            {
                ClearTarget();
            }
        }
예제 #3
0
 public override void Start()
 {
     if (ThrowEventOnStart)
     {
         OnValueChangedEvent.Invoke(Toggled);
         OnValueChanged?.Invoke(Toggled);
     }
 }
예제 #4
0
 public override void Start()
 {
     if (ThrowEventOnStart)
     {
         OnValueChangedEvent.Invoke(CurrentValue);
         OnValueChanged?.Invoke(CurrentValue);
     }
 }
예제 #5
0
 public void GetObjectByComponent(Component component)
 {
     if (!component.TryGetComponent(out pickupable))
     {
         return;
     }
     SetListeners(true);
     onHolding.Invoke(true);
     Pickup(pickupable.transform);
 }
예제 #6
0
        public void Select(bool instant = false, bool silent = false)
        {
            isSelected = true;

            CUIActionHandler.Activate(actionsOnActivated, instant);

            if (!silent)
            {
                onToggled?.Invoke(true);
            }
        }
예제 #7
0
 private void OnGameStateHandler(GameStateMessage gameStateMessage)
 {
     if (gameStateMessage.GameState.Equals(GameState))
     {
         OnStateEvent.Invoke(true);
     }
     else
     {
         OnStateEvent.Invoke(false);
     }
 }
예제 #8
0
        public void OnPointerEnter(PointerEventData eventData)
        {
            if (isHovering)
            {
                return;
            }

            isHovering = true;

            onHovered?.Invoke(true);
        }
예제 #9
0
        /// <summary>
        /// Sets the zoom state.
        /// </summary>
        /// <param name="zoom">Should the camera zoon?</param>
        private void SetZoom(bool zoom)
        {
            if (zoom == m_Zoom)
            {
                return;
            }

            m_Zoom = zoom;
            if (!string.IsNullOrEmpty(m_ZoomState))
            {
                StateManager.SetState(m_GameObject, m_ZoomState, m_Zoom);
                StateManager.SetState(m_Character, m_ZoomState, m_Zoom);

                if (m_CharacterInventory != null && m_StateAppendItemIdentifierName)
                {
                    for (int i = 0; i < m_CharacterInventory.SlotCount; ++i)
                    {
                        var item = m_CharacterInventory.GetActiveItem(i);
                        if (item != null && item.IsActive())
                        {
                            var itemStateName = m_ZoomState + item.ItemDefinition.name;
                            StateManager.SetState(m_GameObject, itemStateName, m_Zoom);
                            StateManager.SetState(m_Character, itemStateName, m_Zoom);
                        }
                    }
                }
            }

            EventHandler.ExecuteEvent <bool>(m_Character, "OnCameraZoom", m_Zoom);
            if (m_OnZoomEvent != null)
            {
                m_OnZoomEvent.Invoke(m_Zoom);
            }
        }
예제 #10
0
    public void CallEvents()
    {
        switch (m_type.ToLower())
        {
        case "int":
        case "integer":
            m_intEvent.Invoke(GetIntValue()); break;

        case "float":
        case "real":
            m_floatEvent.Invoke(GetFloatValue()); break;

        case "string":
        case "text":
            m_stringEvent.Invoke(GetStringValue()); break;

        case "bool":
        case "boolean":
            m_boolEvent.Invoke(GetBoolValue()); break;

        default: break;
        }

        m_optionEvent.Invoke(this);
    }
예제 #11
0
 private void SetRange(bool value)
 {
     if (value == inRange)
     {
         return;
     }
     inRange = value;
     onInRange.Invoke(inRange);
 }
 public virtual void SetFocus(bool value)
 {
     if (isFocused == value)
     {
         return;
     }
     isFocused = value;
     onFocused.Invoke(isFocused);
 }
예제 #13
0
    public static void TriggerBoolEvent(string eventName, bool input)
    {
        UnityBoolEvent thisEvent = null;

        if (instance.boolEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(input);
        }
    }
예제 #14
0
 public void ApplyValue(bool value)
 {
     onValueChanged.Invoke(value);
     if (value)
     {
         onPositive.Invoke();
     }
     else
     {
         onNegative.Invoke();
     }
 }
예제 #15
0
 public void OnCallback(bool value)
 {
     if (value)
     {
         onPostive.Invoke();
     }
     else
     {
         onNegative.Invoke();
     }
     onInvertedValueChanged.Invoke(!value);
 }
예제 #16
0
        /// <summary>
        /// Enables or disables gameplay input. An example of when it will not be enabled is when there is a fullscreen UI over the main camera.
        /// </summary>
        /// <param name="enable">True if the input is enabled.</param>
        protected virtual void EnableGameplayInput(bool enable)
        {
            m_AllowInput = enable;
            enabled      = m_AllowInput && !m_Death;
            if (enabled && !m_HasFocus)
            {
                OnApplicationFocus(true);
            }

            if (m_EnableGamplayInputEvent != null)
            {
                m_EnableGamplayInputEvent.Invoke(enable);
            }
        }
예제 #17
0
    // Update is called once per frame
    void Update()
    {
        if (!start)
        {
            return;
        }

        t -= Time.deltaTime;
        if (t < 0.0f)
        {
            t     = 0.0f;
            start = false;
            timerEvent.Invoke(true);
            Debug.Log("Timer ran out");
        }
        timer.text = t.ToString("0");
    }
예제 #18
0
        /// <summary>
        /// Enables or disables gameplay input. An example of when it will not be enabled is when there is a fullscreen UI over the main camera.
        /// </summary>
        /// <param name="enable">True if the input is enabled.</param>
        protected virtual void EnableGameplayInput(bool enable)
        {
            m_AllowInput = enable;
            enabled      = m_AllowInput && !m_Death;
            if (enabled && !Application.isFocused)
            {
                OnApplicationFocus(true);
            }
            else if (!enabled)
            {
                m_RawLookVector = m_CurrentLookVector = Vector3.zero;
            }

            if (m_EnableGamplayInputEvent != null)
            {
                m_EnableGamplayInputEvent.Invoke(enable);
            }
        }
예제 #19
0
        /// <summary>
        /// Enables or disables gameplay input. An example of when it will not be enabled is when there is a fullscreen UI over the main camera.
        /// </summary>
        /// <param name="enable">True if the input is enabled.</param>
        protected virtual void EnableGameplayInput(bool enable)
        {
            m_AllowInput = enable;
            enabled      = m_AllowInput && !m_Death;
            if (enabled && !m_Focus)
            {
                OnApplicationFocus(true);
            }
            else if (!enabled)
            {
                m_RawLookVector         = m_CurrentLookVector = Vector3.zero;
                m_SmoothLookBufferCount = m_SmoothLookBufferIndex = 0;
            }

            if (m_EnableGamplayInputEvent != null)
            {
                m_EnableGamplayInputEvent.Invoke(enable);
            }
        }
예제 #20
0
 void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
 {
     if (DateTime.Now > clickTime + clickTimeSpan)
     {
         trigger   = !trigger;
         clickTime = DateTime.Now;
         click.Invoke();
         clickBool.Invoke(trigger);
         if (playingSound)
         {
             if (soundType == SoundType.Click)
             {
                 SoundCenter.sounds.PlayClick();
             }
             else if (soundType == SoundType.Coin)
             {
                 SoundCenter.sounds.PlayCoin();
             }
         }
     }
 }
예제 #21
0
        private void FlipButton()
        {
            if (isFlipping)
            {
                return;
            }

            float rotation       = isMyTurn ? 0f : 180f;
            float targetRotation = rotation == 0f ? 180f : 0f;

            var tweener = DOTween.To(() => rotation, x => rotation = x, targetRotation, 1f)
                          .SetEase(Ease.OutBack)
                          .OnStart(() => isFlipping             = true)
                          .OnUpdate(() => transform.eulerAngles = new Vector3(rotation, 0f, 0f))
                          .OnComplete(() =>
            {
                isFlipping = false;
                onFinishedFlipping?.Invoke(isMyTurn);
            });

            isMyTurn = !isMyTurn;
        }
예제 #22
0
    void Update()
    {
        if (animate)
        {
            t += Time.deltaTime;
            if (t > lerpDuration)
            {
                t       = lerpDuration;
                animate = false;

                nextEvent.Invoke(false);
            }
            Vector3 p = Vector3.Lerp(startPos, lerpToPos, t / lerpDuration);
            transform.position = p;
        }


        //Vector3 position = transform.position;
        //Vector3 screenPosition = Camera.main.WorldToScreenPoint(position);

        //if(screenPosition.x < 0 || screenPosition.y < 0 || screenPosition.x > Screen.width || screenPosition.y > Screen.height)
        //	LevelManager.pInstance.ResetGame();
    }
예제 #23
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     PointerEnterExitChanged.Invoke(true);
     PointerEnter.Invoke();
 }
예제 #24
0
        /// <summary>
        /// Sets the view type to the object with the specified type.
        /// </summary>
        /// <param name="type">The type of the ViewType which should be set.</param>
        /// <param name="immediateTransition">Should the ViewType be transitioned immediately?</param>
        public void SetViewType(System.Type type, bool immediateTransition)
        {
            if ((m_ViewType != null && m_ViewType.GetType() == type) || type == null)
            {
                return;
            }

            // The ViewTypes may not be deserialized yet.
            if (m_ViewTypeNameMap.Count == 0)
            {
                DeserializeViewTypes();
            }

            int index;

            if (!m_ViewTypeNameMap.TryGetValue(type.FullName, out index))
            {
                Debug.LogError("Error: Unable to find the view type with name " + type.FullName);
                return;
            }

            float pitch = 0f, yaw = 0f;
            var   characterRotation = Quaternion.identity;

            // ViewType will be null on startup.
            if (m_ViewType != null && m_Character != null && Application.isPlaying)
            {
                pitch             = m_ViewType.Pitch;
                yaw               = m_ViewType.Yaw;
                characterRotation = m_ViewType.CharacterRotation;
                m_ViewType.ChangeViewType(false, 0, yaw, characterRotation);

                EventHandler.ExecuteEvent(m_GameObject, "OnCameraChangeViewTypes", m_ViewType, false);
                if (m_OnChangeViewTypesEvent != null)
                {
                    m_OnChangeViewTypesEvent.Invoke(m_ViewType, false);
                }
            }

            var originalViewType = m_ViewType;

            m_ViewTypeFullName = type.FullName;
            m_ViewType         = m_ViewTypes[index];

            // Keep the first/third person view type updated to be able to switch back to the last active type.
            if (m_ViewType.FirstPersonPerspective)
            {
                m_FirstPersonViewTypeFullName = m_ViewTypeFullName;
                m_FirstPersonViewType         = m_ViewType;
            }
            else
            {
                m_ThirdPersonViewTypeFullName = m_ViewTypeFullName;
                m_ThirdPersonViewType         = m_ViewType;
            }

            // If the original view type is not null then the view type has been changed at runtime. Transition to that new view type.
            if (originalViewType != null && m_Character != null && Application.isPlaying)
            {
                m_ViewType.ChangeViewType(true, pitch, yaw, characterRotation);

                EventHandler.ExecuteEvent(m_GameObject, "OnCameraChangeViewTypes", m_ViewType, true);
                if (m_OnChangeViewTypesEvent != null)
                {
                    m_OnChangeViewTypesEvent.Invoke(m_ViewType, true);
                }
                if (originalViewType.FirstPersonPerspective != m_ViewType.FirstPersonPerspective)
                {
                    EventHandler.ExecuteEvent <bool>(m_Character, "OnCameraWillChangePerspectives", m_ViewType.FirstPersonPerspective);
                }

                // Use the transitioner if it exists.
                if (!immediateTransition && m_Transitioner != null)
                {
                    // StartTransition will return success if the transition is started.
                    if (m_Transitioner.StartTransition(originalViewType, m_ViewType))
                    {
                        return;
                    }
                    else if (m_Transitioner.IsTransitioning)
                    {
                        m_Transitioner.StopTransition(false);
                    }
                }
                else
                {
                    // If there isn't a transitioner then immediately move to the target position.
                    if (m_ViewType.RotatePriority)
                    {
                        KinematicObjectManager.SetCameraRotation(m_KinematicObjectIndex, m_ViewType.Rotate(0, 0, true));
                        KinematicObjectManager.SetCameraPosition(m_KinematicObjectIndex, m_ViewType.Move(true));
                    }
                    else
                    {
                        KinematicObjectManager.SetCameraPosition(m_KinematicObjectIndex, m_ViewType.Move(true));
                        KinematicObjectManager.SetCameraRotation(m_KinematicObjectIndex, m_ViewType.Rotate(0, 0, true));
                    }
                }

                // Execute the perspective event if the transitioner does not exist or is not active. The transitioner will execute this event when it finishes.
                if (originalViewType.FirstPersonPerspective != m_ViewType.FirstPersonPerspective)
                {
                    EventHandler.ExecuteEvent <bool>(m_Character, "OnCameraChangePerspectives", m_ViewType.FirstPersonPerspective);

                    if (m_OnChangePerspectivesEvent != null)
                    {
                        m_OnChangePerspectivesEvent.Invoke(m_ViewType.FirstPersonPerspective);
                    }
                }
            }
        }
 public void OnEventRaised(bool value)
 {
     BoolResponce.Invoke(value);
 }
 public void Dispatch(bool boolValue)
 {
     m_boolEvent.Invoke(boolValue);
 }
예제 #27
0
 private void invertRaise(bool obj)
 {
     listener.Invoke(!obj);
 }
예제 #28
0
 private void OnEnable()
 {
     onEnabled.Invoke();
     onEnableChanged.Invoke(true);
     onEnableChangedInverted.Invoke(false);
 }
예제 #29
0
 public void OnPointerDown(PointerEventData eventData)
 {
     Debug.Log("down");
     onPress?.Invoke(true);
 }
예제 #30
0
 public void Toggle(bool value)
 {
     onValueChanged.Invoke(value);
 }