Ejemplo n.º 1
0
        /// <summary>
        /// Reads a 6-byte <see cref="Vector3s"/> structure from the data stream and advances the position of the stream by
        /// 6 bytes.
        /// </summary>
        /// <returns>The vector3s.</returns>
        /// <param name="binaryReader">The current <see cref="BinaryReader"/></param>
        /// <param name="convertTo">Which axis configuration the read vector should be converted to.</param>
        public static Vector3s ReadVector3s(this BinaryReader binaryReader, AxisConfiguration convertTo = AxisConfiguration.YUp)
        {
            switch (convertTo)
            {
            case AxisConfiguration.Native:
            {
                return(new Vector3s(binaryReader.ReadInt16(), binaryReader.ReadInt16(), binaryReader.ReadInt16()));
            }

            case AxisConfiguration.YUp:
            {
                short X = binaryReader.ReadInt16();
                short Z = binaryReader.ReadInt16();
                short Y = (short)(binaryReader.ReadInt16() * -1);

                return(new Vector3s(X, Y, Z));
            }

            case AxisConfiguration.ZUp:
            {
                short X = binaryReader.ReadInt16();
                short Z = (short)(binaryReader.ReadInt16() * -1);
                short Y = binaryReader.ReadInt16();

                return(new Vector3s(X, Y, Z));
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null);
            }
            }
        }
Ejemplo n.º 2
0
 private void OnDestroy()
 {
     IsOpen = false;
     Texture2D.DestroyImmediate(_highlightTexture);
     _highlightTexture = null;
     _copySource       = null;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads a 12-byte <see cref="Vector3f"/> structure from the data stream and advances the position of the stream by
        /// 12 bytes.
        /// </summary>
        /// <returns>The vector3f.</returns>
        /// <param name="binaryReader">The current <see cref="BinaryReader"/></param>
        /// <param name="convertTo">Which axis configuration the read vector should be converted to.</param>
        public static Vector3f ReadVector3f(this BinaryReader binaryReader, AxisConfiguration convertTo = AxisConfiguration.YUp)
        {
            switch (convertTo)
            {
            case AxisConfiguration.Native:
            {
                return(new Vector3f(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()));
            }

            case AxisConfiguration.YUp:
            {
                float X = binaryReader.ReadSingle();
                float Z = binaryReader.ReadSingle();
                float Y = binaryReader.ReadSingle() * -1.0f;

                return(new Vector3f(X, Y, Z));
            }

            case AxisConfiguration.ZUp:
            {
                float X = binaryReader.ReadSingle();
                float Z = binaryReader.ReadSingle() * -1.0f;
                float Y = binaryReader.ReadSingle();

                return(new Vector3f(X, Y, Z));
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null);
            }
            }
        }
Ejemplo n.º 4
0
        private void PasteAxisConfig()
        {
            InputConfiguration inputConfig = _inputManager.inputConfigurations[_selectionPath[0]];
            AxisConfiguration  axisConfig  = inputConfig.axes[_selectionPath[1]];

            axisConfig.Copy(_copySource);
        }
Ejemplo n.º 5
0
		private void InitializeAxisConfig()
		{
			m_axisConfig = InputManager.GetAxisConfiguration(m_inputConfigName, m_axisConfigName);
			if(m_axisConfig != null)
			{
				if(m_rebindType == RebindType.Keyboard || m_rebindType == RebindType.GamepadButton)
				{
					if(m_changePositiveKey)
					{
						if(m_changeAltKey)
							m_keyDescription.text = m_axisConfig.altPositive == KeyCode.None ? "" : m_axisConfig.altPositive.ToString();
						else
							m_keyDescription.text = m_axisConfig.positive == KeyCode.None ? "" : m_axisConfig.positive.ToString();
					}
					else
					{
						if(m_changeAltKey)
							m_keyDescription.text = m_axisConfig.altNegative == KeyCode.None ? "" : m_axisConfig.altNegative.ToString();
						else
							m_keyDescription.text = m_axisConfig.negative == KeyCode.None ? "" : m_axisConfig.negative.ToString();
					}
				}
				else
				{
					m_keyDescription.text = m_axisNames[m_axisConfig.axis];
				}
			}
			else
			{
				m_keyDescription.text = "";
				Debug.LogError(string.Format(@"Input configuration '{0}' does not exist or axis '{1}' does not exist", m_inputConfigName, m_axisConfigName));
			}
		}
