void Awake() { DontDestroyOnLoad(gameObject); if (cur && cur != this) { Destroy(this); } else { cur = this; } }
void SetupDataCarrier() { GameObject dataObj = GameObject.FindGameObjectWithTag("data"); if (dataObj != null) { data = dataObj.GetComponent <DataCarrier>(); } else { dataObj = GameObject.Instantiate(DataCarrierPrefab); data = dataObj.GetComponent <DataCarrier>(); } }
private void AddQuestionsDataToScene(DataCarrier levelDataCarrier, List <Question> levelQuestionList) { int count = 0; for (int i = 0; i < levelDataCarrier.levelQuestions.Length; i++) { levelDataCarrier.levelQuestions[i] = levelQuestionList[i].question; levelDataCarrier.levelInformation[i] = levelQuestionList[i].information; Debug.Log(String.Format("Question: {0}", i.ToString())); levelDataCarrier.allLevelAnswers[count] = levelQuestionList[i].correct_answer + ":y"; levelDataCarrier.allLevelAnswers[count + 1] = levelQuestionList[i].incorrect_answer_1 + ":y"; levelDataCarrier.allLevelAnswers[count + 2] = levelQuestionList[i].incorrect_answer_2 + ":y"; count += 3; } }
// Start is called before the first frame update void Awake() { Time.timeScale = 1; gameState = GameState.startup; SpawnPlayer(); driver = GetComponent <Driver>(); networking = GetComponent <NetworkingManager>(); driver.steeringEnabled = true; levelTimer = 0f; GameObject dataObj = GameObject.FindGameObjectWithTag("data"); if (dataObj != null) { data = dataObj.GetComponent <DataCarrier>(); dataObj.GetComponent <SoundtrackBehaviour>().OnSceneLoad(); player.name = data.playerName; gameState = GameState.running; } }
public void Invoke(string method, string data) { try { _SentMessages++; DataCarrier dataCarrier = new DataCarrier() { H = _HubName, M = method, A = new string[] { data } }; string wsPacket = JsonConvert.SerializeObject(dataCarrier); this._ws.Send(wsPacket); } catch (Exception E) { if (OnException != null) { OnException(E); } throw (E); } }
void GameFinished_Enter() { currentState = SessionState.GameFinished; presentList = objectDetector.GetPresentList(); countdownText.text = "Finish!"; countdownAnimator.SetTrigger("go"); foreach (GameObject present in presentList) { DataCarrier data = present.GetComponent <DataCarrier>(); if (data != null) { Debug.Log("You sent a " + data.presentName + "!"); } CrazyPresent crazyPresent = present.GetComponent <CrazyPresent>(); if (crazyPresent != null) { crazyPresent.enabled = false; } } }
void Awake() { stateMachine = Camera.main.GetComponent <StateMachine>().levelData; updateUI = GameObject.FindGameObjectWithTag("MainCanvas").GetComponent <UpdateUI>(); incorrectlyAnsweredQs.Add(-1); questions = stateMachine.GetQuestions(); allAnswers = stateMachine.allLevelAnswers; audioSource = GetComponent <AudioSource>(); #region Error Prevention if ((allAnswers.Length) % 3 != 0) { Debug.LogError("Some questions do not have 3 answers"); Application.Quit(); return; } if ((questions.Length) * 3 != allAnswers.Length) { Debug.LogError("Number of questions is not relative to the amount of answers. 3 per Question"); Application.Quit(); return; } foreach (string answer in allAnswers) { try { string[] tempDiv = answer.Split(':'); if (tempDiv[1] == "n") { } else if (tempDiv[1] == "y") { } else { Debug.LogWarning(tempDiv[0] + " is incorrectly formatted"); } } catch { Debug.LogError("Question " + answer + "is not formatted properly! " + "Remember to include a ':' along with a 'y' or 'n' depending on if the answer is correct"); return; } } if (maxHP > 8) { maxHP = 8; Debug.LogWarning("HP cannot be higher than 8!"); } #endregion curHP = maxHP; answerArrays = new string[questions.Length][]; correctAnswers = new string[questions.Length]; int allAnswerCounter = 0; for (int i = 0; i < questions.Length; i++) { answerArrays[i] = new string[3] { allAnswers[allAnswerCounter], allAnswers[allAnswerCounter + 1], allAnswers[allAnswerCounter + 2] }; ParseCorrectAnswer(i); allAnswerCounter += 3; } #region Debug Output //int r = 0; //for (int d=0; d < answerArrays.Length; d++) //{ // Debug.Log("Question " + d); // Debug.Log(answerArrays[d][r]); // Debug.Log(answerArrays[d][r+1]); // Debug.Log(answerArrays[d][r+2]); // Debug.Log("--------------------"); //} //for (int c=0; c < correctAnswers.Length; c++) //{ // Debug.Log(correctAnswers[c]); //} #endregion }