//Takes the current controller structure and amount of ready structure and cuts it done to only the useful elements to set up the players in the main game public void SetupInputControl(int _activePlayers, InputControl[] _allInput, bool[] _readyPlayers) { inputControllers = new InputControl[_activePlayers]; numOfPlayers = _activePlayers; players = new GameObject[numOfPlayers]; // hardcoding is the best thing ever scores = new int[MAX_PLAYERS]; timeTaken = new float[MAX_PLAYERS]; timesDied = new int[MAX_PLAYERS]; int counter = 0; //Counter which is used to place elements into the new XInputPlayers structure //For all players for (int i = 0; i < MAX_PLAYERS; ++i) { //If they are ready if(_readyPlayers[i]) { //If the player is controlling the dpad if((i % 2) == 0) { inputControllers[counter] = _allInput[(int)Mathf.Floor(i / 2)]; inputControllers[counter].isDpad = true; ++counter; } //if the player is controlling the buttons else { inputControllers[counter] = _allInput[(int)Mathf.Floor(i / 2)]; inputControllers[counter].isDpad = false; ++counter; } } } }
void Start () { input = GameObject.FindWithTag ("InputControl").GetComponent<InputControl> (); god = GameObject.FindWithTag ("GameController").GetComponent<God> (); intensityText = GameObject.Find("Intensity"); line = gameObject.GetComponent<LineRenderer> (); line.enabled = false; }
void Start () { input = GameObject.FindWithTag ("InputControl").GetComponent<InputControl> (); master = GameObject.Find ("LaserWheel").GetComponent<LaserWheel> (); player = GameObject.FindWithTag ("Player").GetComponent<PlayerControl> (); line = gameObject.GetComponent<LineRenderer> (); line.enabled = false; }
//========= CONSTRUCTORS ========= /** <summary> Constructs the default control. </summary> */ public Trigger() { this.button = new InputControl(); this.disabledState = DisableState.Enabled; this.pressure = 0.0; this.deadZone = 0.12; }
public static InputControl CreateControl(string name, Type t, object value) { InputControl res = new InputControl(); if( t.Name.StartsWith("Nullable") ) { t = Nullable.GetUnderlyingType(t); res.IsNullable = true; } if( !res.IsNullable && value == null ) value = Tools.GetDefault(t); if( t == typeof(string) ) { res.IsNullable = true; res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.String; } else if( IsInteger(t) ) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Int; } else if( IsDecimal(t) ) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Decimal; } else if( t.IsEnum ) { res.Control = new ComboBoxInputControl(t, value); res.DataType = DataType.Enum; } else if( t == typeof(bool) ) { res.Control = new CheckBoxInputControl(value); res.DataType = DataType.Bool; } else if( IsDateTime(t) ) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Date; } else if( IsGuid(t) ) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Guid; } else if( t.IsArray ) { res.Control = new ArrayInputControl(t, value, name); res.DataType = DataType.Array; res.IsNullable = true; } else if( t.IsClass ) { res.Control = new ComplexDataInputControl(name, t, value); res.DataType = DataType.Complex; res.IsNullable = true; } else MessageBox.Show("Unhandled type " + t.ToString()); return res; }
public void SetupPlayer(int _playerNumber, InputControl _inputControl) { playerNumber = _playerNumber; inputControl = _inputControl; #if !XINPUT_CONTROL inputControl.prevState = new bool[4]; #endif GetComponent<PlayerMovement> ().SetInputControl (inputControl); }
void Start () { input = GameObject.FindWithTag ("InputControl").GetComponent<InputControl> (); god = GameObject.FindWithTag("GameController").GetComponent<God>(); //playerShip playerShip = GameObject.FindGameObjectWithTag("PlayerShip"); //shield animationController = GetComponentInChildren<AnimationController>(); playerShield = GameObject.FindGameObjectWithTag("PlayerShield"); if (shieldPower > 0f) { ActivateShield(); } else { DissactivateShield(); } }
public override Vector2 Process(Vector2 value, InputControl control) { return(Mouse.current.rightButton.isPressed ? value : Vector2.zero); }
public override float Process(float value, InputControl <float> control) { return(value * factor); }
// Start is called before the first frame update void Start() { this.playerMove = GetComponent <PlayerMove>(); this.inputControl = GetComponent <InputControl>(); }
void refreshControls() { idevice = InputManager.ActiveDevice; ctrl_Jump = idevice.GetControl(InputControlType.Action1); ctrl_LeftStickX = idevice.GetControl(InputControlType.LeftStickX); ctrl_LeftStickY = idevice.GetControl(InputControlType.LeftStickY); ctrl_Select = idevice.GetControl(InputControlType.Select); ctrl_Start = idevice.GetControl(InputControlType.Start); ctrl_RightBumper = idevice.GetControl(InputControlType.RightBumper); ctrl_RightJoystickButton = idevice.GetControl(InputControlType.RightStickButton); ctrl_O = idevice.GetControl(InputControlType.Action2); }
void Start () { input = GameObject.FindWithTag ("InputControl").GetComponent<InputControl> (); line = gameObject.GetComponent<LineRenderer> (); line.enabled = false; }
/// <summary> /// Return <paramref name="value"/> scaled by <see cref="x"/> and <see cref="y"/>. /// </summary> /// <param name="value">Input value.</param> /// <param name="control">Ignored.</param> /// <returns>Scaled vector.</returns> public override Vector2 Process(Vector2 value, InputControl control) { return(new Vector2(value.x * x, value.y * y)); }
public override float Process(float value, InputControl control) { return(value * -1.0f); }
private void CheckController(InputControl trigger, InputControl bumper, InputControl stickButton, TwoAxisInputControl stick, int selectedNum, Ray controller) { if (trigger.IsPressed) { if (SelectedObject[selectedNum] == null) { Collider[] hits = Physics.OverlapSphere(controller.origin, 0.1f, 1 << BuiltLayer); ; if (hits.Length > 0) { Collider closest = hits.OrderBy(hit => Vector3.Distance(hit.transform.position, controller.origin)).First(); SelectedObject[selectedNum] = closest.transform; } else { SelectedObject[selectedNum] = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; SelectedObject[selectedNum].GetComponent<Renderer>().material.color = CurrentColors[selectedNum]; SelectedObject[selectedNum].gameObject.layer = BuiltLayer; StartCoroutine(PopIn(SelectedObject[selectedNum])); } } SelectedObject[selectedNum].position = controller.origin; } else SelectedObject[selectedNum] = null; if (stickButton.IsPressed) { if (ColorWheels[selectedNum] == null) { ColorWheels[selectedNum] = GameObject.Instantiate(ColorWheelPrefab).GetComponent<ColorWheel>(); } CurrentColors[selectedNum] = ColorWheels[selectedNum].Select(stick.Vector); if (SelectedObject[selectedNum] != null) SelectedObject[selectedNum].GetComponent<Renderer>().material.color = CurrentColors[selectedNum]; ColorWheels[selectedNum].transform.position = controller.origin; ColorWheels[selectedNum].transform.LookAt(KinectManager.Instance.CurrentAvatar.Head); } else { if (ColorWheels[selectedNum] != null) Destroy(ColorWheels[selectedNum].gameObject); } if (bumper.IsPressed) { if (GunAim[selectedNum] == null) { GunAim[selectedNum] = GameObject.Instantiate(AimPrefab).GetComponent<Aim>(); } GunAim[selectedNum].DoUpdate(controller.origin, controller.direction); } else { if (GunAim[selectedNum] != null) { Destroy(GunAim[selectedNum].gameObject); GameObject bullet = GameObject.Instantiate<GameObject>(BulletPrefab); bullet.GetComponent<Bullet>().Launch(controller); } } }
private IEnumerator PerformRebinding(int minKeys, int maxKeys, bool isAxisComposite = false) { rebinding = true; List <ButtonControl> allControls = new List <ButtonControl>(); foreach (InputDevice device in InputSystem.devices) { allControls.AddRange(device.allControls.Where(x => x is ButtonControl).Cast <ButtonControl>()); } overrideKeybindPaths.Clear(); int keys = 0; while (keys < maxKeys) { yield return(new WaitUntil(() => allControls.Find(x => x.wasPressedThisFrame) != null)); InputControl control = allControls.Find(x => x.wasPressedThisFrame && x != Keyboard.current.anyKey); if (control is null || control.path.ToUpper().Contains("POSITION")) { continue; } if (control.path == Keyboard.current.enterKey.path) { // Do not stop rebinding if we do not reach minimum keys // This prevents 1DAxis and 2DVector keybinds from breaking if (keys < minKeys) { continue; } break; } else { // Combine some common left/right keys into their generic counterparts if (control.path.ToUpper().Contains("SHIFT")) { control = Keyboard.current.shiftKey; } else if (control.path.ToUpper().Contains("CTRL")) { control = Keyboard.current.ctrlKey; } else if (control.path.ToUpper().Contains("ALT")) { control = Keyboard.current.altKey; } else if (control.path.ToUpper().Contains("PRESS")) { control = Mouse.current.leftButton; } Debug.Log($"Detected key {control.path}"); string name = PrettifyName(control.path.Split('/').Last()); if (keybindNameToInputField.ContainsKey(name)) { continue; } overrideKeybindPaths.Add(control.path); TMP_InputField field = keybindInputFields[keys]; field.gameObject.SetActive(true); field.text = name; keybindNameToInputField.Add(name, field); } keys++; } }
public void Set <TValue>(InputControl <TValue> control, TValue value, double timeOffset = 0) where TValue : struct { input.Set(control, value, timeOffset); }
void Start () { input = GameObject.FindWithTag ("InputControl").GetComponent<InputControl> (); player = GameObject.FindWithTag ("Player"); }
private ButtonBasedInputMapping(List <String> validButtons, List <String> validAxes, InputControl controls) : base(validButtons, validAxes, controls) { }
public static InputControl CreateControl(string name, Type t, object value) { InputControl res = new InputControl(); if (t.Name.StartsWith("Nullable")) { t = Nullable.GetUnderlyingType(t); res.IsNullable = true; } if (!res.IsNullable && value == null) { value = Tools.GetDefault(t); } if (t == typeof(string)) { res.IsNullable = true; res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.String; } else if (IsInteger(t)) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Int; } else if (IsDecimal(t)) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Decimal; } else if (t.IsEnum) { res.Control = new ComboBoxInputControl(t, value); res.DataType = DataType.Enum; } else if (t == typeof(bool)) { res.Control = new CheckBoxInputControl(value); res.DataType = DataType.Bool; } else if (IsDateTime(t)) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Date; } else if (IsGuid(t)) { res.Control = new TextInputControl(value, t, res.IsNullable); res.DataType = DataType.Guid; } else if (t.IsArray) { res.Control = new ArrayInputControl(t, value, name); res.DataType = DataType.Array; res.IsNullable = true; } else if (t.IsClass) { res.Control = new ComplexDataInputControl(name, t, value); res.DataType = DataType.Complex; res.IsNullable = true; } else { MessageBox.Show("Unhandled type " + t.ToString()); } return(res); }
public override Vector3 Process(Vector3 value, InputControl <Vector3> control) { return(value.normalized); }
/// <summary> /// Allows the screen to handle user input. Unlike Update, this method /// is only called when the screen is active, and not when some other /// screen has taken the focus. /// </summary> public virtual void HandleInput(InputControl input) { }
// Update is called once per frame void Update() { if (bubbleSolve == BubbleSolve.Keycodes && InputControl.GetAnyInput(keycode)) { StartCoroutine(CompleteAnimation()); } if (bubbleSolve == BubbleSolve.KeycodesCombo && InputControl.GetAnyInput(keycode) && InputControl.GetAnyInput(keycode2)) { StartCoroutine(CompleteAnimation()); } if (bubbleSolve == BubbleSolve.KeycodesTrio && InputControl.GetAnyInput(keycode) && InputControl.GetAnyInput(keycode2) && InputControl.GetAnyInput(keycode3)) { StartCoroutine(CompleteAnimation()); } }
void Start() { myTransform = transform; //define transforms for efficiency mainCamTransform = Camera.main.transform; //set up external script references InputComponent = playerObj.GetComponent <InputControl>(); FPSWalkerComponent = playerObj.GetComponent <FPSRigidBodyWalker>(); FPSPlayerComponent = playerObj.GetComponent <FPSPlayer>(); IronsightsComponent = playerObj.GetComponent <Ironsights>(); CameraControlComponent = mainCamTransform.GetComponent <CameraControl>(); CurrentWeaponBehaviorComponent = weaponOrder[firstWeapon].GetComponent <WeaponBehavior>(); WeaponBehavior BackupWeaponBehaviorComponent = weaponOrder[backupWeapon].GetComponent <WeaponBehavior>(); weaponBehaviors = myTransform.GetComponentsInChildren <WeaponBehavior>(true); aSources = transform.GetComponents <AudioSource>(); aSource = playerObj.AddComponent <AudioSource>(); aSource.spatialBlend = 0.0f; aSource.playOnAwake = false; //Create instance of GUIText to display ammo amount on hud. This will be accessed and updated by WeaponBehavior script. ammoGuiObjInstance = Instantiate(FPSPlayerComponent.ammoGuiObj, Vector3.zero, myTransform.rotation) as GameObject; //set the weapon order number in the WeaponBehavior scripts for (int i = 0; i < weaponOrder.Length; i++) { weaponOrder[i].GetComponent <WeaponBehavior>().weaponNumber = i; } currentGrenade = 0; GrenadeWeaponBehaviorComponent = grenadeOrder[currentGrenade].GetComponent <WeaponBehavior>(); grenadeWeapon = GrenadeWeaponBehaviorComponent.weaponNumber; //Select first weapon, if firstWeapon is not in inventory, player will spawn unarmed. if (weaponOrder[firstWeapon].GetComponent <WeaponBehavior>().haveWeapon) { StartCoroutine(SelectWeapon(firstWeapon)); } else { StartCoroutine(SelectWeapon(0)); } //set droppable value for backup weapon to false here if it was set to true in inspector //to prevent multiple instances of backup weapon from being dropped and not selecting next weapon BackupWeaponBehaviorComponent.droppable = false; //set addsToTotalWeaps value for backup weapon to false here if it was set to true in inspector //to prevent picking up a backup weapon from swapping current weapon BackupWeaponBehaviorComponent.addsToTotalWeaps = false; UpdateTotalWeapons(); //automatically assign sunlight object for weapon shading if (!sunLightObj) { Light[] lightList = FindObjectsOfType(typeof(Light)) as Light[]; for (int i = 0; i < lightList.Length; i++) { if (lightList[i].type == LightType.Directional && lightList[i].gameObject.activeInHierarchy) { sunLightObj = lightList[i].transform; break; } } } }
public void Controls_CanKeepListsOfControls_WithoutAllocatingGCMemory() { InputSystem.AddDevice <Mouse>(); // Noise. var gamepad = InputSystem.AddDevice <Gamepad>(); var keyboard = InputSystem.AddDevice <Keyboard>(); var list = new InputControlList <InputControl>(); try { Assert.That(list.Count, Is.Zero); Assert.That(list.ToArray(), Is.Empty); Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>()); list.Capacity = 10; list.Add(gamepad.leftStick); list.Add(null); // Permissible to add null entry. list.Add(keyboard.spaceKey); list.Add(keyboard); Assert.That(list.Count, Is.EqualTo(4)); Assert.That(list.Capacity, Is.EqualTo(6)); Assert.That(list[0], Is.SameAs(gamepad.leftStick)); Assert.That(list[1], Is.Null); Assert.That(list[2], Is.SameAs(keyboard.spaceKey)); Assert.That(list[3], Is.SameAs(keyboard)); Assert.That(() => list[4], Throws.TypeOf <ArgumentOutOfRangeException>()); Assert.That(list.ToArray(), Is.EquivalentTo(new InputControl[] { gamepad.leftStick, null, keyboard.spaceKey, keyboard })); Assert.That(list.Contains(gamepad.leftStick)); Assert.That(list.Contains(null)); Assert.That(list.Contains(keyboard.spaceKey)); Assert.That(list.Contains(keyboard)); list.RemoveAt(1); list.Remove(keyboard); Assert.That(list.Count, Is.EqualTo(2)); Assert.That(list.Capacity, Is.EqualTo(8)); Assert.That(list[0], Is.SameAs(gamepad.leftStick)); Assert.That(list[1], Is.SameAs(keyboard.spaceKey)); Assert.That(() => list[2], Throws.TypeOf <ArgumentOutOfRangeException>()); Assert.That(list.ToArray(), Is.EquivalentTo(new InputControl[] { gamepad.leftStick, keyboard.spaceKey })); Assert.That(list.Contains(gamepad.leftStick)); Assert.That(!list.Contains(null)); Assert.That(list.Contains(keyboard.spaceKey)); Assert.That(!list.Contains(keyboard)); list.AddRange(new InputControl[] { keyboard.aKey, keyboard.bKey }, count: 1, destinationIndex: 0); Assert.That(list.Count, Is.EqualTo(3)); Assert.That(list.Capacity, Is.EqualTo(7)); Assert.That(list, Is.EquivalentTo(new InputControl[] { keyboard.aKey, gamepad.leftStick, keyboard.spaceKey })); list.AddRange(new InputControl[] { keyboard.bKey, keyboard.cKey }); Assert.That(list.Count, Is.EqualTo(5)); Assert.That(list.Capacity, Is.EqualTo(5)); Assert.That(list, Is.EquivalentTo(new InputControl[] { keyboard.aKey, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey })); using (var toAdd = new InputControl[] { gamepad.buttonNorth, gamepad.buttonEast, gamepad.buttonWest }.ToControlList()) list.AddSlice(toAdd, count: 1, destinationIndex: 1, sourceIndex: 2); Assert.That(list.Count, Is.EqualTo(6)); Assert.That(list.Capacity, Is.EqualTo(4)); Assert.That(list, Is.EquivalentTo(new InputControl[] { keyboard.aKey, gamepad.buttonWest, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey })); list[0] = keyboard.zKey; Assert.That(list, Is.EquivalentTo(new InputControl[] { keyboard.zKey, gamepad.buttonWest, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey })); list.Clear(); Assert.That(list.Count, Is.Zero); Assert.That(list.Capacity, Is.EqualTo(10)); Assert.That(list.ToArray(), Is.Empty); Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>()); Assert.That(!list.Contains(gamepad.leftStick)); Assert.That(!list.Contains(null)); Assert.That(!list.Contains(keyboard.spaceKey)); Assert.That(!list.Contains(keyboard)); } finally { list.Dispose(); } }
//获取表单控件列表 private void GetOrderFormContent(string orderPage) { string frmContent, inputContent; Match tempMatch; MatchCollection matches = Regex.Matches(orderPage, "<form\\s+id\\s*=\\s*\"J_Form\"\\s+.*?>.*?<\\s*/\\s*form\\s*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (matches.Count > 0) { auctionLog.Log("通知:发现了订单页面中的表单"); frmContent = matches[0].ToString(); //读取获取newCheckCode的地址 tempMatch = Regex.Match(frmContent, "J_checkCodeUrl.*?value\\s*=\\s*\"(?<checkCodeUrl>.*?)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { checkCode.J_checkCodeUrl = tempMatch.Groups["checkCodeUrl"].ToString(); } matches = Regex.Matches(frmContent, "<\\s*(?<control>input|textarea|select).*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (matches.Count > 0) { auctionLog.Log("通知:发现了订单页面表单中的input控件"); foreach (Match match in matches) { InputControl inputControl = new InputControl(); inputContent = match.ToString(); tempMatch = Regex.Match(inputContent, "name\\s*=\\s*[\"\'](?<name>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { inputControl.Control = match.Groups["control"].ToString(); inputControl.Name = tempMatch.Groups["name"].ToString(); tempMatch = Regex.Match(inputContent, "value\\s*=\\s*[\"\'](?<value>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { inputControl.Value = tempMatch.Groups["value"].ToString(); } tempMatch = Regex.Match(inputContent, "type\\s*=\\s*[\"\'](?<type>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { inputControl.Type = tempMatch.Groups["type"].ToString(); } inputControls.Add(inputControl); //读取获取newCheckCode所需的信息 if (inputControl.Name.Trim().ToLower() == "ischeckcode" && inputControl.Value.Trim().ToLower() == "true") { checkCode.isCheckCode = "true"; } if (inputControl.Name.Trim().ToLower() == "encrypterstring") { checkCode.encrypterString = inputControl.Value; } if (inputControl.Name.Trim().ToLower() == "sid") { checkCode.sid = inputControl.Value; } if (inputControl.Name.Trim().ToLower() == "gmtcreate") { checkCode.gmtCreate = inputControl.Value; } if (inputControl.Name.Trim().ToLower() == "checkcodeids") { checkCode.checkCodeIds = inputControl.Value; } } } } } }
private ControlItem BuildControlTreeRecursive(InputControl control, int depth, ref int id) { // Build children. List <TreeViewItem> children = null; var isLeaf = control.children.Count == 0; if (!isLeaf) { children = new List <TreeViewItem>(); foreach (var child in control.children) { var childItem = BuildControlTreeRecursive(child, depth + 1, ref id); if (childItem != null) { children.Add(childItem); } } // If none of our children returned an item, none of their data is different, // so if we are supposed to show only controls that differ in value, we're sitting // on a branch that has no changes. Cull the branch except if we're all the way // at the root (we want to have at least one item). if (children.Count == 0 && showDifferentOnly && depth != 0) { return(null); } // Sort children by name. children.Sort((a, b) => string.Compare(a.displayName, b.displayName)); } // Compute offset. Offsets on the controls are absolute. Make them relative to the // root control. var controlOffset = control.stateBlock.byteOffset; var rootOffset = m_RootControl.stateBlock.byteOffset; var offset = controlOffset - rootOffset; // Read state. GUIContent value; GUIContent[] values; if (!ReadState(control, out value, out values)) { return(null); } ////TODO: come up with nice icons depicting different control types var item = new ControlItem { id = id++, displayName = control.name, control = control, depth = depth, layout = new GUIContent(control.layout), format = new GUIContent(control.stateBlock.format.ToString()), offset = new GUIContent(offset.ToString()), bit = new GUIContent(control.stateBlock.bitOffset.ToString()), sizeInBits = new GUIContent(control.stateBlock.sizeInBits.ToString()), type = new GUIContent(control.GetType().Name), value = value, values = values, children = children }; if (children != null) { foreach (var child in children) { child.parent = item; } } return(item); }
public override void HandleInput(InputControl input, bool inFocus) { if (!Locked && inFocus) { Texture2D texture = Source; if (!isItemInUse) { if (input.MouseX() > Position.X && input.MouseX() < (Position.X + texture.Width) && input.MouseY() > Position.Y && input.MouseY() < (Position.Y + texture.Height)) { if (input.MouseReleased(1)) { isItemInUse = true; } } } else { if (input.MouseX() > Position.X && input.MouseX() < (Position.X + texture.Width) && input.MouseY() > Position.Y && input.MouseY() < (Position.Y + texture.Height)) { if (input.MouseReleased(1)) { isItemInUse = false; } } for (int i = 0; i < values.Count(); i++) { if (input.MouseX() > Position.X && input.MouseX() < (Position.X + texture.Width) && input.MouseY() > Position.Y + (texture.Height * (i + 1)) && input.MouseY() < (Position.Y + texture.Height + (texture.Height * (i + 1)))) { if (input.MouseReleased(1)) { isItemInUse = false; current = i; } } } } } }
public OutputData(float sst, GNGTrialTypes st, float rst, InputAction ra, int tn, InputControl c) { stimStartTime = sst; stimType = st; respStartTime = rst; respAction = ra; trialNumber = tn; control = c; }
public float Process(float value, InputControl control) { return(Mathf.Clamp(value, min, max)); }
/// <summary> /// @Author Troy, Edited by Steven /// </summary> /// <param name="mainScreen"></param> private void CreateMenuControls(Screen mainScreen) { //TODO: Change Label Colors to white //Account Name Label LabelControl accountNameLabel = GuiHelper.CreateLabel("Account Name", UIConstants.LOGIN_ACCOUNT_LABEL.X, UIConstants.LOGIN_ACCOUNT_LABEL.Y, UIConstants.LOGIN_ACCOUNT_LABEL.Width, UIConstants.LOGIN_ACCOUNT_LABEL.Height); mainScreen.Desktop.Children.Add(accountNameLabel); //Error Text Label errorText = new LabelControl(); errorText.Bounds = new UniRectangle(275.0f, 300.0f, 110.0f, 25.0f); mainScreen.Desktop.Children.Add(errorText); //Account Name Input accountNameInput = GuiHelper.CreateInput("", UIConstants.LOGIN_ACCOUNT_INPUT.X, UIConstants.LOGIN_ACCOUNT_INPUT.Y, UIConstants.LOGIN_ACCOUNT_INPUT.Width, UIConstants.LOGIN_ACCOUNT_INPUT.Height); mainScreen.Desktop.Children.Add(accountNameInput); //Password Label passwordLabel = GuiHelper.CreateLabel("Password", UIConstants.LOGIN_PASSWORD_LABEL.X, UIConstants.LOGIN_PASSWORD_LABEL.Y, UIConstants.LOGIN_ACCOUNT_LABEL.Width, UIConstants.LOGIN_PASSWORD_LABEL.Height); mainScreen.Desktop.Children.Add(passwordLabel); //TODO: Create Password field where characters show up as black circles //Password Input passwordInput = GuiHelper.CreatePasswordInput(UIConstants.LOGIN_PASSWORD_INPUT.X, UIConstants.LOGIN_PASSWORD_INPUT.Y, UIConstants.LOGIN_PASSWORD_INPUT.Width, UIConstants.LOGIN_PASSWORD_INPUT.Height); mainScreen.Desktop.Children.Add(passwordInput); //TODO: Change to a contrasting color (Yellow) //Login Button. ButtonControl loginButton = GuiHelper.CreateButton("Login", UIConstants.LOGIN_BUTTON.X, UIConstants.LOGIN_BUTTON.Y, UIConstants.LOGIN_BUTTON.Width, UIConstants.LOGIN_BUTTON.Height); loginButton.Pressed += delegate(object sender, EventArgs arguments) { errorText.Text = ""; errors = false; if (accountNameInput.Text == "") { errorText.Text += "Username field cannot be empty!\n"; errors = true; } if (passwordInput.Text == "") { errorText.Text += "Password field cannot be empty!"; errors = true; } if (errors) { return; } /* * game.Player.Username = accountNameInput.Text; * game.Player.Password = passwordInput.GetText(); * * game.Communication.sendLoginRequest(game.Player); * Thread.Sleep(2000); * game.Player = game.Communication.getPlayer(); * Console.WriteLine(game.Player.Username); * if (game.Player != null)*/ game.EnterMainMenu(); }; mainScreen.Desktop.Children.Add(loginButton); //Debug Button. ButtonControl multiplayerButton = GuiHelper.CreateButton("Debug Game", -300, -300, 200, 50); multiplayerButton.Pressed += delegate(object sender, EventArgs arguments) { game.StartGame(); }; mainScreen.Desktop.Children.Add(multiplayerButton); //Ship Select Button. ButtonControl shipSelectButton = GuiHelper.CreateButton("Select Ship", -300, -225, 200, 50); shipSelectButton.Pressed += delegate(object sender, EventArgs arguments) { game.EnterShipSelectionScreen(); }; mainScreen.Desktop.Children.Add(shipSelectButton); //Button to close game. ButtonControl quitButton = GuiHelper.CreateButton("Quit", UIConstants.LOGIN_QUIT.X, UIConstants.LOGIN_QUIT.Y, UIConstants.LOGIN_QUIT.Width, UIConstants.LOGIN_QUIT.Height); quitButton.Pressed += delegate(object sender, EventArgs arguments) { game.Exit(); }; mainScreen.Desktop.Children.Add(quitButton); }
protected CharacterState(InputControl inputControl, GameObject gameObject) { this.inputControl = inputControl; this.gameObject = gameObject; }
private string GetControlHelp(InputControl control) { return(string.Format("Use {0} to {1}!", control.GetPrimarySourceName(), control.name)); }
/// <summary> /// Handles the input provided by the ScreenManager's InputControl. You should not need to override this - use the specialized input methods instead! /// </summary> /// <param name="input">The InputControl object passed in from the ScreenManager.</param> public override void HandleInput(InputControl input) { base.HandleInput(input); //store mouse pos Point mousePos = input.CurrentMouse; //check for a widget at mouse point Widget widgetAtPoint = baseWidget.ChildAtPoint(mousePos, HitFlags.Mouse); //handle mouse movement bool cascade = true; if (input.MouseMoved()) { //check for mouse enter/leave events if (widgetAtPoint != mouseHoverWidget) { if (mouseHoverWidget != null) cascade = !mouseHoverWidget.MouseLeave(mousePos); mouseHoverWidget = widgetAtPoint; if (mouseHoverWidget != null) cascade &= !mouseHoverWidget.MouseEnter(mousePos); } if (cascade) MouseMove(mousePos,input.PreviousMouse); } //handle mouse clicks for (int i = 1; i <= 5; i++) { ButtonState current; if (input.MouseChanged(i,out current)) { cascade = true; if (current == ButtonState.Pressed) { mouseDownWidgets[i-1] = widgetAtPoint; if (widgetAtPoint != null) cascade = !widgetAtPoint.MouseDown(mousePos, i); if (cascade) MouseDown(mousePos, i); } else { if (mouseDownWidgets[i-1] != null) cascade = !mouseDownWidgets[i - 1].MouseUp(mousePos, i); mouseDownWidgets[i-1] = null; if (cascade) MouseUp(mousePos, i); } } } //check keyboard events for (int i = 0; i < watchedKeys.Length; i++) { if (input.KeyReleased(watchedKeys[i])) { cascade = true; if (selectedWidget != null) cascade = !selectedWidget.KeyUp(watchedKeys[i]); if (cascade) KeyUp(watchedKeys[i]); } if (input.KeyPressed(watchedKeys[i])) { cascade = true; if (selectedWidget != null) cascade = !selectedWidget.KeyDown(watchedKeys[i]); if (cascade) KeyDown(watchedKeys[i]); } } }
void LateUpdate() { // Early out if we don't have a target if (!target) { return; } // Update input and get the last active device InputManager.Update(); var inputDevice = InputManager.ActiveDevice; // Only check for input if mouseRotate is true if (mouseRotate) { // Determine which stick to check for input InputControl currentStick = (analogStick == ASticks.Left) ? inputDevice.LeftStickX : inputDevice.RightStickX; // Check for mouse input first if (Input.GetMouseButton((int)mouseButton)) { // Update last cam rotation to stop auto-centering of camera lastCamRotation = Time.time; // Rotate around target based on mouse movement times the multiplier transform.RotateAround(target.position, Vector3.up, Input.GetAxis("Mouse X") * rotationMultiplier * Time.deltaTime); } // If no mouse input detected, check for analog stick input else if ((currentStick.Value != 0 || inputDevice.Analogs[(int)analogStick].Value != 0) && !Input.anyKey) { // Get movement from the active source (Officially supported controller or not supported) float movement = (currentStick.Value != 0) ? -currentStick.Value : -inputDevice.Analogs[(int)analogStick].Value; // Update last cam rotation to stop auto-centering of camera lastCamRotation = Time.time; // Rotate around target based on analog movement times the multiplier transform.RotateAround(target.position, Vector3.up, movement * rotationMultiplier * Time.deltaTime); } else if (Input.GetKey(resetKey) || inputDevice.GetControl(resetButton)) { lastCamRotation = -10.0f; } } // Calculate the current rotation angles (If cam was rotated by mouse within waitTime, keep position) float wantedRotationAngle = (Time.time > lastCamRotation + rotationWaitTime) ? target.eulerAngles.y : transform.eulerAngles.y; float wantedHeight = target.position.y + height; float currentRotationAngle = transform.eulerAngles.y; float currentHeight = transform.position.y; if (camLean) { // calculate the squared length of the vector from the camera to the target float wantedCamDistanceSquared = (wantedHeight - cameraTilt); wantedCamDistanceSquared *= wantedCamDistanceSquared; wantedCamDistanceSquared = wantedCamDistanceSquared + distance * distance; if (Physics.CheckSphere(transform.position, camCollideRadius)) { // move toward zero distance on x-y from target currentDistance = Mathf.Lerp(currentDistance, 0, leanDamping * Time.deltaTime); } else { // move toward user defined distance on x-y from target currentDistance = Mathf.Lerp(currentDistance, distance, leanDamping * Time.deltaTime); } // calculate the required height to retain the retain the same camera distance [b = sqrt(h^2 - a^2)] wantedHeight = Mathf.Sqrt(wantedCamDistanceSquared - currentDistance * currentDistance) + cameraTilt; } // Set the position of the camera on the x-z plane to: // distance meters behind the target transform.position = target.position; if (currentDistance > 0) { // Damp the rotation around the y-axis currentRotationAngle = Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime); // Convert the angle into a rotation Quaternion currentRotation = Quaternion.Euler(0f, currentRotationAngle, 0f); // rotate vector from target by angle transform.position -= currentRotation * Vector3.forward * currentDistance; } // Damp the height currentHeight = Mathf.Lerp(currentHeight, wantedHeight, heightDamping * Time.deltaTime); // Set the height of the camera transform.position = new Vector3(transform.position.x, currentHeight, transform.position.z); // Always look a bit (value of cameraTilt) over the target. Vector3 lookAtPt = new Vector3(target.position.x, target.position.y + cameraTilt, target.position.z); transform.LookAt(lookAtPt); if (camZoom) { Ray[] frustumRays = new Ray[4]; frustumRays[0] = transform.camera.ScreenPointToRay(new Vector3(0, 0, 0)); frustumRays[1] = transform.camera.ScreenPointToRay(new Vector3(transform.camera.pixelWidth, 0, 0)); frustumRays[2] = transform.camera.ScreenPointToRay(new Vector3(0, transform.camera.pixelHeight, 0)); frustumRays[3] = transform.camera.ScreenPointToRay(new Vector3(transform.camera.pixelWidth, transform.camera.pixelHeight, 0)); transform.position = HandleCollisionZoom(transform.position, lookAtPt, minDistance, ref frustumRays); } }
/// <summary> /// Allows the screen to handle user input. Unlike Update, this method /// is only called when the screen is active, and not when some other /// screen has taken the focus. /// </summary> public override void HandleInput(InputControl input) { for (int i = 0; i < menuItems.Count(); i++) menuItems[i].HandleInput(input, selectedMenuItem == null || selectedMenuItem == menuItems[i]); }
private void Awake() { _self = this; }
//获取表单控件列表 private void GetOrderFormContent(string orderPage) { string frmContent, inputContent; Match tempMatch; bool addressInfoGeted = false; MatchCollection matches = Regex.Matches(orderPage, "<form\\s+name\\s*=\\s*\"mainform\"\\s+.*?>.*?<\\s*/\\s*form\\s*>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (matches.Count > 0) { auctionLog.Log("通知:发现了订单页面中的表单"); frmContent = matches[0].ToString(); matches = Regex.Matches(frmContent, "<\\s*(?<control>input|select|textarea).*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (matches.Count > 0) { auctionLog.Log("通知:发现了订单页面表单中的input控件"); foreach (Match match in matches) { InputControl inputControl = new InputControl(); inputContent = match.ToString(); tempMatch = Regex.Match(inputContent, "name\\s*=\\s*[\"\'](?<name>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { inputControl.Control = match.Groups["control"].ToString(); inputControl.Name = tempMatch.Groups["name"].ToString(); //读取收货地址信息 if (!addressInfoGeted && inputControl.Control.ToLower() == "input" && inputControl.Name.ToLower() == "address") { tempMatch = Regex.Match(inputContent, "ah:params\\s*=\\s*[\"\'](?<params>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressParams = tempMatch.Groups["params"].ToString(); tempMatch = Regex.Match(addressParams, "id\\s*=\\s*(?<id>\\d+)\\s*\\^\\^", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.Id = tempMatch.Groups["id"].ToString(); tempMatch = Regex.Match(addressParams, "address\\s*=\\s*(?<address>.*?)\\s*\\^\\^", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.Address = tempMatch.Groups["address"].ToString(); tempMatch = Regex.Match(addressParams, "postCode\\s*=\\s*(?<postCode>\\d+)\\s*\\^\\^", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.Postcode = tempMatch.Groups["postCode"].ToString(); tempMatch = Regex.Match(addressParams, "addressee\\s*=\\s*(?<addressee>.*?)\\s*\\^\\^", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.Addressee = tempMatch.Groups["addressee"].ToString(); tempMatch = Regex.Match(addressParams, "phone\\s*=\\s*(?<phone>.*?)\\s*\\^\\^", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.Phone = tempMatch.Groups["phone"].ToString(); tempMatch = Regex.Match(addressParams, "mobile\\s*=\\s*(?<mobile>\\d+)\\s*\\^\\^", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.Mobile = tempMatch.Groups["mobile"].ToString(); tempMatch = Regex.Match(addressParams, "areaCode\\s*=\\s*(?<areaCode>\\d+)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); addressInformation.AreaCode = tempMatch.Groups["areaCode"].ToString(); addressInfoGeted = true; } tempMatch = Regex.Match(inputContent, "value\\s*=\\s*[\"\'](?<value>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { inputControl.Value = tempMatch.Groups["value"].ToString(); } tempMatch = Regex.Match(inputContent, "type\\s*=\\s*[\"\'](?<type>.*?)[\"\']", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); if (tempMatch.Success) { inputControl.Type = tempMatch.Groups["type"].ToString(); } //读取验证码信息 if (inputControl.Name.Trim().ToLower() == "ischeckcode" && inputControl.Value.Trim().ToLower() == "true") { isCheckCode = true; } if (inputControl.Name.Trim().ToLower() == "encryptstring") { encryptString = inputControl.Value; } inputControls.Add(inputControl); } } } } }
public WaitForPressThunk(InputControl control) { Subscription = control.AddListener(EventHandler); }
public new Vector3 Process(Vector3 vector, InputControl control) { return(base.Process(vector * kAccelerationMultiplier, control)); }
public float Process(float value, InputControl control) { return(curve.Evaluate(value)); }
public void SetPlayer(string playerTyp) { controls = new InputControl(this.gameObject, playerTyp); }
public override float Process(float value, InputControl <float> control) { throw new NotImplementedException(); }
public bool EventHandler(InputControl c, InputEvent e) { if (e.Type == InputEventType.Press) { Subscription.Dispose(); Future.SetResult(NoneType.None, null); } return true; }
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToInputEventForAction"/> public void WriteToInputEventForAction(InputEventPtr eventPtr, InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
public override void HandleInput(InputControl input, bool inFocus) { if (inFocus) { downPrevious = down; down = false; Texture2D texture = Source; if (texture != null) { int offset = (int)GetAlignment(texture).X; if (input.MouseX() > Position.X-offset && input.MouseX() < (Position.X-offset + texture.Width) && input.MouseY() > Position.Y && input.MouseY() < (Position.Y + texture.Height)) { down = input.MouseHold(1); if (downPrevious == true && down == false) { if (Selected != null) { Selected(this, new EventArgs()); } } // Check to see button is just being clicked and play a sound if (down == true && downPrevious == false) { if (clickSound != null) { clickSound.Play(); } } } } else { int mw = (int)font.MeasureString(text).X; int mh = (int)font.MeasureString(text).Y; int mx = (int)Position.X; switch (align) { case Alignment.Center: { mx -= mw / 2; } break; case Alignment.Right: { mx -= mw; } break; } int my = (int)Position.Y; if (input.MouseX() > mx && input.MouseX() < mx + mw && input.MouseY() > my && input.MouseY() < my + mh) { down = input.MouseHold(1); if (downPrevious == true && down == false) { if (Selected != null) { Selected(this, new EventArgs()); } } // Check to see button is just being clicked and play a sound if (down == true && downPrevious == false) if (clickSound != null) clickSound.Play(); } } } }
/// <summary> /// Updates PWM values from the given <see cref="UnityPacket.OutputStatePacket.DIOModule"/>s, and control index. /// </summary> /// <param name="dioModules"></param> /// <param name="controlIndex"></param> /// <param name="mecanum"></param> /// <returns></returns> public static float[] GetPwmValues(UnityPacket.OutputStatePacket.DIOModule[] dioModules, int controlIndex, bool mecanum) { bool IsMecanum = mecanum; float[] pwm; float[] can; if (dioModules[0] != null) { pwm = dioModules[0].pwmValues; can = dioModules[0].canValues; } else { pwm = new float[10]; can = new float[10]; } if (IsMecanum) { #region Mecanum Drive pwm[(int)MecanumPorts.FrontRight] += (InputControl.GetAxis(Controls.axes[controlIndex].vertical) * -SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].horizontal) * -SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].pwm2Axes) * -SpeedArrowPwm); pwm[(int)MecanumPorts.FrontLeft] += (InputControl.GetAxis(Controls.axes[controlIndex].vertical) * SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].horizontal) * SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].pwm2Axes) * -SpeedArrowPwm); //For some reason, giving the back wheels 0.25 power instead of 0.5 works for strafing pwm[(int)MecanumPorts.BackRight] += (InputControl.GetAxis(Controls.axes[controlIndex].vertical) * -SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].horizontal) * -SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].pwm2Axes) * 0.25f); pwm[(int)MecanumPorts.BackLeft] += (InputControl.GetAxis(Controls.axes[controlIndex].vertical) * SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].horizontal) * SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].pwm2Axes) * 0.25f); pwm[4] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm4Axes) * SpeedArrowPwm); pwm[5] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm5Axes) * SpeedArrowPwm); pwm[6] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm6Axes) * SpeedArrowPwm); pwm[7] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm7Axes) * SpeedArrowPwm); pwm[8] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm8Axes) * SpeedArrowPwm); pwm[9] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm9Axes) * SpeedArrowPwm); #endregion } if (Controls.TankDriveEnabled) { #region Tank Drive //pwm[0] += // (InputControl.GetButton(Controls.buttons[controlIndex].tankFrontLeft) ? SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].tankBackLeft) ? -SPEED_ARROW_PWM : 0.0f); //pwm[1] += // (InputControl.GetButton(Controls.buttons[controlIndex].tankFrontRight) ? -SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].tankBackRight) ? SPEED_ARROW_PWM : 0.0f); pwm[0] += (InputControl.GetAxis(Controls.axes[controlIndex].tankRightAxes) * SpeedArrowPwm); pwm[1] += (InputControl.GetAxis(Controls.axes[controlIndex].tankLeftAxes) * SpeedArrowPwm); pwm[2] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm2Axes) * SpeedArrowPwm); pwm[3] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm3Axes) * SpeedArrowPwm); pwm[4] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm4Axes) * SpeedArrowPwm); pwm[5] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm5Axes) * SpeedArrowPwm); pwm[6] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm6Axes) * SpeedArrowPwm); pwm[7] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm7Axes) * SpeedArrowPwm); pwm[8] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm8Axes) * SpeedArrowPwm); pwm[9] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm9Axes) * SpeedArrowPwm); #endregion } else { #region Arcade Drive //pwm[0] += // (InputControl.GetButton(Controls.buttons[controlIndex].forward) ? SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].backward) ? -SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].left) ? -SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].right) ? SPEED_ARROW_PWM : 0.0f); //pwm[1] += // (InputControl.GetButton(Controls.buttons[controlIndex].forward) ? -SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].backward) ? SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].left) ? -SPEED_ARROW_PWM : 0.0f) + // (InputControl.GetButton(Controls.buttons[controlIndex].right) ? SPEED_ARROW_PWM : 0.0f); pwm[0] += (InputControl.GetAxis(Controls.axes[controlIndex].vertical) * -SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].horizontal) * SpeedArrowPwm); pwm[1] += (InputControl.GetAxis(Controls.axes[controlIndex].vertical) * SpeedArrowPwm) + (InputControl.GetAxis(Controls.axes[controlIndex].horizontal) * SpeedArrowPwm); pwm[2] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm2Axes) * SpeedArrowPwm); pwm[3] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm3Axes) * SpeedArrowPwm); pwm[4] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm4Axes) * SpeedArrowPwm); pwm[5] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm5Axes) * SpeedArrowPwm); pwm[6] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm6Axes) * SpeedArrowPwm); pwm[7] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm7Axes) * SpeedArrowPwm); pwm[8] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm8Axes) * SpeedArrowPwm); pwm[9] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm9Axes) * SpeedArrowPwm); #endregion } return(pwm); }
public override void HandleInput(InputControl input, bool inFocus) { if (inFocus) { if (input.MousePressed(1)) { if (input.MouseX() > Position.X && input.MouseX() < (Position.X + width) && input.MouseY() > Position.Y && input.MouseY() < (Position.Y + height)) { isSelected = true; } else { isSelected = false; } } if (isSelected) { foreach (Keys key in keysToCheck) { if (input.KeyPressed(key) && (OnKeyPressed == null || !OnKeyPressed(this, key))) { switch (key) { case (Keys.Back): if (textValue.Length > 0 && index > 0) { textValue = textValue.Remove(index - 1, 1); index--; } break; case (Keys.Enter): if(Submitted != null) Submitted(this); index = 0; break; case (Keys.Space): textValue += " "; break; case (Keys.Left): if (index > 0) index--; break; case (Keys.Right): if (index < textValue.Count()) index++; break; default: string charToAdd = key.ToString(); if (!input.KeyDown(Keys.RightShift) && !input.KeyDown(Keys.LeftShift)) { charToAdd = charToAdd.ToLower(); } if (textValue.Length < this.max) { textValue += charToAdd; index++; } break; } } } } } }
/// <summary> /// Updates the motors on the manipulator in mix and match mode. Called every frame. /// </summary> /// <param name="skeleton"></param> /// <param name="dioModules"></param> /// <param name="controlIndex"></param> public static void UpdateManipulatorMotors(RigidNode_Base skeleton, UnityPacket.OutputStatePacket.DIOModule[] dioModules, int controlIndex) { float[] pwm; float[] can; if (dioModules[0] != null) { pwm = dioModules[0].pwmValues; can = dioModules[0].canValues; } else { pwm = new float[10]; can = new float[10]; } pwm[4] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm4Axes) * SpeedArrowPwm); pwm[5] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm5Axes) * SpeedArrowPwm); pwm[6] += (InputControl.GetAxis(Controls.axes[controlIndex].pwm6Axes) * SpeedArrowPwm); listOfSubNodes.Clear(); skeleton.ListAllNodes(listOfSubNodes); for (int i = 0; i < pwm.Length; i++) { foreach (RigidNode_Base node in listOfSubNodes) { RigidNode rigidNode = (RigidNode)node; BRaycastWheel raycastWheel = rigidNode.MainObject.GetComponent <BRaycastWheel>(); if (raycastWheel != null) { if (rigidNode.GetSkeletalJoint().cDriver.port1 == i + 1) { float force = pwm[i]; if (rigidNode.GetSkeletalJoint().cDriver.InputGear != 0 && rigidNode.GetSkeletalJoint().cDriver.OutputGear != 0) { force *= Convert.ToSingle(rigidNode.GetSkeletalJoint().cDriver.InputGear / rigidNode.GetSkeletalJoint().cDriver.OutputGear); } raycastWheel.ApplyForce(force); } } if (rigidNode.GetSkeletalJoint() != null && rigidNode.GetSkeletalJoint().cDriver != null) { if (rigidNode.GetSkeletalJoint().cDriver.GetDriveType().IsMotor() && rigidNode.MainObject.GetComponent <BHingedConstraint>() != null) { if (rigidNode.GetSkeletalJoint().cDriver.port1 == i + 1) { float maxSpeed = 0f; float impulse = 0f; float friction = 0f; if (rigidNode.GetSkeletalJoint().cDriver.InputGear != 0 && rigidNode.GetSkeletalJoint().cDriver.OutputGear != 0) { impulse *= Convert.ToSingle(rigidNode.GetSkeletalJoint().cDriver.InputGear / rigidNode.GetSkeletalJoint().cDriver.OutputGear); } if (rigidNode.HasDriverMeta <WheelDriverMeta>()) { maxSpeed = WheelMaxSpeed; impulse = WheelMotorImpulse; friction = WheelCoastFriction; } else { maxSpeed = HingeMaxSpeed; impulse = HingeMotorImpulse; friction = HingeCostFriction; } BHingedConstraint hingedConstraint = rigidNode.MainObject.GetComponent <BHingedConstraint>(); hingedConstraint.enableMotor = true; hingedConstraint.targetMotorAngularVelocity = pwm[i] > 0f ? maxSpeed : pwm[i] < 0f ? -maxSpeed : 0f; hingedConstraint.maxMotorImpulse = rigidNode.GetSkeletalJoint().cDriver.hasBrake ? HingeMotorImpulse : pwm[i] == 0f ? friction : Mathf.Abs(pwm[i] * impulse); } } else if (rigidNode.GetSkeletalJoint().cDriver.GetDriveType().IsElevator()) { if (rigidNode.GetSkeletalJoint().cDriver.port1 == i + 1 && rigidNode.HasDriverMeta <ElevatorDriverMeta>()) { BSliderConstraint bSliderConstraint = rigidNode.MainObject.GetComponent <BSliderConstraint>(); SliderConstraint sc = (SliderConstraint)bSliderConstraint.GetConstraint(); sc.PoweredLinearMotor = true; sc.MaxLinearMotorForce = MaxSliderForce; sc.TargetLinearMotorVelocity = pwm[i] * MaxSliderSpeed; } } } } } }
// Update is called once per frame void Update() { InputControl.Update(); switch (currentState) { case State.PREGAME: break; case State.INTRO: if (lineTimer > 0.0f) { lineTimer -= Time.deltaTime; if (lineTimer <= 0.0f) { dialog.currentLine++; if (dialog.IntroDone()) { StartGame(); } else { lineTimer = lineDelay; HLG_UI.instance.ShowPlayerTextBubble(dialog.GetCurrentIntroLine()); } } } break; case State.PLAYING: if (lineTimer > 0.0f) { lineTimer -= Time.deltaTime; if (lineTimer <= 0.0f) { dialog.currentLine++; if (dialog.ConversationDone()) { //TODO: figure out what to do here. HLG_UI.instance.HideFollowerTextBubble(); } else { lineTimer = lineDelay; if (dialog.currentLine % 2 == 0) { HLG_UI.instance.ShowFollowerTextBubble(dialog.GetCurrentFollowerLine()); HLG_UI.instance.HidePlayerTextBubble(); //If it's the last line, end the awkward if (dialog.currentLine == dialog.followerConversations [dialog.currentConversation].lines.Length - 1) { follower.StopFollowing(); awkwardLevel = 1.0f; HLG_UI.instance.SetAwkwardMeterFill(0.0f); HLG_UI.instance.UpdateAwkwardMultiLabel(awkwardLevel); DOTween.Kill(HLG_UI.instance.awkwardMeter.transform); } else { currentAwkwardStep++; UpdateAwkwardLevel(); } } else { HLG_UI.instance.ShowPlayerTextBubble(dialog.GetCurrentFollowerLine()); HLG_UI.instance.HideFollowerTextBubble(); } } } } break; case State.GRENADE: if (scoreTimer > 0.0f) { scoreTimer -= Time.deltaTime; if (scoreTimer <= 0.0f) { EndGame(); } } break; case State.ENDGAME: break; } }
private static string MakeControlVariableName(InputControl control) { return("ctrl" + CSharpCodeHelpers.MakeIdentifier(control.path)); }
public void SetInputControl(InputControl _inputControl) { inputControl = _inputControl; }
private static void EmitControlGetterInitializers(this InputActionCodeGenerator.Writer writer, InputControl control, string controlVariableName, Dictionary <Type, List <PropertyInfo> > controlGetterPropertyTable) { var type = control.GetType(); if (!controlGetterPropertyTable.TryGetValue(type, out var controlGetterProperties)) { controlGetterProperties = GetControlGetterProperties(type); controlGetterPropertyTable[type] = controlGetterProperties; } foreach (var property in controlGetterProperties) { var value = (InputControl)property.GetValue(control); if (value == null) { continue; } writer.WriteLine($"{controlVariableName}.{property.Name} = {MakeControlVariableName(value)};"); } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public MultiGameButton(params GameButton[] hotKeys) { this.hotKeys = hotKeys; this.inputControl = new InputControl(); }
private static void EmitControlArrayInitializers(this InputActionCodeGenerator.Writer writer, InputControl control, string controlVariableName, Dictionary <Type, List <PropertyInfo> > controlArrayPropertyTable) { var type = control.GetType(); if (!controlArrayPropertyTable.TryGetValue(type, out var controlArrayProperties)) { controlArrayProperties = GetControlArrayProperties(type); controlArrayPropertyTable[type] = controlArrayProperties; } foreach (var property in controlArrayProperties) { var array = (Array)property.GetValue(control); if (array == null) { continue; } var arrayLength = array.Length; var arrayElementType = array.GetType().GetElementType(); writer.WriteLine($"{controlVariableName}.{property.Name} = new {arrayElementType.FullName.Replace('+','.')}[{arrayLength}];"); for (var i = 0; i < arrayLength; ++i) { var value = (InputControl)array.GetValue(i); if (value == null) { continue; } writer.WriteLine($"{controlVariableName}.{property.Name}[{i}] = {MakeControlVariableName(value)};"); } } }
/// <summary> /// Handles any input needed by the menu item from the user and lets the menu item know if it is in focus. (only needs to be called if the screen is active) /// </summary> /// <param name="input"></param> /// <param name="inFocus">Lets the item know whthere its in focus and can be used or not</param> public virtual void HandleInput(InputControl input, bool inFocus) { }
private bool DefaultAcceptListener(InputControl c, InputEvent e) { if (!IsTopmost) return false; var ml = Game.InputControls.MouseLocation; if (!ml.HasValue) return false; return Handler.HandleAccept(ml.Value, e); }