//------------Data mining------------- public void PushRecords() { TotalAnsNum = TotalFalse + TotalTrue; NotInTime = TimeResCount - TotalAnsNum; TotalFalse = TotalFalse + NotInTime; TotalAnsNum = TotalFalse + TotalTrue; AvgReactTime = TotalAnsNum / 60f; PlayerType = ((TotalFalse + TotalTrue + AvgReactTime + SumOfAns + RecordScore) / 5); records.PlayerType = Euclidean_Distance(OLDrecords.PlayerType, PlayerType); records.TotalFalse = Euclidean_Distance(OLDrecords.TotalFalse, TotalFalse); records.TotalTrue = Euclidean_Distance(OLDrecords.TotalTrue, TotalTrue); records.AvgReactTime = Euclidean_Distance(OLDrecords.AvgReactTime, AvgReactTime); records.SumOfAns = Euclidean_Distance(OLDrecords.SumOfAns, SumOfAns); records.RecordScore = Euclidean_Distance(OLDrecords.RecordScore, RecordScore); records.Detect_Type(records); Debug.Log(Application.persistentDataPath); Debug.Log("Total false = " + records.TotalFalse); Debug.Log("Total true = " + records.TotalTrue); Debug.Log("Total AvgReactTime = " + records.AvgReactTime); Debug.Log("Total SumOfAns = " + records.SumOfAns); Debug.Log("RecordScore = " + RecordScore); Debug.Log("PlayerType = " + PlayerType); string path = "/PlayerRecords.json"; string jsonData = JsonUtility.ToJson(records, true); File.WriteAllText(Application.persistentDataPath + path, jsonData); }
// Start is called before the first frame update void Start() { platforms = GameObject.FindGameObjectsWithTag("Platform"); mp = FindObjectOfType <MovePlatform>(); for (int i = 0; i < 3; i++) { buttons[i].GetComponent <Button>().interactable = false; } moving_platforms.gameObject.SetActive(false); nextgamebtn.gameObject.SetActive(false); time = 0.1f; src = gameObject.AddComponent <AudioSource>(); //----------------------Data mining------------- OLDrecords = new Records(); records = new Records(); string path = "/PlayerRecords.json"; OLDrecords = JsonUtility.FromJson <Records>(File.ReadAllText(Application.persistentDataPath + path)); Debug.Log("Total OLDfalse = " + OLDrecords.TotalFalse); Debug.Log("Total OLDtrue = " + OLDrecords.TotalTrue); Debug.Log("Total OLDAvgReactTime = " + OLDrecords.AvgReactTime); Debug.Log("Total OLDSumOfAns = " + OLDrecords.SumOfAns); Debug.Log("OLDPlayerType = " + OLDrecords.PlayerType); Debug.Log("OLDRecordScore = " + OLDrecords.RecordScore); OLDrecords.Detect_Type(OLDrecords); if (OLDrecords.result == 1) { temp = 10; timestart = 60f; } if (OLDrecords.result == 2) { temp = 12; timestart = 55f; } if (OLDrecords.result == 3) { temp = 14; timestart = 50f; } //---------------------------- }