static IGameplay SelectGameplay(List <IGameplay> gameplays, IUIHandler handler) { bool sensedMode = false; int indexOfSelectedMode = 0; List <string> gameplayCodes = new List <string>(); foreach (IGameplay gameplay in gameplays) { gameplayCodes.Add(gameplay.Code); } while (!sensedMode) { string selectedMode = handler.AskForString($"Selezionare la modalità immettendo il codice corrispondente: ").ToLower(); sensedMode = (gameplayCodes.Contains(selectedMode)) ? true : false; if (sensedMode) { indexOfSelectedMode = gameplayCodes.IndexOf(selectedMode); handler.WriteStringToUI($"Modalità scelta: {gameplays[indexOfSelectedMode].Name}."); } else { handler.WriteStringToUI($"Modalità scelta ({selectedMode}) non valida."); } } return(gameplays[indexOfSelectedMode]); }
public virtual void Deployed(IPasswordInterface ui, IUIHandler previous) { if (previous != null) { previous.Dismissed(ui, this); } }
public TreeViewModel(IUIHandler uiHandler) { this.Tree = new ObservableCollection <ItemViewModel>(); uiHandler.ItemUpdated.ObserveOn(RxApp.MainThreadScheduler).Subscribe(item => { this.Tree.Clear(); this.Tree.Add(new ItemViewModel(item)); }); }
void Start() { handler = GetComponentInParent <IUIHandler>(); if (handler == null) { Debug.Log("UI Handler not found! " + name); Destroy(gameObject); } }
static async Task MainAsync(string[] args) { // bootstrap dependencies IIOHandler ioHandler = new IOHandler(); IHTTPOutputInterpreter httpOutputInterpreter = new HTTPOutputInterpreter(); IArgumentHandler argumentHandler = new ArgumentHandler(args); INetworkCommunicationHandler networkCommunicationHandler = new NetworkCommunicationHandler(); // start application _uiHandler = new UIHandler(argumentHandler, ioHandler, networkCommunicationHandler, httpOutputInterpreter); await _uiHandler.InitAsync(); }
public bool RegisterUIHandler(IUIHandler gameHandler, int numberOfStreamDeckKeys) { Logger.Instance.LogMessage(TracingLevel.INFO, $"RegisterUIHandler was called starting {gameHandler.GetType()}"); numberOfKeys = numberOfStreamDeckKeys; this.uiHandler = gameHandler; if (this.uiHandler == null) { Logger.Instance.LogMessage(TracingLevel.ERROR, $"RegisterUIHandler was called with null gameHandler"); return(false); } return(true); }
public void init() { if (_instance == null) { _instance = gameObject.GetComponent <MainThreadProcessor>(); clientStrategy = GetComponent <IUIHandler>(); if (clientStrategy == null) { Application.Quit(); throw new Exception("Plsss"); } //inputManager = GetComponent<InputManager>(); //DontDestroyOnLoad(this.gameObject); } }
void Awake() { if (_instance == null) { _instance = this; clientStrategy = GetComponent <IUIHandler>(); if (clientStrategy == null) { Application.Quit(); throw new Exception("Please add a client strategy that inherits from IUIHandler for UI updates references."); } //inputManager = GetComponent<InputManager>(); DontDestroyOnLoad(this.gameObject); } }
public bool Remove(UIID id) { if (_managedUIs.ContainsKey(id)) { IUIHandler handler = _managedUIs[id]; _managedUIsSetupParams.Remove(id); _managedUIs.Remove(id); handler.Teardown(); return(true); } return(false); }
public LapseStudioUI(Platform RunningPlatform, IUIHandler UIHandler, MessageBox MsgBox, FileDialog FDialog) { this.UIHandler = UIHandler; this.MsgBox = MsgBox; this.FDialog = FDialog; Error.Init(MsgBox); Init(RunningPlatform); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += HandleUnhandledException; ProjectManager.BrightnessCalculated += CurrentProject_BrightnessCalculated; ProjectManager.FramesLoaded += CurrentProject_FramesLoaded; ProjectManager.ProgressChanged += CurrentProject_ProgressChanged; ProjectManager.WorkDone += CurrentProject_WorkDone; MsgBox.InfoTextChanged += MsgBox_InfoTextChanged; }
public void Run(IUIHandler uiHandler) { do { uiHandler.Clear(); string word = uiHandler.AskForString("Inserisci una parola di cui vuoi conoscere gli anagrammi:"); var anagrams = _words.GetAnagrams(word); uiHandler.WriteMessage("Gli anagrammi trovati sono:"); foreach (var anagram in anagrams) { uiHandler.WriteMessage($"\t{anagram}"); } }while (AnotherMatch(uiHandler)); uiHandler.WriteMessage("Game over"); }
public void Run(IUIHandler uiHandler) { for (int i = 0; i < _rounds; i++) { uiHandler.WriteMessage(); uiHandler.WriteMessage($"Turno { i + 1 }"); uiHandler.WriteMessage("La parola è..."); string word = _wordsRepository.GetRandomWord(5); uiHandler.WriteMessage(word.ToUpper()); uiHandler.WriteMessage(); uiHandler.WriteMessage("GO!!!!"); DateTime startTime = DateTime.Now; DateTime?endTime = null; do { string candidateWord = uiHandler.AskForString(); if (_wordsRepository.IsAnagram(word, candidateWord)) { endTime = DateTime.Now; uiHandler.WriteMessage($"Giusto! { candidateWord } è un anagramma di { word }"); break; } else { uiHandler.WriteMessage($"Non è corretto! Ti restano { TimeLeft(startTime) } secondi"); } }while (!TimeIsOver(startTime)); int roundPoints = CalculateRoundPoints(startTime, endTime); uiHandler.WriteMessage($"Turno {i + 1} terminato. Hai conquistato { roundPoints } punti e in totale sei a { _points }"); uiHandler.WriteMessage(); uiHandler.AskForString("(invio per iniziare il prossimo turno)"); } uiHandler.WriteMessage(); uiHandler.WriteMessage($"Il gioco è terminato. Hai totalizzato { _points } punti"); }
private void Awake() { Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes"); PlayePrefab = (GameObject)Resources.Load("prefab/玩家1", typeof(GameObject)); enemyPrefeb = new GameObject[3]; enemyPrefeb[0] = (GameObject)Resources.Load("prefab/multip/装甲车", typeof(GameObject)); enemyPrefeb[1] = (GameObject)Resources.Load("prefab/multip/中型坦克", typeof(GameObject)); enemyPrefeb[2] = (GameObject)Resources.Load("prefab/multip/重型坦克", typeof(GameObject)); adapter = gameObject.GetComponent <NetWorkAdapter>(); // isSever = adapter.isServer; maxAccpet = 10; controlData = new int[maxAccpet * 2]; adapter.Receiver += receiveDataHandel; if (gameObject.GetComponent <IUIHandler>() != null)//avoid addcomponent repeatedly { return; } inData = gameObject.AddComponent <IUIHandler>(); inData.receiveData += processMessage;//this delegate for deal with incoming UDP data gameObject.AddComponent <NetworkHandler>(); gameObject.AddComponent <MainThreadProcessor>(); }
public void ProcessInput(object eventArgs) { if (FCurrentHandler == null) { //get pick path FPickPath = NotificationUtils.PositionEvent(eventArgs, FPickPath, pos => GetPickPath(pos.GetUnitRect())); //calc hover, active, selected FCurrentHandler = NotificationUtils.MouseKeyboardSwitch(eventArgs, FCurrentHandler, OnMouseDown, OnMouseMove); } else { //calc unhover //NotificationHelpers.MouseKeyboardSwitch(eventArgs, null, null, OnMouseMoveUnhover, null); } //do handler FCurrentHandler = FCurrentHandler?.ProcessInput(eventArgs); //System.Diagnostics.Debug.WriteLine("Notification: " + eventArgs?.ToString()); //System.Diagnostics.Debug.WriteLine("FCurrentHandler: " + FCurrentHandler?.ToString()); }
private void Awake() { controller = transform.parent.GetComponent <IUIHandler>(); background = GetComponent <Image>(); oriColor = background.color; }
public void ResetDefaultHandler() { FDefaultHandler = FFallbackHandler; }
public void OverrideDefaultHandler(IUIHandler defaultInteraction) { FDefaultHandler = defaultInteraction; }
public UIController() { FFallbackHandler = new BasicUIHandler(this); FDefaultHandler = FFallbackHandler; }
public static void InitializeEvents(IUIHandler handler) { UIEvents.handler = handler; }
public abstract void Run(IUIHandler handler, IRepository repo);
public void Deploy(IUIHandler handler) { IUIHandler previous = CurrentHandler; if (handler != null) { handler.Deploy(this, previous); } CurrentHandler = handler; if (previous != null) { previous.Dismissed(this, handler); } if (handler != null) { handler.Deployed(this, previous); } }
public virtual void Dismissed(IPasswordInterface ui, IUIHandler next) { }
void Update() { Vector2 newCameraSpot = mainCamera.transform.position; if (Input.mousePosition.x < 0 + Config.edgePanBoundary || Input.GetKey(KeyCode.A)) { newCameraSpot.x -= Config.screenScrollSpeed * Time.deltaTime; cameraLerp = false; } if (Input.mousePosition.x > screenWidth - Config.edgePanBoundary || Input.GetKey(KeyCode.D)) { newCameraSpot.x += Config.screenScrollSpeed * Time.deltaTime; cameraLerp = false; } if (Input.mousePosition.y < 0 + Config.edgePanBoundary || Input.GetKey(KeyCode.S)) { newCameraSpot.y -= Config.screenScrollSpeed * Time.deltaTime; cameraLerp = false; } if (Input.mousePosition.y > screenHeight - Config.edgePanBoundary || Input.GetKey(KeyCode.W)) { newCameraSpot.y += Config.screenScrollSpeed * Time.deltaTime; cameraLerp = false; } //Camera drag pan section (including checking if the mouse "clicked as button") if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { mousePosOnClick = mainCamera.ScreenToWorldPoint(Input.mousePosition); cameraPosOnClick = mainCamera.transform.position; Vector2 bottomLeftOfScreen = mainCamera.GetComponent <Camera>().ViewportToWorldPoint(new Vector3(bottomLeftOfViewport.x, bottomLeftOfViewport.y, 0)); Vector2 topRightOfScreen = mainCamera.GetComponent <Camera>().ViewportToWorldPoint(new Vector3(topRightOfViewport.x, topRightOfViewport.y, 0)); if (!(mousePosOnClick.x < topRightOfScreen.x && mousePosOnClick.y < topRightOfScreen.y && mousePosOnClick.x > bottomLeftOfScreen.x && mousePosOnClick.y > bottomLeftOfScreen.y)) // If the click is not within the screen as defined in InitScreenScroll { dragPanEnabled = false; } } if (dragPanEnabled && (Input.GetMouseButton(0) || Input.GetMouseButton(1))) // dragPanEnabled can be set in an OnMouseDown event and will order correctly { mainCamera.transform.position = cameraPosOnClick; // Needed so the next line's ScreenToWorldPoint will be contextualized correctly newCameraSpot = cameraPosOnClick + (mousePosOnClick - (Vector2)mainCamera.ScreenToWorldPoint(Input.mousePosition)); cameraLerp = false; } if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) { if ((cameraPosOnClick - (Vector2)mainCamera.transform.position).magnitude + (mousePosOnClick - (Vector2)mainCamera.ScreenToWorldPoint(Input.mousePosition)).magnitude < Config.maxMouseOrCameraMovementInWorldForClick) { IUIHandler uiHandler = GetComponent <IUIHandler>(); if (uiHandler != null && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) { if (Input.GetMouseButtonUp(0)) { uiHandler.LeftClickedAsButton(); } if (Input.GetMouseButtonUp(1)) { uiHandler.RightClickedAsButton(); } } } dragPanEnabled = true; // dragPanEnabled is always reset after the button is released } // Apply camera movement based on lerp target, edge panning, or drag panning if (!cameraLerp) { newCameraSpot = ConformToBounds(newCameraSpot); mainCamera.transform.position = new Vector3(newCameraSpot.x, newCameraSpot.y, -10); } else { mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, cameraLerpTarget, Time.deltaTime * Config.cameraPosLerpRate); } }
public virtual void Deploy(IPasswordInterface ui, IUIHandler current) { }
public void RegisterUIHandler(IUIHandler handler) { _uiHandler = handler; }
private bool AnotherMatch(IUIHandler uiHandler) { string choice = uiHandler.AskForString("Vuoi provare un'altra parola? (S/N)"); return("S".Equals(choice, StringComparison.InvariantCultureIgnoreCase)); }
public override void Run(IUIHandler handler, IRepository repo) { _uiHandler = handler; _wordRepository = repo; Run(); }
public void RegisterUIHandler(IUIHandler handler) { throw new NotImplementedException(); }