public void ActivatePreviousKeyboard() { if (history.Count == 0) { ResetActiveKeyboard(); return; } KeyboardScript next = history.Pop(); ChangeActiveKeyboard(next); }
// Use this for initialization void Start() { initial = activeKeyboard; audioSource = GetComponent <AudioSource>(); isKeyboardActivated = true; KeyboardScript[] keyboards = GetComponentsInChildren <KeyboardScript>(); foreach (KeyboardScript ks in keyboards) { ks.transitionOut(); } activeKeyboard.transitionIn(); KeyboardEventManager.StartListening("LeftSwipe", leftSwipe); KeyboardEventManager.StartListening("RightSwipe", rightSwipe); KeyboardEventManager.StartListening("TopSwipe", topSwipe); KeyboardEventManager.StartListening("BottomSwipe", bottomSwipe); KeyboardEventManager.StartListening("CenterTap", centerTap); }
protected override void initWorld() { // Create Keyboard. Destroy(GameObject.Find("Keyboard")); GameObject keyboardGObj = new GameObject("Keyboard"); //LocalisationMang.init(LanguageCode.GR); List<string> keyboardLayout = LocalisationMang.getKeyboardLayout("tablet","lower"); GameObject backspaceBtnObj = GameObject.Find("BackspaceBtn"); Rect guiBoundsForBackspaceBtn = WorldSpawnHelper.getWorldToGUIBounds(backspaceBtnObj.transform.renderer.bounds,upAxisArr); uiBounds.Add("BackspaceBtn",guiBoundsForBackspaceBtn); //backspaceBtnObj.transform.parent = keyboardGObj.transform; Rect maxWorldKeyboardBounds = CommonUnityUtils.get2DBounds(GameObject.Find("GroundCollection").transform.FindChild("Ground*0").renderer.bounds); //... ks = keyboardGObj.AddComponent<KeyboardScript>(); ks.initKeyboard(keyboardLayout,maxWorldKeyboardBounds,keyboardKeyPrefab,wordBoxPrefab,backspaceBtnObj.transform); ks.disableKeyboard(); // Create Additional Buttons. GameObject prevCarBtnObj = GameObject.Find("PrevCarBtn"); Rect guiBoundsForPrevCarBtn = WorldSpawnHelper.getWorldToGUIBounds(prevCarBtnObj.transform.renderer.bounds,upAxisArr); uiBounds.Add("PrevCarBtn",guiBoundsForPrevCarBtn); GameObject nextCarBtnObj = GameObject.Find("NxtCarBtn"); Rect guiBoundsForNextCarBtn = WorldSpawnHelper.getWorldToGUIBounds(nextCarBtnObj.transform.renderer.bounds,upAxisArr); uiBounds.Add("NxtCarBtn",guiBoundsForNextCarBtn); GameObject detachCarBtnObj = GameObject.Find("DetachCarBtn"); Rect guiBoundsForDetachCarBtn = WorldSpawnHelper.getWorldToGUIBounds(detachCarBtnObj.transform.renderer.bounds,upAxisArr); uiBounds.Add("DetachCarBtn",guiBoundsForDetachCarBtn); GameObject attachCarBtnObj = GameObject.Find("AttachCarBtn"); Rect guiBoundsForAttachCarBtn = WorldSpawnHelper.getWorldToGUIBounds(attachCarBtnObj.transform.renderer.bounds,upAxisArr); uiBounds.Add("AttachCarBtn",guiBoundsForAttachCarBtn); GameObject goBtnObj = GameObject.Find("GoBtn"); Rect guiBoundsForGoBtn = WorldSpawnHelper.getWorldToGUIBounds(goBtnObj.transform.renderer.bounds,upAxisArr); uiBounds.Add("GoBtn",guiBoundsForGoBtn); GameObject nextWord = GameObject.Find("Harvest_NextWordButton"); Rect guiBoundsForNextWordBtn = WorldSpawnHelper.getWorldToGUIBounds(nextWord.transform.renderer.bounds,upAxisArr); uiBounds.Add("NextWordBtn",guiBoundsForNextWordBtn); Transform nxtWordBtnTextAreaGuide = nextWord.transform.FindChild("TextArea"); GameObject nxtWordBoxTextObj = WordBuilderHelper.buildWordBox(99, LocalisationMang.translate("Next word"), CommonUnityUtils.get2DBounds(nxtWordBtnTextAreaGuide.gameObject.renderer.bounds), nxtWordBtnTextAreaGuide.position.z, upAxisArr, wordBoxPrefab); nxtWordBoxTextObj.transform.parent = nextWord.transform; nxtWordBoxTextObj.transform.FindChild("Text").renderer.sortingOrder = 505; Destroy(nxtWordBoxTextObj.transform.FindChild("Board").gameObject); Destroy(nxtWordBtnTextAreaGuide.gameObject); //nxtWordButtonOrigPos = new Vector3(nextWord.transform.position.x,nextWord.transform.position.y,nextWord.transform.position.z); //GameObject carriageDisplayObj = GameObject.Find("CarriagesDisplay"); //GameObject carriageStorageBayTextArea = carriageDisplayObj.transform.FindChild("TextArea").gameObject; //Rect guiBoundsForStorageBayArea = WorldSpawnHelper.getWorldToGUIBounds(carriageStorageBayTextArea.transform.renderer.bounds,upAxisArr); //uiBounds.Add("StorageBay",guiBoundsForStorageBayArea); prevCarBtnObj.transform.parent = Camera.main.transform; nextCarBtnObj.transform.parent = Camera.main.transform; detachCarBtnObj.transform.parent = Camera.main.transform; attachCarBtnObj.transform.parent = Camera.main.transform; goBtnObj.transform.parent = Camera.main.transform; nextWord.transform.parent = Camera.main.transform; // Auto Adjust. GameObject tmpPersonPortrait = GameObject.Find("PersonPortrait"); GameObject tmpPauseButton = GameObject.Find("PauseButton"); GameObject tmpBackdrop = GameObject.Find("BackdropCollection").transform.FindChild("Backdrop*0").gameObject; SpawnNormaliser.adjustGameObjectsToNwBounds(SpawnNormaliser.get2DBounds(tmpBackdrop.renderer.bounds), WorldSpawnHelper.getCameraViewWorldBounds(tmpBackdrop.transform.position.z,true), new List<GameObject>() { tmpPersonPortrait, tmpPauseButton }); tmpPersonPortrait.transform.parent = Camera.main.transform; tmpPauseButton.transform.parent = Camera.main.transform; uiBounds.Add("PersonPortrait",WorldSpawnHelper.getWorldToGUIBounds(tmpPersonPortrait.renderer.bounds,upAxisArr)); uiBounds.Add("PauseBtn",WorldSpawnHelper.getWorldToGUIBounds(tmpPauseButton.renderer.bounds,upAxisArr)); // Fix Keyboard, Word Display and Carriage Display to the Camera. GameObject wDisplayObj = GameObject.Find("WordDisplay"); keyboardGObj.transform.parent = Camera.main.transform; wDisplayObj.transform.parent = Camera.main.transform; //carriageDisplayObj.transform.parent = Camera.main.transform; // Input detectors. inputDetectors = new List<AbsInputDetector>(); ClickDetector cd = transform.gameObject.AddComponent<ClickDetector>(); cd.registerListener("AcScen",this); inputDetectors.Add(cd); // Set camera to start of the screen. Rect firstBackdropBounds = CommonUnityUtils.get2DBounds(tmpBackdrop.renderer.bounds); Rect camWorldBounds = WorldSpawnHelper.getCameraViewWorldBounds(2,true); Vector3 tmpCamPos = Camera.main.transform.position; tmpCamPos.x = firstBackdropBounds.x + (camWorldBounds.width * 0.5f); Camera.main.transform.position = tmpCamPos; // Mechanics Vars Init. //paused = false; trainFrontParkPos = GameObject.Find("Train").transform.FindChild("TrainFront").position; currSelCarriage = -1; appendBtnOn = true; userInputState = true; }
public void SetParent(KeyboardScript ks) { parent = ks; }
public void AddToHistory(KeyboardScript k) { history.Push(k); }
public void ChangeActiveKeyboard(KeyboardScript k) { activeKeyboard.transitionOut(); k.transitionIn(); activeKeyboard = k; }