Entry Scene added; Negative score fix
This commit is contained in:
35
Assets/Scripts/EntrySceneScript.cs
Normal file
35
Assets/Scripts/EntrySceneScript.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class EntrySceneScript : MonoBehaviour {
|
||||
|
||||
public Button firstGameButton;
|
||||
|
||||
public Button secondGameButton;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
Debug.Log("Started");
|
||||
firstGameButton.GetComponent<Button>().onClick.AddListener(LoadFirstGame);
|
||||
secondGameButton.GetComponent<Button>().onClick.AddListener(LoadSecondGame);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
public void LoadFirstGame()
|
||||
{
|
||||
Debug.Log("Load first game");
|
||||
SceneManager.LoadScene("Quiz4Scene");
|
||||
}
|
||||
|
||||
public void LoadSecondGame() {
|
||||
Debug.Log("Load second game");
|
||||
SceneManager.LoadScene("Quiz2Scene");
|
||||
}
|
||||
}
|
||||
12
Assets/Scripts/EntrySceneScript.cs.meta
Normal file
12
Assets/Scripts/EntrySceneScript.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b3103f100f88f54f8c271095f3a3940
|
||||
timeCreated: 1495288200
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Quiz2Controller : MonoBehaviour {
|
||||
|
||||
@@ -129,7 +130,7 @@ public class Quiz2Controller : MonoBehaviour {
|
||||
|
||||
// TODO: Game over
|
||||
if (counterValue > totalGameTime)
|
||||
Debug.Log("Game over!");
|
||||
SceneManager.LoadScene("EntryScene");
|
||||
counterValue += Time.deltaTime;
|
||||
|
||||
UpdateCounter();
|
||||
@@ -197,9 +198,14 @@ public class Quiz2Controller : MonoBehaviour {
|
||||
void LoadNextPair()
|
||||
{
|
||||
scoreValue += GetScore();
|
||||
if (scoreValue < 0)
|
||||
scoreValue = 0;
|
||||
UpdateScore();
|
||||
questionIdx = (questionIdx + 1) % questions.Count;
|
||||
UpdateScene();
|
||||
questionIdx = questionIdx + 1;
|
||||
if (questionIdx == questions.Count)
|
||||
SceneManager.LoadScene("EntryScene");
|
||||
else
|
||||
UpdateScene();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class Quiz4Controller : MonoBehaviour {
|
||||
|
||||
@@ -155,13 +156,23 @@ public class Quiz4Controller : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
else
|
||||
LoadNextQuestion();
|
||||
{
|
||||
if (questionIdx == questions.Count)
|
||||
SceneManager.LoadScene("EntryScene");
|
||||
else
|
||||
LoadNextQuestion();
|
||||
}
|
||||
if (counterDisplayAnswersValue > 0 && counterDisplayAnswersStarted)
|
||||
counterDisplayAnswersValue -= Time.deltaTime;
|
||||
else
|
||||
{
|
||||
UpdateScene();
|
||||
counterDisplayAnswersStarted = false;
|
||||
if (questionIdx == questions.Count)
|
||||
SceneManager.LoadScene("EntryScene");
|
||||
else
|
||||
{
|
||||
UpdateScene();
|
||||
counterDisplayAnswersStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Select answers event handler
|
||||
@@ -251,6 +262,8 @@ public class Quiz4Controller : MonoBehaviour {
|
||||
if (counterDisplayAnswersStarted)
|
||||
return;
|
||||
scoreValue += GetScore();
|
||||
if (scoreValue < 0)
|
||||
scoreValue = 0;
|
||||
UpdateScore();
|
||||
selectedAnswers.Clear();
|
||||
ClearCurrentSceneGlowEffect();
|
||||
@@ -258,7 +271,8 @@ public class Quiz4Controller : MonoBehaviour {
|
||||
counterDisplayAnswersStarted = true;
|
||||
counterValue = counterInitialValue;
|
||||
ShowAnswers();
|
||||
questionIdx = (questionIdx + 1) % questions.Count;
|
||||
questionIdx = questionIdx + 1;
|
||||
Debug.Log(questionIdx);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user