Beispiel #1
0
    void GenerateRooms()
    {
        int i             = 0;
        int roomCount     = Synched.Next(MIN_ROOM_COUNT, MAX_ROOM_COUNT + 1);
        int lootRoomCount = 0;

        int w;
        int h;
        int r;

        int ox;
        int oz;

        int iterations = 0;

        while (rooms.Count < roomCount)
        {
            if (iterations == 5000)
            {
                Debug.LogWarning("Dungeon.Generate() is looping!");
                break;
            }

            w = Synched.Next(MIN_ROOM_SIZE, MAX_ROOM_SIZE + 1);
            h = Synched.Next(MIN_ROOM_SIZE, MAX_ROOM_SIZE + 1);

            while (w % 2 != 0)
            {
                w = Synched.Next(MIN_ROOM_SIZE, MAX_ROOM_SIZE + 1);
            }
            while (h % 2 != 0)
            {
                h = Synched.Next(MIN_ROOM_SIZE, MAX_ROOM_SIZE + 1);
            }

            ox = Synched.Next(1, size - w - 2);
            oz = Synched.Next(1, size - h - 2);

            if (SquareRoom.Validate(ox, oz, i, w, h))
            {
                if (i == 0)
                {
                    rooms.Add(new SquareRoom(ox, oz, i, w, h, RegionProfile.Entrance));
                }
                else if (i >= (roomCount / 2) && lootRoomCount < MAX_LOOT_ROOMS)
                {
                    lootRoomCount++;
                    rooms.Add(new SquareRoom(ox, oz, i, w, h, RegionProfile.Treasure));
                }
                else
                {
                    rooms.Add(new SquareRoom(ox, oz, i, w, h, RegionProfile.Generic));
                }

                i++;
            }

            iterations++;
        }
    }
Beispiel #2
0
 static Mission GenerateKillMission()
 {
     return
         (new Mission(
              "Kill Quest",
              new KillTask(
                  Synched.Next(Mathf.Min(KILL_MIN_COUNT, GameManager.actorCount + 1),
                               Mathf.Max(KILL_MIN_COUNT, GameManager.actorCount + 1)))));
 }
Beispiel #3
0
    public void Initialize(ItemType[] whitelist, ItemRarity maxRarity)
    {
        _items = new Item[Synched.Next(0, 2)];

        //for (int i = 0; i < _items.Length; i++)
        //    _items[i] = Synched.Next(0, 2 + 1) == 2 ? null : ItemGenerator.Get(maxRarity, whitelist);

        _isEmpty = _items.Length == 0 || _items.All(i => i == null);
    }
Beispiel #4
0
    void Awake()
    {
        getInstance = this;

        Synched.SetSeed((int)DateTime.Now.Ticks);

        ItemGenerator.Initialize();
        InitializeCategories();
        InitializeDebugPlayerData();
    }
Beispiel #5
0
    void Start()
    {
        VFX.Initialize();
        ItemGenerator.Initialize();

        GridManager.Initialize();

        Synched.SetSeed(Random.Range(0, int.MaxValue));

        GameManager.Initialize();
    }
Beispiel #6
0
 static void CreateDecals()
 {
     for (int i = 0; i < _region.tiles.Count; i++)
     {
         if (Synched.Next(0f, 1f) <= _region.template.puddleDensity)
         {
             Object.Instantiate(_region.template.puddles.Random(), _region.GetTiles(TileStatus.Vacant)[i].position, Quaternion.Euler(0f, Synched.Next(0f, 360f), 0f), null);
         }
         //else if (Synched.Next(0f, 1f) <= _region.template.dirtDensity)
         //    Object.Instantiate(_region.template.dirt.Random(), _region.tiles[i].position, Quaternion.Euler(0f, Synched.Next(0f, 360f), 0f), null);
     }
 }
