private void OnCollisionEnter2D(Collision2D collision) { Destroy(collision.rigidbody.gameObject); TGOCatcher.lives++; TGOCatcher.lightningSpeed += 5f; DataScript.AddScore(100); }
public void CheckLives() { if (lives < 0) { ResetGame(); DataScript.AddScore(-2500); } livesTxt.text = lives.ToString(); }
// calculate player score private void calculateScore(bool gameOver) { if (gameOver) { DataScript.AddScore(Time.timeSinceLevelLoad * 1.5f); } else { DataScript.AddScore((60 * 900 * 40) / Time.timeSinceLevelLoad); } }
private void Awake() { instance = this; localHighscoreXML = Application.persistentDataPath + "/highscores.xml"; localReportXML = Application.persistentDataPath + "/reports.xml"; localSuggestionXML = Application.persistentDataPath + "/suggestions.xml"; localQuestionXML = Application.persistentDataPath + "/questions.xml"; LoadHighscores(); DataScript.AddScore(0); SaveHighscores(); }
public void LoseLife() { lives--; if (lives == 0) { ResetGame(); DataScript.AddScore(-2500); } else { livesTxt.text = lives.ToString(); Setup(); } FindObjectOfType <TGOBall>().GetRandomAngle(); }
void CheckColor() { hintCount = 0; for (int i = 0; i < gameAnswers.Length; i++) { if (playerAnswers[i] == gameAnswers[i]) { gameHints[hintCount] = new Color(0f, 1f, 0f); hintCount++; } } if (playerAnswers == gameAnswers) { DataScript.AddScore(100000 / prevAnswers.Count); } }
// every button contains an influence this is used to move the happiness slider right or left. This number is given in the xml file private void BtnAnswer(int btn, int number) { answered = true; CameraControl.showingPopUp = false; CameraControl.inQuiz = false; XmlNodeList elemlist = multipleChoiceDoc.GetElementsByTagName("popup"); XmlNodeList list = elemlist[number].ChildNodes[1].ChildNodes; int influence = int.Parse(list[btn].Attributes["influence"].Value); XmlNodeList tekstList = multipleChoiceDoc.GetElementsByTagName("text"); //All code for ScoreCanvas // //Add questionList to QnA question list FindObjectOfType <QnAscore>().questionList.Add(tekstList[number].InnerText); //check which answer is correct answer and add to CorrectAnswerList for (int i = 0; i < elemlist[number].ChildNodes[1].ChildNodes.Count; i++) { if (int.Parse(elemlist[number].ChildNodes[1].ChildNodes[i].Attributes["influence"].Value) > 0) { FindObjectOfType <QnAscore>().correctAnsList.Add(elemlist[number].ChildNodes[1].ChildNodes[i].InnerText); } } //Add player answer to PlayerAnswerList FindObjectOfType <QnAscore>().playerAnsList.Add(elemlist[number].ChildNodes[1].ChildNodes[btn].InnerText); // DataScript.AddScore(influence * 100); for (int i = 0; i < list.Count; i++) { if (int.Parse(list[i].Attributes["influence"].Value) > 0) { EndOfGame.NumberOfCorrectAnswers++; answerBtns[i].GetComponent <Image>().color = Color.green; } else { answerBtns[i].GetComponent <Image>().color = Color.red; } } }
public void ColorPressed(int btnIndex) { if (sequenceActive) { if (btnIndex == activeSequence[sequenceInput]) { sequenceInput++; if (sequenceInput >= activeSequence.Count) { DataScript.AddScore(1000 * activeSequence.Count); correct.Play(); sequencePos = 0; sequenceInput = 0; activeSequence.Add(rnd.Next(0, colors.Length)); colors[activeSequence[sequencePos]].color = new Color(colors[activeSequence[sequencePos]].color.r, colors[activeSequence[sequencePos]].color.g, colors[activeSequence[sequencePos]].color.b, 1f); sounds[activeSequence[sequencePos]].Play(); stayLitCounter = stayLit; isLit = true; sequenceActive = false; } } else { incorrect.Play(); sequenceActive = false; gameActive = false; } } }
/* * private void OnClick(int index) * { * //checks if the user picked two answers and the answers that the user picked don't form a pair * if (ansCount == 2 && (answerList[answersPicked[0]] != answerList[answersPicked[1]] || answersPicked[0] == answersPicked[1])) * { * //reset images back to the default image * prefabList[answersPicked[0]].GetComponent<RawImage>().texture = meganDefault; * prefabList[answersPicked[1]].GetComponent<RawImage>().texture = meganDefault; * //clear the answers picked list * answersPicked.Clear(); * ansCount = 0; * } * prefabList[index].GetComponent<RawImage>().texture = answerList[index]; * answersPicked.Add(index); * * ansCount++; * * if (ansCount == 2) * { * if(answersPicked[0] == answersPicked[1]) * { * answersPicked.Clear(); * ansCount = 0; * } * else if(answerList[answersPicked[0]] == answerList[answersPicked[1]]) * { * DataScript.AddScore(1000); * prefabList[answersPicked[0]].GetComponent<Button>().interactable = false; * prefabList[answersPicked[1]].GetComponent<Button>().interactable = false; * answersPicked.Clear(); * ansCount = 0; * } * } * }*/ private void OnClick(int index) { if (answersPicked.Count == 2) { //reset images back to the default image prefabList[answersPicked[0]].GetComponent <RawImage>().texture = meganDefault; prefabList[answersPicked[1]].GetComponent <RawImage>().texture = meganDefault; //clear the answers picked list answersPicked.Clear(); } prefabList[index].GetComponent <RawImage>().texture = answerList[index]; answersPicked.Add(index); if (answersPicked.Count == 2) { if (answersPicked[0] != answersPicked[1]) { if (answerList[answersPicked[0]] == answerList[answersPicked[1]]) { DataScript.AddScore(1000); prefabList[answersPicked[0]].GetComponent <Button>().interactable = false; prefabList[answersPicked[1]].GetComponent <Button>().interactable = false; answersPicked.Clear(); } } else { //reset images back to the default image prefabList[answersPicked[0]].GetComponent <RawImage>().texture = meganDefault; prefabList[answersPicked[1]].GetComponent <RawImage>().texture = meganDefault; //clear the answers picked list answersPicked.Clear(); } } }
// every button contains an influence this is used to move the happiness slider right or left. This number is given in the xml file private void BtnAnswer(int btn, int number) { //answered = true; CameraControl.showingPopUp = false; CameraControl.inQuiz = false; XmlNodeList elemlist = doc.GetElementsByTagName(parenttag); XmlNodeList list = elemlist[number].ChildNodes[1].ChildNodes; int influence = int.Parse(list[btn].Attributes[childattribute].Value); XmlNodeList tekstList = doc.GetElementsByTagName(childquestiontag); //All code for ScoreCanvas // //Add questionList to QnA question list FindObjectOfType <QnAscore>().questionList.Add(tekstList[number].InnerText); //check which answer is correct answer and add to CorrectAnswerList for (int i = 0; i < elemlist[number].ChildNodes[1].ChildNodes.Count; i++) { if (int.Parse(elemlist[number].ChildNodes[1].ChildNodes[i].Attributes[childattribute].Value) > 0) { FindObjectOfType <QnAscore>().correctAnsList.Add(elemlist[number].ChildNodes[1].ChildNodes[i].InnerText); } } //Add player answer to PlayerAnswerList FindObjectOfType <QnAscore>().playerAnsList.Add(elemlist[number].ChildNodes[1].ChildNodes[btn].InnerText); // if (influence < 0) { if (EndOfGame.NumberOfCorrectAnswers > 0) { EndOfGame.NumberOfCorrectAnswers = 0; } EndOfGame.NumberOfCorrectAnswers--; } if (influence > 0) { if (EndOfGame.NumberOfCorrectAnswers < 0) { EndOfGame.NumberOfCorrectAnswers = 0; } EndOfGame.NumberOfCorrectAnswers++; switch (sceneName) { case "Producer": case "DGO": case "Supplier": AdjustMoney(influence * 1000); break; default: break; } } DataScript.AddScore(influence * 100); for (int i = 0; i < list.Count; i++) { if (int.Parse(list[i].Attributes[childattribute].Value) > 0) { answerBtns[i].GetComponent <Image>().color = Color.green; } else { answerBtns[i].GetComponent <Image>().color = Color.red; } } }
// every button contains an influence this is used to move the happiness slider right or left. This number is given in the xml file private void BtnAnswer(int btn, int number) { //answered = true; CameraControl.showingPopUp = false; CameraControl.inQuiz = false; modifier = list.questionEntries[number].answers[btn].modifier; //All code for ScoreCanvas // //Add questionList to QnA question list FindObjectOfType <QnAscore>().questionList.Add(list.questionEntries[number].question); //check which answer is correct answer and add to CorrectAnswerList for (int i = 0; i < ansCount; i++) { if (list.questionEntries[number].answers[i].modifier > 0) { FindObjectOfType <QnAscore>().correctAnsList.Add(list.questionEntries[number].answers[i].answer); } } //Add player answer to PlayerAnswerList FindObjectOfType <QnAscore>().playerAnsList.Add(list.questionEntries[number].answers[btn].answer); // if (modifier < 0) { if (EndOfGame.NumberOfCorrectAnswers > 0) { EndOfGame.NumberOfCorrectAnswers = 0; } EndOfGame.NumberOfCorrectAnswers--; } if (modifier > 0) { if (EndOfGame.NumberOfCorrectAnswers < 0) { EndOfGame.NumberOfCorrectAnswers = 0; } EndOfGame.NumberOfCorrectAnswers++; switch (sceneName) { case "Producer": case "DGO": case "Supplier": AdjustMoney(modifier * 1000); break; default: break; } } DataScript.AddScore(modifier * 100); for (int i = 0; i < ansCount; i++) { if (list.questionEntries[number].answers[i].modifier > 0) { answerBtns[i].GetComponent <Image>().color = Color.green; } else { answerBtns[i].GetComponent <Image>().color = Color.red; } } }
private void OnCollisionEnter2D(Collision2D collision) { Destroy(gameObject); DataScript.AddScore(250); FindObjectOfType <TGOBreakoutController>().brickCounter--; }