// Use this for initialization void Start() { LoadOrNotSave.Load(); LoadOrNot.loadOr = LoadOrNotSave.loadOri; loadButton = GameObject.Find("Load").GetComponent <Button>(); if (!LoadOrNot.loadOr) { loadButton.interactable = false; } }
void saveGameData() { Game.current.cubeType = cubeType; Game.current.cubeStat = cubeStat; Game.current.score = pointsEarned; Game.current.pastTime = guiTime; Game.current.aveScore = (int)pointsEarnedAveShow; SaveLoad.Save(); LoadOrNot.loadOr = true; LoadOrNotSave.Save(); saveDone.Invoke(); Debug.Log("Game saved, load sign changed to:" + LoadOrNotSave.loadOri); LoadOrNotSave.loadOri = false; Debug.Log("Load flag cleared, load sign changed to:" + LoadOrNotSave.loadOri); LoadOrNotSave.Load(); Debug.Log("Game saved, load sign changed to:" + LoadOrNotSave.loadOri); SaveLoad.savedGame = new Game(); Debug.Log("Deleta saveload class, past time changed to: " + SaveLoad.savedGame.pastTime); SaveLoad.Load(); Debug.Log("Load data, past time changed to: " + SaveLoad.savedGame.pastTime); Debug.Log("Load data, show type 10: " + SaveLoad.savedGame.cubeType[10] + " stat 10: " + SaveLoad.savedGame.cubeType[10]); }
// 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; }