Ejemplo n.º 6
0
    void ChangeButtonBind(string buttonName, KeyCode newButton)
    {
        InputConfiguration config = InputManager.GetInputConfiguration("P" + newButton.ToString()[8].ToString() + "Controls");

        AxisConfiguration button = config.axes.Find(x => x.name == buttonName);

        button.positive = newButton;
    }
        private void OnDisable()
        {
            IsOpen = false;
            Texture2D.DestroyImmediate(_highlightTexture);
            _highlightTexture = null;
            _copySource       = null;

            EditorApplication.playmodeStateChanged -= HandlePlayModeChanged;
        }
Ejemplo n.º 8
0
 private void SetKey(AxisConfiguration axisConfig, KeyCode key, bool positive)
 {
     if (positive)
     {
         axisConfig.positive = (key == KeyCode.Backspace) ? KeyCode.None : key;
     }
     else
     {
         axisConfig.negative = (key == KeyCode.Backspace) ? KeyCode.None : key;
     }
 }
Ejemplo n.º 9
0
        private void CopySelectedAxisConfig()
        {
            if (_copySource == null)
            {
                _copySource = new AxisConfiguration();
            }

            InputConfiguration inputConfig = _inputManager.inputConfigurations[_selectionPath[0]];
            AxisConfiguration  axisConfig  = inputConfig.axes[_selectionPath[1]];

            _copySource.Copy(axisConfig);
        }
Ejemplo n.º 10
0
    //update the text of rebinding menu buttons to corresponding in game button for each player
    void UpdateButtonNames(int playerID)
    {
        InputConfiguration config = InputManager.GetInputConfiguration("P" + playerID + "Controls");

        foreach (Button b in buttons)
        {
            if (b.name == "Jump" || b.name == "Action" || b.name == "Menu")
            {
                AxisConfiguration button = config.axes.Find(x => x.name == b.name);
                b.GetComponentInChildren <Text>().text = b.name + ": " + button.positive;
            }
        }
    }
Ejemplo n.º 11
0
        private void Dispose()
        {
            if (!_isDisposed)
            {
                IsOpen = false;
                Texture2D.DestroyImmediate(_highlightTexture);
                _highlightTexture = null;
                _copySource       = null;

                EditorApplication.playmodeStateChanged -= HandlePlayModeChanged;
                _isDisposed = true;
            }
        }
Ejemplo n.º 12
0
		private void InitAxisConfig()
		{
			m_axisConfig = InputManager.GetAxisConfiguration(m_inputConfigName, m_axisConfigName);
			if(m_axisConfig != null)
			{
				m_status.text = m_axisConfig.invert ? "On" : "Off";
			}
			else
			{
				m_status.text = "Off";
				Debug.LogError(string.Format(@"Input configuration '{0}' does not exist or axis '{1}' does not exist", m_inputConfigName, m_axisConfigName));
			}
		}
Ejemplo n.º 13
0
 private void InitAxisConfig()
 {
     m_axisConfig = InputManager.GetAxisConfiguration(m_inputConfigName, m_axisConfigName);
     if (m_axisConfig != null)
     {
         m_status.text = m_axisConfig.invert ? "On" : "Off";
     }
     else
     {
         m_status.text = "Off";
         Debug.LogError(string.Format(@"Input configuration '{0}' does not exist or axis '{1}' does not exist", m_inputConfigName, m_axisConfigName));
     }
 }
