示例#1
0
        public static void BuildMessage(Synchronizer synchronizer, InputInputMessage message)
        {
            for (int i = 0; i < synchronizer.relevantAxes.Length; i++)
            {
                StoredAxis storedAxis = new StoredAxis();
                storedAxis.id    = i;
                storedAxis.value = Input.GetAxis(synchronizer.relevantAxes[i]);
                message.axes.Add(storedAxis);
            }

            for (int i = 0; i < synchronizer.relevantButtons.Length; i++)
            {
                if (Input.GetButton(synchronizer.relevantButtons[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.ButtonDown;
                    message.buttons.Add(storedInput);
                }
            }

            for (int i = 0; i < synchronizer.relevantKeys.Length; i++)
            {
                if (isKeyPressed(synchronizer, synchronizer.relevantKeys[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.KeyDown;
                    message.buttons.Add(storedInput);
                }
            }

            ProcessMessage(synchronizer, message);
        }
示例#2
0
        public static void BuildMessage(Synchronizer synchronizer, InputInputMessage message)
        {
            for (int i = 0; i < synchronizer.relevantAxes.Length; i++)
            {
                StoredAxis storedAxis = new StoredAxis();
                storedAxis.id = i;
                if (synchronizer.relevantAxes [i] == "flystick horizontal")
                {
                    storedAxis.value = synchronizer.flyStick.GetComponent <TrackerSettings> ().getAnalog().x;
                }
                else if (synchronizer.relevantAxes[i] == "flystick vertical")
                {
                    storedAxis.value = synchronizer.flyStick.GetComponent <TrackerSettings> ().getAnalog().y;
                }
                else
                {
                    storedAxis.value = Input.GetAxis(synchronizer.relevantAxes[i]);
                }
                message.axes.Add(storedAxis);
            }

            for (int i = 0; i < synchronizer.relevantButtons.Length; i++)
            {
                if (Input.GetButton(synchronizer.relevantButtons[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.ButtonDown;
                    message.buttons.Add(storedInput);
                }
            }

            for (int i = 0; i < synchronizer.relevantKeys.Length; i++)
            {
                if (isKeyPressed(synchronizer, synchronizer.relevantKeys[i]))
                {
                    StoredInput storedInput = new StoredInput();
                    storedInput.id        = i;
                    storedInput.inputType = (short)InputType.KeyDown;
                    message.buttons.Add(storedInput);
                }
            }

            ProcessMessage(synchronizer, message);
        }
示例#3
0
        public void Deserialize(Buffer buffer)
        {
            int length = Buffer.Get <int>(buffer);

            for (int i = 0; i < length; i++)
            {
                StoredAxis axis = new StoredAxis();
                axis.id    = Buffer.Get <int>(buffer);
                axis.value = Buffer.Get <float>(buffer);
                axes.Add(axis);
            }

            length = Buffer.Get <int>(buffer);
            for (int i = 0; i < length; i++)
            {
                StoredInput input = new StoredInput();
                input.id        = Buffer.Get <int>(buffer);
                input.inputType = Buffer.Get <short>(buffer);
                buttons.Add(input);
            }
        }