Exemple #1
0
    public void SaveSettings(BinaryFormatter bf, Stream file)
    {
        ControllerType controllerType = ControllerType.PC;

        bf.Serialize(file, 1);
        bf.Serialize(file, this.m_ActionsByInputAction.Count);
        foreach (KeyValuePair <int, InputActionData[]> keyValuePair in this.m_ActionsByInputAction)
        {
            int key = keyValuePair.Key;
            if (key < 117)
            {
                string name = EnumUtils <InputsManager.InputAction> .GetName((InputsManager.InputAction) key);

                bf.Serialize(file, name);
                InputActionData[] value = keyValuePair.Value;
                string            name2 = EnumUtils <KeyCode> .GetName((value != null && value[(int)controllerType] != null)?value[(int)controllerType].m_KeyCode : KeyCode.None);

                bf.Serialize(file, name2);
            }
        }
        foreach (KeyValuePair <int, InputActionData[]> keyValuePair2 in this.m_ActionsByInputAction)
        {
            if (keyValuePair2.Key >= 117)
            {
                string name3 = EnumUtils <TriggerAction.TYPE> .GetName(InputHelpers.GetTriggerAction(keyValuePair2.Key));

                bf.Serialize(file, name3);
                InputActionData[] value2 = keyValuePair2.Value;
                string            name4  = EnumUtils <KeyCode> .GetName((value2 != null && value2[(int)controllerType] != null)?value2[(int)controllerType].m_KeyCode : KeyCode.None);

                bf.Serialize(file, name4);
            }
        }
    }
        protected string GetItemText(MenuItem item, bool isSelected)
        {
            if (item == null)
            {
                Console.WriteLine("GetItemText: item is null");
                return("no item");
            }

            string itemText;
            string displayText = item.Text;

            if (InputHelpers.Contains(displayText, "{value}") && item.Value != null)
            {
                displayText = InputHelpers.Replace(displayText, "{value}", item.Value.ToString());
            }

            itemText = displayText.Substring(0, (displayText.Length >= display.DisplayConfig.Width - 1) ? display.DisplayConfig.Width - 1 : displayText.Length);

            if (isSelected || item.HasSubItems)
            {
                // calculate any neccessary padding to put selector on far right
                int    paddingLength = (display.DisplayConfig.Width - 1 - displayText.Length);
                string padding       = string.Empty;
                if (paddingLength > 0)
                {
                    padding = new string(' ', paddingLength);
                }

                itemText += padding + (isSelected?"*":">");
            }

            return(itemText);
        }
    public static Sprite GetPadIcon(InputActionData action)
    {
        Sprite sprite = null;

        if (action.m_KeyCode != KeyCode.None)
        {
            sprite = InputHelpers.GetIconFromPadButton(action.m_KeyCode.PadButtonFromKey());
        }
        else
        {
            string key      = string.Empty;
            string axisName = action.m_AxisName;
            if (!(axisName == "DPadY"))
            {
                if (!(axisName == "DPadX"))
                {
                    if (!(axisName == "LeftStickY"))
                    {
                        if (!(axisName == "LeftStickX"))
                        {
                            if (!(axisName == "RightStickY"))
                            {
                                if (!(axisName == "RightStickX"))
                                {
                                    key = action.m_AxisName;
                                }
                                else
                                {
                                    key = (action.m_Inverted ? "RightStickLeft" : "RightStickRight");
                                }
                            }
                            else
                            {
                                key = (action.m_Inverted ? "RightStickBackward" : "RightStickForward");
                            }
                        }
                        else
                        {
                            key = (action.m_Inverted ? "LeftStickLeft" : "LeftStickRight");
                        }
                    }
                    else
                    {
                        key = (action.m_Inverted ? "LeftStickBackward" : "LeftStickForward");
                    }
                }
                else
                {
                    key = (action.m_Inverted ? "DPadLeft" : "DPadRight");
                }
            }
            else
            {
                key = (action.m_Inverted ? "DPadDown" : "DPadUp");
            }
            InputHelpers.m_PadIconsMap.TryGetValue(key, out sprite);
        }
        sprite == null;
        return(sprite);
    }
        protected string GetItemText(IMenuItem item, bool isSelected)
        {
            string itemText    = string.Empty;
            string displayText = item.Text;

            if (InputHelpers.Contains(displayText, "{value}") && item.Value != null)
            {
                displayText = InputHelpers.Replace(displayText, "{value}", item.Value.ToString());
            }

            if (isSelected)
            {
                // calculate any neccessary padding to put selector on far right
                int    paddingLength = (_display.DisplayConfig.Width - 1 - displayText.Length);
                string padding       = string.Empty;
                if (paddingLength > 0)
                {
                    padding = new string(' ', paddingLength);
                }
                //
                itemText = displayText.Substring(0, (displayText.Length >= _display.DisplayConfig.Width - 1) ? _display.DisplayConfig.Width - 1 : displayText.Length) + padding + TextCharacters.BoxSelected.ToChar();
            }
            else
            {
                itemText = displayText.Substring(0, (displayText.Length >= _display.DisplayConfig.Width) ? _display.DisplayConfig.Width : displayText.Length);
            }

            return(itemText);
        }
