Example #1
0
    public void PlaceRandomObjects(string seed)
    {
        System.Random pseudoRandom = new System.Random(seed.GetHashCode());

        for (int i = 0; i < floorTilesPos.Count; i++)
        {
            GameObject objectToPlace = null;

            do
            {
                objectToPlace = ObjectFromPercentage(pseudoRandom.Next(0, 4000));
            } while (!ObjectManager.CanPlaceObject(objectToPlace));


            if (objectToPlace != null)
            {
                Vector3    objectPos     = new Vector3(floorTilesPos[i].x, floorTilesPos[i].y + 1f, floorTilesPos[i].z);
                GameObject spawnedObject = Instantiate(objectToPlace, objectPos, Quaternion.identity) as GameObject;

                ObjectManager.AddToLevelObjects(spawnedObject);

                if (spawnedObject.name == "SpawnPoint(Clone)" && spawnPoint == null)
                {
                    spawnPoint = spawnedObject;
                }
            }
        }

        SpawnPlayer();
    }