Beispiel #1
0
 private void MouseInput()
 {
     if (!_mouseInputEnabled || _currentControl != ControlMethod.None)
     {
         return;
     }
     _currentControl = ControlMethod.Mouse;
     if (_state == State.Open)
     {
         if (DetermineTargetAngle(ControlMethod.Mouse))
         {
             _currentLayer.UpdateLayer(_cursorTargetAngle, ControlMethod.Mouse);
         }
         if (!_clickTimer.IsActive && Input.GetMouseButtonUp(0))
         {
             _clickTimer.StartTimer();
             _currentLayer.Confirm();
         }
         if (!_clickTimer.IsActive && Input.GetMouseButtonUp(1))
         {
             _clickTimer.StartTimer();
             _currentLayer.Cancel();
         }
     }
     else if (!_clickTimer.IsActive && (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)))
     {
         _clickTimer.StartTimer();
         _currentLayer.Skip();
     }
 }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ControlMethodId,Name,UserId")] ControlMethod controlMethod)
        {
            if (id != controlMethod.ControlMethodId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(controlMethod);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ControlMethodExists(controlMethod.ControlMethodId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", controlMethod.UserId);
            return(View(controlMethod));
        }
Beispiel #3
0
        private void ControllerInput()
        {
            if (!_joystickInputEnabled || Input.GetJoystickNames().Length <= 0 || _currentControl != ControlMethod.None)
            {
                return;
            }
            if (_state == State.Open)
            {
                if (DetermineTargetAngle(ControlMethod.Joystick))
                {
                    _currentLayer.UpdateLayer(_cursorTargetAngle, ControlMethod.Joystick);
                }
                if (Input.GetButtonDown(_inputJoystickConfirm))
                {
                    _currentControl = ControlMethod.Joystick;
                    _currentLayer.Confirm();
                }

                if (Input.GetButtonDown(_inputJoystickCancel))
                {
                    _currentControl = ControlMethod.Joystick;
                    _currentLayer.Cancel();
                }
            }
            else if (Input.GetButtonDown(_inputJoystickConfirm) || Input.GetButtonDown(_inputJoystickCancel))
            {
                _currentLayer.Skip();
            }
        }
Beispiel #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ControlMethod setInBindingsControlMethod    = (ControlMethod)value;
            ControlMethod elementParameterControlMethod = (ControlMethod)parameter;

            return(setInBindingsControlMethod == elementParameterControlMethod ? "Visible" : "Collapsed");
        }
Beispiel #5
0
    public Controller()
    {
        _controlMethod = ControlMethod.Keyboard; //default

        if (_controlMethod == ControlMethod.Touchscreen)
        {
            ConfigureTouchInput();
        }
    }
Beispiel #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // this is what is set in Bindings (e.g. ControlMethod.Manual)
            ControlMethod setInBindingsControlMethod = (ControlMethod)value;

            // this is the ConverterParameter attribute of the target (UI element)
            ControlMethod elementParameterControlMethod = (ControlMethod)parameter;

            return(setInBindingsControlMethod == elementParameterControlMethod); // to target (MainWindow)
        }
