TileSet.cs 923 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace DunGen
  5. {
  6. /// <summary>
  7. /// A set of tiles with weights to be picked from at random
  8. /// </summary>
  9. [Serializable]
  10. [CreateAssetMenu(menuName = "DunGen/Tile Set", order = 700)]
  11. public sealed class TileSet : ScriptableObject
  12. {
  13. public GameObjectChanceTable TileWeights = new GameObjectChanceTable();
  14. public List<LockedDoorwayAssociation> LockPrefabs = new List<LockedDoorwayAssociation>();
  15. public void AddTile(GameObject tilePrefab, float mainPathWeight, float branchPathWeight)
  16. {
  17. TileWeights.Weights.Add(new GameObjectChance(tilePrefab, mainPathWeight, branchPathWeight, this));
  18. }
  19. public void AddTiles(IEnumerable<GameObject> tilePrefab, float mainPathWeight, float branchPathWeight)
  20. {
  21. foreach (var tile in tilePrefab)
  22. AddTile(tile, mainPathWeight, branchPathWeight);
  23. }
  24. }
  25. }