Inheritance: MonoBehaviour
        public void GenerateRoomsInGrid_Transitions()
        {
            // ARRANGE
            var transition           = RoomTransition.CreateGlobalExit();
            var availableTransitions = new[] { transition };

            var randomMock = new Mock <IRoomGeneratorRandomSource>();

            randomMock.Setup(x => x.RollRoomMatrixPositions(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(new[] { new OffsetCoords(0, 0) });
            randomMock.Setup(x => x.RollTransitions(It.IsAny <IEnumerable <RoomTransition> >()))
            .Returns(new[] { transition });
            randomMock.Setup(x => x.RollRoomSize(It.IsAny <int>(), It.IsAny <int>(), It.IsIn <int>(1)))
            .Returns <int, int, int>((min, max, count) => { return(new[] { new Size(0, 0) }); });
            var random = randomMock.Object;

            var generator = new RoomGenerator(random);

            var expectedTransitions = new[] { transition };

            // ACT
            var factRooms = generator.GenerateRoomsInGrid(1, 1, 1, availableTransitions);

            // ASSERT
            factRooms.ElementAt(0).Transitions.Should().BeEquivalentTo(availableTransitions);
        }
Beispiel #2
0
    public List <Node> CalculateDungeon(int maxPasses, int roomMinWidth, int roomMinLength, float bottomCornerModifier, float topCornerModifier, int roomOffset, int corridorWidth, EnemySpawner enemSpawner, DungeonCreator dungeonCreator, ItemSpawner itemSpawner, ObjectSpawner objSpawner)
    {
        BinarySpacePartitioner bsp = new BinarySpacePartitioner(dungeonWidth, dungeonLength);

        allSpaceNodes = bsp.PrepareNodesCollection(maxPasses, roomMinWidth, roomMinLength);
        List <Node>     roomSpaces    = StructureHelper.TraverseGraphToExtractLowestLeaves(bsp.rootNode);
        RoomGenerator   roomGenerator = new RoomGenerator(maxPasses, roomMinLength, roomMinWidth);
        List <RoomNode> roomList      = roomGenerator.GenerateRoomsInGivenSpaces(roomSpaces, bottomCornerModifier, topCornerModifier, roomOffset);
        //first room will be the spawn point for the player
        RoomNode firstRoom = roomList[0];

        UnityEngine.CharacterController player = GameObject.FindWithTag("Player").GetComponent <UnityEngine.CharacterController>();
        Vector2Int firstRoomCenter             = StructureHelper.CalculateMiddlePoint(firstRoom.BottomLeftCorner, firstRoom.TopRightCorner);
        Vector3    newPos = new Vector3(firstRoomCenter.x, 0.0f, firstRoomCenter.y);

        player.enabled            = false;
        player.transform.position = newPos;
        player.enabled            = true;

        //generate spawn points before we add the corridors
        for (int i = 0; i < roomList.Count; i++)
        {
            RoomNode room = roomList[i];

            if (enemSpawner != null)
            {
                GameObject newRoom = new GameObject("RoomObj", typeof(Room), typeof(BoxCollider));
                newRoom.tag = "RoomObject";
                BoxCollider col = newRoom.GetComponent <BoxCollider>();
                col.isTrigger = true;
                col.size      = new Vector3(1.2f, 1.2f, 1.2f);

                Vector2Int roomPos = StructureHelper.CalculateMiddlePoint(room.BottomLeftCorner, room.TopRightCorner);
                newRoom.transform.position = new Vector3(roomPos.x, 2, roomPos.y);
                Room roomComp = newRoom.GetComponent <Room>();
                room.roomObjReference        = roomComp;
                newRoom.transform.localScale = new Vector3(room.Width, 4, room.Length);
                roomComp.enemySpawnPoints    = new List <Vector3>();
                roomComp.itemSpawnPoints     = new List <Vector3>();
                roomComp.weaponSpawnPoints   = new List <Vector3>();
                roomComp.objectSpawnPoints   = new List <Vector3>();
                roomComp.doors = new List <Transform>();
                dungeonCreator.spawnedRooms.Add(roomComp);

                if (i != 0)
                {
                    enemSpawner.GenerateEnemySpawnPointsForRoom(room);
                    itemSpawner.GenerateItemSpawnPointsForRoom(room);
                    objSpawner.GenerateObjectSpawnPointsForRoom(room);
                }
            }
        }

        CorridorGenerator corridorGenerator = new CorridorGenerator();
        var corridorList = corridorGenerator.CreateCorridor(allSpaceNodes, corridorWidth);

        dungeonCreator.GenerateDoors(corridorList);

        return(new List <Node>(roomList).Concat(corridorList).ToList());
    }
Beispiel #3
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        roomGenerator = GetComponent <RoomGenerator>();

        levelGenerator = GetComponent <LevelGenerator>();

        mapController = GetComponent <MapController>();

        fightManager = GetComponent <FightManager>();

        gearManager = GetComponent <GearManager>();

        statManager = GetComponent <StatManager>();

        InitGame();
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        if (setSeed != 0)
        {
            Random.seed = setSeed;
        }

        allRooms       = new LinkedList <RoomNode>();
        interCorridors = new LinkedList <RoomNode>();
        foreach (RoomGenerator rg in roomGens)
        {
            rg.totalBounds.center += rg.transform.position;
            rg.totalBounds.size    = Vector3.Scale(rg.totalBounds.size, rg.transform.localScale);
            rg.minRoomSize         = Vector3.Scale(rg.minRoomSize, rg.transform.localScale);
            rg.maxRoomSize         = Vector3.Scale(rg.maxRoomSize, rg.transform.localScale);
            rg.MakeDungeon();
            Util.LLAppend <RoomNode>(allRooms, rg.roomNodeList);
        }
        ConnectMulti();

        foreach (RoomGenerator rg in roomGens)
        {
            RoomGenerator.InstantiateRooms(rg.roomNodeList, rg.roomStyle);
        }

        foreach (RoomGenerator rg in roomGens)
        {
            RoomGenerator.FurnishRooms(rg.roomNodeList, rg.roomStyle, rg.doorPiecePrefab);
        }

        RoomGenerator.InstantiateRooms(interCorridors, interCorridorStyle);
    }
    IEnumerator DoorAnimation()
    {
        // Freezes player movement
        player.FreezePlayer();
        // Instantiates the NextRoom
        RoomGenerator newRoomGenerator =
            FindObjectOfType <DungeonDisplay>()
            .InstantiateRoom(door.GetNextRoom(currentRoom.GetCurrentRoom()));

        // Disables Door Animations For the new Room
        newRoomGenerator.EnableDoorAnimations(false);

        // Changes the player animation to walk in appropreate direction.
        if (direction == Cardinal4.Direction.NORTH)
        {
            playerAnimator.SetFloat("deltaX", 0);
            playerAnimator.SetFloat("deltaY", 1);
        }
        else if (direction == Cardinal4.Direction.SOUTH)
        {
            playerAnimator.SetFloat("deltaX", 0);
            playerAnimator.SetFloat("deltaY", -1);
        }

        //Move player into the door
        Coroutine a =
            StartCoroutine(player.MovePlayerToPoint(
                               (Vector2)this.transform.position,
                               player.GetSpeed()));

        yield return(a);

        //Update the current room
        Room nextRoom = door.GetNextRoom(currentRoom.GetCurrentRoom());

        currentRoom.SetCurrentRoom(nextRoom);
        //Moves camera to new room
        Coroutine b =
            StartCoroutine(mainCamera.MoveCameraToNewRoom(
                               currentRoom.GetCurrentRoom(),
                               cameraMovementTime));

        yield return(b);

        // Move player out of the door into the room
        Coroutine c =
            StartCoroutine(player.MovePlayerToPoint(
                               (Vector2)this.transform.position +
                               Cardinal4.DirectionToVector2(direction, distanceFromDoor),
                               player.GetSpeed()));

        yield return(c);

        // Enable Door Animations for the Next Room
        newRoomGenerator.EnableDoorAnimations(true);
        // Allow for Player Movement
        player.UnfreezePlayer();
        // Destroy current RoomGenerator
        Destroy(currentRoomGenerator.gameObject);
    }
Beispiel #6
0
    public static void Apply(Level level, Parameters parameters, int seed)
    {
        var stopwatch = new System.Diagnostics.Stopwatch();

        stopwatch.Start();

        BSPAlgorithm bsp = new BSPAlgorithm();

        bsp.m_minNodeSize = new Vector2Int(level.Grid.Tiles.GetLength(0) / parameters.MinNumRooms, level.Grid.Tiles.GetLength(1) / parameters.MinNumRooms);
        //Random.InitState(seed);

        var root = new Node(level.Grid.Tiles);

        bsp.DivideGrid(level.Grid, root);

        level.Rooms = new HashSet <Tile[, ]>();
        var roomGenerator = new RoomGenerator(level, new Vector2Int(parameters.MinRoomWidth, parameters.MinRoomHeight));

        roomGenerator.PlaceRooms(root);

        var corridorGenerator = new CorridorGenerator(level.Grid, parameters.CorridorType);

        corridorGenerator.PlaceCorridors(root);

        stopwatch.Stop();
        Debug.Log("BSPAlgorithm took " + stopwatch.ElapsedMilliseconds + " milliseconds to complete.");
    }
Beispiel #7
0
 //-------------------------------------------------------------------
 // This checks if a door is needed in the room at a specific direction.
 //      roomGen: the roomgenerator that the door is part of.
 //      doorPlace: a doorPlace that gives us information about the door
 //      index: the index of the room in the map
 //      x: the x position of the door
 //      y: the y position of the door
 //-------------------------------------------------------------------
 void Checkdoor(RoomGenerator roomGen, DoorPlacement doorPlace, int index, float x, float y)
 {
     if (!roomGen.CheckAvailability(doorPlace.m_dir))
     {
         Drawdoor(roomGen, new Vector3(x, y, 1), doorPlace.m_quat, doorPlace.m_ori, index, doorPlace.m_offset);
     }
 }
Beispiel #8
0
    // Start is called before the first frame update
    void Start()
    {
        _generator         = GetComponent <RoomGenerator>();
        map                = new _Room[rows, columns];
        _playerX           = 0;
        _playerY           = 0;
        _playerRoomChanged = true;

        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < columns; j++)
            {
                map[i, j] = new _Room();
                map[i, j].generate();
            }
        }
        for (int i = 0; i < nrOfEmptyRooms; i++)
        {
            int roomX = Random.Range(1, columns);
            int roomY = Random.Range(1, rows);
            //Debug.Log("X: "+roomX + " Y: "+roomY);
            map[roomX, roomY].empty = true;
        }
        _chestHandle();
        _respawnHandle();
    }