Exemple #5
0
        AbstractTsf ReduceNoise(AbstractTsf[] updatedTrackingRecord, int boneIndex)
        {
            bool applyPosition, applyRotation;

            if (boneIndex == 0 || boneIndex == 1)
            {
                applyPosition = model.configuration.applyToWristPosition;
                applyRotation = model.configuration.applyToWristRotation;
            }
            else
            {
                applyPosition = model.configuration.applyToFingersPosition;
                applyRotation = model.configuration.applyToFingersRotation;
            }

            switch (model.configuration.movingAverage)
            {
            case MovingAverage.Simple:
                return(InputHelpers.SimpleMovingAverage(updatedTrackingRecord, applyPosition, applyRotation));

            case MovingAverage.Weighted:
                return(InputHelpers.WeightedMovingAverage(updatedTrackingRecord, model.wmaWeights, applyPosition, applyRotation));

            case MovingAverage.Exponential:
                Debug.LogError("Exponential Moving Average is not supperted for input noise reduction");
                return(updatedTrackingRecord[updatedTrackingRecord.Length - 1]);

            default:
                return(updatedTrackingRecord[updatedTrackingRecord.Length - 1]);
            }
        }
Exemple #6
0
 private void UpdateInputs()
 {
     if (!Player.Get().GetMovesBlocked())
     {
         this.m_Inputs.m_Vertical   = InputsManager.Get().GetActionValue(InputsManager.InputAction.Forward) - InputsManager.Get().GetActionValue(InputsManager.InputAction.Backward);
         this.m_Inputs.m_Vertical   = Mathf.Sign(this.m_Inputs.m_Vertical) * (this.m_Inputs.m_Vertical * this.m_Inputs.m_Vertical);
         this.m_Inputs.m_Horizontal = InputsManager.Get().GetActionValue(InputsManager.InputAction.Right) - InputsManager.Get().GetActionValue(InputsManager.InputAction.Left);
         this.m_Inputs.m_Horizontal = Mathf.Sign(this.m_Inputs.m_Horizontal) * (this.m_Inputs.m_Horizontal * this.m_Inputs.m_Horizontal);
         this.m_Inputs.m_Jump       = InputsManager.Get().IsActionActive(InputsManager.InputAction.Jump);
         if (GreenHellGame.IsPadControllerActive() && HUDWheel.Get().m_Active)
         {
             this.m_Inputs.m_Duck = false;
         }
         if (GreenHellGame.Instance.m_Settings.m_ToggleRunOption == GameSettings.ToggleRunOption.No)
         {
             this.m_Inputs.m_Sprint = InputsManager.Get().IsActionActive(InputsManager.InputAction.Sprint);
         }
     }
     else if (!MainLevel.Instance.IsPause())
     {
         this.m_Inputs.m_Jump   = false;
         this.m_Inputs.m_Sprint = false;
     }
     if (!this.m_Player.GetRotationBlocked())
     {
         Vector2 lookInput = InputHelpers.GetLookInput(this.m_LookSensitivityX, this.m_LookSensitivityY, this.m_PadSensitivity);
         this.m_Inputs.m_MouseX = lookInput.x;
         this.m_Inputs.m_MouseY = lookInput.y;
     }
 }
