private void SetActiveCellBehaviour() { if (CellBehaviours.Count == 0) { Debug.LogError("No CellBehaviours set in Main Manager", this); } CellBehaviourActive = CellBehaviours[(int)_cGridGameMode]; }
/// <summary> /// /// </summary> public void SetupNewGrid(CellLogic[,] grid, CellData[,] matrixCellData, CellBehaviour cellBehaviour = null) { for (int i = 0; i < MatrixLength.x; i++) { for (int j = 0; j < MatrixLength.y; j++) { grid[i, j].InstallCellData(matrixCellData[i, j]); grid[i, j].CreateNeisghborList(grid); if (cellBehaviour != null) { grid[i, j].CellBehaviour = cellBehaviour; } } } }
/// <summary> /// Active CellBehaviour from ManagerCGridGame, defining CellLogic behaviour, determined by Game Mode /// </summary> /// <param name="cellBehaviour"></param> public void StartGame(CellBehaviour cellBehaviour) { SetDifficulty(); // --- Original grid GridOriginal = CreateGrid(GridOriginalVisuals.CellPrefab, MatrixLength.x, MatrixLength.y, GridOriginalVisuals.Distance, GridOriginalVisuals.transform, GridOriginalVisuals.HeightDiff, GridOriginalVisuals.WidthDiff); CreateMatrixOriginalCellData(ref MatrixOriginalCellData); // Randomization: GridMain gets "broken" CellData if (ManagerCGridGame.I.FixedDataCellsImage) { MatrixOriginalCellData = RandomizeMatrixCellData(MatrixOriginalCellData, TilesToRandomize); } // TODO: Make game able to use saved images else { MatrixOriginalCellData = RandomizeMatrixCellData(MatrixOriginalCellData, TilesToRandomize); } SetupNewGrid(GridOriginal, MatrixOriginalCellData); // --- Grid for players to interact with GridMain = CreateGrid(GridMainVisuals.CellPrefab, MatrixLength.x, MatrixLength.y, GridMainVisuals.Distance, GridMainVisuals.transform, GridMainVisuals.HeightDiff, GridMainVisuals.WidthDiff); // Cloning MatrixOriginalCellData for (int i = 0; i < MatrixLength.x; i++) { for (int j = 0; j < MatrixLength.y; j++) { MatrixMainCellData[i, j] = CellData.CreateInstance <CellData>(); MatrixMainCellData[i, j] = (CellData)MatrixOriginalCellData[i, j].Clone(); } } // Randomization: GridMain gets "broken" CellData MatrixMainCellData = RandomizeMatrixCellData(MatrixMainCellData, TilesToRandomize); SetupNewGrid(GridMain, MatrixMainCellData, cellBehaviour); // --- Palette //GridPalette = GridPaletteVisuals.GetComponentsInChildren<CellLogic>().ToList(); //ManagerAuVisuals.I.UpdateGridPalette(); TotalTiles = MatrixLength.x * MatrixLength.y; // For debugging //GridLowestRowArray = new CellData[MatrixRandomizedCellData.GetLength(1)]; //for (int j = 0; j < MatrixRandomizedCellData.GetLength(1); j++) //{ // GridLowestRowArray[j] = MatrixRandomizedCellData[0, j]; // GridMainLogicLowestRow.Add(GridMain[0, j]); //} //for (int i = 0; i < MatrixRandomizedCellData.GetLength(0); i++) //{ // GridMainLogicFirstColumn.Add(GridMain[i, 0]); //} }