public void Init(int part, int level) { GameObject levelInstance = Instantiate(Resources.Load(string.Format("Levels/{0}/{1}", part, level), typeof(GameObject))) as GameObject; BoardInitInfo boardInitInfo = levelInstance.GetComponent <BoardInitInfo>(); starCounter = levelInstance.GetComponent <StarsCounter>(); gameStat = new GameStat(); board = gameObject.GetComponentInChildren <Board>(); player = FindObjectOfType <Player>(); board.Init(boardInitInfo); score = 0; scoreText = GameObject.Find("Score").GetComponent <TextMeshProUGUI>(); targets = levelInstance.GetComponents <Target>(); game = levelInstance.GetComponent <Game>(); game.Init(); }
public void Init(BoardInitInfo boardInitInfo) { Init(); countX = boardInitInfo.countX; countY = boardInitInfo.countY; if (boardInitInfo.randomBoard) { minNumber = Mathf.Max(boardInitInfo.minValue, 1); maxNumber = boardInitInfo.maxValue; CreateSquares(); } else { CreateSquares(boardInitInfo.board); CorrectMinMax(); } SetSizeAndPosition(); }