Ejemplo n.º 14
0
        private void DisplayAxisConfigurationFields(InputConfiguration inputConfigx, AxisConfiguration axisConfig, Rect screenRect)
        {
            GUIContent gravityInfo     = new GUIContent("Gravity", "The speed(in units/sec) at which a digital axis falls towards neutral.");
            GUIContent sensitivityInfo = new GUIContent("Sensitivity", "The speed(in units/sec) at which an axis moves towards the target value.");
            GUIContent snapInfo        = new GUIContent("Snap", "If input switches direction, do we snap to neutral and continue from there? For digital axes only.");
            GUIContent deadZoneInfo    = new GUIContent("Dead Zone", "Size of analog dead zone. Values within this range map to neutral.");

            GUILayout.BeginArea(screenRect);
            _mainPanelScrollPos    = GUILayout.BeginScrollView(_mainPanelScrollPos);
            axisConfig.name        = EditorGUILayout.TextField("Name", axisConfig.name);
            axisConfig.description = EditorGUILayout.TextField("Description", axisConfig.description);

            //	Positive Key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingPositiveKey, "Positive",
                                       "editor_positive_key", axisConfig.positive);
            ProcessKeyString(ref axisConfig.positive, ref _editingPositiveKey);
            //	Negative Key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingNegativeKey, "Negative",
                                       "editor_negative_key", axisConfig.negative);
            ProcessKeyString(ref axisConfig.negative, ref _editingNegativeKey);
            //	Alt Positive Key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltPositiveKey, "Alt Positive",
                                       "editor_alt_positive_key", axisConfig.altPositive);
            ProcessKeyString(ref axisConfig.altPositive, ref _editingAltPositiveKey);
            //	Alt Negative key
            EditorToolbox.KeyCodeField(ref _keyString, ref _editingAltNegativeKey, "Alt Negative",
                                       "editor_alt_negative_key", axisConfig.altNegative);
            ProcessKeyString(ref axisConfig.altNegative, ref _editingAltNegativeKey);

            axisConfig.gravity     = EditorGUILayout.FloatField(gravityInfo, axisConfig.gravity);
            axisConfig.deadZone    = EditorGUILayout.FloatField(deadZoneInfo, axisConfig.deadZone);
            axisConfig.sensitivity = EditorGUILayout.FloatField(sensitivityInfo, axisConfig.sensitivity);
            axisConfig.snap        = EditorGUILayout.Toggle(snapInfo, axisConfig.snap);
            axisConfig.invert      = EditorGUILayout.Toggle("Invert", axisConfig.invert);
            axisConfig.type        = (InputType)EditorGUILayout.EnumPopup("Type", axisConfig.type);
            axisConfig.axis        = EditorGUILayout.Popup("Axis", axisConfig.axis, _axisOptions);
            axisConfig.joystick    = EditorGUILayout.Popup("Joystick", axisConfig.joystick, _joystickOptions);

            if (EditorApplication.isPlaying)
            {
                EditorGUILayout.Space();
                GUI.enabled = false;
                EditorGUILayout.FloatField("Raw Axis", axisConfig.GetAxisRaw());
                EditorGUILayout.FloatField("Axis", axisConfig.GetAxis());
                EditorGUILayout.Toggle("Button", axisConfig.GetButton());
                GUI.enabled = true;
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }
Ejemplo n.º 15
0
 private void ProcessKeyString(ref KeyCode key, ref bool isEditing)
 {
     if (isEditing && Event.current.type == EventType.KeyUp)
     {
         key = AxisConfiguration.StringToKey(_keyString);
         if (key == KeyCode.None)
         {
             _keyString = string.Empty;
         }
         else
         {
             _keyString = key.ToString();
         }
         isEditing = false;
     }
 }
Ejemplo n.º 16
0
    void ChangeAxis(PlayerID playerID)
    {
        AxisConfiguration button = InputManager.GetAxisConfiguration((PlayerID)playerID, "Horizontal");

        button.axis = 7;

        AxisConfiguration button2 = InputManager.GetAxisConfiguration((PlayerID)playerID, "Vertical");

        button2.sensitivity = -1.0f;   //some controllers have inverted axis for some reason
        button2.axis        = 8;

        ControllerBind bindings = FindObjectOfType <ControllerBind>();

        bindings.ChangeButton(playerID, "Jump", (KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + (int)(playerID + 1) + "Button" + 0));
        bindings.ChangeButton(playerID, "Action", (KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + (int)(playerID + 1) + "Button" + 2));
    }
