public static void PlaceTile(Coordinate coordinate, TID id, TileBehavior behavior, int spriteIndex) { Tile oldTile = tree.GetTile(coordinate); if (oldTile.IsFilled()) { return; } tree.InsertTile(coordinate, id, behavior != null, spriteIndex); if (behavior != null) { behavior.coordinate = coordinate; behavior.Initialize(); tileBehaviors[coordinate] = behavior; } worldRenderer.UpdateAtCoordinate(coordinate); }
// Use this for initialization void Start() { tiles = new List <GameObject>(); int boardWidth = boardSize - 1; for (int q = -boardWidth; q < boardSize; q++) { int rLowBound = -boardWidth - q; int rHighBound = boardWidth; if (q > 0) { rLowBound = -boardWidth; rHighBound = boardWidth - q; } for (int r = rLowBound; r < rHighBound + 1; r++) { VectorHex posHex = new VectorHex(q, r); Vector2 cartCoord = HexToCart(posHex); GameObject newTile = Instantiate(boardTile, board.transform); newTile.transform.position = new Vector3(cartCoord.x, 0f, cartCoord.y); TileBehavior tb = newTile.GetComponentInChildren <TileBehavior>(); tb.Initialize(posHex); tiles.Add(newTile); } } /* * for (int i = 0; i < boardSize; i++) * { * * * * } */ UIManager.Instance.Initialize(); }