Beispiel #7
0
    /// <summary>
    /// TestBlock constructor.
    /// </summary>
    /// <param name="vrHmd"> The selected HMD.</param>
    /// <param name="participantCode"> Code of the participant.</param>
    /// <param name="conditionCode"> Code of the condition.</param>
    /// <param name="blockCode"> Code of the block.</param>
    /// <param name="numberOfTargets"> The number of targets per sequence.</param>
    /// <param name="targetAmplitudes"> A list of target amplitudes.</param>
    /// <param name="targetDiameters"> A list of target widths.</param>
    /// <param name="errorThreshold"> If this threshold is exceeded, a sequence has to be repeated.</param>
    /// <param name="spatialHysteresis"> A multiplier for the target collider. Applied upon entering the target.</param>
    /// <param name="controlMethod"> The chosen control method.</param>
    /// <param name="selectedConfirmationMethod"> The chosen confirmation(activation) method.</param>
    /// <param name="dwellTime"> Time in milliseconds required to activate a target when using the dwell confirmation method.</param>
    /// <param name="timeout"> Time in milliseconds before a timeout error is logged for a trial.</param>
    /// <param name="eyeSmoothFactor"> Number of frames over which gaze point is smoothed over.</param>
    /// <param name="mouseSensivity"> Mouse cursor sensitivity; this is different from your machine's default mouse sensitivity setting.
    /// For our tests, we set the mouse sensitivity in the system settings to average, and set this variable to 10.</param>
    /// <param name="targetConditionsRandomized"> Applies randomisation to width/amplitude combination order if enabled.</param>
    /// <param name="beepOnError"> If enabled, the program will make a sound if a click occurs outside a target.</param>
    /// <param name="showCursor"> If enabled, shows a cursor in the shape of a small circle.</param>
    /// <param name="hoverHightlight"> If enabled, upon hovering over a target its' color will change to the one set in hoverColor.</param>
    /// <param name="buttonDownHighlight"> If enabled, upon clicking and holding the button while over a target its' color will change to the one set in buttonDownColor.</param>
    /// <param name="recordGazePosition"> If enabled, gaze position will be logged in DataLogs.</param>
    /// <param name="backgroundColor"> Color of the background.</param>
    /// <param name="cursorColor"> Color of the cursor.</param>
    /// <param name="targetColor"> Default color of the target.</param>
    /// <param name="buttonDownColor"> Color of the target if clicked and held.</param>
    /// <param name="hoverColor"> Color of the target if hovered over.</param>
    /// <param name="readyForGestureColor"> Color of the target if using head gesture (nod) as confirmation method.</param>
    public TestBlock(VRHMD vrHmd, string participantCode, string conditionCode, string blockCode, int numberOfTargets, List <int> targetAmplitudes, List <float> targetDiameters,
                     float errorThreshold, float spatialHysteresis, ControlMethod controlMethod, ConfirmationMethod selectedConfirmationMethod, float dwellTime, int timeout, int eyeSmoothFactor,
                     float mouseSensivity, bool targetConditionsRandomized, bool beepOnError, bool showCursor, bool hoverHightlight, bool buttonDownHighlight, bool recordGazePosition,
                     Color backgroundColor, Color cursorColor, Color targetColor, Color buttonDownColor, Color hoverColor, Color readyForGestureColor)
    {
        SelectedVRHMD              = vrHmd;
        StartTime                  = DateTime.Now;
        ParticipantCode            = participantCode;
        ConditionCode              = conditionCode;
        BlockCode                  = blockCode;
        NumberOfTargets            = numberOfTargets;
        TargetAmplitudes           = targetAmplitudes;
        TargetDiameters            = targetDiameters;
        ErrorThreshold             = errorThreshold;
        SpatialHysteresis          = spatialHysteresis;
        SelectedControlMethod      = controlMethod;
        SelectedConfirmationMethod = selectedConfirmationMethod;
        DwellTime                  = dwellTime;
        Timeout                    = timeout;
        EyeSmoothFactor            = eyeSmoothFactor;
        MouseSensivity             = mouseSensivity;
        TargetConditionsRandomized = targetConditionsRandomized;
        BeepOnError                = beepOnError;
        ShowCursor                 = showCursor;
        HoverHightlight            = hoverHightlight;
        ButtonDownHighlight        = buttonDownHighlight;
        RecordGazePosition         = recordGazePosition;
        BackgroundColor            = backgroundColor;
        CursorColor                = cursorColor;
        TargetColor                = targetColor;
        ButtonDownColor            = buttonDownColor;
        HoverColor                 = hoverColor;
        ReadyForGestureColor       = readyForGestureColor;

        Sequences = new List <TestSequence>();
        int trialnumber = 0;

        //for (int i = 0; i < 1; ++i)
        for (int i = 0; i < TargetAmplitudes.Count; ++i)
        {
            Sequences.Add(new TestSequence(trialnumber, TargetAmplitudes[i], targetDiameters[i], NumberOfTargets));
            trialnumber++;
        }

        //foreach (int amplitude in TargetAmplitudes)
        //{
        //    foreach (float diameter in targetDiameters)
        //    {
        //        Sequences.Add(new TestSequence(trialnumber, amplitude, diameter, NumberOfTargets));
        //        trialnumber++;
        //    }
        //}
    }