Beispiel #9
0
 public RoomPlan(Rectangle rect, RoomGenerator generator, int index)
 {
     Index = index;
     Rect = rect;
     Generator = generator;
     Doors = new Dictionary<RoomPlan, Rectangle>();
 }
Beispiel #10
0
    //-------------------------------------------------------------------
    // This creates the door game object at the correct location and orientation.
    //      roomGen: the roomgenerator that the door is part of
    //      position: the position to spawn the door
    //      quat: the rotation to spawn the door
    //      ori: this determines which direction the door needs to teleport the player
    //      index: the index of the room
    //      offset: the offset to find the index of the room the door leads to
    //-------------------------------------------------------------------
    void Drawdoor(RoomGenerator roomGen, Vector3 position, Quaternion quat, Door.Orientation ori, int index, int offset)
    {
        GameObject door;
        int        i       = 1;
        bool       success = false;

        // We start i at 1 because, we do NOT want to put the first key behind a locked door.
        for (; i < m_finalRooms.Count; ++i)
        {
            if (index + offset == m_finalRooms[i])
            {
                success = true;
                break;
            }
        }
        if (success)
        {
            door = Instantiate(m_lockedDoor, position, quat, m_map[index].transform);
            door.GetComponent <Door>().type = (Door.Type)i;
        }
        else
        {
            door = Instantiate(m_door, position, quat, m_map[index].transform);
        }

        Door doorComp = door.GetComponent <Door>();

        doorComp.orientation = ori;

        Debug.Assert(m_map.ContainsKey(roomGen.GetIndex()));
        doorComp.curRoom = m_map[roomGen.GetIndex()].GetComponent <SpriteRenderer>();

        Debug.Assert(m_map.ContainsKey(roomGen.GetIndex() + offset), offset);
        doorComp.nextRoom = m_map[roomGen.GetIndex() + offset].GetComponent <SpriteRenderer>();
    }
