public void RestartOnGameScreen() { var gameSettings = ToolBox.Get <SettingsGame>(); var controller = GameObject.Find("Puzzle").GetComponent <PuzzleController>(); PuzzleState puzState = PuzzlesCreator.CreatePuzzle(gameSettings.lines, gameSettings.columns); //////// foreach (var dataItem in controller.DataPuzzleState.puzzleStates) { if (dataItem.puzzleID == controller.originalImage.sprite.name) { controller.DataPuzzleState.puzzleStates.Remove(dataItem); break; } } //// controller.Clear(); controller.DataPuzzleState.puzzleStates.Add(puzState); puzState.puzzleID = controller.originalImage.sprite.name; controller.currentState = puzState; controller.InitView(puzState.puzzleDatas); controller.UpdateProgress(); SetGamePanelsGamePositions(); }
public void NewGame() { //InitGameState(); string ID = originalImage.sprite.name; foreach (var panel in imageManager.backgroundPanels) { panel.sprite = backgroundImage.sprite; } if (DataPuzzleState == null) { PuzzleState puzzleState = PuzzlesCreator.CreatePuzzle(gameSettings.lines, gameSettings.columns); puzzleState.puzzleID = ID; DataPuzzleState = new PuzzleStateList(); DataPuzzleState.puzzleStates.Add(puzzleState); currentState = puzzleState; Debug.Log("puzzleCreator"); InitView(puzzleState.puzzleDatas); UIController.GetComponent <UIController>().GoToGameScreen(); } else { bool isInited = false; foreach (var pID in DataPuzzleState.puzzleStates) { if (pID.puzzleID == ID) { currentState = pID; UIController.GetComponent <UIController>().OnContinueScreen(); //затем смотрим чо нажмет и только потом вызываем InitView Debug.Log(pID.puzzleID); //InitView(pID.puzzleDatas); isInited = true; break; } } if (!isInited) { PuzzleState puzState = PuzzlesCreator.CreatePuzzle(gameSettings.lines, gameSettings.columns); puzState.puzzleID = ID; currentState = puzState; DataPuzzleState.puzzleStates.Add(puzState); InitView(puzState.puzzleDatas); UIController.GetComponent <UIController>().GoToGameScreen(); } /*progressCount = InitProgress(currentState); * currentState.progressCount = progressCount;*/ } //UpdateProgress(); //InitView(DataPuzzleState.puzzleStates); //SetAlphaToPuzzles(progressCount); }
public void OnNewGameButtonClick() { Debug.Log("OnContinuePuzzleClick"); controller.UIController.GetComponent <UIController>().GoToGameScreen(); PuzzleState puzState = PuzzlesCreator.CreatePuzzle(gameSettings.lines, gameSettings.columns); //////// foreach (var dataItem in controller.DataPuzzleState.puzzleStates) { if (dataItem.puzzleID == controller.originalImage.sprite.name) { controller.DataPuzzleState.puzzleStates.Remove(dataItem); break; } } //// controller.DataPuzzleState.puzzleStates.Add(puzState); puzState.puzzleID = controller.originalImage.sprite.name; controller.currentState = puzState; controller.InitView(puzState.puzzleDatas); controller.UpdateProgress(); }