Exemple #7
0
    private void UpdateInputs()
    {
        if (this.m_Player.GetRotationBlocked())
        {
            return;
        }
        this.m_Inputs.m_Vertical   = 0f;
        this.m_Inputs.m_Horizontal = 0f;
        if (InputsManager.Get().IsActionActive(InputsManager.InputAction.Forward))
        {
            this.m_Inputs.m_Vertical = 1f;
        }
        else if (InputsManager.Get().IsActionActive(InputsManager.InputAction.Backward))
        {
            this.m_Inputs.m_Vertical = -1f;
        }
        if (InputsManager.Get().IsActionActive(InputsManager.InputAction.Left))
        {
            this.m_Inputs.m_Horizontal = -1f;
        }
        else if (InputsManager.Get().IsActionActive(InputsManager.InputAction.Right))
        {
            this.m_Inputs.m_Horizontal = 1f;
        }
        Vector2 lookInput = InputHelpers.GetLookInput(this.m_LookSensitivityX, this.m_LookSensitivityY, 150f);

        this.m_Inputs.m_MouseX = lookInput.x;
        this.m_Inputs.m_MouseY = lookInput.y;
    }
Exemple #8
0
    public void OnSceneGUI()
    {
        Event   currentEvent = Event.current;
        Vector3 worldPoint   = InputHelpers.GetXZPlaneCollisionInEditorFixedHeight(0f, currentEvent);

        Debug.Log(worldPoint);

        if (InputHelpers.ClickedLeft())
        {
            //Vector3 worldPoint = InputHelpers.GetXZPlaneCollisionInEditorFixedHeight(0f, currentEvent);
            //Debug.Log(worldPoint);

            if (Event.current.control)
            {
                worldPoint = worldPoint.SnapToGrid();
            }

            Node_Behaviour nodeBehaviour = graphBehaviour.CreateNodeBehaviour(worldPoint);

            nodeBehaviour.gameObject.SelectInEditor();
        }

        //if (GUI.changed)
        //    EditorUtility.SetDirty(graphBehaviour);
    }
        protected override void PerformRunCommand(string[] args)
        {
            var afterEventId = args.Length > 0 ? args[0] : null;

            var eventIdCurrent = afterEventId;

            do
            {
                ConsoleContext.Events = ConsoleContext.DiadocApi.GetNewEvents(ConsoleContext.CurrentToken, ConsoleContext.CurrentBoxId, eventIdCurrent);
                foreach (var boxEvent in ConsoleContext.Events.Events)
                {
                    System.Console.Write("{0} {1} {2}", boxEvent.Timestamp, boxEvent.EventId, boxEvent.MessageId);
                    if (boxEvent.Message != null)
                    {
                        System.Console.WriteLine(" [{0} -> {1}]", boxEvent.Message.FromTitle, boxEvent.Message.ToTitle);
                    }
                    else
                    {
                        System.Console.WriteLine();
                    }
                    var attachments = boxEvent.Entities
                                      .Where(e => e.EntityType == EntityType.Attachment && e.AttachmentType != AttachmentType.AttachmentComment);
                    foreach (var attach in attachments)
                    {
                        System.Console.WriteLine("\t{0} [{1}]", attach.FileName, attach.AttachmentType);
                    }
                }

                if (ConsoleContext.Events.TotalCount <= ConsoleContext.Events.Events.Count)
                {
                    break;
                }
                eventIdCurrent = ConsoleContext.Events.Events.Last().EventId;
            } while (InputHelpers.YesNoChoice(false, "...Есть ещё письма... Показать следующую страницу?"));
        }
    public bool CheckIfActivated()
    {
        InputHelpers.IsPressed(controller.inputDevice, drawButton, out bool isGripped, activationThreshold);
        string heldSpell = (handName == "right") ? player.rightHandSpell : player.leftHandSpell;

        return(isGripped && (heldSpell == null || heldSpell == ""));
    }