Beispiel #11
0
        public MapGenerator(IRMap map, IMobPackManager mobPackManager)
        {
            _map                = map;
            _mobPackManager     = mobPackManager;
            _rows               = map.Rows;
            _cols               = map.Columns;
            _directions         = RHelper.GetDirections();
            _oppositeDirections = new Dictionary <Direction, Direction>
            {
                { Direction.North, Direction.South },
                { Direction.East, Direction.West },
                { Direction.South, Direction.North },
                { Direction.West, Direction.East },
                { Direction.Center, Direction.Center }
            };

            var roomGen         = new RoomGenerator(5, 5, 10, 10, _map);
            var corridorGen     = new HallwayGenerator(20, 20, 50, 50, _map);
            var drunkDrigger    = new DrunkDigger(50, 50, 100, 100, _map);
            var treasureRoomGen = new TreasureRoom(5, 5, 13, 13, _map);

            _generators = new RandomContainer <IGenerator>
            {
                { roomGen, 60 },
                { corridorGen, 5 },
                { drunkDrigger, 180 },
                { treasureRoomGen, 2 }
            };

            roomGen.EnableEnemySpawning(_mobPackManager, 15);
            drunkDrigger.EnableEnemySpawning(_mobPackManager, 20);
        }
Beispiel #12
0
    public void CreateRoom(int n, int e, int s, int w, int x, int y)
    {
        Vector2 roomPosition = CoordinateToPosition(x, y);


        string     roomName = "Room" + x + y;
        GameObject nr       = new GameObject(roomName);

        nr.AddComponent <RoomGenerator>();
        RoomGenerator rg = nr.GetComponent("RoomGenerator") as RoomGenerator;

        rg.east                 = e;
        rg.west                 = w;
        rg.south                = s;
        rg.north                = n;
        rg.wallPrefab           = wallPrefab;
        rg.passPrefab           = passPrefab;
        rg.floorPrefab          = floorPrefab;
        rg.tilePrefab           = tilePrefab;
        rg.obsticalPrefab       = obsticalPrefab;
        rg.exitPrefab           = exitPrefab;
        rg.mapSize              = mapSize;
        rg.tileSize             = mapSize.x + 4;
        rg.obsticleCount        = obsticleCount;
        rg.seed                 = prng.Next();
        rg.mapLocation          = roomPosition;
        rg.tileOutlinePercent   = 1;
        rg.transform.parent     = newRoom;
        rg.transform.localScale = Vector3.one;
        rg.enemyPrefab          = enemyPrefab;
        rg.enemySPPrefab        = enemySPPrefab;
        rg.enemyCount           = enemyCount;
        rg.enemySPCount         = enemySPCount;
        rg.wayPoint             = wayPoint;
    }
Beispiel #13
0
    void Start()
    {
        world = GetComponent <World2D>();

        generator = new RoomGenerator();
        generator.GetGridSystem.SetGridSize(new IntVector2(50, 50));
        generator.GenerateRooms(world);

        world.worldMap = LinqConvert(generator.GetGridSystem.GetGrid);
        GameObject[] o = GameObject.FindGameObjectsWithTag("Player");
        loader = new GameLoader(windows);
        List <FPSPlayer> players = new List <FPSPlayer>();

        for (int i = 0; i < o.Length; i++)
        {
            players.Add(o[i].GetComponent <FPSPlayer>());
        }

        for (int i = 0; i < generator.SpawnPointList.Count; i++)
        {
            players[i % players.Count].SpawnPos.Add(generator.SpawnPointList[i]);
            players[i % players.Count].GetComponent <FPSPlayer>().SetPosition(generator.SpawnPointList[i]);
        }


        //get the target and objective entities
        //targetEntity = generator
    }