Beispiel #7
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (_useNetworkedRandom)
        {
            _value = _useFloatingPointPrecision ? Synched.Next((float)_min, _max + 1) : Synched.Next(_min, _max + 1);
        }
        else
        {
            _value = _useFloatingPointPrecision ? Random.Range((float)_min, _max + 1) : Random.Range(_min, _max + 1);
        }

        animator.SetFloat(_parameter, _value);
    }
Beispiel #8
0
    static void CreatePillars()
    {
        Tile o = Grid.Get(_room.centerX, _room.centerZ);

        int totalWidth  = (_room.centerX - _room.originX) * 2;
        int totalHeight = (_room.centerZ - _room.originZ) * 2;

        //how far in from edge
        int insetX = Synched.Next(2, 3 + 1);
        int insetZ = Synched.Next(2, 3 + 1);

        int width  = totalWidth - (insetX * 2);
        int height = totalHeight - (insetZ * 2);

        int stepX = Synched.Next(2, (width / 2) + 1);
        int stepZ = Synched.Next(2, (height / 2) + 1);

        while (width % stepX != 0)
        {
            stepX = Synched.Next(2, (width / 2) + 1);
        }
        while (height % stepZ != 0)
        {
            stepZ = Synched.Next(2, (height / 2) + 1);
        }

        for (int x = _room.originX + insetX; x <= _room.originX + width + insetX; x += stepX)
        {
            for (int z = _room.originZ + insetZ; z <= _room.originZ + height + insetZ; z += stepZ)
            {
                if (x == _room.originX + insetX || x == _room.originX + width + insetX || z == _room.originZ + insetZ || z == _room.originZ + height + insetZ)
                {
                    Tile t = Grid.Get(x, z);

                    if (t.status != TileStatus.Vacant)
                    {
                        continue;
                    }

                    if (Synched.Next(0f, 1f) <= _room.template.pillarSpawnProbability)
                    {
                        Spawn(_room.template.pillars.Random(), t, Quaternion.Euler(0, Synched.Next(0, 3 + 1) * 90, 0));
                    }
                    //else if (_region.template.statues.Length > 0 && Synched.Next(0f, 1f) <= _room.template.statueSpawnProbability)
                    //    Spawn(_room.template.statues.Random(), t, Quaternion.Euler(0, Synched.Next(0, 3 + 1) * 90, 0));
                }
            }
        }
    }
Beispiel #9
0
    static void CreateLoot()
    {
        if (_region.template.lootSpawnProbability == 0f)
        {
            return;
        }

        for (int i = 0; i < _region.GetTiles(TileStatus.Vacant).Length; i++)
        {
            if (Synched.Next(0f, 1f) <= _region.template.lootSpawnProbability)
            {
                Spawn(_table.loot.Random(), _region.GetTiles(TileStatus.Vacant)[i], Quaternion.Euler(0f, Synched.Next(0f, 360f), 0f));
            }
        }
    }
Beispiel #10
0
    public Dungeon()
    {
        this.size = Synched.Next(MIN_MAP_SIZE, MAX_MAP_SIZE + 1);

        this.rooms   = new List <Room>();
        _connections = new List <Connection>();

        _lootTable = Resources.LoadAll <LootTable>("Collections/Loot Tables/").Random();

        GlobalEvents.Raise(GlobalEvent.SetLoadingBarProgress, 0f);
        GlobalEvents.Raise(GlobalEvent.SetLoadingBarText, "Initializing grid...");
        Grid.Initialize(size);

        Generate();
        Instantiate();
    }
Beispiel #11
0
    void GenerateConnection(Tile from, Tile to, int thickness)
    {
        List <Tile> tiles = new List <Tile>();

        //randomize which L shape
        if (Synched.Next(0, 1 + 1) == 1)
        {
            tiles.AddRange(CreateHorizontalConnection(from, to, from, thickness));
            tiles.AddRange(CreateVerticalConnection(from, to, to, thickness));
        }
        else
        {
            tiles.AddRange(CreateVerticalConnection(from, to, to, thickness));
            tiles.AddRange(CreateHorizontalConnection(from, to, from, thickness));
        }

        _connections.Add(new Connection(tiles, new ConnectionType[] { ConnectionType.Corridor, ConnectionType.Bridge }.RandomWeighted(75, 25)));
    }