Beispiel #8
0
        public async Task <IActionResult> Create([Bind("ControlMethodId,Name,UserId")] ControlMethod controlMethod)
        {
            if (ModelState.IsValid)
            {
                _context.Add(controlMethod);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", controlMethod.UserId);
            return(View(controlMethod));
        }
 // Use this for initialization
 void Start()
 {
     _UIController      = GameObject.FindGameObjectWithTag("UIController").GetComponent <UIController>();
     _ControlMethod     = Camera.main.GetComponent <ControlMethod>();
     targetSize         = GetComponent <RectTransform>().sizeDelta;
     targetAnchor       = GetComponent <RectTransform>().anchoredPosition;
     selfTransform      = GetComponent <RectTransform>();
     sizeTreshold       = 0.2f;
     anchorTreshold     = 0.2f;
     sizeAnimationSpeed = 0.1f;
     moveAnimationSpeed = 0.1f;
     _EventSystem       = GameObject.FindGameObjectWithTag("EventSystem").GetComponent <EventSystem>();
 }
Beispiel #10
0
        public Bindings()
        {
            this.settings = new ConfigurationBuilder <IAppSettings>()
                            .UseIniFile("Focusu.config.ini")
                            .Build();

            this.controlMethod        = this.settings.ControlMethod;
            this.manualControlType    = this.settings.ManualControlType;
            this.unblankForMapBreak   = this.settings.UnblankForMapBreak;
            this.unblankForSongPaused = this.settings.UnblankForSongPaused;
            this.unblankForMapStart   = this.settings.UnblankForMapStart;
            this.streamlabsEnabled    = this.settings.StreamlabsEnabled;
            this.streamlabsApiKey     = this.settings.StreamlabsApiKey;
        }
Beispiel #11
0
        public Animation(string ID, ControlMethod InvalidateControl, float Value, float TargetValue)
        {
            this.ID = ID;

            this.InvalidateControl = InvalidateControl;

            this.Value       = Value;
            this.TargetValue = TargetValue;

            StartValue = Value;
            Volume     = TargetValue - Value;

            p15 = ValueByPercent(15);
            p30 = ValueByPercent(30);
            p70 = ValueByPercent(70);
            p85 = ValueByPercent(85);
        }
Beispiel #12
0
        protected float timeTillNextFlop = 0; // To limit switching direction while using keyboard to play

        #endregion Fields

        #region Constructors

        public Player(Texture2D textureImage, Point sheetSize,Texture2D bulletTex, Texture2D missileTex, Vector2 position, float health, float maxEngineTorque, int bulletFireDelay, ControlMethod controlMethod, Rectangle window, ExplosionManager explosionManager, SoundBank soundBank)
            : base(textureImage, sheetSize, position, Vector2.Zero, window, explosionManager,soundBank)
        {
            this.bulletTex = bulletTex;
            this.missileTex = missileTex;

            this.health = this.maxHealth = health;
            this.maxEngineTorque = this.engineTorque = maxEngineTorque;
            this.initBulletFireDelay = bulletFireDelay;

            this.explosionDamage = 20f;
            this.explosionRadius = 10f;
            this.materialDensity = 10f;

            this.controlMethod = controlMethod;

            this.side = Side.Player;
        }
        public IEnumerable <ControlMethod> GetAll()
        {
            //get
            {
                List <ControlMethod> prodCharacteristics = new List <ControlMethod>();
                try
                {
                    using (SqlConnection connection = new SqlConnection(FMEADBConnectionstring))
                    {
                        using (SqlCommand command = new SqlCommand())
                        {
                            command.Connection     = connection;
                            command.CommandText    = "FMEA_SP_GetAllProdCharacteristicsRecords";
                            command.CommandType    = System.Data.CommandType.StoredProcedure;
                            command.CommandTimeout = SqlConnectionTimeout;

                            connection.Open();

                            SqlDataReader reader = command.ExecuteReader();

                            while (reader.Read())
                            {
                                ControlMethod pdChar = new ControlMethod()
                                {
                                    PD_Characteristics_ID   = reader.GetInt32(reader.GetOrdinal(FMEAConstants.PD_Characteristics_ID)),
                                    PD_Characteristics_Desc = reader.IsDBNull(reader.GetOrdinal(FMEAConstants.PD_Characteristics_Desc)) ? null : reader.GetString(reader.GetOrdinal(FMEAConstants.PD_Characteristics_Desc)),
                                };
                                prodCharacteristics.Add(pdChar);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                return(prodCharacteristics);
            }
        }
Beispiel #14
0
        const double VCO_LOW  = 0;            // lower input range of the VCO

        private void StartAcquisition()
        {
            if (((string)Environs.Hardware.GetInfo("phaseLockControlMethod")) == "analog")
            {
                cm = ControlMethod.analog;
            }
            else
            {
                cm = ControlMethod.synth;  //synth is default
            }
            if (cm == ControlMethod.synth)
            {
                redSynth = (HP3325BSynth)Environs.Hardware.Instruments["red"];
                redSynth.Connect();
            }
            else
            {
                redSynth = null;
            }

            if (cm == ControlMethod.analog && !Environs.Debug)
            {
                configureAnalogOutput();
            }

            oscillatorFrequency        = OSCILLATOR_TARGET_RATE;
            accumulatedPhaseDifference = 0;
            sampleCounter = 0;
            ClearGUI();
            PrepareDataStores();

            if (!Environs.Debug)
            {
                StartCounter();
            }
            else
            {
                StartFakeCounter();
            }
        }
Beispiel #15
0
        void Update()
        {
            if (_state == State.Disabled || _state == State.Closing)
            {
                return;
            }
            switch (_state)
            {
            case State.Opening:
                if (_fadeIn.Active)
                {
                    _canvasGroup.alpha = _fadeIn.Get();
                }
                if (_currentLayer.TransitionComplete() && !_fadeIn.Active)
                {
                    _state = State.Open;
                }
                break;

            case State.Changing:
                if (_currentLayer.TransitionComplete() && _nextLayer.TransitionComplete())
                {
                    _currentLayer = _nextLayer;
                    _state        = State.Open;
                }
                break;
            }
            //hurry up is breaking animation fix later
            if (_currentLayer == null || _currentLayer.IsTransitioningOut || _state == State.Opening)
            {
                return;
            }
            _currentControl = ControlMethod.None;
            TouchInput();
            ControllerInput();
            MouseInput();
        }
Beispiel #16
0
        private bool DetermineTargetAngle(ControlMethod method)
        {
            Vector2 input;

            switch (method)
            {
            default:
            case ControlMethod.Mouse:
                if (_oldMousePosition == (Vector2)Input.mousePosition)
                {
                    return(false);
                }
                _oldMousePosition = Input.mousePosition;
                input             = ((Vector2)Input.mousePosition - (Vector2)PanelTransform.position).normalized;
                break;

            case ControlMethod.Joystick:
                if ((Mathf.Abs(Input.GetAxis(_inputHorizontal)) < _inputDeadzone) && (Mathf.Abs(Input.GetAxis(_inputVertical)) < _inputDeadzone))
                {
                    return(false);
                }
                _currentControl = ControlMethod.Joystick;
                input           = new Vector2(Input.GetAxis(_inputHorizontal), Input.GetAxis(_inputVertical)).normalized;
                break;
            }
            //work out the clockwise angle from up to the target direction
            var tempTargetAngle = Mathf.Atan2(input.x, input.y) * Mathf.Rad2Deg;

            //if the target direction is to the left
            if (input.x < 0.0f)
            {
                tempTargetAngle = 360.0f - Mathf.Abs(tempTargetAngle);
            }
            _cursorTargetAngle = tempTargetAngle;
            return(true);
        }
Beispiel #17
0
 private void Label_Membership_Click(object sender, EventArgs e)
 {
     ControlMethod.SetFormLoad(frm_membership.Obj_Form);
 }
Beispiel #18
0
    void Update()
    {
        if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) ||
            Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow))
        {
            if (ROSAgentManager.Instance.GetIsCurrentActiveAgent(gameObject))
            {
                controlMethod = ControlMethod.UnityKeyboard;

                if (Input.GetKey(KeyCode.UpArrow))
                {
                    vertical += Time.deltaTime * UnityVerticalSensitivity;
                }
                else if (Input.GetKey(KeyCode.DownArrow))
                {
                    vertical -= Time.deltaTime * UnityVerticalSensitivity;
                }
                else
                {
                    if (vertical > 0f)
                    {
                        vertical -= Time.deltaTime * UnityVerticalSensitivity;
                        if (vertical < 0f)
                        {
                            vertical = 0f;
                        }
                    }
                    else if (vertical < 0f)
                    {
                        vertical += Time.deltaTime * UnityVerticalSensitivity;
                        if (vertical > 0f)
                        {
                            vertical = 0f;
                        }
                    }
                }

                if (Input.GetKey(KeyCode.RightArrow))
                {
                    horizontal += Time.deltaTime * UnityHorizontalSensitivity;
                }
                else if (Input.GetKey(KeyCode.LeftArrow))
                {
                    horizontal -= Time.deltaTime * UnityHorizontalSensitivity;
                }
                else
                {
                    if (horizontal > 0f)
                    {
                        horizontal -= Time.deltaTime * UnityHorizontalSensitivity;
                        if (horizontal < 0f)
                        {
                            horizontal = 0f;
                        }
                    }
                    else if (horizontal < 0f)
                    {
                        horizontal += Time.deltaTime * UnityHorizontalSensitivity;
                        if (vertical > 0f)
                        {
                            horizontal = 0f;
                        }
                    }
                }
            }
        }
        else
        {
            controlMethod = ControlMethod.ROS;
        }

        if (Bridge != null && Bridge.Status != Comm.BridgeStatus.Connected)
        {
            wheelLeftVel = wheelRightVel = 0.0f;
        }

        vertical   = Mathf.Clamp(vertical, -1f, 1f);
        horizontal = Mathf.Clamp(horizontal, -1f, 1f);


        SetWheelMeshPose();
    }
Beispiel #19
0
 private void Label_Borrow_Return_Click(object sender, EventArgs e)
 {
     ControlMethod.SetUserControlOnPanel(Panel_Main, List_Panels["Panel_Borrow_Return"]);
 }
Beispiel #20
0
    void Update()
    {
        bool allowRobotControl = EventSystem.current.currentSelectedGameObject == null;

        if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.DownArrow) ||
            Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow))
        {
            if (MainCamera.gameObject.activeSelf && allowRobotControl)
            {
                controlMethod = ControlMethod.UnityKeyboard;

                if (Input.GetKey(KeyCode.UpArrow))
                {
                    vertical += Time.deltaTime * UnityVerticalSensitivity;
                }
                else if (Input.GetKey(KeyCode.DownArrow))
                {
                    vertical -= Time.deltaTime * UnityVerticalSensitivity;
                }
                else
                {
                    if (vertical > 0f)
                    {
                        vertical -= Time.deltaTime * UnityVerticalSensitivity;
                        if (vertical < 0f)
                        {
                            vertical = 0f;
                        }
                    }
                    else if (vertical < 0f)
                    {
                        vertical += Time.deltaTime * UnityVerticalSensitivity;
                        if (vertical > 0f)
                        {
                            vertical = 0f;
                        }
                    }
                }

                if (Input.GetKey(KeyCode.RightArrow))
                {
                    horizontal += Time.deltaTime * UnityHorizontalSensitivity;
                }
                else if (Input.GetKey(KeyCode.LeftArrow))
                {
                    horizontal -= Time.deltaTime * UnityHorizontalSensitivity;
                }
                else
                {
                    if (horizontal > 0f)
                    {
                        horizontal -= Time.deltaTime * UnityHorizontalSensitivity;
                        if (horizontal < 0f)
                        {
                            horizontal = 0f;
                        }
                    }
                    else if (horizontal < 0f)
                    {
                        horizontal += Time.deltaTime * UnityHorizontalSensitivity;
                        if (vertical > 0f)
                        {
                            horizontal = 0f;
                        }
                    }
                }
            }
        }
        else
        {
            controlMethod = ControlMethod.ROS;
        }

        if (MainCamera.gameObject.activeSelf && allowRobotControl)
        {
            if (Input.GetKeyDown(KeyCode.Alpha1))
            {
                ManualControl = !ManualControl;
                if (ManualControl)
                {
                    wheelLeftVel = wheelRightVel = 0.0f;
                }
                var stamp = new BoolStamped()
                {
                    header = new Ros.Header()
                    {
                        stamp    = Ros.Time.Now(),
                        seq      = seq++,
                        frame_id = "joystick",
                    },
                    data = ManualControl,
                };

                if (Bridge.Version == 1)
                {
                    Bridge.Publish(JOYSTICK_OVERRIDE_TOPIC_ROS1, stamp);
                    var joy = new Ros.Joy()
                    {
                        header = new Ros.Header()
                        {
                            stamp    = Ros.Time.Now(),
                            seq      = seq++,
                            frame_id = "joystick",
                        },
                        axes    = new float[6],
                        buttons = new int[15],
                    };
                    joy.buttons[5] = 1;
                    Bridge.Publish(JOYSTICK_ROS1, joy);
                }
                else
                {
                    Bridge.Publish(JOYSTICK_OVERRIDE_TOPIC_ROS2, stamp);
                }
            }
        }

        if (Bridge != null && Bridge.Status != Ros.Status.Connected)
        {
            wheelLeftVel = wheelRightVel = 0.0f;
        }

        vertical   = Mathf.Clamp(vertical, -1f, 1f);
        horizontal = Mathf.Clamp(horizontal, -1f, 1f);
    }