Beispiel #14
0
    private void updatePlayerPosOnMinimap()
    {
        RoomGenerator  RGScript = RG.GetComponent <RoomGenerator>();
        PlayerMovement pm       = player.GetComponent <PlayerMovement>();

        GameObject[] currentIndicators = GameObject.FindGameObjectsWithTag("CurrentPosIndicator");
        foreach (GameObject obje in currentIndicators)
        {
            Destroy(obje);
        }

        // ******************************** IMPORTANT UI-CAMERA FOLLOW OFFSET VALUE RIGHT HERE. With example below.
        // + (pm.CurrentRoomPosOnMatrix.y - 2) * 21f;
        // - (pm.CurrentRoomPosOnMatrix.x - 2) * 13f;
        // this offset is needed because it seems that the camera's position is not updated when this is called in the same frame.
        // if making the following code in a coroutine, the offset won't be needed.
        float xcenter = RGScript.centerX + (pm.CurrentRoomPosOnMatrix.y - 2) * 21f;
        float ycenter = RGScript.centerY - (pm.CurrentRoomPosOnMatrix.x - 2) * 13f;
        float xpos    = xcenter + (pm.CurrentRoomPosOnMatrix.y - 2) * 0.5f;
        float ypos    = ycenter - (pm.CurrentRoomPosOnMatrix.x - 2) * 0.5f;

        Debug.Log("heyhey" + xpos + "," + ypos);
        GameObject obj = Instantiate(playerIndicatorOnMiniMap, new Vector3(xpos, ypos, 0), Quaternion.identity, canvas.transform);

        playerMatrixPosComparator = pm.CurrentRoomPosOnMatrix;
    }
Beispiel #15
0
    public List <Node> CalculateDungeon(
        int maxIterations,
        int roomWidthMin,
        int roomLengthMin,
        float roomBottomCornerModifier,
        float roomTopCornerModifier,
        int roomOffset,
        int corridorWidth)
    {
        //splits the room
        BinarySpacePartitioner bsp = new BinarySpacePartitioner(dungeonWidth, dungeonLength);

        allNodesCollection = bsp.PrepareNodesCollection(maxIterations, roomWidthMin, roomLengthMin);
        List <Node> roomSpaces = StructureHelper.TraverseGraphToExtractLowestLeafes(bsp.RootNode);

        RoomGenerator   roomGenerator = new RoomGenerator(maxIterations, roomLengthMin, roomWidthMin);
        List <RoomNode> roomList      = roomGenerator.GenerateRoomsInGivenSpace(roomSpaces,
                                                                                roomBottomCornerModifier,
                                                                                roomTopCornerModifier,
                                                                                roomOffset);

        CorridorGenerator corridorGenerator = new CorridorGenerator();
        var corridorList = corridorGenerator.CreateCorridor(allNodesCollection, corridorWidth);


        return(new List <Node>(roomList).Concat(corridorList).ToList());
    }
    public void ReportPlayerPosition(RoomGenerator room)
    {
        //Reference the current room against the list of rooms in Every's territory.
        //If Some is in Every's territory, we reveal his symbol to Every.

        //If Some is
    }
        public async Task Create_RealRandom_NoOverlapNodesAsync()
        {
            // ARRANGE
            var dice          = new Dice(3245);
            var randomSource  = new RoomGeneratorRandomSource(dice);
            var roomGenerator = new RoomGenerator(randomSource);
            var factory       = new RoomMapFactory(roomGenerator);
            var sectorScheme  = CreateSectorScheme();



            // ACT
            var map = await factory.CreateAsync(sectorScheme);



            // ARRANGE
            var hexNodes = map.Nodes.Cast <HexNode>().ToArray();

            foreach (var node in hexNodes)
            {
                var sameNode = hexNodes.Where(x => x != node && x.OffsetX == node.OffsetX && x.OffsetY == node.OffsetY);
                sameNode.Should().BeEmpty();
            }
        }
Beispiel #18
0
    private void Start()
    {
        CardMB.CardBgs              = CardBgs;
        CardMB.CardPrefab           = CardPrefab;
        RoomMB.RoomPrefab           = RoomPrefab;
        EntityMB.EntityPrefab       = EntityPrefab;
        AddCardMB.AddCardPrefab     = AddCardPrefab;
        FountainMB.FountainPrefab   = FountainPrefab;
        BattleManager.EndGameObject = EndGameObject.GetComponent <EndGameMB>();

        new Player();

        Deck.Draws = new List <Card>
        {
            new Punch(),
            new ComboStrike(),
            new HealingBeam(),
            // Top three will always be drawn first turn but after that, shuffle.
            new LesserHealing(),
            new Jab(),
            new HammerThrust(),
            new Punch(),
            new Punch()
        };

        Deck.DrawCard();
        Deck.DrawCard();
        Deck.DrawCard();

        Deck.Shuffle(Deck.Draws);

        RoomGenerator.GenerateRoom();
    }
