Example #1
0
 private void OnStateChanged(GameState oldState, GameState newState)
 {
     if (oldState != trackedState && newState == trackedState)
     {
         onStateChanged.Invoke(!inverseValue);  //State became active
     }
     else if (oldState == trackedState && newState != trackedState)
     {
         onStateChanged.Invoke(inverseValue); //State deactivated
     }
 }
Example #2
0
 void Update()
 {
     if (eventType == EventType.Pressed && Input.GetKeyDown(key))
     {
         actions.Invoke(true);
     }
     if (eventType == EventType.Released && Input.GetKeyUp(key))
     {
         actions.Invoke(false);
     }
     if (eventType == EventType.Repeat)
     {
         actions.Invoke(Input.GetKey(key));
     }
 }
Example #3
0
 public override void Interact()
 {
     active = !active;
     Display(true);
     base.Interact();
     ToogleEvents.Invoke(active);
 }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         _OnCompletedEvent.Invoke(true);
         gameObject.SetActive(false);
     }
 }
Example #5
0
 public void Dispatch(bool boolValue)
 {
     m_OnBoolEvents.Invoke(boolValue);
     if (OnBoolEvents != null)
     {
         OnBoolEvents.Invoke(this, new BoolEventArgs()
         {
             value = boolValue
         });
     }
 }
    private void GetBinaryInputChange(BoolUnityEvent eventToFire, string inputButtonName, ref bool lastInputValue)
    {
        bool currentInputValue = Input.GetButtonDown(inputButtonName);

        if (currentInputValue != lastInputValue)
        {
            lastInputValue = currentInputValue;

            if (eventToFire != null)
            {
                eventToFire.Invoke(true);
            }
        }
        else if (Input.GetButtonUp(inputButtonName))
        {
            if (eventToFire != null)
            {
                eventToFire.Invoke(false);
            }
        }
    }
Example #7
0
 public void CloseWindow(string windowName)
 {
     if (string.IsNullOrWhiteSpace(windowName))
     {
         return;
     }
     if (_openWindowsNameToComponents.TryGetValue(windowName, out var window))
     {
         CloseWindow(window);
         _openWindowsNameToComponents.Remove(windowName);
         _openWindowsComponentsToNames.Remove(window);
         if (_openWindowsNameToComponents.Count == 0)
         {
             _anyWindowOpenState.Invoke(false);
         }
     }
     else
     {
         Logger.Instance.LogWarning($"WindowService:: no window with name of {windowName} found to close");
     }
 }
Example #8
0
        public void MoveHorizontal(float value)
        {
            m_Velocity = new Vector2(value * m_Speed, m_Rigidbody2D.velocity.y);

            if (value < 0)
            {
                transform.localScale = new Vector3(-1f, 1f, 1f);
            }
            if (value > 0)
            {
                transform.localScale = Vector3.one;
            }

            m_OnMoving?.Invoke(value != 0.0f);
        }
Example #9
0
    protected override void ApplySet()
    {
        bool conditionResult = conditional.CheckCondition(inputData.Value);

        if (invertOutput)
        {
            conditionResult = !conditionResult;
        }

        if (output != conditionResult)
        {
            output.Value = conditionResult;
            onOutputUpdated.Invoke(conditionResult);
        }
    }
Example #10
0
        private void Update()
        {
            // Poll Input
            // Grip
            bool leftGripIsPressed = false;

            if (_leftController.isValid)
            {
                _leftController.IsPressed(InputHelpers.Button.Grip, out leftGripIsPressed);
            }
            if (leftGripIsPressed != _leftGripPressedState)
            {
                _leftGripPressed.Invoke(leftGripIsPressed);
                _leftGripPressedState = leftGripIsPressed;
            }

            bool rightGripIsPressed = false;

            if (_rightController.isValid)
            {
                _rightController.IsPressed(InputHelpers.Button.Grip, out rightGripIsPressed);
            }
            if (rightGripIsPressed != _lastRightGripIsPressed)
            {
                _rightGripPressed.Invoke(rightGripIsPressed);
                _lastRightGripIsPressed = rightGripIsPressed;
            }

            // Polling velocity requires the node states... Unity is weird
            List <XRNodeState> nodes = new List <XRNodeState>();

            InputTracking.GetNodeStates(nodes);

            foreach (XRNodeState ns in nodes)
            {
                if (ns.nodeType == XRNode.LeftHand)
                {
                    ns.TryGetVelocity(out _leftVelocity);
                }
                if (ns.nodeType == XRNode.RightHand)
                {
                    ns.TryGetVelocity(out _rightVelocity);
                }
            }

            LeftVelocityUpdate.Invoke(_leftVelocity);
            RightVelocityUpdate.Invoke(_rightVelocity);
        }
Example #11
0
 public void SetData(MBool data)
 {
     _value = data;
     if (_onValueChangeEvent != null)
     {
         _onValueChangeEvent.Invoke(_value);
     }
     if (_value && _onValueTrueEvent != null)
     {
         _onValueTrueEvent.Invoke();
     }
     if (!_value && _onValueFalseEvent != null)
     {
         _onValueFalseEvent.Invoke();
     }
 }
Example #12
0
    protected void CheckValue()
    {
        if (value != lastValue || onlySetIfValueDiffers.Value == false)
        {
            lastValue = value;
            onValueChanged?.Invoke(value);

            if (value)
            {
                onValueTrue?.Invoke();
            }
            else
            {
                onValueFalse?.Invoke();
            }
        }
    }