Exemple #11
0
        private void Run()
        {
            var lines = InputHelpers.GetAllLinesAsListInt();

            var answer = GetThreeAnswerCombo(lines);

            Console.WriteLine($"Answer: {answer}");
        }
Exemple #12
0
    public InputActionData GetInputActionData(TriggerAction.TYPE trigger)
    {
        InputActionData[] array = null;
        int actionId            = InputHelpers.GetActionId(trigger);

        this.m_ActionsByInputAction.TryGetValue(actionId, out array);
        return(array[(int)GreenHellGame.Instance.m_Settings.m_ControllerType]);
    }
Exemple #13
0
 void Update()
 {
     InputHelpers.IsPressed(InputDevices.GetDeviceAtXRNode(controller), btn, out bool isPressed);
     if (isPressed)
     {
         PhotonNetwork.Disconnect();
         PhotonNetwork.LoadLevel(0);
     }
 }
Exemple #14
0
        public override void Method()
        {
            int delta;

            if (int.TryParse(Parameters[0], out delta))
            {
                InputHelpers.SendMouseWheel(delta);
            }
        }
Exemple #15
0
        protected override void Method()
        {
            int x, y;

            if (int.TryParse(Parameters[0], out x) && int.TryParse(Parameters[1], out y))
            {
                InputHelpers.SendMouseMove(x, y);
            }
        }
Exemple #16
0
 public InputActionData GetActionDataByTriggerAction(TriggerAction.TYPE trigger_action, ControllerType controller_type = ControllerType._Count)
 {
     InputActionData[] array;
     if (this.m_ActionsByInputAction.TryGetValue(InputHelpers.GetActionId(trigger_action), out array))
     {
         return(array[(int)((controller_type == ControllerType._Count) ? GreenHellGame.Instance.m_Settings.m_ControllerType : controller_type)]);
     }
     return(null);
 }
Exemple #17
0
    void Update()
    {
        if (inputDelayCounter > 0)
        {
            inputDelayCounter -= Time.deltaTime;
        }
        else
        {
            inputDelayCounter = 0;
        }


        if (mapIndex == 0)
        {
            UpArrow.interactable   = false;
            DownArrow.interactable = true;
        }
        else if (mapIndex == Maps.Length - 1)
        {
            UpArrow.interactable   = true;
            DownArrow.interactable = false;
        }
        else
        {
            UpArrow.interactable   = true;
            DownArrow.interactable = true;
        }

        //poll players controllers
        var players = ReInput.players;

        for (int i = 0; i <= players.playerCount - 1; i++)
        {
            var player = players.GetPlayer(i);


            if (player.controllers.joystickCount > 0 && inputDelayCounter == 0)
            {
                Debug.Log(player.GetAxis(0) + " " + player.GetAxis(1));
                if (InputHelpers.MenuDownOrRight(player))
                {
                    DownArrowClicked();
                    inputDelayCounter = inputDelayTimer;
                }
                if (InputHelpers.MenuUpOrLeft(player))
                {
                    UpArrowClicked();
                    inputDelayCounter = inputDelayTimer;
                }
                if (InputHelpers.MenuAccept(player))
                {
                    MapClick();
                }
            }
        }
    }
        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            bool b = InputHelpers.IsValidDigitKey(e.Key);

            if (b == false)
            {
                e.Handled = true;
            }
            base.OnKeyDown(e);
        }