Beispiel #19
0
    public void ResetRooms()
    {
        roomList.Clear();

        if (this.transform.childCount > 0)
        {
            DestroyImmediate(this.transform.GetChild(0).gameObject);
        }

        GameObject roomSet = new GameObject("Room Set");

        roomSet.transform.parent = this.transform;
        for (int i = 0; i < path.Count; i++)
        {
            Transform room = (Transform)Instantiate(roomPrefab, path[i], Quaternion.identity);
            room.transform.parent = roomSet.transform;
            RoomGenerator roomGen = room.GetComponent <RoomGenerator>();

            roomGen.width             = roomSize;
            roomGen.height            = roomSize;
            roomGen.seed              = Random.Range(0, 50000);
            roomGen.randomFillPercent = Random.Range(25, 35);
            roomList.Add(roomGen);
            roomGen.GenerateMap();
        }
    }
Beispiel #20
0
 public void SelectRoom(int roomNumber)
 {
     if (RoomNumber == roomNumber)
     {
         return;
     }
     if (!Initialized)
     {
         if (WhiteFlash != null)
         {
             WhiteFlash.gameObject.SetActive(true);
             WhiteFlash.canvasRenderer.SetAlpha(0.0f);
         }
     }
     else
     {
         if (WhiteFlash != null)
         {
             WhiteFlash.canvasRenderer.SetAlpha(1.0f);
             WhiteFlash.CrossFadeAlpha(0.0f, 0.2f, false);
             TimeMachineSound.Play();
         }
         RoomGenerator.ResetCommonInteractablePulse();
     }
     Initialized = true;
     RoomNumber  = roomNumber;
     MainCam.transform.position = RoomCam[roomNumber].transform.position;
     MainCam.transform.rotation = RoomCam[roomNumber].transform.rotation;
 }
Beispiel #21
0
    //-------------------------------------------------------------------
    // This generates the rooms in the dungeon
    //-------------------------------------------------------------------
    void CreateRooms()
    {
        int randomStart = Random.Range(0, m_mapSize);

        m_roomGenMap.Add(randomStart, new RoomGenerator(randomStart));
        ++m_roomCount;

        toExpand.Enqueue(m_roomGenMap[randomStart]);

        // Outward expand
        if (outwardExpand)
        {
            while (toExpand.Count > 0)
            {
                RoomGenerator roomGen = toExpand.Dequeue();
                Expand(roomGen.GetIndex());
            }
        }

        // Linear expand
        else
        {
            Expand(randomStart, true);
        }

        Dijkstra(randomStart);

        PrimsMST(randomStart);

        m_startIndex = randomStart;
    }
Beispiel #22
0
    private void Awake()
    {
        //static変数を設定
        MAP_SIZE_X = INS_MAP_SIZE_X;
        MAP_SIZE_Y = INS_MAP_SIZE_Y;
        MAP_SCALE  = INS_MAP_SCALE;
        MAP_DATA   = new int[MAP_SIZE_X, MAP_SIZE_Y];

        //ダンジョン生成クラス取得
        DG = new DungeonGenerator();
        //部屋生成コンポーネント取得
        RG = this.gameObject.GetComponent <RoomGenerator>();

        //マップ切り替え時の処理を設定
        m_mapID.mChanged += value =>
        {
            //リセット
            ResetMap();
            //マップ基盤生成
            GenerateBaseMap();
            //部屋生成
            GenerateRooms();
            //通路生成
            GeneratePass();
            //オブジェクト配置
            GenerateObject();
            //マネージャー設定
            //ReloadManager();
        };
    }
Beispiel #23
0
    public IEnumerator GenerateMap()
    {
        //FillBackground();
        yield return(GenerateRooms());

        yield return(MazeFill());

        yield return(ConnectMap());

        yield return(Uncarve());


        RoomGenerator rGen = GetComponent <RoomGenerator>();

        foreach (Room r in roomList)
        {
            rGen.Generate(r);
        }
        yield return(ExpandPath());

        rGen.GeneratePaths(this);
        Room start = roomList[Random.Range(0, roomList.Count)];

        gameMan.SignalReady(start);
    }
Beispiel #24
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        RoomGenerator roomGen = (RoomGenerator)target;

        if (GUILayout.Button("Snap To Grid"))
        {
            GameObject[] objects = GameObject.FindGameObjectsWithTag("Grid");

            GridGenerator[] allGrids = FindObjectsOfType <GridGenerator>();
            for (int i = 0; i < allGrids.Length; i++)
            {
                GridGenerator gridGen = allGrids[i].GetComponent <GridGenerator>();
                gridGen.gameObject.transform.position = Utility.GetGridSnappedPosition
                                                            (gridGen.gameObject.transform.position, gridGen.transform.localScale);
            }
        }

        if (GUILayout.Button("Create Hallways"))
        {
            Utility.MakeStraightLines(roomGen);
        }

        if (GUILayout.Button("Delete Rooms"))
        {
            for (int i = 0; i < roomGen.roomsToDelete.Count; i++)
            {
                Destroy(roomGen.roomsToDelete[i]);
            }
        }
    }
