public virtual LevelCompletionData LoadObjData() { string path = Application.persistentDataPath + "/" + uniqueId; if (!Toolbox.Instance.allIds.Contains(this)) { Toolbox.Instance.allIds.Add(this); } if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); LevelCompletionData data = formatter.Deserialize(stream) as LevelCompletionData; stream.Close(); return(data); } else { Debug.LogError("Platform file not found in " + path); return(null); } }
public void ObjSetup(LevelCompletionData objectData) { if (objectData != null && objectData.completed) { GetComponent <PuzzleCompletion>().innerRing.gameObject.SetActive(false); GetComponent <Renderer>().enabled = false; } }
public override void Awake() { platform = GetComponent <PuzzleCompletion>(); if (Application.isPlaying) { // Debug.Log("platform ID: " + uniqueId); LevelCompletionData data = LoadObjData(); ObjSetup(data); } }
protected override void Start() { base.Start(); // When operation finishes then update the current move text MatrixParent.OnMovesIncreased.AddListener(OnMovesIncreased); // Use the current level completion data to determine how to display the fewest moves that the player has solved the puzzle in LevelCompletionData completionData = GameplayManager.CurrentLevelCompletionData; fewestMovesText.text = "Fewest Moves: " + completionData.FewestMovesString; }
public override void SaveObj() { // Debug.Log("saving platform to " + uniqueId); BinaryFormatter formatter = new BinaryFormatter(); Debug.Log(uniqueId); string path = Application.persistentDataPath + "/" + uniqueId; FileStream stream = new FileStream(path, FileMode.Create); LevelCompletionData data = new LevelCompletionData(platform); formatter.Serialize(stream, data); stream.Close(); }
protected override void Start() { base.Start(); // Disable the root uiRoot.SetActive(false); // Disable all of the items that are revealed at the end panel.enabled = false; panel.color = Color.clear; congratsText.enabled = false; movesText.textRoot.gameObject.SetActive(false); fewestMovesText.textRoot.gameObject.SetActive(false); highScoreCongratsObject.SetActive(false); mainMenuButton.SetActive(false); advanceButton.SetActive(false); replayButton.SetActive(false); // Create a copy of the current level completion data at the start completionDataOnPuzzleStart = new LevelCompletionData(GameplayManager.CurrentLevelCompletionData); // When the matrix is solved then start the routine MatrixParent.OnMatrixSolved.AddListener(() => StartCoroutine(MatrixSolvedUIRoutine())); }
public LevelCompletionData(LevelCompletionData other) : this(other.completed, other.fewestMoves) { }