public void trolleyManoeuvre(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (!initialize) { GetComponent <Rigidbody> ().AddForce(-forceStrength * Vector3.Normalize(trolley.transform.position - avatar.transform.position)); } }
protected override void Definition() { Enter = ControlInput("Enter", (flow) => { delayValue = flow.GetValue <int>(Delay); return(Exit); }); Exit = ControlOutput("Exit"); Delay = ValueInput <int>("Delay", 0); Title = ValueInput <string>("Title", string.Empty); SubTitle = ValueInput <string>("SubTitle", string.Empty); Body = ValueInput <string>("Body", string.Empty); Identifier = ValueOutput <string>("id", (flow) => { id = IosNotify(flow.GetValue <int>(Delay), flow.GetValue <string>(Title), flow.GetValue <string>(SubTitle), flow.GetValue <string>(Body)); return(id); }); Requirement(Title, Enter); Requirement(Body, Enter); Succession(Enter, Exit); }
private void colourResponse(MenuItem menuOption, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject avatar) { // Remember where the button was. Color buttonOrigin = new Color(0, 0, 0); foreach (MeshRenderer r in menuOption.button.GetComponentsInChildren <MeshRenderer> ()) { buttonOrigin = r.material.color; } // Set/reset the time when focus is lost. menuOption.lastTouch = Time.time + buttonColourRecoveryTime; if (!menuOption.outOfPosition) { // If not focus, then move. foreach (MeshRenderer r in menuOption.button.GetComponentsInChildren <MeshRenderer> ()) { r.material.color = new Color(0, 1, 0); } menuOption.outOfPosition = true; // Play sound. if (touchSound != null) { touchSound.Play(); } // Start timer to recover if moves out of focus. StartCoroutine(returnToNormalColour(menuOption, buttonOrigin)); } }
/// <summary> /// Returns the joystick input, modified according to protocol specifications. /// </summary> /// <returns>The modified joystick input</returns> private ControlInput GetInput() { ControlInput controlInput; ControlInput joystickInput; joystickInput = InputController.JoystickInput; // Rotate or mirror joystick input according to protocol file if (trial.JoystickControlType == Trial.JoystickControl.Clockwise) { controlInput = new ControlInput(-joystickInput.y, joystickInput.x, joystickInput.trigger, joystickInput.blanked); } else if (trial.JoystickControlType == Trial.JoystickControl.Counterclockwise) { controlInput = new ControlInput(joystickInput.y, -joystickInput.x, joystickInput.trigger, joystickInput.blanked); } else if (trial.JoystickControlType == Trial.JoystickControl.Mirrored) { controlInput = new ControlInput(-joystickInput.x, -joystickInput.y, joystickInput.trigger, joystickInput.blanked); } else { controlInput = joystickInput; } return(controlInput); }
private void removeBook(TreeNode n, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (!initialize) { Debug.Log("Remove" + n.filepath); } }
void checkScroll(ControlInput controller, ControlInput.ControllerDescription controllerObject, bool trigger, bool debounceTrigger, Vector3 direction, Vector3 position, GameObject avatarout, bool touchpad, Vector2 touchposition) { if (touchpad) { if (!haveOffset) { scrollStart = touchposition; haveOffset = true; } Vector2 scrollOffset = 0.5f * (touchposition - scrollStart); Debug.Log("Touchpad " + touchpad + " " + touchposition + " " + haveOffset + " " + scrollOffset); scroll(scrollOffset.y); reflow(); scrollStart = touchposition; } else { // if (haveOffset) // { // Vector2 scrollOffset = 100.0f * (touchposition - scrollStart); // Debug.Log ("Touchpad " + touchpad + " " + touchposition + " " + haveOffset + " " + scrollOffset); // scroll (scrollOffset.y); // reflow (); haveOffset = false; // } } }
protected override void Definition() { // Inputs on = ControlInput("on", TurnOn); off = ControlInput("off", TurnOff); if (showMonitored) { monitored = ValueInput <K>("monitored", null); } // Outputs m_trigger = ControlOutput("trigger"); if (showEventArgs) { eventArgs = ValueOutput("eventArgs", (flow) => { return(m_eventArgs); }); } turnedOn = ControlOutput("turnedOn"); turnedOff = ControlOutput("turnedOff"); // Error handling Succession(on, turnedOn); Succession(off, turnedOff); }
// Respond to the door being selected. public void summonTrolley(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (!initialize) { Debug.Log("Summoning"); TrolleyManager [] tm = Object.FindObjectsOfType <TrolleyManager> (); TrolleyManager thisTrolley = null; foreach (TrolleyManager t in tm) { Debug.Log("Got tr " + t.trolleyName); if (t.trolleyName == trolleyIdentifier) { thisTrolley = t; break; } } if (thisTrolley == null) { Debug.Log("Creating trolley "); thisTrolley = Instantiate(trolleyTemplate, transform.position + 0.0f * transform.forward, Quaternion.identity).GetComponent <TrolleyManager> (); } Debug.Log("Calling"); thisTrolley.track(avatar); } }
public InputManager() { ControlInput = new ControlInput(KeyboardAdapter); PlayerInputs = new List <PlayerInput>(); TextInput = new TextEditInput(KeyboardAdapter); SelectInput = new SelectionInput(KeyboardAdapter); }
protected override RunStatus Run(object context) { var gameState = (CurrentGameState)context; if (!ScreenReader.AreTalentsOpen()) { ControlInput.MouseClick(ControlInput.MouseClickButton.Left, 95, 942); } Thread.Sleep(700); //ScreenReader.UpdateCurrentTalentLevel(gameState); MainWindow.Log("Leveling talents for level " + gameState.Me.CharacterLevel); foreach (var talent in gameState.Me.HeroData.Talents) { if (gameState.Me.CharacterLevel < talent.TalentLevel) { continue; } if (!talent.IsLeveled) { ControlInput.ChooseTalent(talent.TalentLevel, talent.TalentIndex); talent.IsLeveled = true; talent.HeroChanges(gameState.Me.HeroData); MainWindow.Log("Leveling " + talent.TalentName + "(" + talent.TalentLevel + ")"); Thread.Sleep(200); } } Thread.Sleep(400); if (ScreenReader.AreTalentsOpen()) { ControlInput.MouseClick(ControlInput.MouseClickButton.Left, 95, 942); } return(RunStatus.Failure); }
// Switch between open and closed. public void toggleCloseBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (initialize) { // enforce current state. if (open) { setOpen(); } else { setClosed(); } } else { // switch state. if (open) { setClosed(); } else { setOpen(); } } }
public void returnToLibrary(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (!initialize) { RoomChangeMenuInteraction.changeToRoom("Library", this); } }
public override void restore(GameObject actor, EmptyActorState previousState) { base.restore(actor, previousState); movementMode = previousState != null ? (previousState as PlayerActorState).movementMode : ControlInput.Stop; coins = previousState != null ? (previousState as PlayerActorState).coins : 0; actor.SetActive(!dead); }
public override string GenerateControlInput(ControlInput input, int indent) { var outputString = string.Empty; var conditionConnection = liveUnit.condition.connection; var conditionSource = conditionConnection.source; var defaultValue = liveUnit.valueInputsData.GetValueOrDefault("condition").defaultValue; var logic = conditionConnection != null?liveUnit.condition.connection.source.unit.CodeGenerator().GenerateValueOutput(conditionSource, 0) : Patcher.ActualValue(typeof(bool), defaultValue); var hasTrue = [email protected] != null; var hasFalse = [email protected] != null; var trueDestination = [email protected]?.destination; outputString += CodeBuilder.Indent(indent) + "if (" + logic + ") \n"; outputString += CodeBuilder.OpenBody(indent) + "\n"; outputString += (hasTrue ? trueDestination.unit.CodeGenerator().GenerateControlInput(trueDestination, indent + 1) : string.Empty) + "\n"; outputString += CodeBuilder.CloseBody(indent); if (hasFalse) { var falseDestination = [email protected]; outputString += "\n" + CodeBuilder.Indent(indent) + "else" + "\n"; outputString += CodeBuilder.OpenBody(indent) + "\n"; outputString += falseDestination.unit.CodeGenerator().GenerateControlInput(falseDestination, indent + 1) + "\n"; outputString += CodeBuilder.CloseBody(indent) + "\n"; } return(outputString); }
protected override void DefinePorts() { if (returnType != null) { if (returnType.IsEnumerable()) { enter = ControlInput("enter", OnEnterCoroutine); if (yieldable != null) { if (yieldable.@yield) { exit = ControlOutput("exit"); } } } else { enter = ControlInput("enter", OnEnter); } if (returnType != typeof(Void)) { returns = ValueInput(returnType, "returns"); } } }
public override ControlInput GetControlInput(float dt, ControlInput original) { foreach (IControlable obstacle in obstacles) { if (obstacle.IsThreatTo(this.host)) { original.ThrustPercent = 1; original[InputAction.MoveForward] = true; Vector2D dir = Vector2D.Normalize(obstacle.Current.Position.Linear - host.Current.Position.Linear); if (host.DirectionVector * dir > 0) { original.TorquePercent = 1; if (host.DirectionVector.LeftHandNormal * dir > 0) { original[InputAction.RotateLeft] = true; } else { original[InputAction.RotateRight] = true; } } return(original); } } if (obstacles.Contains(target)) { original[InputAction.Action] = true; original.ActiveActions[0] = true; } return(base.GetControlInput(dt, original)); }
protected override void Definition() { indexes.Clear(); enter = ControlInput("enter", SetItem); array = ValueInput <Array>("array"); for (int i = 0; i < dimensions; i++) { var dimension = ValueInput <int>(i.ToString() + " Index", 0); indexes.Add(dimension); } value = ValueInput <object>("value"); exit = ControlOutput("exit"); Succession(enter, exit); for (int i = 0; i < indexes.Count; i++) { Requirement(indexes[i], enter); } }
private Composite MountingRoutine() { ControlInput.SendKey(Keys.S); ControlInput.SendKey(Keys.Z); Thread.Sleep(1100); return(null); }
public override void save(GameObject actor, EmptyActorState previousState) { base.save(actor, previousState); movementMode = previousState != null ? (previousState as PlayerActorState).movementMode : ControlInput.Stop; coins = previousState != null ? (previousState as PlayerActorState).coins : 0; dead = !actor.activeSelf; }
protected override void DefinePorts() { base.DefinePorts(); @true = ControlOutput("true"); @false = ControlOutput("false"); next = ControlOutput("next"); enter = ControlInput("enter", (flow) => { if (flow.GetValue <bool>(condition)) { flow.Invoke(@true); } else { flow.Invoke(@false); } return(next); }); condition = ValueInput <bool>("condition"); Requirement(condition, enter); Succession(enter, @true); Succession(enter, @false); Succession(enter, next); }
public void resume(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (!initialize) { gameObject.SetActive(false); } }
protected override void Update(GameTime gameTime) { Sound.Update(); Music.Play("music1"); QuakeManager.Update(); ControlInput.Update(); FrameTime = (float)gameTime.ElapsedGameTime.TotalSeconds; if (SlowTime > 0f) { SlowTime -= FrameTime; FrameTime /= 10f; } switch (GameMode) { case GameModes.Playing: UpdateGame(); break; case GameModes.Menu: if (Menu.MenuMode == MenuMode.Dead) { var pTime = FrameTime; FrameTime /= 3f; UpdateGame(); FrameTime = pTime; } Menu.Update(this); break; } base.Update(gameTime); }
internal void CloneFrom(PlayerInput playerInput) { this.ci = playerInput.ci; this.istate = playerInput.istate; this.kmb = playerInput.kmb; this.mapper = playerInput.mapper; }
/// <summary> /// Defines the ports of this unit. /// </summary> protected override void Definition() { base.Definition(); arguments.Clear(); enter = ControlInput("enter", Enter); name = ValueInput <string>("name", string.Empty); if (!global) { target = ValueInput <GameObject>("target", (GameObject)null).NullMeansSelf(); } for (int i = 0; i < count; i++) { var input = ValueInput <object>(i.ToString()); arguments.Add(input); Requirement(input, enter); } exit = ControlOutput("exit"); value = ValueOutput <object>("value", GetValue); Succession(enter, exit); Requirement(name, enter); if (!global) { Requirement(target, enter); } Succession(enter, trigger); }
protected override void Definition() { enter = ControlInput("enter", (flow) => { PerformOperation(flow); return(exit); }); collection = ValueInput <IEnumerable>("collection"); exit = ControlOutput("exit"); if (Dictionary) { key = ValueOutput <object>("key"); Assignment(enter, key); } value = ValueOutput <object>("item"); Succession(enter, exit); Assignment(enter, value); Requirement(collection, enter); }
public override void Check() { int inputRowNo = InPortList[0].RowNo; int inputColNo = InPortList[0].ColNo; if (inputRowNo < 0 && inputColNo < 0) { if (rowNo < 0 && colNo < 0) { rowNo = 0; colNo = 0; } else { InPortList[0].RowNo = rowNo; InPortList[0].ColNo = colNo; } } else if (rowNo < 0 && colNo < 0) { rowNo = inputRowNo; colNo = inputColNo; } else if (inputColNo != colNo) { throw logger.Error(new ModelException(this, $"Column number inconsistent, got {inputColNo}, but {colNo} expected.")); } else if (inputRowNo != rowNo) { throw logger.Error(new ModelException(this, $"Row number inconsistent, got {inputRowNo}, but {rowNo} expected.")); } handle = ControlInput.CreateInput(varName ?? Name, rowNo, colNo); OutPortList[0].SetShape(rowNo, colNo); }
protected override void Definition() { enter = ControlInput("enter", new Action <Flow>(Enter)); name = ValueInput <string>("name", string.Empty); if (trigger == TriggerType.Children) { count = ValueInput <int>("below", 0); } else if (trigger == TriggerType.Parent) { count = ValueInput <int>("above", 0); } else { if (trigger == TriggerType.Both) { count = ValueInput("away", 0); } } for (int i = 0; i < argumentCount; i++) { int _i = i; base.ValueOutput <object>("argument_" + i, (Recursion recursion) => arguments[1 + _i]); } exit = ControlOutput("exit"); Relation(enter, exit); }
protected override void Definition() { enter = ControlInput("enter", (flow) => { if (_delegate is IAction) { flow.GetValue <IAction>(a).Bind(flow.GetValue <TDelegateInterface>(b)); } else { if (_delegate is IFunc) { flow.GetValue <IFunc>(a).Bind(flow.GetValue <TDelegateInterface>(b)); } } return(exit); }); exit = ControlOutput("exit"); if (_delegate != null) { a = ValueInput(_delegate.GetType(), "a"); b = ValueInput(_delegate.GetType(), "b"); } else { a = ValueInput(typeof(object), "a"); b = ValueInput(typeof(object), "b"); } Requirement(a, enter); Requirement(b, enter); Succession(enter, exit); }
// Drop the book. public void dropBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { if (!initialize) { // Close it first. // setClosed (); // Switch off menu - a dropped book is no longer in use. hideMenu(); // Switch off settings. // settingsOpen = false; // updateSettings (); // Let physics have it. GetComponent <Rigidbody> ().useGravity = true; GetComponent <Rigidbody> ().isKinematic = false; GetComponent <Rigidbody> ().angularVelocity = new Vector3(-1.1f, -1.2f, -1.3f); // Remove it from the managed set. transform.SetParent(null); dropped = true; // Ensure it doesn't get transferred between scenes. // SceneManager.MoveGameObjectToScene (gameObject, SceneManager.GetActiveScene ()); // Sound effect. bookDropSound.Play(); } }
// Pick up a book, also used when a book is first created. public void pickupBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false) { // Open the book. // setOpen (); // Enable the menu. showMenu(); // Disable physics. GetComponent <Rigidbody> ().useGravity = false; GetComponent <Rigidbody> ().isKinematic = true; transform.SetParent(null); dropped = false; // Add the book to the collection of active books. GameObject activeBooks = GameObject.Find("ActiveBooks"); if (activeBooks != null) { transform.SetParent(activeBooks.transform); } // Bring it near the user and let them position it somewhere. this.transform.position = controllerObject.controllerObject.transform.position + 1.0f * controllerObject.controllerObject.transform.forward; moveBook(controller, controllerObject, null, avatar); }
bool Off(int flags, ControlInput inp) { return !On(flags, inp); }
bool On(int flags, ControlInput inp) { return (flags & (int)inp) != 0; }