public void SetSameAs(CombinedTile ct) { lightTile = ct.lightTile; lightSprites = ct.lightSprites; darkSprites = ct.darkSprites; isPreview = true; SetType(); }
// Level loader public void PlaceTile(CombinedTile tile) { tile.GameObject = Instantiate(tile.Tile.TileObject); tile.GameObject.transform.position = new Vector2(tile.Tile.X, tile.Tile.Y); tile.GameObject.transform.rotation = new Quaternion(0, 0, 0, 1); tile.GameObject.transform.Rotate(0, 0, 90 * tile.Tile.Rotation); if (tile.Tile.Category == "ConveyorBelt") { tile.GameObject.GetComponent <ConveyorBelt>().TileRotation = tile.Tile.Rotation; } Debug.Log("Tile " + tile.Tile.TileObject + " placed at " + tile.Tile.X + " " + tile.Tile.Y + " layer: " + tile.Tile.Layer); }
public void PlaceTile() { if (activeTileIndex != -1 && activeObject != null && activeObjectIndex != -1) { if (editorTexture.transform.position.x >= Mathf.Ceil(levelWidth / -2 + 0.5f) && editorTexture.transform.position.x <= Mathf.Ceil(levelWidth / 2 - 0.5f) && editorTexture.transform.position.y <= Mathf.Ceil(levelHeight / 2 - 0.5f) && editorTexture.transform.position.y >= Mathf.Ceil(levelHeight / -2 + 0.5f)) { CombinedTile temp = levelTiles.Where(obj => obj.Tile.X == (int)ray.x && obj.Tile.Y == (int)ray.y && obj.Tile.Layer == tileLayer).SingleOrDefault <CombinedTile>(); if (temp == null) { temp = new CombinedTile(null, null); temp.Tile = new Tile(activeObjectIndex, activeObject, activeObject.name, tileRotation, tileLayer, (int)ray.x, (int)ray.y, activeObjectProperties.Dimensions, activeObjectProperties.Category); temp.GameObject = Instantiate(activeObject); temp.GameObject.transform.position = new Vector2(ray.x, ray.y); levelTiles.Add(temp); Debug.Log("Tile placed at " + ray.x + " " + ray.y + " layer: " + tileLayer); Debug.Log("Number of tiles saved: " + levelTiles.Count); } else { Debug.Log("Tile already exists. Overwriting..."); Destroy(temp.GameObject); temp.Tile = new Tile(activeObjectIndex, activeObject, activeObject.name, tileRotation, tileLayer, (int)ray.x, (int)ray.y, activeObjectProperties.Dimensions, activeObjectProperties.Category); temp.GameObject = Instantiate(activeObject); temp.GameObject.transform.position = new Vector2(ray.x, ray.y); Debug.Log("Tile replaced at " + ray.x + " " + ray.y + " layer: " + tileLayer); Debug.Log("Number of tiles saved: " + levelTiles.Count); } temp.Tile.Rotation = tileRotation; temp.GameObject.transform.rotation = new Quaternion(0, 0, 0, 1); temp.GameObject.transform.Rotate(0, 0, Mathf.Floor(tileRotation * 90)); } else { Debug.Log("Editor texture is out of level bounds."); } } }
static void SwitchSprite() { Transform[] selection = Selection.transforms; if (selection.Length > 0) { for (int i = 0; i < selection.Length; i++) { CombinedTile dspr = selection[i].GetComponent <CombinedTile>(); if (dspr != null) { dspr.SwitchSprites(); Debug.Log("Switched sprites on selected tiles"); } } } else { Debug.Log("Nothing selected"); } }
static void FlipTileY() { Transform[] selection = Selection.transforms; if (selection.Length > 0) { for (int i = 0; i < selection.Length; i++) { CombinedTile dspr = selection[i].GetComponent <CombinedTile>(); if (dspr != null) { dspr.FlipY(); Debug.Log("Flipped tile on Y on selected tiles"); } } } else { Debug.Log("Nothing selected"); } }