void showingTimeAScore() { guiTime = Time.time - startTime + pastTime; int hours = (int)(guiTime / 3600); int minutes = (int)((guiTime % 3600) / 60); int seconds = (int)(guiTime % 60); //int fraction = (int)((guiTime * 10) % 10); textTime = string.Format(" {0:00} : {1:00} : {2:00}", hours, minutes, seconds); timeText.text = "Time:" + textTime; timeText1.text = "Time:" + textTime; if (guiTime < 1) { guiTime = 1.0f; } pointsEarnedAve = pointsEarned / guiTime * 60; if (pointsEarnedAve > pointsEarnedAveShow) { pointsEarnedAveShow = pointsEarnedAve; var tt = Score.savedScores[5]; Score.savedScores[5] = (int)pointsEarnedAveShow; SaveLoadRecords.Save(); SaveLoadRecords.Load(); Debug.Log(" " + SaveLoadRecords.savedScore[0] + " " + SaveLoadRecords.savedScore[1] + " " + SaveLoadRecords.savedScore[2] + " " + SaveLoadRecords.savedScore[3] + " " + SaveLoadRecords.savedScore[4] + " " + SaveLoadRecords.savedScore[5]); } aveTextStr = string.Format(" {0} ", (int)pointsEarnedAveShow); aveText.text = "Ave Points:" + aveTextStr + "p/m"; aveText1.text = "Ave Points" + aveTextStr + "p/m"; }
// Use this for initialization void Start() { SaveLoadRecords.Load(); int[] ttScore = SaveLoadRecords.savedScore; for (var i = 0; i < 5; i++) { string name = "PFrame" + (i + 1); Text txtTemp = GameObject.Find(name).GetComponent <Button>().GetComponentInChildren <Text>(); txtTemp.text = string.Format("{0} p/m", (int)ttScore[i]); } }
// Use this for initialization void Start() { // load saved scores SaveLoadRecords.Load(); Score.savedScores = SaveLoadRecords.savedScore; // get plane and set color GameObject x = GameObject.Find("Plane"); rend = x.GetComponent <Renderer>(); rend.material.color = planeColor; GameObject y = GameObject.Find("AddLayer"); rend = y.GetComponent <Renderer>(); addPlaneColor = planeColor; addPlaneColor.a = 0.9f; rend.material.color = addPlaneColor; // initiate rotation cubes countInUse = new int[numOfCols * numOfRows]; rotateTag = new int[numOfCols * numOfRows]; cubeRotate = new GameObject[numOfCols * numOfRows]; // load saved loadornot flag LoadOrNotSave.Load(); LoadOrNot.loadOr = LoadOrNotSave.loadOri; Debug.Log("This is loaded from saved data: " + LoadOrNot.loadOr); if (LoadOrNot.loadOr == true) { SaveLoad.Load(); Game.current = SaveLoad.savedGame; // initiate label of connenctions cubeType = new int[numOfCols * numOfRows]; cubeStat = new int[numOfCols * numOfRows]; conStat = new byte[numOfCols * numOfRows, 4]; cubeType = Game.current.cubeType; cubeStat = Game.current.cubeStat; pointsEarned = Game.current.score; pastTime = Game.current.pastTime; pointsEarnedAveShow = Game.current.aveScore; createBaseCubes(numOfCols, numOfRows, sizeCubes, intCubes, baseYHeight); createTopCubesFromGD(numOfCols, numOfRows, sizeCubes, intCubes, baseYHeight, topYHeight); } else if (LoadOrNot.loadOr == false) { // initiate label of connenctions cubeType = new int[numOfCols * numOfRows]; cubeStat = new int[numOfCols * numOfRows]; conStat = new byte[numOfCols * numOfRows, 4]; // create base cubes createBaseCubes(numOfCols, numOfRows, sizeCubes, intCubes, baseYHeight); // randomly generating small cubes createTopCubes(numOfCols, numOfRows, sizeCubes, intCubes, baseYHeight, topYHeight); } // Iniation of the neighbour list neiList = new int[numOfCols * numOfRows, 4]; conNeiList = new int[numOfCols * numOfRows, 3]; // Initiation of cube list cbList = new ArrayList[numOfCols * numOfRows]; cubeCalYet = new int[numOfCols * numOfRows]; listNum = 0; listClosed = new int[numOfCols * numOfRows]; for (var i = 0; i < numOfCols * numOfRows; i++) { conNeiList[i, 0] = 0; conNeiList[i, 1] = -1; conNeiList[i, 2] = -1; } desCubeId = new ArrayList(); getIniNeighbor(); getConnectNeigbor(); createGlobalConList(); checkClose(); //changeColorClosedLists(); desClosedLists(); calDone = false; desDone = false; // enable mouse mouIpForbid = false; mouIpForPulse = mouIFPLength; // set create time sedBfCreateIt = sedBfCreate; // Set score scoreText.text = "Points: " + pointsEarned; scoreText1.text = "Points: " + pointsEarned; // set time startTime = Time.time; // add the button listener myButton = GameObject.Find("Close").GetComponent <Button>(); myButton.onClick.AddListener(saveGameData); saveDone = new UnityEvent(); saveDone.AddListener(() => { SceneManager.LoadScene(sceneChangeTo); Debug.Log("change scene to:" + sceneChangeTo); }); // lift camera height Camera.main.enabled = true; Camera.main.orthographic = true; Camera.main.orthographicSize = 5.5f; }