Beispiel #21
0
        private void StartAcquisition()
        {
            if (((string)Environs.Hardware.GetInfo("phaseLockControlMethod")) == "analog")
                cm = ControlMethod.analog;
            else cm = ControlMethod.synth; //synth is default

            if (cm == ControlMethod.synth)
            {
                redSynth = (Synth)Environs.Hardware.Instruments["red"];
                redSynth.Connect();
            }
            else redSynth = null;

            if (cm == ControlMethod.analog && !Environs.Debug) configureAnalogOutput();

            oscillatorFrequency = OSCILLATOR_TARGET_RATE;
            accumulatedPhaseDifference = 0;
            sampleCounter = 0;
            ClearGUI();
            PrepareDataStores();

            if (!Environs.Debug) StartCounter();
            else StartFakeCounter();
        }
Beispiel #22
0
 private void Label_Myprofile_Click(object sender, EventArgs e)
 {
     ControlMethod.SetUserControlOnPanel(Panel_Main, List_Panels["Panel_Myprofile"]);
 }
Beispiel #23
0
        private void TouchInput()
        {
            if (!_touchInputEnabled || !Input.touchSupported || _currentControl != ControlMethod.None)
            {
                return;
            }
            if (Input.touchCount <= 0)
            {
                _touchTimer = 0;
                return;
            }
            _currentControl = ControlMethod.Touch;
            var pointer = new PointerEventData(EventSystem.current);

            pointer.position = Input.GetTouch(0).position;
            var results = new List <RaycastResult>();

            EventSystem.current.RaycastAll(pointer, results);
            if (results.Count <= 0)
            {
                return;
            }
            var uiCoord = Input.GetTouch(0).position - (Vector2)PanelTransform.position;
            //if the touch is closer to the center of the menu than its radius
            //the radius of the menu is adjusted to compensate for different screen scalings
            float check = 1;

            switch ((byte)_scaler.uiScaleMode)
            {
            case 1:
                check = MathEx.Min(PanelTransform.rect.width, PanelTransform.rect.height) / Mathf.Lerp(ScreenScale.x, ScreenScale.y, _scaler.matchWidthOrHeight) * ((_panelOffset + _elementMaxSize) / 2.0f + _inputLeeway);
                break;

            case 2:
                check = MathEx.Min(PanelTransform.rect.width, PanelTransform.rect.height) * ((_panelOffset + _elementMaxSize) / 2.0f + _inputLeeway * 2.0f);
                break;

            default:
                check = MathEx.Min(PanelTransform.rect.width, PanelTransform.rect.height) * ((_panelOffset + _elementMaxSize) / 2.0f + _inputLeeway);
                break;
            }
            if (new Vector2(uiCoord.x, uiCoord.y).magnitude > check)
            {
                _touchTimer = 0;
                return;
            }
            if (_state != State.Open)
            {
                return;
            }
            //Save the mouse position to the observer variable
            _oldMousePosition = Input.mousePosition;
            //get the normalised form of the touch coordinates
            var uiDir = uiCoord.normalized;
            //Work out the clockwise angle from up to the UIDir
            var tempTargetAngle = Mathf.Atan2(uiDir.x, uiDir.y) * Mathf.Rad2Deg;

            //if the Direction is toward the left of the screen the angleneeds flipping
            if (uiCoord.x < 0.0f)
            {
                tempTargetAngle = 360.0f - Mathf.Abs(tempTargetAngle);
            }

            var angleSet = false;

            //Check how to see how the touch should operate
            if (!_dragAndTouch)
            {
                _cursorTargetAngle = tempTargetAngle;
                angleSet           = true;
            }
            //increment the touch timer by the time since the last frame
            _touchTimer += Time.deltaTime;
            //if the touch timer is above the threshold
            if (_touchTimer >= _touchTime)
            {
                if (!angleSet)
                {
                    _cursorTargetAngle = tempTargetAngle;
                }

                //update the layer
                _currentLayer.UpdateLayer(_cursorTargetAngle, ControlMethod.Touch);
            }
            else
            {
                //if the touch let go this frame
                if (!_clickTimer.IsActive && Input.GetMouseButtonUp(0))
                {
                    _touchTimer = 0;
                    _clickTimer.StartTimer();
                    _currentLayer.UpdateLayer(_cursorTargetAngle, ControlMethod.Touch);
                    _currentLayer.Confirm();
                }
            }
        }
Beispiel #24
0
 private void Form_Main_Load(object sender, EventArgs e)
 {
     ControlMethod.SetUserControlOnPanel(Panel_Main, List_Panels["Panel_Home"]);
 }