private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { AxisDic an = (AxisDic)listBox1.SelectedItem; propertyGrid1.SelectedObject = an.axis; } }
private void FormAixs_Load(object sender, EventArgs e) { listBox1.Items.Clear(); for (int i = 0; i < _axisList.Count; i++)//Axis axis in _axisList) { AxisDic an = new AxisDic(); an.name = _axisList.Keys.ElementAt(i); an.axis = _axisList[an.name]; listBox1.Items.Add(an); } if (listBox1.Items.Count > 0) { listBox1.SelectedIndex = 0; } }
public static float GetAxis(string IName) { string InputName = IName; string InputNameMend; float ValueGap; float SustainAxisValue = 0; float AxisValue = 0; float Computation = 0; try { if (AxisDic.ContainsKey(InputName)) { SustainAxisValue = AxisDic[InputName]; } else { AxisDic[InputName] = 0; } if (InputName.EndsWith("+")) { InputNameMend = InputName.Substring(0, InputName.Length - 1); AxisValue = Input.GetAxis(InputNameMend); if (AxisValue > AxisDeadZone) { ValueGap = AxisValue - SustainAxisValue; if (-0.05f <= ValueGap && ValueGap <= 0.05f) { AxisValue = SustainAxisValue + (AxisValue - SustainAxisValue); } else if (0.05f < ValueGap) { AxisValue = SustainAxisValue + (0.01f * AxisSensitivity); } else if (ValueGap < -0.05f) { AxisValue = SustainAxisValue - (0.01f * AxisGravity); } } else { AxisValue = SustainAxisValue - (0.01f * AxisGravity); } AxisValue = Mathf.Clamp(AxisValue, 0, 1); } else if (InputName.EndsWith("-")) { InputNameMend = InputName.Substring(0, InputName.Length - 1); AxisValue = Input.GetAxis(InputNameMend); if (AxisValue < -AxisDeadZone) { AxisValue = Mathf.Abs(AxisValue); ValueGap = AxisValue - SustainAxisValue; if (-0.05f <= ValueGap && ValueGap <= 0.05f) { AxisValue = SustainAxisValue + (AxisValue - SustainAxisValue); } else if (0.05f < ValueGap) { AxisValue = SustainAxisValue + (0.01f * AxisSensitivity); } else if (ValueGap < -0.05f) { AxisValue = SustainAxisValue - (0.01f * AxisGravity); } } else { AxisValue = SustainAxisValue - (0.01f * AxisGravity); } AxisValue = Mathf.Clamp(AxisValue, 0, 1); } else if (InputName == "") { } else { KeyCode InputKeyCode = (KeyCode)System.Enum.Parse(typeof(KeyCode), InputName); if (Input.GetKey(InputKeyCode)) { AxisValue = SustainAxisValue + (0.01f * AxisSensitivity); if (AxisValue >= 1) { AxisValue = 1; } } else { AxisValue = SustainAxisValue - (0.01f * AxisGravity); if (AxisValue <= 0) { AxisValue = 0; } } } } catch (System.Exception e) { Debug.LogError(e); InputNameUnsuitable(); } Computation = AxisValue; AxisDic[InputName] = AxisValue; if (Computation > 0) { Computation = Computation + 0.07f;//0.07f is Margin of maxim Computation = Mathf.Clamp(Computation, 0, 1); } return(Computation); }