Beispiel #25
0
    public void Start(int[,] map, int width, int height, RoomGenerator gen)
    {
        for (int i = 0; i < numberOfCarvings; i++)
        {
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (map[x, y] == 0)
                    {
                        if (map[x, y + 1] == 1 && map[x + 1, y - 1] == 1)
                        {
                            if (gen.IsInMapRange(x, y + 1) && gen.IsInMapRange(x + 1, y - 1))
                            {
                                tmp.Add(new Coord(x, y + 1));
                                tmp.Add(new Coord(x + 1, y - 1));
                            }
                        }
                        if (map[x, y + 1] == 1 && map[x - 1, y - 1] == 1)
                        {
                            if (gen.IsInMapRange(x, y + 1) && gen.IsInMapRange(x - 1, y - 1))
                            {
                                tmp.Add(new Coord(x, y + 1));
                                tmp.Add(new Coord(x - 1, y - 1));
                            }
                        }

                        if (map[x, y - 1] == 1 && map[x - 1, y + 1] == 1)
                        {
                            if (gen.IsInMapRange(x, y - 1) && gen.IsInMapRange(x - 1, y + 1))
                            {
                                tmp.Add(new Coord(x, y - 1));
                                tmp.Add(new Coord(x - 1, y + 1));
                            }
                        }

                        if (map[x, y - 1] == 1 && map[x + 1, y + 1] == 1)
                        {
                            if (gen.IsInMapRange(x, y - 1) && gen.IsInMapRange(x + 1, y + 1))
                            {
                                tmp.Add(new Coord(x, y - 1));
                                tmp.Add(new Coord(x + 1, y + 1));
                            }
                        }
                    }
                }
            }
        }

        for (int i = 0; i < tmp.Count; i++)
        {
            map[tmp[i].tileX, tmp[i].tileY] = 0;
            if (map[tmp[i].tileX, tmp[i].tileY + 1] == 1 && map[tmp[i].tileX, tmp[i].tileY - 1] == 1)
            {
                map[tmp[i].tileX, tmp[i].tileY + 1] = 0;
                map[tmp[i].tileX, tmp[i].tileY - 1] = 0;
            }
        }
    }
Beispiel #26
0
 private void Start()
 {
     roomGenerator = new RoomGenerator(levelManager);
     roomGenerator.GenerateWalls(this);
     roomGenerator.GenerateBorders(this);
     GenerateTiles(roomGenerator.GetRoomData);
     UpdateRoom();
 }
Beispiel #27
0
 void GenerateRoom(DunGen.Room roomBase)
 {
     // pick a room template from the floor;
     var roomTemplateKey = tpd.RollMap(env.roomTemplateChances);
     var roomTemplate = JSONResource.Get<RoomTemplate>(roomTemplateKey);
     var roomGenerator = new RoomGenerator(env, roomTemplate, roomBase);
     env.rooms.Add(roomGenerator.CreateRoom());
 }
Beispiel #28
0
        public void GenerateRooms()
        {
            Room          parent = new Room(0, 0, Color.None);
            RoomGenerator rg     = new RoomGenerator(parent, 6);

            rg.Generate();
            currentRoom = parent;
        }
 private bool CheckIfInList(RoomGenerator room)
 {
     if (_discoveredRooms.Contains(room))
     {
         return true;
     }
     return false;
 }
    public RoomGenerator InstantiateRoom(Room room)
    {
        RoomGenerator newRoom = Instantiate(roomGenerator);

        newRoom.GenerateRoom(room);
        currentRoomGenerator = newRoom;
        return(newRoom);
    }
Beispiel #31
0
    public Outlet(RoomGenerator prev, RoomGenerator next, MapGenerator.Direction dir)
    {
        m_prev = prev;
        m_next = next;

        m_prev.SetRoom(this, dir);
        m_next.SetRoom(this, MapGenerationHelpers.Opposite(dir));
    }
Beispiel #32
0
    // METHODS
    // Use this for initialization
    void Start()
    {
        gameScript = GameObject.Find("GameTrigger").GetComponent <TriggerStartGame>();

        thisTrigger = this.gameObject;

        roomGenerator = this.transform.parent.FindChild("Room Generator").GetComponent <RoomGenerator>();
    }
    public void ReportBrainPosition(RoomGenerator room)
    {
        //The room that the brain is in is added to the list of territory owned by Every.
        _currentBrainRoom = room;
        _rooms.Add(room);
        AddToDiscoveredRooms(room);

        RedrawBounds();
    }
 public void ReportBrainExit(RoomGenerator room)
 {
     //If the brain leaves and there is no dream--
     //Make sure there's a reference that checks whether or not there's a Dream in the room.--
     //then the room is removed from Every's territory.
     _rooms.Remove(room);
     room.SetColor(discoveredColor);
     Debug.Log(_rooms.Count);
 }
Beispiel #35
0
    void GenerateRoom(DunGen.Room roomBase)
    {
        // pick a room template from the floor;
        var roomTemplateKey = tpd.RollMap(env.roomTemplateChances);
        var roomTemplate    = JSONResource.Get <RoomTemplate>(roomTemplateKey);
        var roomGenerator   = new RoomGenerator(env, roomTemplate, roomBase);

        env.rooms.Add(roomGenerator.CreateRoom());
    }
Beispiel #36
0
 /// <summary>
 /// Constructor of Bigheal Powerup
 /// </summary>
 /// <param name="player">Whom he regenerates</param>
 /// <param name="Room">On which map</param>
 /// <param name="pos">The location of it</param>
 public BigHeal(Player player, RoomGenerator Room, Position pos)
 {
     Position = pos;
     //Regeneration value
     Heal        = 16;
     Type        = Piece.PowerMax;
     this.player = player;
     this.Room   = Room;
 }
