public void ReceiveLevelData(LevelData.LevelDataRow levelData) { currentLevelData = levelData; }
private void GetLevelData(int levelNumber) { currentLevelData = levelData.LevelTable[levelNumber]; }
private void InitializeGrid(LevelData.LevelDataRow initLevelData, GameObject gridPoint, float offset) { /* SUMMARY * - Instantiate levelGrid * - Populate levelGrid elements with GridBlock cells * - Update levelGrid[x, y].location with Vector2Int * - Update levelGrid[x, y].canSpawn */ Debug.LogFormat("Initializing Grid\nWidth: {0}\nHeight: {1}\nFuel Required: {2}\nPhenomena: {3}", initLevelData.levelWidth, initLevelData.levelHeight, initLevelData.jumpFuelAmount, initLevelData.numberOfPhenomenaToSpawn); // Pad width and height by 1 for spawn ring //int _width = initLevelData.levelWidth + 1; //int _height = initLevelData.levelHeight + 1; //levelGrid = new GridBlock[_width, _height]; levelGrid = new GridBlock[initLevelData.levelWidth, initLevelData.levelHeight]; int locationX = BoundaryLeftActual; int locationY = BoundaryBottomActual; for (int i = 0; i < initLevelData.levelWidth; i++) { for (int j = 0; j < initLevelData.levelHeight; j++) { if (j == 0) { locationY = BoundaryBottomActual; } levelGrid[i, j] = new GridBlock(locationX, locationY); if ((locationX == BoundaryLeftActual || locationX == BoundaryRightActual) && locationY != BoundaryTopActual && locationY != BoundaryBottomActual) { eligiblePerimeterSpawns.Add(levelGrid[i, j].location); } else if ((locationX != BoundaryLeftActual && locationX != BoundaryRightActual) && (locationY == BoundaryTopActual || locationY == BoundaryBottomActual)) { eligiblePerimeterSpawns.Add(levelGrid[i, j].location); } else { eligibleInteriorSpawns.Add(levelGrid[i, j].location); } GameObject point = Instantiate ( gridPoint, new Vector3(locationX + offset, locationY + offset, 0f), Quaternion.identity, gridContainer ); levelGrid[i, j].DebugRenderPoint = point; /* OLD CODE TO ALTER LEVELGRID POINT COLORS * if (locationX == BoundaryLeftActual || locationX == BoundaryRightActual) * { * //point.GetComponent<Renderer>().material.color = Color.green; * } * * else if (locationY == BoundaryBottomActual || locationY == BoundaryTopActual) * //point.GetComponent<Renderer>().material.color = Color.green; */ locationY += 1; } locationX += 1; } Debug.Log("Object: [levelGrid] successfully created."); Debug.LogFormat("levelGrid d1 length: {0} \n levelgrid d2 length: {1}", levelGrid.GetLength(0), levelGrid.GetLength(1)); }