public override void Initialise(WorldManager worldManager) { seed = worldSeed + (int)transform.position.x + (int)transform.position.y; System.Random random = new System.Random(seed); if (randomiseDirection) { direction = (Village.Direction)random.Next(0, 4); } if (!usePrefabBuilding) { Array type = Enum.GetValues(typeof(BuildingType)); Array size = Enum.GetValues(typeof(BuildingSize)); buildingType = (BuildingType)type.GetValue(random.Next(type.Length)); buildingSize = (BuildingSize)type.GetValue(random.Next(size.Length)); base.Initialise(worldManager); } else { if (useRandomPrefabBuilding) { prefab = worldManager.buildingPrefabs[random.Next(0, worldManager.buildingPrefabs.Length)]; } Generate(prefab); } StartCoroutine(SpawnCollectable()); }
public void PlaceBuilding(Vector3Int position, TilemapPrefab building) { var go = Instantiate(buildingPrefab, position, Quaternion.identity); var v = go.GetComponent <Building>(); v.Initialise(worldSeed, building, Village.Direction.Up); }
public void Initialise(int seed, TilemapPrefab building, Village.Direction direction) { this.seed = seed + (int)transform.position.x + (int)transform.position.y; //System.Random rand = new System.Random(this.seed); prefab = building; this.direction = direction; Generate(prefab); StartCoroutine(SpawnCollectable()); }
public void Initialise(int seed, TilemapPrefab[] potentialBuildings, Village.Direction direction) { this.seed = seed + (int)transform.position.x + (int)transform.position.y; System.Random rand = new System.Random(this.seed); prefab = potentialBuildings[rand.Next(0, potentialBuildings.Length)]; this.direction = direction; Generate(prefab); StartCoroutine(SpawnCollectable()); }
public void Generate(TilemapPrefab prefab) { if (prefab.isSet && prefab != null) { TilemapData data = new TilemapData() { tilePositions = new Vector3Int[prefab.tilePositions.Length], tiles = prefab.tiles }; for (int i = 0; i < prefab.tilePositions.Length; i++) { var oldPos = prefab.tilePositions[i]; Vector3Int newPos; //Rotate switch (direction) { default: case Village.Direction.Up: newPos = oldPos; break; case Village.Direction.Down: newPos = oldPos * -1; break; case Village.Direction.Right: newPos = new Vector3Int(oldPos.y, -oldPos.x, 0); break; case Village.Direction.Left: newPos = new Vector3Int(-oldPos.y, oldPos.x, 0); break; } newPos += Vector3Int.RoundToInt(transform.position); data.tilePositions[i] = newPos; } ObjectStore.instance.mapDisplay.DrawVillage(data); } else { Debug.LogWarning("prefab is not suitable"); } }
public void DrawBuilding(TilemapPrefab villageData) { ObjectStore.instance.villageMap.SetTiles(villageData.tilePositions, villageData.tiles); }