Beispiel #37
0
    void Start()
    {
        currentState = HumanStates.Search;
        gm = GameObject.Find("GameManager").GetComponent<GameManager>();
        rm = GameObject.Find("GameManager").GetComponent<RoomGenerator>();
        rcm = GameObject.Find("GameManager").GetComponent<RoomChangeManager>();

        SpecialItems = rm.AiTracker;
        ItemGoalPlacement = GameObject.FindGameObjectsWithTag("Heartagram").ToList();
    }
    private void AddToDiscoveredRooms(RoomGenerator room)
    {
        _discoveredRooms.Add(room);
        foreach(Portal portal in room.portals)
        {
            RoomGenerator neighbor = portal.GetDestinationRoom();
            if (neighbor != null && !CheckIfInList(neighbor))
            {
                _discoveredRooms.Add(neighbor);
            }

        }
    }
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy (gameObject);

        DontDestroyOnLoad (gameObject);
        boats = new List<GameObject> ();
        boardManager = GetComponent<RoomGenerator> ();
        if (GameObject.FindGameObjectWithTag ("Player") == null)
        {
            player = (GameObject)Instantiate (playerPrefab);
        }
        InitGame ();
    }
Beispiel #40
0
	void Start ()
    {
        roomGenerator = GetComponent<RoomGenerator>();
        generateWorld(0);

		ChTimeTotalS =ChTimeTotal;
		SpeakingBool =  Random.Range(0.0f,1.0f)>=0.5f ?  true :  false;
		if(SpeakingBool)
		{
			SpeakingBoolP.transform.Rotate(new Vector3(0.0f,180.0f,0.0f));
		}
		if(!SpeakingBool)
		{
			SpeakingBoolP.transform.Rotate(new Vector3(0.0f,0.0f,0.0f));
		}
	}
Beispiel #41
0
    public void ShowNeighbors()
    {
        if (_transform == null)
        {
            Debug.Log("Why null?" + gameObject.name);
            return;
        }

        RoomGenerator currentRoom = GetCurrentRoom(_transform.position);

        List<RoomGenerator> neighbors = _levelManager.GetNeighbors(currentRoom);

        foreach(RoomGenerator neighbor in neighbors)
        {
            neighbor.SetAvailable();
        }

        _lastRoom = currentRoom;
    }
Beispiel #42
0
    public void GenerateLevel()
    {
        if (trunksParent) {
            Object.Destroy(trunksParent);
            trunksParent = null;
        }

        trunksParent = new GameObject ();
        trunksParent.name = string.Format (parentNameFormatter, levelIdx);

        rmg = new RoomGenerator ();
        rmg.GenerateRoom ();
        rmg.FillTilemap ();
        rmg.GenerateNeighborMap ();

        RoomGenerator.TileType[,] tiles = rmg.TileMapData;

        TrunkManager tm = new TrunkManager (rmg.mapWidth);
        tm.FillWithData (rmg.NeighborMapData, tiles);

        TextureConfig.TextureData td = TextureConfig.BackgroundTextures[levelIdx];

        for (int i = 0; i < TrunkManager.MaxTrunks; i ++) {
            if (tm[i] == null) continue;
            GameObject t = new GameObject((string.Format(trunkNameFormatter, i)) ,typeof(MeshRenderer), typeof(MeshFilter));
            Trunk trunk = tm[i];
            t.GetComponent<MeshFilter>().mesh = trunk.mesh;
            Vector3 pos = t.transform.position;
            pos.x = trunk.x;
            pos.y = trunk.y;
            t.transform.position = pos;
            t.transform.SetParent(trunksParent.transform);
            MeshRenderer mr = t.GetComponent<MeshRenderer>();
            Material mtl = Resources.Load(td.path) as Material;
            mr.sharedMaterial = mtl;
        }
    }
 private void DesignateAsBody(RoomGenerator room)
 {
     room.colorNum = 0;
 }
 private void DesignateAsMind(RoomGenerator room)
 {
     room.colorNum = 0;
     _gameManager.SetUpMind(room);
 }
 private void DesignateAsNeutral(RoomGenerator room)
 {
     room.colorNum = 1;
 }
Beispiel #46
0
		// Use this for initialization
		void Start ()
		{
				rg = GetComponent<RoomGenerator> ();
	
		}
Beispiel #47
0
    public void FillWithData(byte[,] neighborTiles, RoomGenerator.TileType[,] tiles)
    {
        int height, width;
        width = tiles.GetLength (0);
        height = tiles.GetLength (1);

        for(int y = 0; y < height; y ++) {
            for (int x = 0; x < width; x ++) {
                if (tiles[x, y] != RoomGenerator.TileType.Empty){
                    Trunk t = GetTrunk(x, y);
                    Vector2[] uvlis;

                    byte neighbotValue = neighborTiles[x, y];

        //					Debug.Log(neighbotValue);
                    if (Config.NEIGHBOR_TO_WALLTYPE_2(neighbotValue) != Config.WallType.NOT_A_WALL){
                        uvlis = TextureConfig.WallUvMap[ Config.NEIGHBOR_TO_WALLTYPE_2(neighbotValue) ];
                    }else{
                        uvlis = new Vector2[]{ new Vector2(), new Vector2(), new Vector2(), new Vector2() };
                    }

                    t.FillTile(x, y, uvlis);
                }
            }
        }

        for (int i = 0; i < MaxTrunks; i ++)
            if (trunks [i] != null)
                trunks [i].GenerateMesh ();
    }
 public void ReportPlayerExit(RoomGenerator room)
 {
     //TODO decide what should be done with hiding some.
 }
