void ReleaseObject(object sender, ControllerEventArgs e) { if (e.isLeft && leftActive != null) { if (leftActive.GetComponent <Rigidbody>() != null) { leftActive.GetComponent <Rigidbody>().velocity = SteamVR_Controller.Input((int)e.controller.index).velocity; leftActive.GetComponent <Rigidbody>().angularVelocity = SteamVR_Controller.Input((int)e.controller.index).angularVelocity; } leftActive.Release(); leftActive = null; //controllers.GetComponent<ControllerAnimation>().isLeftGrabbing = false; } else if (!e.isLeft && rightActive != null) { if (rightActive.GetComponent <Rigidbody>() != null) { rightActive.GetComponent <Rigidbody>().velocity = SteamVR_Controller.Input((int)e.controller.index).velocity; rightActive.GetComponent <Rigidbody>().angularVelocity = SteamVR_Controller.Input((int)e.controller.index).angularVelocity; } rightActive.Release(); rightActive = null; //controllers.GetComponent<ControllerAnimation>().isRightGrabbing = false; } }
/// <summary> /// Method is called when <see cref="IMike1DController.ControllerEvent"/> is triggered. /// </summary> private void CatchmentUrbanSnowPlowingControllerEvent(object sender, ControllerEventArgs e) { // Listen for Prepared event (i.e. model is ready to run) if (e.State == ControllerState.Prepared) { Mike1DController controller = (Mike1DController)sender; // Find all urban catchments, loop over all catchments foreach (ICatchment catchment in controller.Mike1DData.RainfallRunoffData.Catchments) { // Check if it is an urban catchment if (catchment is CatchmentAbstractUrban) { CatchmentAbstractUrban catchmentAbstractUrban = catchment as CatchmentAbstractUrban; // Check if snow-module is enabled. if (catchmentAbstractUrban.UseSnowModule) { // Set up plowing for urban catchment UrbanCatchmentPlowing urbanCatchmentPlowing = new UrbanCatchmentPlowing(catchmentAbstractUrban); catchment.PostTimeStepEvent += urbanCatchmentPlowing.Plowing; } } } } }
private void CheckGrip(int handIndex) { if (Player.instance.hands[handIndex].controller.GetPressDown(grip)) { if (OnGripDown != null) { ControllerEventArgs e = new ControllerEventArgs(); e = ApplyEventArgs(e, handIndex); OnGripDown(e); } } if (Player.instance.hands[handIndex].controller.GetPressUp(grip)) { if (OnGripUp != null) { ControllerEventArgs e = new ControllerEventArgs(); e = ApplyEventArgs(e, handIndex); OnGripUp(e); } } if (Player.instance.hands[handIndex].controller.GetPressUp(grip)) { if (OnGripUp != null) { ControllerEventArgs e = new ControllerEventArgs(); e = ApplyEventArgs(e, handIndex); OnGripUp(e); } } }
void Controller_ControllerEvent(object sender, ControllerEventArgs e) { // When model is prepared, we can connect to the HD Module if (e.State == ControllerState.Prepared) { // We are done with the ControllerEvent, so unregister controller.ControllerEvent -= Controller_ControllerEvent; // Register for event triggered every time step, where the weir coefficient will be updated controller.EngineNet.PostTimeStepEvent += UpdateWeirCoefficients; // Find upstream H gridpoint, where to extract the water level. ProxyUtil proxy = new ProxyUtil(controller.EngineNet); for (int i = 0; i < _weirCoefficients.Count; i++) { HonmaWeir weir = _weirCoefficients[i].Weir; // Find location of weir, and upstream reach and grid point - for a water level getter we need the H grid point // This is chainage-upstream and not flow-upstream. EngineReach engineReach = controller.EngineNet.FindReach(weir.Location); if (engineReach == null) { continue; // throw error? } GridPoint gp = engineReach.GetClosestUpstreamGridPoint(weir.Location.Chainage, gpm => gpm is HGridPoint, false); if (gp == null) { continue; // throw error? } // Extract a getter which will return the current water level _weirCoefficients[i].Getter = proxy.Getter(engineReach, gp.PointIndex, Quantity.Create(PredefinedQuantity.WaterLevel)); } } }
private static void insertKeyboardConditions(ControllerEventArgs args) { float vertical = Input.GetAxisRaw("Vertical"), horizontal = Input.GetAxisRaw("Horizontal"); if (vertical != 0) { if (vertical > 0) { args.UP = true; } else { args.DOWN = true; } } if (horizontal != 0) { if (horizontal > 0) { args.RIGHT = true; } else { args.LEFT = true; } } }
public void CreateControllerTest_InputAlienWave() { //Erzeugung Testumgebung ControllerManager target = new ControllerManager(); //Nicht benötigt object sender = null; BehaviourEnum behaviour = BehaviourEnum.BlockMovement; LinkedList <IGameItem> controllees = new LinkedList <IGameItem>(); controllees.AddFirst(new Alien(Vector2.Zero, new Vector2(5, 5), 1, 1, new PlayerNormalWeapon(), 7)); DifficultyLevel difficultyLevel = DifficultyLevel.EasyDifficulty; ControllerEventArgs desiredController = new ControllerEventArgs(behaviour, controllees, difficultyLevel); // TODO: Initialize to an appropriate value //Test start target.CreateController(sender, desiredController); //Testergebnis Assert.AreEqual(target.Controllers.Count, 1); }
public virtual void OnRightGripHolding(ControllerEventArgs e) { if (RightGripHolding != null) { RightGripHolding(this, e); } }
public virtual void OnRightGripUnpressed(ControllerEventArgs e) { if (RightGripUnpressed != null) { RightGripUnpressed(this, e); } }
protected override void ControllerConnected(ControllerEventArgs e) { Controller.SetDeadZone(e.Controller.PlayerIndex, ControllerAxis.LeftStickX, 5500); Controller.SetDeadZone(e.Controller.PlayerIndex, ControllerAxis.LeftStickY, 5500); Controller.SetDeadZone(e.Controller.PlayerIndex, ControllerAxis.RightStickX, 5500); Controller.SetDeadZone(e.Controller.PlayerIndex, ControllerAxis.RightStickY, 5500); }
public virtual void OnRightPadUntouched(ControllerEventArgs e) { if (RightPadUntouched != null) { RightPadUntouched(this, e); } }
public virtual void OnLeftGripUnpressed(ControllerEventArgs e) { if (LeftGripUnpressed != null) { LeftGripUnpressed(this, e); } }
public virtual void OnRightPadRight(ControllerEventArgs e) { if (RightPadRight != null) { RightPadRight(this, e); } }
public virtual void OnLeftPadUntouched(ControllerEventArgs e) { if (LeftPadUntouched != null) { LeftPadUntouched(this, e); } }
public virtual void OnLeftGripHolding(ControllerEventArgs e) { if (LeftGripHolding != null) { LeftGripHolding(this, e); } }
public virtual void OnLeftPadTouching(ControllerEventArgs e) { if (LeftPadTouching != null) { LeftPadTouching(this, e); } }
public virtual void OnLeftPadRight(ControllerEventArgs e) { if (LeftPadLeft != null) { LeftPadLeft(this, e); } }
public virtual void OnLeftPadDown(ControllerEventArgs e) { if (LeftPadDown != null) { LeftPadDown(this, e); } }
public void OnControllerAdded(object sender, ControllerEventArgs e) { if (!mControllers.Contains(e.Controller)) { mControllers.Add(e.Controller); } }
public virtual void OnRightPadTouching(ControllerEventArgs e) { if (RightPadTouching != null) { RightPadTouching(this, e); } }
public void OnControllerDeleted(object sender, ControllerEventArgs e) { if (mControllers.Contains(e.Controller)) { mControllers.Remove(e.Controller); } }
/// <summary> /// Handler for controller OnError events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Controller_OnError(object sender, ControllerEventArgs e) { // Just re-broadcase the error to our listeners. BroadcastError(e.Message); e.Dispose(); // Recycle the ControllerEventArgs object }
public virtual void OnTriggerPressed(ControllerEventArgs e) { if (TriggerPressed != null) { TriggerPressed(this, e); } }
public virtual void OnMenuPressedUp(ControllerEventArgs e) { if (MenuPressedUp != null) { MenuPressedUp(this, e); } }
/// <summary> /// Method that is invoked whenever the controller changes state. /// When the controller is initialized, we can setup the PowerPlant /// calculations /// </summary> private void ControllerOnControllerEvent(object sender, ControllerEventArgs e) { if (e.State == ControllerState.Initialized) { Initialize(); } }
public virtual void OnTouchpadAxisChanged(ControllerEventArgs e) { if (TouchpadAxisChanged != null) { TouchpadAxisChanged(this, e); } }
public virtual void OnGripPressedUp(ControllerEventArgs e) { if (GripPressedUp != null) { GripPressedUp(this, e); } }
public virtual void OnTouchpadPressedUp(ControllerEventArgs e) { if (TouchpadPressedUp != null) { TouchpadPressedUp(this, e); } }
void FinalizeVector(object sender, ControllerEventArgs e) { if (coordType == CoordSystemType.CARTESIAN) { if (e.isLeft) { leftActiveVec.CreateInCartesian(); leftActiveVec = null; } else { rightActiveVec.CreateInCartesian(); rightActiveVec = null; } } else { if (e.isLeft) { leftActiveVec.CreateInGeneral(); leftActiveVec = null; } else { rightActiveVec.CreateInGeneral(); rightActiveVec = null; } } }
void GrabObject(object sender, ControllerEventArgs e) { //Transform tip = e.controller.GetComponent<InitAttachment>().tip; Transform tip = e.controller.transform.Find("Custom_Model"); if (e.isLeft && leftActive != null) { if (leftActive.isAttach) { leftActive.transform.SetParent(tip, true); } else { leftActive.MoveTowards(tip.position); } } else if (!e.isLeft && rightActive != null) { if (rightActive.isAttach) { rightActive.transform.SetParent(tip, true); } else { rightActive.MoveTowards(tip.position); } } }
public override void fillControllerEvent(ControllerEventArgs args) { foreach (Map map in activeMaps) { map.fillControllerEvent(args); } }
public override void fillControllerEvent(ControllerEventArgs args) { args.UP |= upPressed; args.DOWN |= downPressed; args.RIGHT |= rightPressed; args.LEFT |= leftPressed; args.send = true; }
public override bool captureEvent(ControllerEventArgs args) { bool was = upPressed || leftPressed || downPressed || rightPressed; backupUp = args.UP; backupLeft = args.LEFT; backupDown = args.DOWN; backupRight = args.RIGHT; return was; }
public override void fillControllerEvent(ControllerEventArgs args) { if(this.mode == 0) if (args.isLeftDown) { GameEvent ge = ScriptableObject.CreateInstance<GameEvent>(); ge.Name = "ended fragment"; ge.setParameter ("Launcher", launcher); Game.main.enqueueEvent (ge); GUIManager.removeGUI (this); ScriptableObject.DestroyImmediate(this); } //throw new System.NotImplementedException (); }
public static void tick() { /** * -Evento de control -> Controllador: -> Iniciamos un nuevo ControllerEventArgs -> -> Recopila: -> Posicion y estado del raton -> Posicion y estado del teclado -> Pregunta GUI si quiere el evento -> Si la GUI no lo captura -> Le da el evento al mapa para que: -> Detecte la celda -> Detecte la entidad -> Detecte las opciones -> Si la GUI lo captura -> Le da el evento a la GUI para que lo termine. -> Si el evento se tiene que enviar -> Se manda el nuevo evento. */ if(enabled){ //Tactil = raton if(Input.simulateMouseWithTouches == false) Input.simulateMouseWithTouches = true; ControllerEventArgs args = new ControllerEventArgs(); // Recopilamos estado insertMouseConditions(args); insertKeyboardConditions(args); //Preguntamos a la GUI. IsoGUI gui = GUIManager.getGUICapturing(args); if(gui == null) MapManager.getInstance().fillControllerEvent(args); else gui.fillControllerEvent(args); if(args.send) onControllerEvent(args); } }
public virtual bool captureEvent(ControllerEventArgs args) { return true; }
/* class USBDeviceInfo { public USBDeviceInfo(string deviceID, string pnpDeviceID, string description) { this.DeviceID = deviceID; this.PnpDeviceID = pnpDeviceID; this.Description = description; } public string DeviceID { get; private set; } public string PnpDeviceID { get; private set; } public string Description { get; private set; } } */ // fired either at startup time and after a new z-wave node has been added to the controller private void DiscoveryEvent(object sender, ControllerEventArgs e) { switch (e.Status) { case ControllerStatus.DISCOVERY_START: RaisePropertyChanged(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "1", SourceType = "Z-Wave Controller", Path = "Controller.Status", Value = "Discovery Started" }); break; case ControllerStatus.DISCOVERY_END: RaisePropertyChanged(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "1", SourceType = "Z-Wave Controller", Path = "Controller.Status", Value = "Discovery Complete" }); if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction(){ Domain = this.Domain }); break; case ControllerStatus.NODE_ADDED: RaisePropertyChanged(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "1", SourceType = "Z-Wave Controller", Path = "Controller.Status", Value = "Added node " + e.NodeId }); lastAddedNode = e.NodeId; if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction(){ Domain = this.Domain }); break; case ControllerStatus.NODE_UPDATED: RaisePropertyChanged(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "1", SourceType = "Z-Wave Controller", Path = "Controller.Status", Value = "Updated node " + e.NodeId }); //if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction(){ Domain = this.Domain }); break; case ControllerStatus.NODE_REMOVED: lastRemovedNode = e.NodeId; RaisePropertyChanged(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "1", SourceType = "Z-Wave Controller", Path = "Controller.Status", Value = "Removed node " + e.NodeId }); if (InterfaceModulesChangedAction != null) InterfaceModulesChangedAction(new InterfaceModulesChangedAction(){ Domain = this.Domain }); break; case ControllerStatus.NODE_ERROR: RaisePropertyChanged(new InterfacePropertyChangedAction() { Domain = this.Domain, SourceId = "1", SourceType = "Z-Wave Controller", Path = "Controller.Status", Value = "Node " + e.NodeId + " response timeout!" }); break; } }
public override void fillControllerEvent(ControllerEventArgs args) { if(OptionsToCreate!=null){ optionsGUI = ScriptableObject.CreateInstance<OptionsGUI>(); optionsGUI.init(args, args.mousePos, OptionsToCreate); OptionsToCreate = null; GUIManager.addGUI(optionsGUI,100); } if(args.options != null) Debug.Log("he recibido opciones"); }
public void fillControllerEvent(ControllerEventArgs args) { bool encontrado = false; if(args.isLeftDown){ RaycastHit[] hits = Physics.RaycastAll(Camera.main.ScreenPointToRay(args.mousePos)); if(hits.Length>0){ Heap<float> pqHits = new Heap<float>(hits.Length); for(int i = 0; i<hits.Length; i++){ if(hits[i].collider.transform.IsChildOf(this.transform)) pqHits.push(i+1, hits[i].distance); } while(!encontrado && !pqHits.isEmpty()){ RaycastHit hit = hits[pqHits.top().elem-1]; pqHits.pop(); Cell c = hit.collider.GetComponent<Cell>(); if(c!=null){ args.cell = c; Entity[] entities = c.getEntities(); if(entities.Length==1) fillEntity(entities[0], args); encontrado = true; }else{ Entity e = hit.collider.GetComponent<Entity>(); if(e!=null) fillEntity(e,args); encontrado=true; } } } } args.send = args.UP || args.DOWN || args.LEFT || args.RIGHT || encontrado; }
/*************** * CONTROLLER ZONE * **************/ private void fillEntity(Entity e, ControllerEventArgs args) { args.entity = e; args.cell = args.entity.Position; args.options = args.entity.getOptions(); }
private static void insertKeyboardConditions(ControllerEventArgs args) { float vertical = Input.GetAxisRaw("Vertical"), horizontal = Input.GetAxisRaw("Horizontal"); if(vertical != 0){ if(vertical>0) args.UP = true; else args.DOWN = true; } if(horizontal != 0){ if(horizontal>0) args.RIGHT = true; else args.LEFT = true; } }
private void onControllerEvent(ControllerEventArgs args) { }
public void ReceiveCommand(object sender, ControllerEventArgs args) { ScriptRobot.Standing = (ScriptRobot.CharacterController as RobotController).Standing; ScriptRobot.ExecuteCommand(args.Commande); var forceX = 0f; var forceY = 0f; var absVelocityX = Mathf.Abs(rigidBody.velocity.x); var absVelocityY = Mathf.Abs(rigidBody.velocity.y); ForceMode2D mode = ForceMode2D.Force; if (ScriptRobot.X != 0) { if (absVelocityX < ScriptRobot.MaxSpeed) { forceX = ScriptRobot.X * ScriptRobot.Speed; } transform.localScale = new Vector3(ScriptRobot.X, 1, 1); } if (ScriptRobot.Y != 0) { rigidBody.velocity = new Vector2(rigidBody.velocity.x, 0); forceY = ScriptRobot.Y * JUMP_HEIGHT; mode = ForceMode2D.Impulse; } if (!ScriptRobot.Standing) { forceX *= SIDEJUMP_DISTANCE_MULTIPLIER; } rigidBody.AddForce(new Vector2(forceX, forceY), mode); if (ScriptRobot.Shooting) { SoundEffectsHelper.Instance.MakeShotSound(transform.position); OnShoot(); } if (CheckOutOfBound()) { StartCoroutine(WaitAndLoad("DefeatVideo", 0.1f)); } if (levelScript.Level.Timer.CurrentTime <= 0) { OnKilled(); } }
private static void insertMouseConditions(ControllerEventArgs args) { args.mousePos = Input.mousePosition; args.leftStatus = Input.GetMouseButton(0); args.isLeftDown = left == false && args.leftStatus == true; args.isLeftUp = left == true && args.leftStatus == false; left = args.leftStatus; }
public abstract void fillControllerEvent(ControllerEventArgs args);
public void onControllerEvent(ControllerEventArgs args) { // # Avoid responding controller event when inactive if (!active) return; // # Normal threatment // Multiple controller events only give one launch result per tick if(toLaunch == null){ // If options received (from entities) if( args.options != null){ // If there's only one, proceed to launch if(args.options.Length==1){ // The action is the event we have to launch, // so in order to know who's launching, we put a mark if(args.options[0].Action!=null) args.options[0].Action.setParameter("Executer", this.Entity); // If we've to move to perform the action if(args.options[0].HasToMove){ GameEvent ge = ScriptableObject.CreateInstance<GameEvent>(); ge.setParameter("entity", this.Entity); ge.setParameter("cell", args.cell); ge.setParameter("synchronous", true); ge.setParameter("distance", args.options[0].Distance); ge.Name = "move"; movement = ge; Game.main.enqueueEvent(ge); // Here we've launched the movement. As it's synchronous, we'll receive // the movement finished when the Mover considers it's done. } toLaunch = args.options[0].Action; } // If there're multiple actions we have to display a menu so player can choose else if(args.options.Length > 1){ OptionsGUI gui = ScriptableObject.CreateInstance<OptionsGUI>(); gui.init(args, Camera.main.WorldToScreenPoint(args.entity.transform.position), args.options); GUIManager.addGUI(gui, 100); } } // If the argument doesn't contain options but it has a cell, we'll try to move over there else if(args.cell != null){ GameEvent ge = ScriptableObject.CreateInstance<GameEvent>(); ge.setParameter("entity", this.Entity); ge.setParameter("cell", args.cell); ge.Name = "move"; Game.main.enqueueEvent(ge); } // Otherwise, the controller event should contain keys pressed else { int to = -1; if(args.LEFT){ to = 0; } else if(args.UP){ to = 1;} else if(args.RIGHT){ to = 2;} else if(args.DOWN){ to = 3; } if(to > -1){ if(Entity == null) Debug.Log ("Null!"); Cell destination = Entity.Position.Map.getNeightbours(Entity.Position)[to]; // Can move to checks if the entity can DIRECT move to this cells. // This should solve bug #29 Mover em = this.Entity.GetComponent<Mover>(); if (em != null && em.CanMoveTo(destination)) { GameEvent ge = ScriptableObject.CreateInstance<GameEvent>(); ge.setParameter("entity", this.Entity); ge.setParameter("cell", destination); ge.Name = "move"; Game.main.enqueueEvent(ge); } else { GameEvent ge = ScriptableObject.CreateInstance<GameEvent>(); ge.setParameter("entity", this.Entity); ge.setParameter("direction", fromIndex(to)); ge.Name = "turn"; Game.main.enqueueEvent(ge); } } } } }
public override void fillControllerEvent(ControllerEventArgs args) { }
public override bool captureEvent(ControllerEventArgs args) { bool r = false; if (args.isLeftDown) { Debug.Log ("LeftDown"); } if (args.isLeftDown && mouseDownFix) { mouseDownFix = false; r = true; } return r; }
public override void fillControllerEvent(ControllerEventArgs args) { foreach(Map map in activeMaps){ map.fillControllerEvent(args); } }