Example #1
0
        public void StartListening(ListenMode listenMode)
        {
            _listenMode = listenMode;
            if (!_listenOnTables.Any())
            {
                string _schema = "*";
                if (!String.IsNullOrWhiteSpace(_connectionBuilder.GetConnection().SchemaName))
                {
                    _schema = _connectionBuilder.GetConnection().SchemaName;
                }
                string _table = "*";
                if (!String.IsNullOrWhiteSpace(_connectionBuilder.GetConnection().TableName))
                {
                    _table = _connectionBuilder.GetConnection().TableName;
                }

                _listenOnTables.Add($"{_schema}.{_table}");
            }

            var notifyName = "";

            switch (listenMode)
            {
            case ListenMode.TableEntryPrimaryKeys:
            case ListenMode.TableEntry:
                notifyName = $"XA-Notify-TableEvent_ByReference";
                break;

            default:
                throw new NotImplementedException(listenMode.ToString());
            }
            _startListening(notifyName);
        }
Example #2
0
    public void Reset()
    {
        listenMode = ListenMode.LINE_LENGTH;
        marker.transform.localScale    = new Vector3((minScale + maxScale) / 2, 1, (minScale + maxScale) / 2);
        marker.transform.localPosition = Vector3.zero;
        speedSlider.value = 0;

        rigidBody.Sleep();
        rigidBody.useGravity = false;
        transform.position   = BallSpawn.transform.position;
    }
Example #3
0
 public SubOptions(ListenMode mode, bool sendValueWithEvent)
 {
     Mode = mode;
     SendValueWithEvent = sendValueWithEvent;
 }
Example #4
0
 private void toolStripCBMode_SelectedIndexChanged(object sender, EventArgs e)
 {
     listenMode = (ListenMode)(toolStripCBMode.SelectedIndex);
 }
Example #5
0
    // Update is called once per frame
    void Update()
    {
#if !UNITY_EDITOR
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);

            if (listenMode == ListenMode.LINE_LENGTH)
            {
                if (touch.phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(touch.fingerId))
                {
                    Ray        ray = Camera.main.ScreenPointToRay(touch.position);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        if (hit.collider == boundaryCollider)
                        {
                            movingMarker = true;
                        }
                    }
                }
                else if (touch.phase == TouchPhase.Moved && movingMarker)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(touch.position);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit))
                    {
                        if (hit.collider == boundaryCollider)
                        {
                            Vector3 newPos = hit.point;
                            newPos.y = 0;
                            if (boundaryCollider.bounds.Contains(newPos))
                            {
                                marker.transform.position = newPos;
                            }
                        }
                    }
                }
                else if (touch.phase == TouchPhase.Ended && !EventSystem.current.IsPointerOverGameObject(touch.fingerId))
                {
                    listenMode++;
                    UpdateHelpContent();
                }
            }
            else if (listenMode == ListenMode.ACCURACY || listenMode == ListenMode.SPEED)
            {
                if (touch.phase == TouchPhase.Began && !EventSystem.current.IsPointerOverGameObject(touch.fingerId))
                {
                    listenMode++;
                    UpdateHelpContent();
                }
            }
        }
#else
        if (listenMode == ListenMode.LINE_LENGTH)
        {
            if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    if (hit.collider == boundaryCollider)
                    {
                        movingMarker = true;
                    }
                }
            }
            else if (Input.GetMouseButton(0) && movingMarker)
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    if (hit.collider == boundaryCollider)
                    {
                        Vector3 newPos = hit.point;
                        newPos.y = 0;
                        if (boundaryCollider.bounds.Contains(newPos))
                        {
                            marker.transform.position = newPos;
                        }
                    }
                }
            }
            else if (Input.GetMouseButtonUp(0) && !EventSystem.current.IsPointerOverGameObject())
            {
                listenMode++;
                UpdateHelpContent();
            }
        }
        else if (listenMode == ListenMode.ACCURACY || listenMode == ListenMode.SPEED)
        {
            if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
            {
                listenMode++;
                UpdateHelpContent();
            }
        }
#endif

        if (listenMode == ListenMode.ACCURACY)
        {
            float deltaScale = Mathf.PingPong(Time.time * scaleSpeed, maxScale - minScale);
            marker.transform.localScale = new Vector3(minScale + deltaScale, 1, minScale + deltaScale);
        }
        else if (listenMode == ListenMode.SPEED)
        {
            speedSlider.value = Mathf.PingPong(Time.time * sliderSpeed, 1);
        }

        if (listenMode == ListenMode.NONE)
        {
            Vector3 pitchPoint = marker.transform.position;
            ballSpeed = speedSlider.value * (maxSpeed - minSpeed) + minSpeed;

            Vector3 maxBounds = accuracyCollider.bounds.max;
            Vector3 minBounds = accuracyCollider.bounds.min;

            pitchPoint.x       = Random.Range(minBounds.x, maxBounds.x);
            pitchPoint.z       = Random.Range(minBounds.z, maxBounds.z);
            ballThrowDirection = (pitchPoint - transform.position).normalized;

            listenMode = ListenMode.OFF;
            OnInputsReceived?.Invoke();
        }
    }
Example #6
0
 public void Silence()
 {
     listenMode = ListenMode.OFF;
 }
Example #7
0
 public void ListenToInput()
 {
     listenMode = ListenMode.LINE_LENGTH;
     UpdateHelpContent();
 }