Adding Practice Targets in main game (Let user practice before being timed

This commit is contained in:
Davcris911 2021-11-16 10:58:13 -05:00
parent dfa8eec9bf
commit e38c1e02b2
4 changed files with 1891 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@ -9,15 +9,21 @@ namespace Assets.Scripts.HammerScript
public class Executable : MonoBehaviour
{
public Timer timer;
public string NextScene;
public TextMesh text;
public bool noMovementChange = true;
public bool bloquer = false;
public string NextScene;
public ChoiceOfMovement nextMouv;
public MovementGen target;
public bool noMovementChange = true;
public bool changeMouvementForPractice = false;
// Si on veut skipper/bypasser le 5-4-3-2-1
public bool IsQuickTeleport = false;
private bool prevent_hit_twice = false;
void Start()
{
//Set the tag of this GameObject to Player
@ -30,8 +36,8 @@ namespace Assets.Scripts.HammerScript
public void Execute()
{
if (!bloquer) {
bloquer = true;
if (!prevent_hit_twice) {
prevent_hit_twice = true;
if (timer)
{
timer.Stop();
@ -46,6 +52,11 @@ namespace Assets.Scripts.HammerScript
{
LoadScene();
}
else if (changeMouvementForPractice)
{
StartCoroutine("Practice");
//LoadChangeMouvement();
}
else
{
StartCoroutine("TimerExecute");
@ -68,15 +79,26 @@ namespace Assets.Scripts.HammerScript
text.text = "Done";
}
yield return new WaitForSeconds(1.0f);
DataSaver.SaveTime();
if (count <= 0)
{
DataSaver.SaveTime();
LoadScene();
}
}
}
private IEnumerator Practice()
{
yield return new WaitForSeconds(2);
PlayerPrefs.SetInt(Constant.PPK_MOVEMENT_CHOICE, (int)nextMouv);
target.ChangeMovement(nextMouv);
}
private void LoadChangeMouvement()
{
PlayerPrefs.SetInt(Constant.PPK_MOVEMENT_CHOICE, (int)nextMouv);
target.ChangeMovement(nextMouv);
}
private void LoadScene()

View File

@ -6,6 +6,7 @@
// Files
public const string FILE_PATH = ""; // DO NOT PUSH THIS, OR I KILL YOU... TWICE
public const string FILE_INSIDE_PROJECT_PATH = "Task/Times/";
public const string FILE_TIME = "TimeFile";
public const string FILE_EXTENSION = ".txt";

View File

@ -12,7 +12,7 @@ namespace Assets.Scripts.Utilities
string movementName = ((MovementGen.ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE)).ToString();
string time = PlayerPrefs.GetString(Constant.PPK_TIMER_TIME);
string stage = PlayerPrefs.GetString(Constant.PPK_SCENE_NAME);
string toSave = movementName + Constant.SEPARATOR + playerName + Constant.SEPARATOR + stage + Constant.SEPARATOR + time;
string toSave = movementName + " " + Constant.SEPARATOR + " " + playerName + " " + Constant.SEPARATOR + " " + stage + " " + Constant.SEPARATOR + " " + time;
WriteToFile(toSave);
}
@ -21,13 +21,13 @@ namespace Assets.Scripts.Utilities
string playerName = PlayerPrefs.GetString(Constant.PPK_PLAYER_NAME);
string movementName = ((MovementGen.ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE)).ToString();
string stage = PlayerPrefs.GetString(Constant.PPK_SCENE_NAME);
string fileName = "position" + Constant.SEPARATOR + movementName + Constant.SEPARATOR + playerName + Constant.SEPARATOR + stage;
string fileName = "position " + Constant.SEPARATOR + " " + movementName + " " + Constant.SEPARATOR + " " + playerName + " " + Constant.SEPARATOR + " " + stage;
WriteToFile(positions, fileName);
}
private static async void WriteToFile(string toSave)
{
using StreamWriter file = File.AppendText(Constant.FILE_PATH + Constant.FILE_TIME + Constant.FILE_EXTENSION);
using StreamWriter file = File.AppendText(Constant.FILE_PATH + Constant.FILE_INSIDE_PROJECT_PATH + Constant.FILE_TIME + Constant.FILE_EXTENSION);
await file.WriteLineAsync(toSave);
}