public void PickUpGridObject(GameObject obj) { FreeTile newTile = (FreeTile)Instantiate(freeTilePrefab, obj.transform.position, obj.transform.rotation); newTile.SetMaterial(obj.GetComponent <Renderer>().material); newTile.SetMaterialValue(.7f); gameManager.ReplaceBoardTile(obj.GetComponent <Tile>(), newTile); PickUpObject(obj); }
protected void createFreeTileRectangle(int x, int y, int width, int height, int level, bool push, bool locked) { for (int i = x; i < x + width; i++) { for (int j = y; j < y + height; j++) { tileMap[level][i, j] = new FreeTile(push, locked); } } }
protected void fillMap() { for (int i = 0; i < levels; i++) { for (int j = 0; j < width; j++) { for (int k = 0; k < height; k++) { tileMap[i][j, k] = new FreeTile(false, false); } } } }
public void Update(SizeF size) { var center = new PointF(size.Width / 2f, size.Height / 2f); var c = new SizeF(center); var a = Math.Min(size.Width, size.Height) / 9; var sqrt3 = (float)Math.Sqrt(3); fieldHexagons = new Dictionary <int, HexagonView> { { 0, new HexagonView(a, new PointF(3 * a, sqrt3 * a) + c, fieldHexagonStyle) }, { 1, new HexagonView(a, new PointF(3 * a, 0) + c, fieldHexagonStyle) }, { 2, new HexagonView(a, new PointF(3 * a, -sqrt3 * a) + c, fieldHexagonStyle) }, { 3, new HexagonView(a, new PointF(1.5f * a, 1.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 4, new HexagonView(a, new PointF(1.5f * a, 0.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 5, new HexagonView(a, new PointF(1.5f * a, -0.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 6, new HexagonView(a, new PointF(1.5f * a, -1.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 7, new HexagonView(a, new PointF(0, 2 * sqrt3 * a) + c, fieldHexagonStyle) }, { 8, new HexagonView(a, new PointF(0, sqrt3 * a) + c, fieldHexagonStyle) }, { 9, new HexagonView(a, new PointF(0, 0) + c, fieldHexagonStyle) }, { 10, new HexagonView(a, new PointF(0, -sqrt3 * a) + c, fieldHexagonStyle) }, { 11, new HexagonView(a, new PointF(0, -2 * sqrt3 * a) + c, fieldHexagonStyle) }, { 12, new HexagonView(a, new PointF(-1.5f * a, 1.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 13, new HexagonView(a, new PointF(-1.5f * a, 0.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 14, new HexagonView(a, new PointF(-1.5f * a, -0.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 15, new HexagonView(a, new PointF(-1.5f * a, -1.5f * sqrt3 * a) + c, fieldHexagonStyle) }, { 16, new HexagonView(a, new PointF(-3 * a, sqrt3 * a) + c, fieldHexagonStyle) }, { 17, new HexagonView(a, new PointF(-3 * a, 0) + c, fieldHexagonStyle) }, { 18, new HexagonView(a, new PointF(-3 * a, -sqrt3 * a) + c, fieldHexagonStyle) } }; gameTiles = new Dictionary <int, TileView>(); foreach (var tile in game.GetTiles()) { var fieldHexagon = fieldHexagons[tile.Key].Hexagon; var tileView = new TileView(tile.Value, fieldHexagon.Edge /*a*/, fieldHexagon.Center, tilesHexagonStyle); gameTiles.Add(tile.Key, tileView); } //TODO: Consider Update _vs_ create new //freeTile = new TileView(game.NewTile/*freeTile.Tile*/, a, freeTile.Hexagon.Center, tilesHexagonStyle); FreeTile?.Update(a); }