예제 #1
0
        public override void Process(System.Random randomStream, Tile tile)
        {
            if (Props.Weights.Count <= 0)
            {
                return;
            }

            var chosenEntry = Props.GetRandom(randomStream, tile.Placement.IsOnMainPath, tile.Placement.NormalizedDepth, null, true, true);
            var prefab      = chosenEntry.Value;

            GameObject newProp = (GameObject)GameObject.Instantiate(prefab);

            newProp.transform.parent = transform;

            if (ZeroPosition)
            {
                newProp.transform.localPosition = Vector3.zero;
            }
            else
            {
                newProp.transform.localPosition = prefab.transform.localPosition;
            }

            if (ZeroRotation)
            {
                newProp.transform.localRotation = Quaternion.identity;
            }
            else
            {
                newProp.transform.localRotation = prefab.transform.localRotation;
            }
        }
예제 #2
0
        private List <GameObjectChance> CalculateOrderedListOfTiles()
        {
            List <GameObjectChance> tiles = new List <GameObjectChance>(TileWeights.Count);

            GameObjectChanceTable table = new GameObjectChanceTable();

            table.Weights.AddRange(TileWeights);

            while (table.Weights.Any(x => x.Value != null && x.GetWeight(IsOnMainPath, NormalizedDepth) > 0.0f))
            {
                tiles.Add(table.GetRandom(RandomStream, IsOnMainPath, NormalizedDepth, null, true, true));
            }

            return(tiles);
        }
예제 #3
0
        public override void Process(System.Random randomStream, Tile tile)
        {
            if (Props.Weights.Count <= 0)
            {
                return;
            }

            var chosenEntry = Props.GetRandom(randomStream, tile.Placement.IsOnMainPath, tile.Placement.NormalizedDepth, null, true, true);
            var prefab      = chosenEntry.Value;

            GameObject newProp = (GameObject)GameObject.Instantiate(prefab);

            newProp.transform.parent        = transform;
            newProp.transform.localPosition = Vector3.zero;
            newProp.transform.localRotation = Quaternion.identity;

            foreach (var childProp in newProp.GetComponentsInChildren <RandomPrefab>())
            {
                childProp.Process(randomStream, tile);
            }
        }