Beispiel #49
0
    // START:
    /// <summary>
    /// Start this instance.
    /// </summary>
    public void Start()
    {
        // Get the components
        dungeonGenerator = GetComponent<DungeonGenerator> ();
        sceneryGenerator = GetComponent<SceneryGenerator> ();

        stairsGenerator = GetComponent<StairsGenerator> ();
        roomGenerator = GetComponent<RoomGenerator> ();
        perimeterGenerator = GetComponent<PerimeterGenerator> ();
        entranceGenerator = GetComponent<EntranceGenerator> ();
        corridorGenerator = GetComponent<CorridorGenerator> ();
        voidGenerator = GetComponent<VoidGenerator> ();
        pitGenerator = GetComponent<PitGenerator> ();
        chestGenerator = GetComponent<ChestGenerator> ();
        caveGenerator = GetComponent<CaveGenerator> ();

        terrainCarver = GetComponent<TerrainCarver> ();
        terrainGenerator = GetComponent<TerrainGenerator> ();
        textureGenerator = 	GetComponent<TerrainTextureGenerator> ();

        // Initialize the instances
        stairsGenerator.Start ();
        roomGenerator.Start ();
        perimeterGenerator.Start ();
        entranceGenerator.Start ();
        corridorGenerator.Start ();
        voidGenerator.Start ();
        pitGenerator.Start ();
        chestGenerator.Start ();
        caveGenerator.Start ();

        terrainCarver.Start ();
        terrainGenerator.Start ();
        textureGenerator.Start ();

        // Initialize the floor array
        allFloors = new Floor[dungeonGenerator.numFloors];
    }
    public RoomDatum(RoomGenerator room, int id, int x, int y)
    {
        this.id = id;
        this.xPos = x;
        this.yPos = y;

        this.room = room;
        neighbors = new RoomDatum[4];
    }
Beispiel #51
0
 public void AssignIdentity(RoomGenerator room, int direction)
 {
     _room = room;
     _compassDirection = (Direction)direction;
 }
 public List<RoomGenerator> GetNeighbors(RoomGenerator room)
 {
     List<RoomGenerator> neighbors = new List<RoomGenerator>();
     foreach (RoomDatum roomDatum in _roomData)
     {
         if (roomDatum.room == room)
         {
             foreach(RoomDatum neighbor in roomDatum.neighbors)
             {
                 if (neighbor != null)
                 {
                     neighbors.Add(neighbor.room);
                 }
             }
             break;
         }
     }
     return neighbors;
 }
    void Start()
    {
        _RoomGenerator = GameObject.FindGameObjectWithTag("GameManager").GetComponent<RoomGenerator>();

        if (playerNumOrder == null)
        {
            playerNumOrder = new List<int>();
        }
    }
Beispiel #54
0
 /// <summary>
 /// Used for initialization.
 /// </summary>
 public void Start()
 {
     dungeonGenerator = GetComponent<DungeonGenerator> ();
     roomGenerator = GetComponent<RoomGenerator> ();
 }
        private Map<Cell> Map()
        {
            var map = new Map<BinaryCell>(SOME_WIDTH, SOME_HEIGHT);

            new MazeGenerator<BinaryCell>().ProcessMap(map, mConfiguration, mRandomizer);
            new SparsenessReducer<BinaryCell>().ProcessMap(map, mConfiguration, mRandomizer);
            var newMap = new MapDoubler<Cell, BinaryCell>().ConvertMap(map, mConfiguration, mRandomizer);

            var roomGenerator = new RoomGenerator<Cell>();
            roomGenerator.ProcessMap(newMap, mConfiguration, mRandomizer);
            return newMap;
        }
Beispiel #56
0
 public void Start()
 {
     dungeonGenerator = GetComponent<DungeonGenerator> ();
     roomGenerator = GetComponent<RoomGenerator> ();
     perimeterGenerator = GetComponent<PerimeterGenerator> ();
     entranceGenerator = GetComponent<EntranceGenerator> ();
     sceneryGenerator = GetComponent<SceneryGenerator> ();
 }
Beispiel #57
0
            public void Initialize(XElement elem)
            {
                Generator = RoomGenerator.Get(elem.Attribute("class").Value);

                Definitions.LoadProperties(this, elem);
            }
Beispiel #58
0
 void Start()
 {
     numberOfPlayers = PlayerPrefs.GetInt("Players_Number", 1);
     roomGenerator = GetComponent<RoomGenerator>();
 }
Beispiel #59
0
 void Awake()
 {
     hillGenerator = terrain.GetComponent<HillGenerator>();
     roomGenerator = terrain.GetComponent<RoomGenerator>();
     if(hillGenerator) defaultCurve = hillGenerator.contourCurve;
 }
Beispiel #60
0
    public void ShowNeighbors(Vector3 position)
    {
        RoomGenerator currentRoom = GetCurrentRoom(position);

        List<RoomGenerator> neighbors = _levelManager.GetNeighbors(currentRoom);

        foreach(RoomGenerator neighbor in neighbors)
        {
            neighbor.SetAvailable();
        }

        _lastRoom = currentRoom;
    }