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 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 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 (args.cell != null) { actionCell = args.cell; } // If we've to move to perform the action if (args.options[0].HasToMove) { GameEvent ge = new 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 = new 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 = new GameEvent(); ge.setParameter("entity", this.Entity); ge.setParameter("cell", destination); ge.Name = "move"; Game.main.enqueueEvent(ge); } else { GameEvent ge = new GameEvent(); ge.setParameter("entity", this.Entity); ge.setParameter("direction", fromIndex(to)); ge.Name = "turn"; Game.main.enqueueEvent(ge); } } } } }
public void onControllerEvent(ControllerEventArgs args) { if (toLaunch == null) { if (args.options != null) { if (args.options.Length == 1) { if (args.options[0].Action != null) { args.options[0].Action.setParameter("Executer", this.Entity); } if (args.options[0].HasToMove) { GameEvent ge = ScriptableObject.CreateInstance <GameEvent>(); ge.setParameter("entity", this.Entity); ge.setParameter("cell", args.cell); ge.setParameter("distance", args.options[0].Distance); ge.setParameter("syncronous", true); ge.Name = "move"; movement = ge; Game.main.enqueueEvent(ge); } toLaunch = args.options[0].Action; } 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); } } else if (args.cell != null) { GameEvent ge = ScriptableObject.CreateInstance <GameEvent>(); ge.setParameter("entity", this.Entity.gameObject.GetInstanceID()); ge.setParameter("cell", args.cell.Map.getCoords(args.cell.gameObject)); ge.setParameter("distance", 0); ge.Name = "AlcanzarPosicion"; Game.main.enqueueEvent(ge); } 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!"); } if (Entity.Position is Cell) { Cell destino = ((Cell)Entity.Position).Map.getNeightbours((Cell)Entity.Position)[to]; GameEvent ge = ScriptableObject.CreateInstance <GameEvent>(); ge.setParameter("entity", this.Entity); ge.setParameter("cell", destino); ge.Name = "move"; Game.main.enqueueEvent(ge); } } } } }