Ejemplo n.º 17
0
        private void DisplayMainPanel()
        {
            Rect screenRect = new Rect(_hierarchyPanelWidth + 5.0f, _toolbarHeight + 5,
                                       position.width - (_hierarchyPanelWidth + 5.0f),
                                       position.height - _toolbarHeight - 5.0f);
            InputConfiguration inputConfig = _inputManager.inputConfigurations[_selectionPath[0]];

            if (_selectionPath.Count < 2)
            {
                DisplayInputConfigurationFields(inputConfig, screenRect);
            }
            else
            {
                AxisConfiguration axisConfig = inputConfig.axes[_selectionPath[1]];
                DisplayAxisConfigurationFields(inputConfig, axisConfig, screenRect);
            }
        }
Ejemplo n.º 18
0
    private string GetKeyName(string axisName, bool positive)
    {
        AxisConfiguration axisConfig = InputManager.GetAxisConfiguration("KeyboardAndMouse", axisName);

        if (axisConfig != null)
        {
            if (positive)
            {
                return((axisConfig.positive != KeyCode.None) ? axisConfig.positive.ToString() : string.Empty);
            }
            else
            {
                return((axisConfig.negative != KeyCode.None) ? axisConfig.negative.ToString() : string.Empty);
            }
        }
        return(string.Empty);
    }
Ejemplo n.º 19
0
 public void Copy(AxisConfiguration source)
 {
     name        = source.name;
     description = source.description;
     positive    = source.positive;
     altPositive = source.altPositive;
     negative    = source.negative;
     altNegative = source.altNegative;
     deadZone    = source.deadZone;
     gravity     = source.gravity;
     sensitivity = source.sensitivity;
     snap        = source.snap;
     invert      = source.invert;
     type        = source.type;
     axis        = source.axis;
     joystick    = source.joystick;
 }