Beispiel #12
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.M))
     {
         Player.storage.Add(ItemGenerator.GetWeapon((WeaponType)Synched.Next(0, Enum.GetNames(typeof(WeaponType)).Length), ItemRarity.Common));
         UpdateStorage();
     }
     if (Input.GetKeyDown(KeyCode.N))
     {
         Player.storage.Add(ItemGenerator.GetArmour((EquipSlot)Synched.Next(2, Enum.GetNames(typeof(EquipSlot)).Length), ItemRarity.Common));
         UpdateStorage();
     }
     if (Input.GetKeyDown(KeyCode.B))
     {
         Player.storage.Add(ItemGenerator.GetLightSource(ItemRarity.Common));
         UpdateStorage();
     }
 }
Beispiel #13
0
    public static Tile GetRandom(params TileStatus[] filter)
    {
        int  iterations = 0;
        Tile t          = _tiles[Synched.Next(0, _tiles.GetLength(0)), Synched.Next(0, _tiles.GetLength(1))];

        while (!filter.Contains(t.status))
        {
            if (iterations > 5000)
            {
                UnityEngine.Debug.LogWarning("Grid.GetRandom() is probably looping!");
                return(null);
            }

            t = _tiles[Synched.Next(0, _tiles.GetLength(0)), Synched.Next(0, _tiles.GetLength(1))];
            iterations++;
        }

        return(t);
    }
Beispiel #14
0
    void UpdateModel(ActorData data, int index)
    {
        if (data == null)
        {
            Player.party[index] = null;

            _models[index].gameObject.SetActive(false);
            _troopListItems[index].transform.Find("name").GetComponent <Text>().text = "EMPTY TROOP SLOT";
        }
        else
        {
            Player.party[index] = data;

            _models[index].gameObject.SetActive(true);
            _models[index].SetActorData(data);
            _models[index].GetComponentInChildren <Animator>().SetFloat("idle", int.Parse(_models[index].transform.parent.tag));
            _models[index].GetComponentInChildren <Animator>().SetFloat("random", Synched.Next(0, 2));
            _troopListItems[index].transform.Find("name").GetComponent <Text>().text = data.name;
        }
    }
Beispiel #15
0
    void GenerateConnections()
    {
        //Prim's MST alg
        //not really an mst lol
        List <Tile> mst = new List <Tile>();

        for (int i = 0; i < rooms.Count; i++)
        {
            Tile rt = Grid.Get(rooms[i].centerX, rooms[i].centerZ);
            mst.Add(rt);

            Tile  closest  = null;
            float distance = Mathf.Infinity;

            for (int j = 0; j < rooms.Count; j++)
            {
                //ignore self
                if (rooms[i] == rooms[j])
                {
                    continue;
                }

                Tile  t = Grid.Get(rooms[j].centerX, rooms[j].centerZ);
                float d = Pathfinder.Distance(rt, t);

                if (closest == null || d < distance)
                {
                    closest  = t;
                    distance = d;
                }
            }

            mst.Add(closest);
        }
        for (int i = 1; i < mst.Count; i++)
        {
            GenerateConnection(mst[i - 1], mst[i], Synched.Next(0, 5 + 1) == 5 ? 3 : 2);
        }
    }