Example #13
0
    // Update is called once per frame
    void Update()
    {
        timeLeft -= Time.deltaTime;

        int minutes = (int)timeLeft / 60;
        int seconds = (int)timeLeft - minutes * 60;

        text.text = $"Time left: {minutes}:{seconds}";

        text.transform.position = new Vector3(Screen.width - 100, Screen.height - 50);

        if (timeLeft < 0 && !timeOver)
        {
            timeOver = true;
            _OnCompleteEvent.Invoke(true);
        }
    }
Example #14
0
 public void SetState(bool togg)
 {
     ToggleValue = togg;
     if (togg)
     {
         toggleImage.sprite = onSprite;
         toggleImage.color  = onColor;
         tmp.text           = onString;
     }
     else
     {
         toggleImage.sprite = offSprite;
         toggleImage.color  = offColor;
         tmp.text           = offString;
     }
     toggleEvent.Invoke(togg);
 }
Example #15
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //ensure that it is the player it collides with
        if (collision.tag == "Player")
        {
            sound.Play();

            if (Color != "Gold")
            {
                _onCompleteEvent.Invoke(Color);
            }
            else
            {
                _OnGoldTrigger.Invoke(true);
                gameObject.SetActive(false);
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "RockGoal")
        {
            transform.position = collision.transform.position;
            rb2d.velocity      = new Vector2(0, 0);
            sound.Stop();
            goalFound = true;
            _ObjectComplete.Invoke(true);
        }

        if (collision.tag == "Ground")
        {
            rb2d.velocity = new Vector2(0, 0);
            sound.Stop();

            if (transform.position.x - (int)transform.position.x != 0.5)
            {
                if (transform.position.x - (int)transform.position.x >= 0)
                {
                    transform.position = new Vector3((int)transform.position.x + 0.5f, transform.position.y);
                }

                else if (transform.position.x - (int)transform.position.x < 0)
                {
                    transform.position = new Vector3((int)transform.position.x - 0.5f, transform.position.y);
                }
            }

            if (transform.position.y - (int)transform.position.y != 0.5)
            {
                if (transform.position.y - (int)transform.position.y < 0)
                {
                    transform.position = new Vector3(transform.position.x, (int)transform.position.y - 0.5f);
                }

                else if (transform.position.y - (int)transform.position.y >= 0)
                {
                    transform.position = new Vector3(transform.position.x, (int)transform.position.y + 0.5f);
                }
            }
        }
    }
    /// <summary>
    /// 检查箭头指示
    /// </summary>
    protected override void CheckArrowHint()
    {
        if (m_ScrollView == null)
        {
            return;
        }

        if (m_EnableArrowHintEvent)
        {
            //anchoredPosition.y停留在上方可能存在一些误差,不完全等于0,设置当大于等于0.13有向上箭头指示
            var contentTopY = m_ScrollView.content.anchoredPosition.y;
            m_ArrowUpEvent.Invoke(contentTopY >= 0.13f);

            //计算当前在viewport下边缘处content的Y坐标
            var viewportHeight = m_ScrollView.viewport.rect.height;
            var bottomY        = contentTopY + viewportHeight;
            m_ArrowDownEvent.Invoke((m_ScrollView.content.rect.height - 0.13f) > bottomY);
        }
    }
Example #18
0
    protected override void CheckArrowHint()
    {
        if (m_ScrollView == null)
        {
            return;
        }

        if (m_EnableArrowHintEvent)
        {
            //anchoredPosition.x停留在左方可能存在一些误差,不完全等于0,设置当小于等于-0.13有向左箭头指示
            var contentLeftX = m_ScrollView.content.anchoredPosition.x;
            m_ArrowLeftEvent.Invoke(contentLeftX <= -0.13f);

            //计算当前在viewport右边缘处content的X坐标
            var viewportRightX = m_ScrollView.viewport.rect.width;
            var contentRightX  = m_ScrollView.content.rect.width + contentLeftX;
            m_ArrowRightEvent.Invoke((contentRightX) > (viewportRightX + 0.13f));
        }
    }
Example #19
0
 // Update is called once per frame
 void Update()
 {
     ButtonAction.Invoke(Input.GetButtonUp(InputName));
 }
 public void SetInteractable(bool value)
 {
     interactable = value;
     onInteractable?.Invoke(interactable);
 }
Example #21
0
 public void Update()
 {
     m_OnJumping?.Invoke(!m_IsGround);
 }
 protected virtual void OnApplicationFocus(bool hasFocus)
 {
     OnApplicationFocusEvent(hasFocus);
     onApplicationFocus.Invoke(hasFocus);
 }
 private void SetMouseOver(bool value)
 {
     over = value;
     onMouseOver?.Invoke(over);
 }
 private void OnEventRaised(bool arg)
 {
     onEvent.Invoke(arg);
 }
Example #25
0
 protected virtual void OnApplicationPause(bool pauseStatus)
 {
     OnApplicationPauseEvent(pauseStatus);
     onApplicationPause.Invoke(pauseStatus);
 }
 private void Start()
 {
     OnRewardAvailable?.Invoke(GAds.Instance.HasCachedAd(adId));
 }
 //só funciona em componentes Canvas com "RaycastTarget" ativo
 public void OnPointerDown(PointerEventData eventData)
 {
     OnChanged.Invoke(true);
 }
Example #28
0
 public override void OnEventRaised(bool data)
 {
     _response.Invoke(data);
 }
 public void OnEventRaised(bool newState)
 {
     onStateChanged.Invoke(newState);
 }
Example #30
0
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ public override void Invoke()
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ onInvoke.Invoke(value);
/*AUTO SCRIPT*/ }