Ejemplo n.º 20
0
 private void ProcessKeyString(ref bool isEditing, SerializedProperty key)
 {
     if (isEditing && Event.current.type == EventType.KeyUp)
     {
         KeyCode keyCode = AxisConfiguration.StringToKey(_keyString);
         if (keyCode == KeyCode.None)
         {
             key.enumValueIndex = 0;
             _keyString         = string.Empty;
         }
         else
         {
             key.enumValueIndex = IndexOfKeyName(key.enumNames, _keyString);
             _keyString         = keyCode.ToString();
         }
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Reads a 16-byte <see cref="Vector4"/> structure from the data stream and advances the position of the stream by
        /// 16 bytes.
        /// </summary>
        /// <returns>The vector3f.</returns>
        /// <param name="binaryReader">The current <see cref="BinaryReader"/></param>
        /// <param name="convertTo">Which axis configuration the read vector should be converted to.</param>
        public static Vector4 ReadVector4(this BinaryReader binaryReader, AxisConfiguration convertTo = AxisConfiguration.YUp)
        {
            switch (convertTo)
            {
            case AxisConfiguration.Native:
            {
                return(new Vector4(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()));
            }

            case AxisConfiguration.YUp:
            {
                float x1 = binaryReader.ReadSingle();
                float y1 = binaryReader.ReadSingle();
                float z1 = binaryReader.ReadSingle();

                float x = x1;
                float y = z1;
                float z = -y1;

                float w = binaryReader.ReadSingle();

                return(new Vector4(x, y, z, w));
            }

            case AxisConfiguration.ZUp:
            {
                float x1 = binaryReader.ReadSingle();
                float y1 = binaryReader.ReadSingle();
                float z1 = binaryReader.ReadSingle();

                float x = x1;
                float y = -z1;
                float z = y1;

                float w = binaryReader.ReadSingle();

                return(new Vector4(x, y, z, w));
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null);
            }
            }
        }
Ejemplo n.º 22
0
        private void DuplicateAxisConfiguration()
        {
            InputConfiguration inputConfig = _inputManager.inputConfigurations[_selectionPath[0]];
            AxisConfiguration  source      = inputConfig.axes[_selectionPath[1]];
            AxisConfiguration  axisConfig  = AxisConfiguration.Duplicate(source);

            if (_selectionPath[1] < inputConfig.axes.Count - 1)
            {
                inputConfig.axes.Insert(_selectionPath[1], axisConfig);
                _selectionPath[1]++;
            }
            else
            {
                inputConfig.axes.Add(axisConfig);
                _selectionPath[1] = inputConfig.axes.Count - 1;
            }
            Repaint();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Reads a 12-byte <see cref="Vector3"/> structure from the data stream and advances the position of the stream by
        /// 12 bytes.
        /// </summary>
        /// <returns>The vector3f.</returns>
        /// <param name="binaryReader">The reader.</param>
        /// <param name="convertTo">Which axis configuration the read vector should be converted to.</param>
        public static Vector3 ReadVector3(this BinaryReader binaryReader, AxisConfiguration convertTo = AxisConfiguration.YUp)
        {
            switch (convertTo)
            {
            case AxisConfiguration.Native:
            {
                return(new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()));
            }

            case AxisConfiguration.YUp:
            {
                var x1 = binaryReader.ReadSingle();
                var y1 = binaryReader.ReadSingle();
                var z1 = binaryReader.ReadSingle();

                var x = x1;
                var y = z1;
                var z = -y1;

                return(new Vector3(x, y, z));
            }

            case AxisConfiguration.ZUp:
            {
                var x1 = binaryReader.ReadSingle();
                var y1 = binaryReader.ReadSingle();
                var z1 = binaryReader.ReadSingle();

                var x = x1;
                var y = -z1;
                var z = y1;

                return(new Vector3(x, y, z));
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null);
            }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Reads a 6-byte <see cref="Vector3s"/> structure from the data stream and advances the position of the stream by
        /// 6 bytes.
        /// </summary>
        /// <returns>The vector3s.</returns>
        /// <param name="binaryReader">The current <see cref="BinaryReader"/></param>
        /// <param name="convertTo">Which axis configuration the read vector should be converted to.</param>
        public static Vector3s ReadVector3s(this BinaryReader binaryReader, AxisConfiguration convertTo = AxisConfiguration.YUp)
        {
            switch (convertTo)
            {
            case AxisConfiguration.Native:
            {
                return(new Vector3s(binaryReader.ReadInt16(), binaryReader.ReadInt16(), binaryReader.ReadInt16()));
            }

            case AxisConfiguration.YUp:
            {
                short x1 = binaryReader.ReadInt16();
                short y1 = binaryReader.ReadInt16();
                short z1 = binaryReader.ReadInt16();

                short x = x1;
                short y = z1;
                short z = (short)-y1;

                return(new Vector3s(x, y, z));
            }

            case AxisConfiguration.ZUp:
            {
                short x1 = binaryReader.ReadInt16();
                short y1 = binaryReader.ReadInt16();
                short z1 = binaryReader.ReadInt16();

                short x = x1;
                short y = (short)-z1;
                short z = y1;

                return(new Vector3s(x, y, z));
            }

            default:
            {
                throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null);
            }
            }
        }
Ejemplo n.º 25
0
 private void InitializeAxisConfig()
 {
     m_axisConfig = InputManager.GetAxisConfiguration(m_inputConfigName, m_axisConfigName);
     if (m_axisConfig != null)
     {
         if (m_rebindType == RebindType.Keyboard || m_rebindType == RebindType.GamepadButton)
         {
             if (m_changePositiveKey)
             {
                 if (m_changeAltKey)
                 {
                     m_keyDescription.text = m_axisConfig.altPositive == KeyCode.None ? "" : m_axisConfig.altPositive.ToString();
                 }
                 else
                 {
                     m_keyDescription.text = m_axisConfig.positive == KeyCode.None ? "" : m_axisConfig.positive.ToString();
                 }
             }
             else
             {
                 if (m_changeAltKey)
                 {
                     m_keyDescription.text = m_axisConfig.altNegative == KeyCode.None ? "" : m_axisConfig.altNegative.ToString();
                 }
                 else
                 {
                     m_keyDescription.text = m_axisConfig.negative == KeyCode.None ? "" : m_axisConfig.negative.ToString();
                 }
             }
         }
         else
         {
             m_keyDescription.text = m_axisNames[m_axisConfig.axis];
         }
     }
     else
     {
         m_keyDescription.text = "";
         Debug.LogError(string.Format(@"Input configuration '{0}' does not exist or axis '{1}' does not exist", m_inputConfigName, m_axisConfigName));
     }
 }
Ejemplo n.º 26
0
    private bool HandleKeyScanResult(KeyCode key, params object[] args)
    {
        //if (!IsValidKeyboardKey (key))
        //return false;

        string axisName = (string)args [0];
        bool   positive = (bool)args [1];

        if (key != KeyCode.None)
        {
            AxisConfiguration axisConfig = InputManager.GetAxisConfiguration("KeyboardAndMouse", axisName);
            if (axisConfig != null)
            {
                SetKey(axisConfig, key, positive);
            }
        }
        scanIndex  = -1;
        justScaned = true;

        return(true);
    }
Ejemplo n.º 27
0
        private void ImportSelectedMapping()
        {
            if (_configurator == null)
            {
                EditorUtility.DisplayDialog("Error", "Unable to import joystick mapping. Did you close the advanced input editor?", "Close");
                return;
            }

            InputConfiguration inputConfig = new InputConfiguration(_mappings[_selection].Name.Replace(' ', '_'));

            foreach (AxisMapping am in _mappings[_selection])
            {
                if (am.ScanType == MappingWizard.ScanType.Button)
                {
                    AxisConfiguration axisConfig = new AxisConfiguration(am.Name);
                    axisConfig.type     = InputType.Button;
                    axisConfig.positive = am.Key;
                    inputConfig.axes.Add(axisConfig);
                }
                else
                {
                    if (am.JoystickAxis < 0 || am.JoystickAxis >= AxisConfiguration.MaxJoystickAxes)
                    {
                        Debug.LogError("Joystick axis is out of range. Cannot import axis configuration: " + am.Name);
                        continue;
                    }

                    AxisConfiguration axisConfig = new AxisConfiguration(am.Name);
                    axisConfig.type        = InputType.AnalogAxis;
                    axisConfig.axis        = am.JoystickAxis;
                    axisConfig.joystick    = 0;
                    axisConfig.deadZone    = 0.0f;
                    axisConfig.sensitivity = 1.0f;
                    inputConfig.axes.Add(axisConfig);
                }
            }

            _configurator.AddInputConfiguration(inputConfig);
        }
        private void ImportSelectedMapping()
        {
            if (_configurator == null)
            {
                EditorUtility.DisplayDialog("Error", "Unable to import joystick mapping. Did you close the advanced input editor?", "Close");
                return;
            }

            InputConfiguration inputConfig = new InputConfiguration(_mappings[_selection].Name.Replace(' ', '_'));

            foreach (AxisMapping am in _mappings[_selection])
            {
                if (am.ScanType == MappingWizard.ScanType.Button)
                {
                    AxisConfiguration axisConfig = new AxisConfiguration(am.Name);
                    axisConfig.type     = InputType.Button;
                    axisConfig.positive = am.Key;
                    inputConfig.axes.Add(axisConfig);
                }
                else
                {
                    if (am.JoystickAxis < 0 || am.JoystickAxis > 9)
                    {
                        throw new ArgumentOutOfRangeException("joystickAxis");
                    }

                    AxisConfiguration axisConfig = new AxisConfiguration(am.Name);
                    axisConfig.type        = InputType.AnalogAxis;
                    axisConfig.axis        = am.JoystickAxis;
                    axisConfig.joystick    = 0;
                    axisConfig.deadZone    = 0.0f;
                    axisConfig.sensitivity = 1.0f;
                    inputConfig.axes.Add(axisConfig);
                }
            }

            _configurator.AddInputConfiguration(inputConfig);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Writes a 12-byte <see cref="Vector3"/> value to the data stream. This function
        /// expects a Y-up vector. By default, this function will store the vector in a Z-up axis configuration, which
        /// is what World of Warcraft expects. This can be overridden. Passing <see cref="AxisConfiguration.Native"/> is
        /// considered Y-up, as it is the way vectors are handled internally in the library.
        /// </summary>
        /// <param name="binaryWriter">The current <see cref="BinaryWriter"/> object.</param>
        /// <param name="vector">The Vector to write.</param>
        /// <param name="storeAs">Which axis configuration the read vector should be stored as.</param>
        public static void WriteVector3(this BinaryWriter binaryWriter, Vector3 vector, AxisConfiguration storeAs = AxisConfiguration.ZUp)
        {
            switch (storeAs)
            {
            case AxisConfiguration.Native:
            case AxisConfiguration.YUp:
            {
                binaryWriter.Write(vector.X);
                binaryWriter.Write(vector.Y);
                binaryWriter.Write(vector.Z);
                break;
            }

            case AxisConfiguration.ZUp:
            {
                binaryWriter.Write(vector.X);
                binaryWriter.Write(vector.Z * -1.0f);
                binaryWriter.Write(vector.Y);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(storeAs), storeAs, null);
            }
        }
Ejemplo n.º 30
0
    public void player1UsingKeyboard()
    {
        keyboardP1 = !keyboardP1;
        AxisConfiguration axisConfigMoveHorizontal1   = InputManager.GetAxisConfiguration("MoveHorizontal");                                            //1st Player Start
        AxisConfiguration axisConfigMoveVertical1     = InputManager.GetAxisConfiguration("MoveVertical");
        AxisConfiguration axisConfigRotateVertical1   = InputManager.GetAxisConfiguration("RotateVertical");
        AxisConfiguration axisConfigRotateHorizontal1 = InputManager.GetAxisConfiguration("RotateHorizontal");
        AxisConfiguration axisConfigFire1             = InputManager.GetAxisConfiguration("Fire");                                                              //1st Player end
        AxisConfiguration axisConfigMoveVertical2     = InputManager.GetAxisConfiguration("MoveVertical2");                                                     //2nd Player Start
        AxisConfiguration axisConfigMoveHorizontal2   = InputManager.GetAxisConfiguration("MoveHorizontal2");
        AxisConfiguration axisConfigRotateVertical2   = InputManager.GetAxisConfiguration("RotateVertical2");
        AxisConfiguration axisConfigRotateHorizontal2 = InputManager.GetAxisConfiguration("RotateHorizontal2");
        AxisConfiguration axisConfigFire2             = InputManager.GetAxisConfiguration("Fire2");                                                             //2nd Player end
        AxisConfiguration axisConfigMoveVertical3     = InputManager.GetAxisConfiguration("MoveVertical3");                                                     //3rd Player Start
        AxisConfiguration axisConfigMoveHorizontal3   = InputManager.GetAxisConfiguration("MoveHorizontal3");
        AxisConfiguration axisConfigRotateVertical3   = InputManager.GetAxisConfiguration("RotateVertical3");
        AxisConfiguration axisConfigRotateHorizontal3 = InputManager.GetAxisConfiguration("RotateHorizontal3");
        AxisConfiguration axisConfigFire3             = InputManager.GetAxisConfiguration("Fire3");                                                             //3rd Player end
        AxisConfiguration axisConfigMoveVertical4     = InputManager.GetAxisConfiguration("MoveVertical4");                                                     //4th Player Start
        AxisConfiguration axisConfigMoveHorizontal4   = InputManager.GetAxisConfiguration("MoveHorizontal4");
        AxisConfiguration axisConfigRotateVertical4   = InputManager.GetAxisConfiguration("RotateVertical4");
        AxisConfiguration axisConfigRotateHorizontal4 = InputManager.GetAxisConfiguration("RotateHorizontal4");
        AxisConfiguration axisConfigFire4             = InputManager.GetAxisConfiguration("Fire4");                                                                             //4th Player end

        if (keyboardP1)
        {
            Debug.Log("Player1PlayingOnTheKeyBoard");
            Gamepad.SetActive(false);
            Keyboard.SetActive(true);
            SetKey(axisConfigFire1, KeyCode.Mouse0, true);
            axisConfigMoveVertical2.joystick     = 0;
            axisConfigMoveHorizontal2.joystick   = 0;
            axisConfigRotateVertical2.joystick   = 0;
            axisConfigRotateHorizontal2.joystick = 0;
            axisConfigFire2.joystick             = 0;
            SetKey(axisConfigFire2, KeyCode.Joystick1Button5, true);


            axisConfigMoveVertical3.joystick     = 1;
            axisConfigMoveHorizontal3.joystick   = 1;
            axisConfigRotateVertical3.joystick   = 1;
            axisConfigRotateHorizontal3.joystick = 1;
            axisConfigFire3.joystick             = 1;
            SetKey(axisConfigFire3, KeyCode.Joystick2Button5, true);

            axisConfigMoveVertical4.joystick     = 2;
            axisConfigMoveHorizontal4.joystick   = 2;
            axisConfigRotateVertical4.joystick   = 2;
            axisConfigRotateHorizontal4.joystick = 2;
            axisConfigFire4.joystick             = 2;
            SetKey(axisConfigFire4, KeyCode.Joystick3Button5, true);
            fireButtonText.text  = "fire = " + GetKeyName("Fire", true);
            fireButtonText1.text = "fire = " + GetKeyName("Fire2", true);
            fireButtonText2.text = "fire = " + GetKeyName("Fire3", true);
            fireButtonText3.text = "fire = " + GetKeyName("Fire4", true);
        }
        if (!keyboardP1)
        {
            Debug.Log("Player1PlayingOnTheGamePad");
            Gamepad.SetActive(true);
            Keyboard.SetActive(false);
            SetKey(axisConfigFire1, KeyCode.Joystick1Button5, true);
            axisConfigMoveVertical2.joystick     = 1;
            axisConfigMoveHorizontal2.joystick   = 1;
            axisConfigRotateVertical2.joystick   = 1;
            axisConfigRotateHorizontal2.joystick = 1;
            axisConfigFire2.joystick             = 1;
            SetKey(axisConfigFire2, KeyCode.Joystick2Button5, true);

            axisConfigMoveVertical3.joystick     = 2;
            axisConfigMoveHorizontal3.joystick   = 2;
            axisConfigRotateVertical3.joystick   = 2;
            axisConfigRotateHorizontal3.joystick = 2;
            axisConfigFire3.joystick             = 2;
            SetKey(axisConfigFire3, KeyCode.Joystick3Button5, true);

            axisConfigMoveVertical4.joystick     = 3;
            axisConfigMoveHorizontal4.joystick   = 3;
            axisConfigRotateVertical4.joystick   = 3;
            axisConfigRotateHorizontal4.joystick = 3;
            axisConfigFire4.joystick             = 3;
            SetKey(axisConfigFire4, KeyCode.Joystick4Button5, true);
            fireButtonText.text  = "fire = " + GetKeyName("Fire", true);
            fireButtonText1.text = "fire = " + GetKeyName("Fire2", true);
            fireButtonText2.text = "fire = " + GetKeyName("Fire3", true);
            fireButtonText3.text = "fire = " + GetKeyName("Fire4", true);
        }
    }
Ejemplo n.º 31
0
		private static void SetupAxis(Axis axis, AxisConfiguration configuration)
		{
			SetupGrid(axis.MajorGrid, configuration.MajorGrid);
			SetupGrid(axis.MinorGrid, configuration.MinorGrid);

			axis.LabelStyle.Enabled = configuration.ShowLabels ?? false;

			if (axis.LabelStyle.Enabled)
			{
				axis.Enabled        = AxisEnabled.True;
				axis.Title          = configuration.AxisTitleName ?? String.Empty;
				axis.TitleAlignment = StringAlignment.Far;
			}
			else
			{
				axis.Enabled        = AxisEnabled.False;
			}
		}
Ejemplo n.º 32
0
 public MovementCalculator(AxisConfiguration axisConf, string axisName)
 {
     _axisConf = axisConf;
     _axisName = axisName;
 }
Ejemplo n.º 33
0
 private KeyCode PropertyToKeyCode(SerializedProperty key)
 {
     return(AxisConfiguration.StringToKey(key.enumNames[key.enumValueIndex]));
 }