private void generateWorld() { TempLoader temp = new TempLoader(); graphics = GameObject.Find("BoardObject").GetComponent <BoardGraphics>(); TileManager tileManager = new TileManager(tileI, tileJ, tileSize, graphics, temp); tM = tileManager; continents = new List <Continent>(); generateContinents(tM.getTileList()); generateCountries(); }
public TileManager(int ntileI, int ntileJ, float ntileSize, BoardGraphics graphics, TempLoader temp) { tileI = ntileI; tileJ = ntileJ; tileSize = ntileSize; graphics.setup(tileI * tileJ); tileHeight = tileSize * 2; tileWidth = Mathf.Sqrt(3) / 2 * tileHeight; mapX = tileWidth * (float)tileI; tileList = new List <Tile>(); vertexList = new List <Vertex>(); edgeList = new List <Edge>(); tileDictQRS = new Dictionary <int, Dictionary <int, Tile> >(); tileDictIJ = new Dictionary <int, Dictionary <int, Tile> >(); Dictionary <int, Tile> rowListQRS; //Q=X, R=Z, S=Y in the old cube coordinates Dictionary <int, Tile> rowListIJ; int tileCount = 0; for (int j = 0; j < tileJ; j++) { rowListIJ = new Dictionary <int, Tile>(); rowListQRS = new Dictionary <int, Tile>(); tileDictQRS.Add(-j, rowListQRS); tileDictIJ.Add(j, rowListIJ); int offset = Mathf.CeilToInt((float)j / 2); for (int i = 0; i < tileI; i++) { float x_Offset; if (j % 2 == 1) { x_Offset = tileWidth; } else { x_Offset = tileWidth / 2; } int q = i + offset; int s = -(i + offset) + j; int r = -j; bool inWestHalf; if (i <= tileI / 2) { inWestHalf = true; } else { inWestHalf = false; } Tile tile = new Tile(q, r, s, tileWidth * i + x_Offset, (tileSize) + (tileHeight * 0.75f * j), i, j, tileCount, graphics, inWestHalf, mapX); //Debug.Log (i+":"+j); tile.addStockList(temp.setUpStockList()); tile.addPriceList(temp.setUpStockList()); rowListIJ.Add(i, tile); rowListQRS.Add(i + offset, tile); tileList.Add(tile); addVerticesToTile(tile, graphics); addEdgesToTile(tile, graphics); tileCount = tileCount + 1; } } this.addEdgesToVertices(); graphics.setUpEdgeNum(edgeList.Count); graphics.setUpVertexNum(vertexList.Count); graphics.buildCollider(tileList[tileList.Count - 1]); this.wrapAroundMap(); }