Exemple #19
0
    public override void HandleFire(PlayerState p)
    {
        if (p != p1 && p != p2)
        {
            return;
        }

        InputHelpers.BasicPullTrigger(p);
        InputHelpers.BasicReleaseTrigger(p);
    }
 protected override void PerformRunCommand(string[] args)
 {
     if (!InputHelpers.YesNoChoice(true, "Использовать системный прокси? (по-умолчанию 'Y')"))
     {
         ConsoleContext.DiadocApi.DisableSystemProxyUsage();
         System.Console.WriteLine("Прокси не будет использоваться в последующих запросах.");
         return;
     }
     ConsoleContext.DiadocApi.EnableSystemProxyUsage();
     SetProxyCredentials();
     System.Console.WriteLine("Прокси настроен.");
 }
Exemple #21
0
        protected override void PerformRunCommand(string[] args)
        {
            var boxId = args.Length > 0 ? args[0] : null;

            if (boxId == null)
            {
                OutputHelpers.ShowBoxes(ConsoleContext);
                return;
            }
            ConsoleContext.CurrentBoxId = InputHelpers.AutocompleteBoxId(ConsoleContext, boxId);
            System.Console.WriteLine("Текущий ящик: " + ConsoleContext.CurrentBoxId);
            ConsoleContext.Events = null;
        }
Exemple #22
0
        protected override void PerformRunCommand(string[] args)
        {
            System.Console.Write("Login: "******"Password: "******"Аутентификация пройдена.");
            OutputHelpers.ShowBoxes(ConsoleContext);
        }
Exemple #23
0
    void OnMouseUp()
    {
        // We get the camera to cancel the Z vector and ScreenToWorldPoint returns distances in the same Z value
        float cameraZPos = Camera.main.transform.position.z;

        finalTouchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0f, 0f, -cameraZPos));

        if (OnMouseOverItemEventHandler != null)
        {
            SwipeDirection direction = InputHelpers.GetSwipeDirection(new Vector2(x, y), finalTouchPosition, 0.5f);
            OnMouseOverItemEventHandler(this, direction);
        }
    }
Exemple #24
0
        public UpdateAttempt AddShip(AddShipModel model)
        {
            var grid = this.GetGrid();

            var xBoundary = grid.Dimensions.X;
            var yBoundary = grid.Dimensions.Y;

            if (model.IsOutOfBounds(xBoundary, yBoundary))
            {
                return new UpdateAttempt {
                           Message = "Coorindates are out of bounds"
                }
            }
            ;

            var shipId = 1;

            if (grid.Ships != null && grid.Ships.Any())
            {
                shipId = grid.Ships.Select(ship => ship.Id).Max() + 1;
            }

            var orientation = InputHelpers.MapDirectionInput(model.Orientation);

            if (orientation == null)
            {
                return new UpdateAttempt {
                           Message = "Invalid direction"
                }
            }
            ;
            var shipToAdd = new ShipModel
            {
                Id          = shipId,
                Lost        = false,
                Orientation = orientation.Value,
                Position    = new CoordinateModel
                {
                    X = model.Position.X,
                    Y = model.Position.Y,
                }
            };

            grid.Ships = grid.Ships == null ? new[] { shipToAdd } : grid.Ships.Concat(new[] { shipToAdd });
            var gridJson = JsonConvert.SerializeObject(grid);
            var result   = _dataService.UpdateGrid(gridJson);

            return(result);
        }
    }
}
    private void UpdateInputs()
    {
        this.m_Inputs.m_Horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
        this.m_Inputs.m_Vertical   = CrossPlatformInputManager.GetAxis("Vertical");
        this.m_Inputs.m_Jump       = CrossPlatformInputManager.GetButton("Jump");
        this.m_Inputs.m_Duck       = CrossPlatformInputManager.GetButton("Duck");
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            this.m_Inputs.m_Sprint = !this.m_Inputs.m_Sprint;
        }
        Vector2 lookInput = InputHelpers.GetLookInput(this.m_LookSensitivityX, this.m_LookSensitivityY, 150f);

        this.m_Inputs.m_MouseX = lookInput.x;
        this.m_Inputs.m_MouseY = lookInput.y;
    }
