mirror of
https://github.com/ConjureETS/MTI860_VR_Multi_Controller.git
synced 2026-03-24 04:21:15 +00:00
Refactor
This commit is contained in:
parent
f23ed304ba
commit
04d85e080b
@ -1,93 +1,93 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Assets.Scripts;
|
|
||||||
using Assets.Scripts.Utilities;
|
using Assets.Scripts.Utilities;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
|
||||||
using static MovementGen;
|
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
using static Assets.Scripts.MovementGen;
|
||||||
|
|
||||||
public class Executable : MonoBehaviour
|
namespace Assets.Scripts.HammerScript
|
||||||
{
|
{
|
||||||
public Timer timer;
|
public class Executable : MonoBehaviour
|
||||||
public string NextScene;
|
|
||||||
public TextMesh text;
|
|
||||||
public bool noMovementChange = true;
|
|
||||||
public bool bloquer = false;
|
|
||||||
public ChoiceOfMovement nextMouv;
|
|
||||||
|
|
||||||
// Si on veut skipper/bypasser le 5-4-3-2-1
|
|
||||||
public bool IsQuickTeleport = false;
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
//Set the tag of this GameObject to Player
|
public Timer timer;
|
||||||
gameObject.tag = Constant.GT_TARGET;
|
public string NextScene;
|
||||||
if(noMovementChange)
|
public TextMesh text;
|
||||||
text.text = "";
|
public bool noMovementChange = true;
|
||||||
else
|
public bool bloquer = false;
|
||||||
text.text = nextMouv.ToString();
|
public ChoiceOfMovement nextMouv;
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute()
|
// Si on veut skipper/bypasser le 5-4-3-2-1
|
||||||
{
|
public bool IsQuickTeleport = false;
|
||||||
if (!bloquer) {
|
|
||||||
bloquer = true;
|
|
||||||
if (timer)
|
|
||||||
{
|
|
||||||
timer.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!noMovementChange)
|
void Start()
|
||||||
{
|
|
||||||
PlayerPrefs.SetInt(Constant.PPK_MOVEMENT_CHOICE, (int)nextMouv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsQuickTeleport)
|
|
||||||
{
|
|
||||||
LoadScene();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StartCoroutine("TimerExecute");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private int count = 0;
|
|
||||||
IEnumerator TimerExecute()
|
|
||||||
{
|
|
||||||
count = 6;
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
count--;
|
//Set the tag of this GameObject to Player
|
||||||
if (text != null) {
|
gameObject.tag = Constant.GT_TARGET;
|
||||||
if (count >= 0)
|
if(noMovementChange)
|
||||||
text.text = "" + count;
|
text.text = "";
|
||||||
else
|
else
|
||||||
text.text = "Done";
|
text.text = nextMouv.ToString();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
yield return new WaitForSeconds(1.0f);
|
|
||||||
DataSaver.SaveTime();
|
|
||||||
if (count <= 0)
|
|
||||||
{
|
|
||||||
LoadScene();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public void Execute()
|
||||||
|
{
|
||||||
|
if (!bloquer) {
|
||||||
|
bloquer = true;
|
||||||
|
if (timer)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadScene()
|
if (!noMovementChange)
|
||||||
{
|
{
|
||||||
PlayerPrefs.SetString(Constant.PPK_SCENE_NAME, NextScene);
|
PlayerPrefs.SetInt(Constant.PPK_MOVEMENT_CHOICE, (int)nextMouv);
|
||||||
SceneManager.LoadScene(NextScene);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other)
|
if (IsQuickTeleport)
|
||||||
{
|
{
|
||||||
Debug.Log("Demon detected the colision");
|
LoadScene();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StartCoroutine("TimerExecute");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int count = 0;
|
||||||
|
private IEnumerator TimerExecute()
|
||||||
|
{
|
||||||
|
count = 6;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
count--;
|
||||||
|
if (text != null) {
|
||||||
|
if (count >= 0)
|
||||||
|
text.text = "" + count;
|
||||||
|
else
|
||||||
|
text.text = "Done";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(1.0f);
|
||||||
|
DataSaver.SaveTime();
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
LoadScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadScene()
|
||||||
|
{
|
||||||
|
PlayerPrefs.SetString(Constant.PPK_SCENE_NAME, NextScene);
|
||||||
|
SceneManager.LoadScene(NextScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
Debug.Log("Demon detected the colision");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +1,30 @@
|
|||||||
using System.Collections;
|
using Assets.Scripts.Utilities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Assets.Scripts;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class HammerTrigger : MonoBehaviour
|
namespace Assets.Scripts.HammerScript
|
||||||
{
|
{
|
||||||
// Start is called before the first frame update
|
public class HammerTrigger : MonoBehaviour
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
gameObject.tag = Constant.GT_HAMMER;
|
// Start is called before the first frame update
|
||||||
}
|
void Start()
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider other)
|
|
||||||
{
|
|
||||||
Debug.Log("Hammer detected the colision");
|
|
||||||
if (other.gameObject.tag == Constant.GT_TARGET)
|
|
||||||
{
|
{
|
||||||
Executable ex = other.gameObject.GetComponent("Executable") as Executable;
|
gameObject.tag = Constant.GT_HAMMER;
|
||||||
ex.Execute();
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
Debug.Log("Hammer detected the colision");
|
||||||
|
if (other.gameObject.tag == Constant.GT_TARGET)
|
||||||
|
{
|
||||||
|
Executable ex = other.gameObject.GetComponent("Executable") as Executable;
|
||||||
|
ex.Execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,67 +1,69 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Assets.Scripts;
|
|
||||||
using Assets.Scripts.Movements;
|
using Assets.Scripts.Movements;
|
||||||
|
using Assets.Scripts.Utilities;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class MovementGen : MonoBehaviour
|
namespace Assets.Scripts
|
||||||
{
|
{
|
||||||
private Dictionary<ChoiceOfMovement, MonoBehaviour> components;
|
public class MovementGen : MonoBehaviour
|
||||||
private ChoiceOfMovement currentMovement;
|
|
||||||
|
|
||||||
[SerializeField] private ChoiceOfMovement selectedMovement;
|
|
||||||
[SerializeField] private String nomDuJoueur = string.Empty;
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
components = new Dictionary<ChoiceOfMovement, MonoBehaviour>();
|
private Dictionary<ChoiceOfMovement, MonoBehaviour> components;
|
||||||
components.Add(ChoiceOfMovement.wasd, this.GetComponent<WasdMovement>());
|
private ChoiceOfMovement currentMovement;
|
||||||
components.Add(ChoiceOfMovement.teleport, this.GetComponent<TeleportMovement>());
|
|
||||||
components.Add(ChoiceOfMovement.joystick, this.GetComponent<JoystickMovement>());
|
|
||||||
components.Add(ChoiceOfMovement.joycon, this.GetComponent<JoyCon.JoyConMovement>());
|
|
||||||
components.Add(ChoiceOfMovement.omni, this.GetComponent<OmniMovement>());
|
|
||||||
|
|
||||||
selectedMovement = (ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE, 0);
|
[SerializeField] private ChoiceOfMovement selectedMovement;
|
||||||
currentMovement = (ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE, 0);
|
[SerializeField] private String nomDuJoueur = string.Empty;
|
||||||
components[currentMovement].enabled = true;
|
|
||||||
|
|
||||||
if (nomDuJoueur == string.Empty)
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
{
|
{
|
||||||
nomDuJoueur = DateTime.Now.ToString("MM-dd HH:mm");
|
components = new Dictionary<ChoiceOfMovement, MonoBehaviour>();
|
||||||
}
|
components.Add(ChoiceOfMovement.wasd, this.GetComponent<WasdMovement>());
|
||||||
PlayerPrefs.SetString(Constant.PPK_PLAYER_NAME, nomDuJoueur);
|
components.Add(ChoiceOfMovement.teleport, this.GetComponent<TeleportMovement>());
|
||||||
}
|
components.Add(ChoiceOfMovement.joystick, this.GetComponent<JoystickMovement>());
|
||||||
|
components.Add(ChoiceOfMovement.joycon, this.GetComponent<JoyCon.JoyConMovement>());
|
||||||
|
components.Add(ChoiceOfMovement.omni, this.GetComponent<OmniMovement>());
|
||||||
|
|
||||||
// Update is called once per frame
|
selectedMovement = (ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE, 0);
|
||||||
void FixedUpdate()
|
currentMovement = (ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE, 0);
|
||||||
{
|
components[currentMovement].enabled = true;
|
||||||
if(selectedMovement != currentMovement)
|
|
||||||
{
|
if (nomDuJoueur == string.Empty)
|
||||||
if (components[currentMovement] is IScriptDeMovement)
|
|
||||||
{
|
{
|
||||||
|
nomDuJoueur = DateTime.Now.ToString("MM-dd HH:mm");
|
||||||
((IScriptDeMovement) components[currentMovement]).BeforeDisable();
|
|
||||||
}
|
}
|
||||||
|
PlayerPrefs.SetString(Constant.PPK_PLAYER_NAME, nomDuJoueur);
|
||||||
components[currentMovement].enabled = false;
|
|
||||||
components[selectedMovement].enabled = true;
|
|
||||||
currentMovement = selectedMovement;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void ChangeMovement(ChoiceOfMovement newChoice)
|
// Update is called once per frame
|
||||||
{
|
void FixedUpdate()
|
||||||
selectedMovement = newChoice;
|
{
|
||||||
}
|
if(selectedMovement != currentMovement)
|
||||||
|
{
|
||||||
|
if (components[currentMovement] is IScriptDeMovement)
|
||||||
|
{
|
||||||
|
|
||||||
public enum ChoiceOfMovement
|
((IScriptDeMovement) components[currentMovement]).BeforeDisable();
|
||||||
{
|
}
|
||||||
wasd = 0,
|
|
||||||
teleport = 1,
|
components[currentMovement].enabled = false;
|
||||||
joystick = 2,
|
components[selectedMovement].enabled = true;
|
||||||
joycon = 3,
|
currentMovement = selectedMovement;
|
||||||
omni = 4
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeMovement(ChoiceOfMovement newChoice)
|
||||||
|
{
|
||||||
|
selectedMovement = newChoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ChoiceOfMovement
|
||||||
|
{
|
||||||
|
wasd = 0,
|
||||||
|
teleport = 1,
|
||||||
|
joystick = 2,
|
||||||
|
joycon = 3,
|
||||||
|
omni = 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,26 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Random = System.Random;
|
using Random = System.Random;
|
||||||
|
|
||||||
public class RandomDemonSpawn : MonoBehaviour
|
namespace Assets.Scripts
|
||||||
{
|
{
|
||||||
public GameObject[] listeCommeTuVeux;
|
public class RandomDemonSpawn : MonoBehaviour
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
public GameObject[] listeCommeTuVeux;
|
||||||
int card = rnd.Next(1, 3);
|
|
||||||
|
|
||||||
listeCommeTuVeux[0].SetActive(card == 1);
|
// Start is called before the first frame update
|
||||||
listeCommeTuVeux[1].SetActive(card != 1);
|
void Start()
|
||||||
}
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
int card = rnd.Next(1, 3);
|
||||||
|
|
||||||
// Update is called once per frame
|
listeCommeTuVeux[0].SetActive(card == 1);
|
||||||
void Update()
|
listeCommeTuVeux[1].SetActive(card != 1);
|
||||||
{
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,6 @@
|
|||||||
using System;
|
namespace Assets.Scripts.Utilities
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Assets.Scripts
|
|
||||||
{
|
{
|
||||||
class Constant
|
public class Constant
|
||||||
{
|
{
|
||||||
public const string SEPARATOR = "-";
|
public const string SEPARATOR = "-";
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,10 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Scripts.Utilities
|
namespace Assets.Scripts.Utilities
|
||||||
{
|
{
|
||||||
class DataSaver
|
public class DataSaver
|
||||||
{
|
{
|
||||||
public static void SaveTime()
|
public static void SaveTime()
|
||||||
{
|
{
|
||||||
@ -17,7 +13,7 @@ namespace Assets.Scripts.Utilities
|
|||||||
string time = PlayerPrefs.GetString(Constant.PPK_TIMER_TIME);
|
string time = PlayerPrefs.GetString(Constant.PPK_TIMER_TIME);
|
||||||
string stage = PlayerPrefs.GetString(Constant.PPK_SCENE_NAME);
|
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);
|
WriteToFile(toSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SavePosition(List<Position> positions)
|
public static void SavePosition(List<Position> positions)
|
||||||
@ -25,17 +21,17 @@ namespace Assets.Scripts.Utilities
|
|||||||
string playerName = PlayerPrefs.GetString(Constant.PPK_PLAYER_NAME);
|
string playerName = PlayerPrefs.GetString(Constant.PPK_PLAYER_NAME);
|
||||||
string movementName = ((MovementGen.ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE)).ToString();
|
string movementName = ((MovementGen.ChoiceOfMovement)PlayerPrefs.GetInt(Constant.PPK_MOVEMENT_CHOICE)).ToString();
|
||||||
string stage = PlayerPrefs.GetString(Constant.PPK_SCENE_NAME);
|
string stage = PlayerPrefs.GetString(Constant.PPK_SCENE_NAME);
|
||||||
string fileName = movementName + Constant.SEPARATOR + playerName + Constant.SEPARATOR + stage;
|
string fileName = "position" + Constant.SEPARATOR + movementName + Constant.SEPARATOR + playerName + Constant.SEPARATOR + stage;
|
||||||
writeToFile(positions, fileName);
|
WriteToFile(positions, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void writeToFile(string toSave)
|
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_TIME + Constant.FILE_EXTENSION);
|
||||||
await file.WriteLineAsync(toSave);
|
await file.WriteLineAsync(toSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void writeToFile(List<Position> positions, string fileName)
|
private static async void WriteToFile(List<Position> positions, string fileName)
|
||||||
{
|
{
|
||||||
using StreamWriter file = File.AppendText(Constant.FILE_PATH + fileName + Constant.FILE_EXTENSION);
|
using StreamWriter file = File.AppendText(Constant.FILE_PATH + fileName + Constant.FILE_EXTENSION);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
namespace Assets.Scripts.Utilities
|
namespace Assets.Scripts.Utilities
|
||||||
{
|
{
|
||||||
class Position
|
public class Position
|
||||||
{
|
{
|
||||||
private float x { get; set; }
|
private float x { get; set; }
|
||||||
private float y { get; set; }
|
private float y { get; set; }
|
||||||
|
|||||||
@ -1,40 +1,42 @@
|
|||||||
using Assets.Scripts.Utilities;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PositionManager : MonoBehaviour
|
namespace Assets.Scripts.Utilities
|
||||||
{
|
{
|
||||||
public GameObject player;
|
public class PositionManager : MonoBehaviour
|
||||||
private List<Position> data;
|
|
||||||
public bool notSended = true;
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
data = new List<Position>();
|
public GameObject player;
|
||||||
StartCoroutine("TackerExecute");
|
private List<Position> data;
|
||||||
}
|
public bool notSended = true;
|
||||||
|
|
||||||
// Update is called once per frame
|
// Start is called before the first frame update
|
||||||
void Update()
|
void Start()
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IEnumerator TackerExecute()
|
|
||||||
{
|
|
||||||
while (notSended)
|
|
||||||
{
|
{
|
||||||
data.Add(new Position(player.transform.position.x, player.transform.position.y));
|
data = new List<Position>();
|
||||||
yield return new WaitForSeconds(1.0f);
|
StartCoroutine("TackerExecute");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public void sendData()
|
|
||||||
{
|
|
||||||
notSended = false;
|
|
||||||
DataSaver.SavePosition(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IEnumerator TackerExecute()
|
||||||
|
{
|
||||||
|
while (notSended)
|
||||||
|
{
|
||||||
|
data.Add(new Position(player.transform.position.x, player.transform.position.y));
|
||||||
|
yield return new WaitForSeconds(1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void sendData()
|
||||||
|
{
|
||||||
|
notSended = false;
|
||||||
|
DataSaver.SavePosition(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,53 +1,53 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Assets.Scripts;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class Timer : MonoBehaviour
|
namespace Assets.Scripts.Utilities
|
||||||
{
|
{
|
||||||
private float time { get; set; }
|
public class Timer : MonoBehaviour
|
||||||
private bool timerStop { get; set; }
|
|
||||||
|
|
||||||
// TODO JIMMY : Rename this
|
|
||||||
[SerializeField]
|
|
||||||
private TextMesh text;
|
|
||||||
// TODO JIMMY : ^ Rename this
|
|
||||||
|
|
||||||
private Coroutine timerRoutine;
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
{
|
||||||
time = 0;
|
private float time { get; set; }
|
||||||
timerRoutine = StartCoroutine("TimerExecute");
|
private bool timerStop { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
private void FixedUpdate()
|
// TODO JIMMY : Rename this
|
||||||
{
|
[SerializeField]
|
||||||
|
private TextMesh text;
|
||||||
|
// TODO JIMMY : ^ Rename this
|
||||||
|
|
||||||
}
|
private Coroutine timerRoutine;
|
||||||
|
|
||||||
public void Stop()
|
// Start is called before the first frame update
|
||||||
{
|
void Start()
|
||||||
timerStop = true;
|
|
||||||
PlayerPrefs.SetString(Constant.PPK_TIMER_TIME, text.text);
|
|
||||||
StopCoroutine(timerRoutine);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator TimerExecute()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
if (!timerStop)
|
time = 0;
|
||||||
{
|
timerRoutine = StartCoroutine("TimerExecute");
|
||||||
time += 0.1f;
|
|
||||||
if (text != null)
|
|
||||||
text.text = ""+ (Mathf.Round(time * 10) * 0.1f).ToString("F1");
|
|
||||||
yield return new WaitForSeconds(.1f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
timerStop = true;
|
||||||
|
PlayerPrefs.SetString(Constant.PPK_TIMER_TIME, text.text);
|
||||||
|
StopCoroutine(timerRoutine);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator TimerExecute()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (!timerStop)
|
||||||
|
{
|
||||||
|
time += 0.1f;
|
||||||
|
if (text != null)
|
||||||
|
text.text = ""+ (Mathf.Round(time * 10) * 0.1f).ToString("F1");
|
||||||
|
yield return new WaitForSeconds(.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user