Skip to content

Checkpoints #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,598 changes: 1,598 additions & 0 deletions Assets/Scenes/Checkpoint.unity

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Assets/Scenes/Checkpoint.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Scripts/Checkpoint.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Assets/Scripts/Checkpoint/AnswerReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;

namespace Assets.Scripts.Checkpoint
{
class AnswerReader : MonoBehaviour
{
private TextMeshProUGUI textMesh;
public bool correct;
public string answer="";

private void Start()
{
textMesh = GetComponent<TextMeshProUGUI>();
}

private void Update()
{
correct = CheckpointManager.CheckAnswer();
answer = textMesh.text.Trim((char)8203); //removes invisible character
CheckpointManager.SetAnswer(answer);
}

}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/AnswerReader.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions Assets/Scripts/Checkpoint/CheckpointButtons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using States.Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace Assets.Scripts.Checkpoint
{
class CheckpointButtons : MonoBehaviour
{
private float timeStamp = 0;
private float timeAfterSubmit = 3;
private bool submitted = false;

public void CheckButtonPressed()
{
TextFieldEditableManager.SetUneditable();
DisplayResult.SetShouldDisplayTrue();
timeStamp = Time.time + timeAfterSubmit;
submitted = true;

if (CheckpointManager.CheckAnswer())
{

}
}

public void Update()
{
if (timeStamp < Time.time && submitted)
{
GameStateManager.Unpause();
SceneManager.UnloadSceneAsync(sceneName: "Checkpoint");
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/CheckpointButtons.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/Scripts/Checkpoint/CheckpointHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Assets.Scripts.Dataset;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Scripts.Checkpoint
{
class CheckpointHandler : MonoBehaviour
{
private void Awake()
{
CheckpointManager.Awake();
}

}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/CheckpointHandler.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Assets/Scripts/Checkpoint/CheckpointManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Assets.Scripts.Dataset;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Scripts.Checkpoint
{
static class CheckpointManager

{
private static MissionData currentQuestion;
private static string answer = "";

public static void Awake()
{
currentQuestion = DataHolder.GetRandomMission();
}

public static MissionData GetCurrentQuestion()
{
return currentQuestion;
}

public static bool CheckAnswer()
{
return answer.Equals(currentQuestion.answers[0]);
}

public static void SetAnswer(String answer)
{
CheckpointManager.answer = answer;
}

}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/CheckpointManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Assets/Scripts/Checkpoint/DisplayResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;

namespace Assets.Scripts.Checkpoint
{
class DisplayResult : MonoBehaviour
{
TextMeshProUGUI textMesh;
static bool shouldDisplay;
string right, wrong;

private void Start()
{
textMesh = GetComponent<TextMeshProUGUI>();
shouldDisplay = false;
right = "Het antwoord is goed.";
wrong = "Het antwoord is fout. Het goede antwoord was: "
+ CheckpointManager.GetCurrentQuestion().answers[0]+".";
}

private void Update()
{
if (shouldDisplay)
{
textMesh.SetText(CheckpointManager.CheckAnswer() ? right : wrong);
textMesh.color= CheckpointManager.CheckAnswer() ? Color.green : Color.red;
}
}

static public void SetShouldDisplayTrue()
{
shouldDisplay = true;
}



}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/DisplayResult.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions Assets/Scripts/Checkpoint/QuestionUpdater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;

namespace Assets.Scripts.Checkpoint
{
class QuestionUpdater : MonoBehaviour
{
private TextMeshProUGUI textMesh;

void Start()
{
textMesh = GetComponent<TextMeshProUGUI>();
}

void Update()
{
textMesh.SetText(CheckpointManager.GetCurrentQuestion().question);//+"\n"+ CheckpointManager.GetCurrentQuestion().didYouKnow);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/QuestionUpdater.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Assets/Scripts/Checkpoint/TextFieldEditableManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;

namespace Assets.Scripts.Checkpoint
{
class TextFieldEditableManager : MonoBehaviour
{
static TMP_InputField inputField;

private void Start()
{
inputField = GetComponent<TMP_InputField>();
}

public static void SetUneditable()
{
inputField.interactable = false;
}


}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Checkpoint/TextFieldEditableManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Scripts/Controllers/CanonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private void Awake()
// Update is called once per frame
void Update()
{
if (GameStateManager.GetGameState() != GameState.PAUSED)
if (GameStateManager.GetGameState() != GameState.PAUSED && GameStateManager.GetGameState() != GameState.CHECKPOINT)
{
// Rotate transform towards mouse position
Vector3 mousePos = Input.mousePosition;
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/Controllers/GameStateManagerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ void Update()
{
GameStateManager.Pause();
}
if (Input.GetKeyDown(KeyCode.N))
{
GameStateManager.SwitchToCheckpoint();
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Dataset/DataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ class DataHandler : MonoBehaviour

public string display;

private void Start()
public DataHandler()
{
dataReader = new DataReader();
}


private void Update()
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Dataset/DataHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static MissionData GetRandomMission()
int index = UnityEngine.Random.Range(lowerBound, upperBound);

//the select questiontype requires pictures that we don't have
while (dataArray[index].questionType == "select")
while (dataArray[index].questionType == "select" || dataArray[index].questionType == "Fill in the blanks")
{
index = UnityEngine.Random.Range(lowerBound, upperBound); //this sure a select is never returned from this method.
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/DevTools/GutterContents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Start()
// Update is called once per frame
void Update()
{
if (GameStateManager.GetGameState() != GameState.PAUSED)
if (GameStateManager.GetGameState() != GameState.PAUSED && GameStateManager.GetGameState() != GameState.CHECKPOINT)
{
RefreshGutter();
}
Expand Down
Loading