Exemple #26
0
        private void Run()
        {
            var data = InputHelpers.GetAllLinesAsKeyValueList();

            var validPassports = 0;

            foreach (var passport in data)
            {
                if (CheckPassport(passport))
                {
                    validPassports++;
                }
            }

            Console.WriteLine($"Valid passports: {validPassports}");
        }
 private void UpdatInputs()
 {
     if (this.m_State == EBIMState.Rotation)
     {
         this.m_MouseAxisX -= InputHelpers.GetLookInput(this.m_MouseSensitivityX, 1f, 150f).x *Time.deltaTime;
         if (this.m_MouseAxisX < -30f)
         {
             this.m_MouseAxisX = -30f;
         }
         if (this.m_MouseAxisX > 30f)
         {
             this.m_MouseAxisX = 30f;
         }
         this.m_LMB = InputsManager.Get().IsActionActive(InputsManager.InputAction.LMB);
     }
 }
Exemple #28
0
        /// <summary>
        /// Main game loop. Processes user input for the menu system and then executes the required function(s) as specified.
        /// </summary>
        public void Play()
        {
            do
            {
                DisplayInGameMenu();
                char userInput = InputHelpers.GetUserChoice();
                switch (userInput)
                {
                case 'N':
                case 'n':
                    NextTurn();
                    break;

                case 'V':
                case 'v':
                    DisplayScore();
                    break;

                case 'C':
                case 'c':
                    Console.Clear();
                    break;

                case 'F':
                case 'f':
                    RunInBatchMode();
                    break;

                case 'H':
                case 'h':
                    DisplayGameInstructions();
                    break;

                case 'Q':
                case 'q':
                    ForceGameOver();
                    break;

                default:
                    Console.WriteLine("Invalid input, please enter \"n\", \"v\", \"f\", \"c\", \"h\", or \"q\".");
                    break;
                }
            } while (!GameOver());
            DisplayGameResults();
            Console.WriteLine("Press enter to exit the program.");
            InputHelpers.ForceUserToPressEnterKey();
        }
Exemple #29
0
    protected override Vector3 DetermineMovement()
    {
        var movement = new Vector3();

        if (!IsDead && InputHelpers.IsAnyKey("w", "s", "a", "d"))
        {
            ShouldMove        = true;
            GunObject.enabled = false;

            var headDirection = PlayerHeadController.HeadDirection.Down;

            if (Input.GetKey("w"))
            {
                movement     += new Vector3(0, 1, 0);
                headDirection = PlayerHeadController.HeadDirection.Up;
            }
            else if (Input.GetKey("s"))
            {
                movement         += new Vector3(0, -1, 0);
                GunObject.enabled = true;
                headDirection     = PlayerHeadController.HeadDirection.Down;
            }
            if (Input.GetKey("a"))
            {
                movement     += new Vector3(-1, 0, 0);
                headDirection = PlayerHeadController.HeadDirection.Left;
            }
            else if (Input.GetKey("d"))
            {
                movement     += new Vector3(1, 0, 0);
                headDirection = PlayerHeadController.HeadDirection.Right;
            }

            movement.Normalize();

            if (!_shootController.IsShooting)
            {
                _headObject.SetHeadDirection(headDirection);
            }
        }
        else if (!IsDead)
        {
            ShouldMove = false;
        }

        return(movement);
    }
Exemple #30
0
 private void Awake()
 {
     InputsManager.s_Instance = this;
     InputHelpers.InitPadIcons();
     this.LoadScript();
     if (this.m_ActionsByKeyCode.Count == 0)
     {
         Debug.LogWarning("[InputsManager:Awake] Input script is empty!");
         UnityEngine.Object.Destroy(this);
     }
     CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis("RightStickXPs4"));
     CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis("RightStickYPs4"));
     CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis("DPadXPs4"));
     CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis("DPadYPs4"));
     CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis("LeftTriggerPs4"));
     CrossPlatformInputManager.RegisterVirtualAxis(new CrossPlatformInputManager.VirtualAxis("RightTriggerPs4"));
 }
 public void Init()
 {
     inputHelpers = new InputHelpers();
 }