Beispiel #16
0
    public static T RandomWeighted <T>(this T[] array, params int[] weights)
    {
        UnityEngine.Debug.Assert(array.Length == weights.Length, "RandomWeighted(): object array length does not match weights array length!");

        int sum = 0;

        for (int i = 0; i < weights.Length; i++)
        {
            sum += weights[i];
        }

        int roll = Synched.Next(0, sum);

        for (int i = 0; i < array.Length; i++)
        {
            if (roll < weights[i])
            {
                return(array[i]);
            }

            roll -= weights[i];
        }

        return(default);
Beispiel #17
0
    static GameObject Spawn(GameObject prefab, Tile origin, Quaternion rotation, Transform parent = null)
    {
        GameObject    g      = Object.Instantiate(prefab, origin.position, rotation);
        PCGEntityData data   = g.GetComponent <PCGEntityData>();
        Entity        entity = g.GetComponentInChildren <Entity>();

        if (data == null)
        {
            Debug.LogWarning("'" + prefab.name + "' is missing a PCGEntityData-component!", prefab);
            return(g);
        }

        if (data.subEntities.Length > 0)
        {
            for (int i = 0; i < data.subEntities.Length; i++)
            {
                if (data.subEntities[i].ignoreSpawnProbability || Synched.Next(0f, 1f) <= _region.template.subEntitiyDensities[(int)data.subEntities[i].type])
                {
                    //spawn random object from list
                    //randomize offset from parameters
                    //randomize rotation from parameters relative to subentity rotation
                    //parent under root, IMPORTANT, subentity placeholder object will be removed
                    GameObject sg = Object.Instantiate(
                        data.subEntities[i].prefabs.Random(),
                        data.subEntities[i].transform.position + new Vector3(
                            Synched.Next(-data.subEntities[i].spawnOffset.x, data.subEntities[i].spawnOffset.x),
                            Synched.Next(-data.subEntities[i].spawnOffset.y, data.subEntities[i].spawnOffset.y),
                            Synched.Next(-data.subEntities[i].spawnOffset.z, data.subEntities[i].spawnOffset.z)),
                        Quaternion.Euler(
                            Synched.Next(0, data.subEntities[i].rotationOffset.x),
                            Synched.Next(0, data.subEntities[i].rotationOffset.y),
                            Synched.Next(0, data.subEntities[i].rotationOffset.z))
                        * data.subEntities[i].transform.rotation,
                        g.transform);

                    //randomize scale - uniformly
                    float scale = Synched.Next(-data.subEntities[i].scaleVariance, data.subEntities[i].scaleVariance);
                    sg.transform.localScale += new Vector3(scale, scale, scale);
                }

                //cleanup junk
                Object.Destroy(data.subEntities[i].gameObject);
            }
        }

        //this is in f*****g world space jfc
        //gonna need to transform this relative to rotation of entity somehow
        //... later
        origin.SetStatus(data.blocksTile ? TileStatus.Blocked : TileStatus.Vacant);
        origin.SetBlocksLineOfSight(data.blocksLineOfSight);

        //for (int x = data.negativeSize.x; x <= data.positiveSize.x; x++)
        //{
        //    for (int z = data.negativeSize.y; z <= data.positiveSize.y; z++)
        //    {
        //        Tile t = Grid.Get(origin.x + x, origin.z + z);

        //        if (t != null)
        //        {
        //            t.SetStatus(data.blocksTile ? TileStatus.Blocked : TileStatus.Vacant);
        //            t.SetBlocksLineOfSight(data.blocksLineOfSight);
        //        }
        //    }
        //}

        entity?.SetPosition(origin);

        //cleanup junk
        Object.Destroy(data);
        return(g);
    }
Beispiel #18
0
 static void CreateTreasureRoom()
 {
     //todo add more stuff here later on
     Spawn(_room.template.specific.Random(), Grid.Get(_room.centerX, _room.centerZ), Quaternion.Euler(0, Synched.Next(0, 3 + 1) * 90, 0));
 }
Beispiel #19
0
 static void CreateGeneric()
 {
     if (_room.template.specific.Length > 0)
     {
         Spawn(_room.template.specific.Random(), Grid.Get(_room.centerX, _room.centerZ), Quaternion.Euler(0, Synched.Next(0, 3 + 1) * 90, 0));
     }
 }
Beispiel #20
0
    static void InstantiateWalls()
    {
        GameObject walls = new GameObject("walls");

        for (int i = 0; i < _region.edges.Count; i++)
        {
            //create walls
            int x = _region.edges[i].x;
            int z = _region.edges[i].z;

            for (int j = 0; j < directions.Length; j++)
            {
                x = _region.edges[i].x + directions[j].x;
                z = _region.edges[i].z + directions[j].y;

                if (x < 0 || x > Grid.size - 1 || z < 0 || z > Grid.size - 1)
                {
                    continue;
                }
                else
                {
                    GameObject g = null;
                    //we're stepping on something that's non-void
                    if (Grid.Get(x, z).index != -1)
                    {
                        //if were stepping on something thats not void and not part of our room
                        //currently just creating doors
                        //will be replaced with a method that takes a continuous line of tiles
                        //creates doors in the middle, and door-neighbours on the sides
                        if (Grid.Get(_region.edges[i].x, _region.edges[i].z).index != Grid.Get(x, z).index)
                        {
                            g = Spawn(_region.template.doors.Random(), Grid.Get(x, z), Quaternion.identity, walls.transform);
                        }
                        //g = Object.Instantiate(_room.template.doors.Random(), Grid.Get(x, z).position, Quaternion.identity, walls.transform);
                    }
                    else
                    {
                        g = Spawn(_region.template.walls.Random(), Grid.Get(x, z), Quaternion.identity, walls.transform);
                    }
                    //g = Object.Instantiate(_room.template.walls.Random(), Grid.Get(x, z).position, Quaternion.identity, walls.transform);

                    //wtf happens that neccesitates this check?
                    if (g == null)
                    {
                        continue;
                    }

                    MeshFilter   mf = g.GetComponentInChildren <MeshFilter>();
                    MeshRenderer mr = g.GetComponentInChildren <MeshRenderer>();

                    //randomize vertex alpha color using perlin for vertex blending in materials
                    Color[] colors = new Color[mf.mesh.vertexCount];

                    for (int k = 0; k < colors.Length; k++)
                    {
                        colors[k] = new Color(1, 1, 1, Mathf.PerlinNoise(mf.mesh.vertices[k].x, mf.mesh.vertices[k].y));
                    }

                    mf.mesh.SetColors(colors.ToList());

                    //will probably initiate meshes with "REPLACE_ME" material
                    //for easier material swapping
                    for (int l = 0; l < mr.materials.Length; l++)
                    {
                        if (mr.materials[l].IsKeywordEnabled("_BlendStrength"))
                        {
                            mr.materials[l].SetFloat("_BlendStrength", Mathf.Clamp(Synched.Next(_region.template.averageDirtiness - _region.template.dirtinessVariance, _region.template.averageDirtiness + _region.template.averageDirtiness), -1f, 1f));
                        }
                    }

                    g.transform.LookAt(_region.edges[i].position, Vector3.up);
                }
            }
        }
    }
Beispiel #21
0
    void Update()
    {
        if (GameManager.turnIndex != 0)
        {
            return;
        }

        if (_inTargetingMode)
        {
            //confirm target selection
            if (Input.GetKeyDown(KeyCode.Space))
            {
                GlobalEvents.Raise(GlobalEvent.ExitTargetingMode, true);
            }
            //exit target selection
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                GlobalEvents.Raise(GlobalEvent.ExitTargetingMode, false);
            }
        }
        else
        {
            UpdateCurrentTile();

            if (Player.selectedActor.isBusy)
            {
                return;
            }

            //iterate alphas
            for (int i = 0; i < _alphaKeys.Length; i++)
            {
                if (Input.GetKeyDown(_alphaKeys[i]))
                {
                    GlobalEvents.Raise(GlobalEvent.HotkeyPressed, i);
                }
            }

            if (Input.GetKeyDown(KeyCode.M))
            {
                Player.selectedActor.data.SetEquipment(ItemGenerator.GetWeapon((WeaponType)Synched.Next(0, System.Enum.GetNames(typeof(WeaponType)).Length), ItemRarity.Common));
            }
            if (Input.GetKeyDown(KeyCode.N))
            {
                Player.selectedActor.data.SetEquipment(ItemGenerator.GetArmour((EquipSlot)Synched.Next(2, System.Enum.GetNames(typeof(EquipSlot)).Length), ItemRarity.Common));
            }
            if (Input.GetKeyDown(KeyCode.B))
            {
                Player.selectedActor.data.AddSpell(ItemGenerator.GetSpellRandom());
            }
            if (Input.GetKeyDown(KeyCode.V))
            {
                Player.selectedActor.data.SetEquipment(ItemGenerator.GetLightSource(ItemRarity.Common));
            }
            if (Input.GetKeyDown(KeyCode.K))
            {
                Player.selectedActor.SetItemIfOpen(ItemGenerator.GetPotion(ItemRarity.Common));
            }
            if (Input.GetKeyDown(KeyCode.I))
            {
                GlobalEvents.Raise(GlobalEvent.ToggleInventory);
            }
            else if (Input.GetKeyDown(KeyCode.C))
            {
                GlobalEvents.Raise(GlobalEvent.ToggleCharacter);
            }

            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                ProcessLeftClick();
            }
            else if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                ProcessRightClick();
            }
            else if (Input.GetKeyDown(KeyCode.Space))
            {
                new EndTurnCommand().Execute();
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                GlobalEvents.Raise(GlobalEvent.ToggleMovement);
            }
            else if (Input.GetKeyDown(KeyCode.Tab))
            {
                GlobalEvents.Raise(GlobalEvent.ToggleGridVisibility);
            }
        }
    }
