private void Start() { gameService = FindObjectOfType <GameService>(); parent = GetComponentInParent <GBSquare>(); inputField.readOnly = !parent.Data.Editable; if (!parent.Data.Editable) { inputField.GetComponentsInChildren <TMP_Text>().ToList().ForEach(_ => _.color = UNEDITABLE); } inputField.text = parent.Data.Value.ToString(); }
private void SetState(GameState state) { CurrentGameState = state; switch (CurrentGameState) { case GameState.Join: timeRemainingInCurrentState = joinDuration; InfoBox.gameObject.SetActive(true); if (gamemode == 1) { InfoBox.GetComponentInChildren <TextMeshProUGUI>().text = "Type \"!join <color>\"\nColors:\nRed\nBlue"; } else { InfoBox.GetComponentInChildren <TextMeshProUGUI>().text = "Type \"!join\""; } break; case GameState.Deciding: timeRemainingInCurrentState = decidingDuration; currround++; Shuffle(locationPoints); foreach (var bot in playerManager.GetBots()) { SetLocation(bot.Username, playerManager.GetLocations()[Random.Range(0, 4)]); } if (PlayerPrefs.GetInt("Endless") != 1) { roundText.text = "Round:" + currround + "/"; if (currround == 1) { roundInput.gameObject.SetActive(true); roundInput.GetComponentsInChildren <TextMeshProUGUI>()[1].text = "" + totalrounds; } } break; case GameState.Randomizer: timeRemainingInCurrentState = randomizerDuration; RandomizeLocationPoints(); UpdateLeaderboard(); break; case GameState.Winner: EndGame(); break; } }
public void SaveQuestion() { int QuestionNumber = EventSystem.current.currentSelectedGameObject.GetComponentInParent <PanelModel>().PanelNumber; TMP_InputField questionInput = EventSystem.current.currentSelectedGameObject.GetComponentInChildren <TMP_InputField>(); //get the question TMP_InputField[] answersInput = questionInput.GetComponentsInChildren <TMP_InputField>(); //get the answers Toggle[] answersIsCorrect = new Toggle[answersInput.Length]; List <AnswerData> answers = new List <AnswerData>(); for (int i = 1; i < answersInput.Length; i++) { answersIsCorrect[i] = answersInput[i].GetComponentInChildren <Toggle>(); //get the correct statement of the answer answers.Add(new AnswerData(answersInput[i].text, answersIsCorrect[i].isOn)); } TrueFalseQuestion question = new TrueFalseQuestion(questionInput.text, answers.ToArray()); //create a new TextQuestion DataModel.Rounds[DataModel.IroundCur].Topics[DataModel.ItopicCur].Questions[QuestionNumber - 1] = question; //add the question to the current topic in the DataModel }
public void GeneralSave() { PanelModel[] questions = gameObject.GetComponentsInChildren <PanelModel>(); foreach (PanelModel qi in questions) { int QuestionNumber = qi.GetComponent <PanelModel>().PanelNumber; TMP_InputField questionInput = qi.GetComponentInChildren <TMP_InputField>(); //get the question TMP_InputField[] answersInput = questionInput.GetComponentsInChildren <TMP_InputField>(); //get the answers Toggle[] answersIsCorrect = new Toggle[answersInput.Length]; List <AnswerData> answers = new List <AnswerData>(); for (int i = 1; i < answersInput.Length; i++) { answersIsCorrect[i] = answersInput[i].GetComponentInChildren <Toggle>(); //get the correct statement of the answer answers.Add(new AnswerData(answersInput[i].text, answersIsCorrect[i].isOn)); } TextQuestion question = new TextQuestion(questionInput.text, answers.ToArray()); //create a new TextQuestion DataModel.Rounds[DataModel.IroundCur].Topics[DataModel.ItopicCur].Questions[QuestionNumber - 1] = question; //add the question to the current topic in the DataModel } DataModel.Save(DataModel.CurrentFilename); }
public void OnRoomNameTextChanged() { // Change color if there's a naming conflict! string newName = tif_roomName.text; Color color; if (newName == room.RoomKey) { color = new Color(0, 0, 0, 0.4f); } // Same name? Black. else if (RoomSaverLoader.MayRenameRoomFile(room, newName)) { color = new Color(130 / 255f, 160 / 255f, 40 / 255f); } // Can rename? Green! else { color = new Color(140 / 255f, 55 / 255f, 40 / 255f); } // CAN'T rename? Red. // Apply the color. foreach (TextMeshProUGUI t in tif_roomName.GetComponentsInChildren <TextMeshProUGUI>()) { t.color = color; } }