void Update() { if (soundEffects == null) { soundEffects = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <SoundEffectsManager>(); } okay = true; if (Input.GetKeyDown(KeyCode.Escape)) { if (anyoneToTakeNoteOf.Length > 0) { for (int i = 0; i < anyoneToTakeNoteOf.Length; i++) { if (!anyoneToTakeNoteOf[i].activeSelf) { shouldCarryOn[i] = true; } else { shouldCarryOn[i] = false; } } for (int i = 0; i < shouldCarryOn.Length; i++) { if (!shouldCarryOn[i]) { okay = false; } } if (okay) { if (soundEffects != null) { soundEffects.playNegativeSound(); } MySQLiteHandler.instance.saveSpecificResult("GlobalSettingTable", "MusicGlobalVolume", LocalDataSingleton.instance.Volume.ToString()); gameObject.SetActive(false); } } else { if (soundEffects != null) { soundEffects.playNegativeSound(); } MySQLiteHandler.instance.saveSpecificResult("GlobalSettingTable", "MusicGlobalVolume", LocalDataSingleton.instance.Volume.ToString()); gameObject.SetActive(false); } } }
public void turnOnInGamePauseMenu() { if (SceneManager.GetActiveScene().buildIndex > 1) { //activate the child canvas //OptionsCanvas.gameObject.SetActive(!OptionsCanvas.gameObject.activeSelf); //InGamePauseCanvas.SetActive(!InGamePauseCanvas.activeSelf); switch (isOpeningInPause) { case true: // If the player happens to be openning in game pause menu, turn it off! if (soundEffects != null) { soundEffects.playNegativeSound(); } InGamePauseCanvas.SetActive(false); isOpeningInPause = false; talking = false; break; default: // If the player is not talking, then player can access the in game pause menu if (!talking) { if (soundEffects != null) { soundEffects.playPositiveSound(); } InGamePauseCanvas.SetActive(true); isOpeningInPause = true; } break; } } }
// Update is called once per frame void Update() { if (soundEffects == null) { soundEffects = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <SoundEffectsManager>(); } //we'll just hardcode the fixed text, everytime. children[0].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.upKey.ToString(); children[1].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.downKey.ToString(); children[2].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.leftKey.ToString(); children[3].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.rightKey.ToString(); children[4].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.attackKey.ToString(); children[5].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.rangeKey.ToString(); children[6].transform.GetChild(0).GetComponent <Text>().text = KeyBindScript.inventoryKey.ToString(); //we handle the input from here. if (Input.GetKeyDown(KeyCode.Return)) { //we need to create a interface to activate some helper text helperText.SetActive(!helperText.activeSelf); // invert the activetext state; if (soundEffects != null) { soundEffects.playPositiveSound(); } //allow for modification if the helpertext is active } else if (Input.GetKeyDown(KeyCode.Escape) && !helperText.activeSelf) { //SAVE HERE. Hardcoding unfortunately but the fastest way to save keybinds int zeUpKeyValue = (int)KeyBindScript.upKey; int zeDownKeyValue = (int)KeyBindScript.downKey; int zeRightKeyValue = (int)KeyBindScript.rightKey; int zeLeftKeyValue = (int)KeyBindScript.leftKey; int zeAttackKeyValue = (int)KeyBindScript.attackKey; int zeRangeKeyValue = (int)KeyBindScript.rangeKey; int zeInventoryKeyValue = (int)KeyBindScript.inventoryKey; MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.upKeyField, zeUpKeyValue.ToString()); MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.downKeyField, zeDownKeyValue.ToString()); MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.rightKeyField, zeRightKeyValue.ToString()); MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.leftKeyField, zeLeftKeyValue.ToString()); MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.attackKeyField, zeAttackKeyValue.ToString()); MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.rangeKeyField, zeRangeKeyValue.ToString()); MySQLiteHandler.instance.saveSpecificResult(KeyBindScript.theSQLiteTable, KeyBindScript.inventoryKeyField, zeInventoryKeyValue.ToString()); if (soundEffects != null) { soundEffects.playNegativeSound(); } //only allow the thing to be closed if not editing a keybind transform.parent.gameObject.SetActive(false); } if (helperText.activeSelf) { helperText.GetComponent <RectTransform>().anchoredPosition = new Vector2(startingX, children[pointingAt].GetComponent <RectTransform>().anchoredPosition.y); children[pointingAt].transform.GetChild(0).GetComponent <Text>().text = ""; //handle the input here if (temp == KeyCode.None) { temp = FetchKey(); } } if (temp != KeyCode.None && helperText.activeSelf) { switch (pointingAt) { case 0: { KeyBindScript.upKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.downKey == temp) { KeyBindScript.downKey = KeyCode.None; break; } else if (KeyBindScript.leftKey == temp) { KeyBindScript.leftKey = KeyCode.None; break; } else if (KeyBindScript.rightKey == temp) { KeyBindScript.rightKey = KeyCode.None; break; } else if (KeyBindScript.attackKey == temp) { KeyBindScript.attackKey = KeyCode.None; break; } else if (KeyBindScript.rangeKey == temp) { KeyBindScript.rangeKey = KeyCode.None; break; } else if (KeyBindScript.inventoryKey == temp) { KeyBindScript.inventoryKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } case 1: { KeyBindScript.downKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.upKey == temp) { KeyBindScript.upKey = KeyCode.None; break; } else if (KeyBindScript.leftKey == temp) { KeyBindScript.leftKey = KeyCode.None; break; } else if (KeyBindScript.rightKey == temp) { KeyBindScript.rightKey = KeyCode.None; break; } else if (KeyBindScript.attackKey == temp) { KeyBindScript.attackKey = KeyCode.None; break; } else if (KeyBindScript.rangeKey == temp) { KeyBindScript.rangeKey = KeyCode.None; break; } else if (KeyBindScript.inventoryKey == temp) { KeyBindScript.inventoryKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } case 2: { KeyBindScript.leftKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.upKey == temp) { KeyBindScript.upKey = KeyCode.None; break; } else if (KeyBindScript.downKey == temp) { KeyBindScript.downKey = KeyCode.None; break; } else if (KeyBindScript.rightKey == temp) { KeyBindScript.rightKey = KeyCode.None; break; } else if (KeyBindScript.attackKey == temp) { KeyBindScript.attackKey = KeyCode.None; break; } else if (KeyBindScript.rangeKey == temp) { KeyBindScript.rangeKey = KeyCode.None; break; } else if (KeyBindScript.inventoryKey == temp) { KeyBindScript.inventoryKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } case 3: { KeyBindScript.rightKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.upKey == temp) { KeyBindScript.upKey = KeyCode.None; break; } else if (KeyBindScript.downKey == temp) { KeyBindScript.downKey = KeyCode.None; break; } else if (KeyBindScript.leftKey == temp) { KeyBindScript.leftKey = KeyCode.None; break; } else if (KeyBindScript.attackKey == temp) { KeyBindScript.attackKey = KeyCode.None; break; } else if (KeyBindScript.rangeKey == temp) { KeyBindScript.rangeKey = KeyCode.None; break; } else if (KeyBindScript.inventoryKey == temp) { KeyBindScript.inventoryKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } case 4: { KeyBindScript.attackKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.upKey == temp) { KeyBindScript.upKey = KeyCode.None; break; } else if (KeyBindScript.downKey == temp) { KeyBindScript.downKey = KeyCode.None; break; } else if (KeyBindScript.leftKey == temp) { KeyBindScript.leftKey = KeyCode.None; break; } else if (KeyBindScript.rightKey == temp) { KeyBindScript.rightKey = KeyCode.None; break; } else if (KeyBindScript.rangeKey == temp) { KeyBindScript.rangeKey = KeyCode.None; break; } else if (KeyBindScript.inventoryKey == temp) { KeyBindScript.inventoryKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } case 5: { KeyBindScript.rangeKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.upKey == temp) { KeyBindScript.upKey = KeyCode.None; break; } else if (KeyBindScript.downKey == temp) { KeyBindScript.downKey = KeyCode.None; break; } else if (KeyBindScript.leftKey == temp) { KeyBindScript.leftKey = KeyCode.None; break; } else if (KeyBindScript.rightKey == temp) { KeyBindScript.rightKey = KeyCode.None; break; } else if (KeyBindScript.attackKey == temp) { KeyBindScript.attackKey = KeyCode.None; break; } else if (KeyBindScript.inventoryKey == temp) { KeyBindScript.inventoryKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } case 6: { KeyBindScript.inventoryKey = temp; for (int i = 0; i < allKeys.Length; i++) { if (i != pointingAt) { if (KeyBindScript.upKey == temp) { KeyBindScript.upKey = KeyCode.None; break; } else if (KeyBindScript.downKey == temp) { KeyBindScript.downKey = KeyCode.None; break; } else if (KeyBindScript.leftKey == temp) { KeyBindScript.leftKey = KeyCode.None; break; } else if (KeyBindScript.rightKey == temp) { KeyBindScript.rightKey = KeyCode.None; break; } else if (KeyBindScript.attackKey == temp) { KeyBindScript.attackKey = KeyCode.None; break; } else if (KeyBindScript.rangeKey == temp) { KeyBindScript.rangeKey = KeyCode.None; break; } } } temp = KeyCode.None; helperText.SetActive(!helperText.activeSelf); break; } } } else //allow navigation if not waiting { if (Input.GetKeyDown(KeyCode.UpArrow) && pointingAt > 0) { if (soundEffects != null) { soundEffects.playPositiveSound(); } --pointingAt; GetComponent <RectTransform>().anchoredPosition = new Vector2(0, children[pointingAt].GetComponent <RectTransform>().anchoredPosition.y); } else if (Input.GetKeyDown(KeyCode.DownArrow) && pointingAt < (children.Length - 1)) { if (soundEffects != null) { soundEffects.playPositiveSound(); } ++pointingAt; GetComponent <RectTransform>().anchoredPosition = new Vector2(0, children[pointingAt].GetComponent <RectTransform>().anchoredPosition.y); } } }