Beispiel #22
0
 public int GetDamageRoll()
 {
     return(Synched.Next(this.minDamage, this.maxDamage + 1));
 }
 public VitalModifierCollectionEntry GetRandom()
 {
     return(_entries[Synched.Next(0, _entries.Length)]);
 }
Beispiel #24
0
    void InitializeDebugPlayerData()
    {
        for (int i = 0; i < Player.characters.Length; i++)
        {
            if (Player.characters[i] == null)
            {
                Player.characters[i] = Resources.Load <ActorTemplate>("ActorTemplates/player").Instantiate();

                //weapons
                Player.characters[i].SetEquipment(ItemGenerator.GetWeapon((WeaponType)Synched.Next(0, Enum.GetNames(typeof(WeaponType)).Length), ItemRarity.Common));

                for (int j = 2; j < Enum.GetNames(typeof(EquipSlot)).Length; j++)
                {
                    Player.characters[i].SetEquipment(ItemGenerator.GetArmour((EquipSlot)j, ItemRarity.Common));
                }
            }
        }
    }
Beispiel #25
0
    //static void CreateDiningArea()
    //{
    //    //get center
    //    Tile c = Grid.Get(_room.centerX, _room.centerZ);

    //    //buffer from edge
    //    int bufferX = _room.centerX - _room.originX - 4;
    //    int bufferZ = _room.centerZ - _room.originZ - 4;

    //    //table alignment direction, so they all place more or less in line
    //    Vector3 tableAlignment = new Vector3(0, Synched.Next(0, 3 + 1) * 90, 0);
    //    bool alignmentIsHorizontal = tableAlignment.y != 90 && tableAlignment.y != 270;

    //    for (int x = _room.centerX - bufferX; x <= _room.centerX + bufferX; x += alignmentIsHorizontal ? 2 : 4)
    //    {
    //        for (int z = _room.centerZ - bufferZ; z <= _room.centerZ + bufferZ; z += alignmentIsHorizontal ? 4 : 2)
    //        {
    //            //add random chance to skip a table
    //            if (Synched.Next(0, 4 + 1) == 4)
    //                continue;

    //            //create table
    //            Tile t = Grid.Get(x, z);

    //            Spawn(_room.template.tables.Random(), t, Quaternion.Euler(0, tableAlignment.y, 0));

    //            for (int chairX = x - 1; chairX <= x + (alignmentIsHorizontal ? 0 : 1); chairX++)
    //            {
    //                for (int chairZ = z - 1; chairZ <= z + (alignmentIsHorizontal ? 1 : 0); chairZ++)
    //                {
    //                    //skip positions, also introduce 25% of chair missing, for more atmosphere
    //                    if (alignmentIsHorizontal && chairZ == z || !alignmentIsHorizontal && chairX == x || Synched.Next(0, 3 + 1) == 3)
    //                        continue;

    //                    Tile ct = Grid.Get(chairX, chairZ);

    //                    Quaternion rotation = Quaternion.LookRotation(t.position - ct.position);
    //                    rotation *= Quaternion.Euler(0, Synched.Next(-15, 15), 0);

    //                    Spawn(_room.template.chairs.Random(), ct, rotation, null);
    //                }
    //            }
    //        }
    //    }
    //}
    //static void CreateKitchen()
    //{

    //}
    //static void CreateLibrary()
    //{
    //    Tile c = Grid.Get(_room.centerX, _room.centerZ);

    //    //buffer from edge
    //    int bufferX = _room.centerX - _room.originX - 3;
    //    int bufferZ = _room.centerZ - _room.originZ - 3;

    //    Vector3 shelfAlignment = new Vector3(0, Synched.Next(0, 3 + 1) * 90, 0);
    //    bool alignmentIsHorizontal = shelfAlignment.y != 90 && shelfAlignment.y != 270;

    //    for (int x = _room.centerX - bufferX; x <= _room.centerX + bufferX; x += alignmentIsHorizontal ? 2 : 4)
    //    {
    //        for (int z = _room.centerZ - bufferZ; z <= _room.centerZ + bufferZ; z += alignmentIsHorizontal ? 4 : 2)
    //        {
    //            //small chance of skipping shelf
    //            if (Synched.Next(0, 4 + 1) == 4)
    //                continue;

    //            //create table
    //            Spawn(_room.template.shelves.Random(), Grid.Get(x, z), Quaternion.Euler(0, shelfAlignment.y, 0));
    //        }
    //    }
    //}
    //static void CreateChapel()
    //{
    //    //make the rostrum first
    //    Tile t = Grid.Get(_room.centerX, _room.centerZ);
    //    Spawn(_room.template.specific.Random(), t, Quaternion.Euler(0, Synched.Next(0, 3 + 1) * 90, 0), null);

    //    int bufferX = _room.centerX - _room.originX - 2;
    //    int bufferZ = _room.centerZ - _room.originZ - 2;

    //    //make pews
    //    for (int x = _room.centerX - bufferX; x <= _room.centerX + bufferX; x += 3)
    //    {
    //        for (int z = _room.centerZ - bufferZ; z <= _room.centerZ + bufferZ; z += 3)
    //        {
    //            if (Mathf.Abs(x) - _room.centerX < 2 && Mathf.Abs(z) - _room.centerZ < 2 || Synched.Next(0, 3 + 1) == 3)
    //                continue;

    //            Tile ct = Grid.Get(x, z);
    //            Spawn(_room.template.benches.Random(), ct, Quaternion.LookRotation(t.position - ct.position), null);
    //        }
    //    }
    //}

    static void CreateEntrance()
    {
        //spawn entrance light
        Spawn(_room.template.specific.Random(), Grid.Get(_room.centerX, _room.centerZ), Quaternion.Euler(0, Synched.Next(0, 3 + 1) * 90, 0));
    }
Beispiel #26
0
 public Armour(string name, string flavor, ItemRarity rarity, EquipSlot slot, GameObject prefab) : base(name, flavor, rarity, slot, prefab)
 {
     this.color = new Color(Synched.Next(0f, 1f), Synched.Next(0f, 1f), Synched.Next(0f, 1f), 1f);
 }
Beispiel #27
0
 public static T Random <T>(this T[] array)
 {
     return(array[Synched.Next(0, array.Length)]);
 }