Exemple #1
0
        private void Start()
        {
            randomContentPicker = new Helpers.DynamicRandomSelector <GameObject>();
            randomContentItems.ForEach(item => randomContentPicker.Add(item.contentToSpawn, item.weight));
            randomContentPicker.Build();

            // TODO: const the tags
            var        picked         = randomContentPicker.SelectRandomItem();
            GameObject spawnedContent = Instantiate(picked, transform.position, Quaternion.identity, contentParent.transform);

            spawnedContent.tag = "Content";
        }
        private void Awake()
        {
            // Don't forget to call .Build, otherwise the picker isn't initialised.
            randomBottom = new Helpers.DynamicRandomSelector <GameObject>();
            bottomRooms.ForEach(item => randomBottom.Add(item.roomTemplate, item.weight));
            randomBottom.Build();

            randomTop = new Helpers.DynamicRandomSelector <GameObject>();
            topRooms.ForEach(item => randomTop.Add(item.roomTemplate, item.weight));
            randomTop.Build();

            randomRight = new Helpers.DynamicRandomSelector <GameObject>();
            rightRooms.ForEach(item => randomRight.Add(item.roomTemplate, item.weight));
            randomRight.Build();

            randomLeft = new Helpers.DynamicRandomSelector <GameObject>();
            leftRooms.ForEach(item => randomLeft.Add(item.roomTemplate, item.weight));
            randomLeft.Build();
        }