示例#1
0
        private static void GenerateInputPairs()
        {
            var iterationsPerLength = new[]
            {
                100,  // 2
                500,  // 3
                500,  // 4
                1000, // 5
                500,  // 6
                100,  // 7
                100,  // 8
            };

            var random        = new Random();
            var wordsByLength = _wordDictionary
                                .GroupBy(word => word.Length)
                                .ToDictionary(g => g.Key, g => g.ToArray());

            List <InputPair> inputPairs = new List <InputPair>();

            for (int i = 0; i < iterationsPerLength.Length; i++)
            {
                int wordLength       = i + 2;
                var wordsOfLength    = wordsByLength[wordLength];
                int numWordsOfLength = wordsOfLength.Length;

                var from = wordsOfLength[random.Next(numWordsOfLength)];
                var to   = wordsOfLength[random.Next(numWordsOfLength)];

                inputPairs.Add(InputPair.Create(from, to));
            }

            _inputPairs = inputPairs.ToArray();
        }
示例#2
0
文件: VRInput.cs 项目: ubisoft/vrtist
        static void UpdateControllerDelta(InputDevice controller, InputFeatureUsage <bool> usage)
        {
            bool bPrevValue;
            bool bCurrValue;

            remapLeftRightHandedDevices = false;
            bPrevValue = GetPrevValue(controller, usage);
            bCurrValue = GetValue(controller, usage);
            remapLeftRightHandedDevices = true;
            InputPair pair = new InputPair(controller, usage);

            if (bPrevValue == bCurrValue)
            {
                justPressed.Remove(pair);
                justReleased.Remove(pair);
            }
            else
            {
                if (bCurrValue)
                {
                    justPressed.Add(pair);
                    justReleased.Remove(pair);
                }
                else
                {
                    justReleased.Add(pair);
                    justPressed.Remove(pair);
                }
            }
        }
示例#3
0
文件: VRInput.cs 项目: ubisoft/vrtist
        public static void GetInstantButtonEvent(InputDevice controller, InputFeatureUsage <bool> usage, ref bool outJustPressed, ref bool outJustReleased)
        {
            InputDevice c    = GetLeftOrRightHandedController(controller);
            InputPair   pair = new InputPair(c, usage);

            outJustPressed  = justPressed.Contains(pair);
            outJustReleased = justReleased.Contains(pair);
        }
示例#4
0
文件: VRInput.cs 项目: ubisoft/vrtist
        public static void ButtonEvent(InputDevice controller, InputFeatureUsage <bool> usage, System.Action onPress = null, System.Action onRelease = null)
        {
            InputDevice c    = GetLeftOrRightHandedController(controller);
            InputPair   pair = new InputPair(c, usage);

            if (onPress != null && justPressed.Contains(pair))
            {
                onPress();
            }

            if (onRelease != null && justReleased.Contains(pair))
            {
                onRelease();
            }
        }
示例#5
0
            public static bool TryParse(string data, out InputPair value)
            {
                value = null;

                if (data.Contains(":"))
                {
                    var parts = data.Split(':');
                    if (int.TryParse(parts[0], out int group) && int.TryParse(parts[1], out int input))
                    {
                        value = new InputPair(group, input);
                        return(true);
                    }
                }
                else if (int.TryParse(data, out int input))
                {
                    value = new InputPair(0, input);
                    return(true);
                }

                return(false);
            }
示例#6
0
 public InputPair(InputPair ip)
 {
     this.input  = ip.input;
     this.frames = ip.frames;
 }