/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> /// <param name="data">If there is custom data pass it here</param> public Tile(int ID, CustomTileData data, TileGameObject assosiateWithThis, Chunk chunk) { tileID = ID; customTileData.Add(data); associatesWithThisGameObject = assosiateWithThis; isInChunk = chunk; }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> /// <param name="data">If there is custom data pass it here</param> public Tile(int ID, List <CustomTileData> data, TileGameObject assosiateWithThis, Chunk chunk) { tileID = ID; customTileData = data; associatesWithThisGameObject = assosiateWithThis; isInChunk = chunk; }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> public Tile(int ID, TileGameObject assosiateWithThis, Chunk chunk, Inventory inv) { tileID = ID; associatesWithThisGameObject = assosiateWithThis; isInChunk = chunk; this.inv = inv; }
public Tile(Tile tile, Inventory inv) { this.tileID = tile.tileID; this.customTileData = tile.customTileData; this.associatesWithThisGameObject = tile.associatesWithThisGameObject; this.inv = inv; }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> /// <param name="data">If there is custom data pass it here</param> public Tile(int ID, List <GameObject> data, TileGameObject assosiateWithThis, Inventory inv) { tileID = ID; customTileData = data; associatesWithThisGameObject = assosiateWithThis; this.inv = inv; }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> /// <param name="data">If there is custom data pass it here</param> public Tile(int ID, GameObject data, TileGameObject assosiateWithThis, Inventory inv) { tileID = ID; customTileData.Add(data); associatesWithThisGameObject = assosiateWithThis; this.inv = inv; }
public void GenerateMap() { if (levelHolder.Find(tileHolderName)) { DestroyImmediate(levelHolder.Find(tileHolderName).gameObject); } GameObject tileHolder = new GameObject(tileHolderName); tileHolder.transform.SetParent(levelHolder); LevelGenerator lg = new LevelGenerator(numberOfTiles, scale, seed, frequencyOfHallwayDiversions, lengthOfHallways); lg.GenerateLevel(); foreach (var room in lg.AllRooms) { GameObject newTileGO = Instantiate(TilePrefab, tileHolder.transform); TileGameObject newTile = newTileGO.GetComponent <TileGameObject>(); newTile.transform.localPosition = new Vector3(room.Position.x, 0, room.Position.y); newTile.DisplayWall(true, LevelGenerator.Direction.All); newTile.tile = room; foreach (var n in newTile.tile.Neighbours) { if (room.Neighbours.Contains(n)) { LevelGenerator.Direction dir = LevelGenerator.GetDirectionBetweenNeighbours(room, n); newTile.DisplayWall(false, dir); } } } }
public Tile(Tile tile) { this.tileID = tile.tileID; this.customTileData = tile.customTileData; this.associatesWithThisGameObject = tile.associatesWithThisGameObject; this.needsUpdate = tile.needsUpdate; this.tileSprite = tile.tileSprite; this.inv = tile.inv; }
public void SpawnChunkInWorld() { GameObject chunkObject = new GameObject("Chunk" + positionClampers.x + ":" + positionClampers.y); chunkObject.transform.position = new Vector2(positionClampers.x, positionClampers.y); for (int i = 0; i < tileArray.GetLength(0); i++) { for (int f = 0; f < tileArray.GetLength(1); f++) { TileGameObject.CreateTileGameObject(tileArray[i, f], i, f, positionClampers.x, positionClampers.y).transform.SetParent(chunkObject.transform); } } }
public TileGameObject OverrideTile(ScriptableTile tile, Matrix4x4 matrix, Vector3Int cellPosition, bool forceUpdate) { RemoveTileAt(cellPosition, forceUpdate); tilemap.SetTile(cellPosition, tile); tilemap.SetTransformMatrix(cellPosition, matrix); TileGameObject result = PlaceTile(tile, cellPosition, forceUpdate); if (tile.neighbourUpdate) { NeighbourgRefresh(cellPosition, forceUpdate); } return(result); }
public void RemoveTileAt(Vector3Int cellPosition, bool forceUpdate) { TileGameObject original = GetObjectsAtTile(cellPosition); if (original != null) { FreeGameObject(original.terrain, cellPosition, forceUpdate); if (tilemap.GetTile <ScriptableTile>(cellPosition).resourceContainer) { TrySavePersistantData(original.building, cellPosition); } FreeGameObject(original.building, cellPosition, forceUpdate); FreeGameObject(original.decoration, cellPosition, forceUpdate); tileObjects.Remove(cellPosition); } }
protected virtual bool Spawn(int x, int y) { if (Manager.Grid[x, y] != BlockEnum.Air) { return(false); } Manager.Grid[x, y] = _block; GameObject = Manager.Instantiate(_prefab.gameObject); _instance = GameObject.GetComponent <TileGameObject>(); UpdateColors(Colors); Manager.GridObject[x, y] = this; GameObject.transform.localPosition = Manager.GridToPosition(x, y) + new Vector3(0.5f, 0.5f, 0); return(true); }
public static BlockBase NewBlock(this BlockEnum block, TileGameObject prefab) { switch (block) { case BlockEnum.Ground: return(new BlockGround(prefab)); case BlockEnum.Spike: return(new BlockSpike(prefab)); case BlockEnum.Powerup: return(new BlockPowerup(prefab)); case BlockEnum.Checkpoint: return(new CheckpointBlock(prefab)); case BlockEnum.Warp: return(new WarpBlock(prefab)); case BlockEnum.End: return(new EndBlock(prefab)); case BlockEnum.Player: return(new PlayerBlock(prefab)); case BlockEnum.Trinket: return(new TrinketBlock(prefab)); case BlockEnum.Object: switch (((CBD_Object)prefab.Data).ObjectType) { case ObjectEnum.Jumper: return(new JumperBlock(prefab)); case ObjectEnum.Tapis: return(new BlockTapis(prefab)); case ObjectEnum.SandBlock: return(new SandBlock(prefab)); case ObjectEnum.Key: return(new KeyBlockEditor(prefab)); case ObjectEnum.KeyBlock: return(new KeyblockBlock(prefab)); case ObjectEnum.Platform: return(new PlatformBlock(prefab)); case ObjectEnum.Monsters: return(new BlockMonster(prefab)); case ObjectEnum.PlatformX: return(new PlatformXYBlock(prefab)); case ObjectEnum.PlatformY: return(new PlatformXYBlock(prefab)); default: return(null); } default: return(null); } }
public PlayerBlock(TileGameObject prefab) : base(prefab) { }
public PlatformXYBlock(TileGameObject prefab) : base(prefab) { }
public TileGameObject PlaceTile(ScriptableTile tile, Vector3Int cellPosition, bool forceUpdate) { TileGameObject tileGameObject = new TileGameObject(); Vector3 tileCenter = GetTileCenter(cellPosition); // ground prefab if (tile.ground) { GameObject terrain = InstantiateGameObject(tile.ground); terrain.transform.localPosition = tileCenter; terrain.transform.localEulerAngles = new Vector3(0, -tilemap.GetTransformMatrix(cellPosition).rotation.eulerAngles.z, 0); terrain.SetActive(true); InitDirt(terrain.GetComponent <Dirt>(), cellPosition); InitWater(terrain.GetComponent <Water>(), cellPosition); InitBridge(terrain.GetComponent <Bridge>(), cellPosition); grid.AddGameObject(terrain, ConstructionLayer.LayerType.Terrain, true, forceUpdate); tileGameObject.terrain = terrain; } // building prefab if (tile.building) { GameObject building = InstantiateGameObject(tile.building); building.transform.localPosition = tileCenter; building.transform.localEulerAngles = new Vector3(0, 90 - tilemap.GetTransformMatrix(cellPosition).rotation.eulerAngles.z, 0); building.SetActive(true); InitWall(building.GetComponent <Wall>(), cellPosition, tile.name); InitFences(building.GetComponent <Fences>(), cellPosition, tile.name); if (tile.resourceContainer) { InitResourceContainer(building, cellPosition); } grid.AddGameObject(building, ConstructionLayer.LayerType.Building, true, forceUpdate); tileGameObject.building = building; } // decoration prefab if (tile.decoration) { GameObject decoration = InstantiateGameObject(tile.decoration); decoration.transform.localPosition = tileCenter + new Vector3(Random.Range(tile.decorationNoisePosition.x, tile.decorationNoisePosition.y), 0, Random.Range(tile.decorationNoisePosition.x, tile.decorationNoisePosition.y)); decoration.transform.localEulerAngles = new Vector3(0, Random.Range(tile.decorationNoiseRotation.x, tile.decorationNoiseRotation.y), 0); float scale = tile.decorationNoiseScale == Vector2.zero ? 1 : Random.Range(tile.decorationNoiseScale.x, tile.decorationNoiseScale.y); decoration.transform.localScale = new Vector3(scale, scale, scale); InitTree(decoration.GetComponent <TreeStandard>(), cellPosition); InitStone(decoration.GetComponent <Stone>(), cellPosition); InitMineral(decoration.GetComponent <MineralRessource>(), cellPosition, tile.optionalMaterial); grid.AddGameObject(decoration, ConstructionLayer.LayerType.Decoration, true, forceUpdate); tileGameObject.decoration = decoration; } if (!tileObjects.ContainsKey(cellPosition)) { tileObjects.Add(cellPosition, tileGameObject); } else { Debug.LogWarning("already a tile Here !!"); } return(tileGameObject); }
public void Action(GridManager gridManager, TileGameObject block, int size, (int, int) mouse)
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> public Tile(int ID, TileGameObject assosiateWithThis, Chunk chunk) { tileID = ID; associatesWithThisGameObject = assosiateWithThis; isInChunk = chunk; }
public BlockSpike(TileGameObject prefab) : base(prefab) { }
public BlockTapis(TileGameObject prefab) : base(prefab) { }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> /// <param name="data">If there is custom data pass it here</param> public Tile(int ID, List <CustomTileData> data, TileGameObject assosiateWithThis) { tileID = ID; customTileData = data; associatesWithThisGameObject = assosiateWithThis; }
public CheckpointBlock(TileGameObject prefab) : base(prefab) { }
public KeyBlockEditor(TileGameObject prefab) : base(prefab) { }
public BlockPowerup(TileGameObject prefab) : base(prefab) { }
public Tile(Tile tile) { this.tileID = tile.tileID; this.customTileData = tile.customTileData; this.associatesWithThisGameObject = tile.associatesWithThisGameObject; }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> public Tile(int ID, TileGameObject assosiateWithThis) { tileID = ID; associatesWithThisGameObject = assosiateWithThis; }
public EndBlock(TileGameObject prefab) : base(prefab) { }
void Start() { tileGameObject = gameObject.GetComponent <TileGameObject>(); }
public void setTile(TileGameObject t) { tile = t; }
/// <summary> /// Constructor of the Tile /// </summary> /// <param name="ID">ID of the tile</param> /// <param name="data">If there is custom data pass it here</param> public Tile(int ID, CustomTileData data, TileGameObject assosiateWithThis) { tileID = ID; customTileData.Add(data); associatesWithThisGameObject = assosiateWithThis; }