Esempio n. 1
0
    /**
     * 1 Go through each result from OCR
     * 2 Go through each character from OCR to determin if it contains a number
     * 3 Check if a string that contains a number colorates with a room number
     * 4 Add each result to the result list
     * 5 If there is no match return 0 else return the list with at least 1 room
     * Needs to be adjusted later, MakerDatabase should not return any rooms!
     */
    public List <Room> ContainsRoom(List <string> potentialMarkerStringsList)
    {
        List <Room> resultList = new List <Room>();

        foreach (string text in potentialMarkerStringsList)
        {
            bool containsNumber = false;
            foreach (char character in text)
            {
                if (Char.IsDigit(character))
                {
                    containsNumber = true;
                }
            }
            if (containsNumber)
            {
                var resultRoom = _RoomDatabase.GetRoom(text.Replace(" ", ""));
                if (resultRoom != null)
                {
                    resultList.Add(resultRoom);
                }
            }
        }
        if (resultList.Count == 0)
        {
            return(null);
        }
        else
        {
            return(resultList);
        }
    }
    public static Map GenerateShipMap(MapData data)
    {
        Debug.Log("Rooms Size: " + data.roomSizeX + ", " + data.roomSizeY);

        RoomData roomData = RoomDatabase.GetRoom(RoomType.Ship);

        data.roomSizeX = roomData.mWidth;
        data.roomSizeY = roomData.mHeight;

        Debug.Log("Rooms Size: " + data.roomSizeX + ", " + data.roomSizeY);
        Map map = new Map(data);



        map.SetTileMap(roomData.tiles);
        Debug.Log("Rooms Size: " + map.getMapSize().x + ", " + map.getMapSize().y);

        AddBounds(map);

        /*
         * map.AddEntity(new NPCData(1, 1, NPCType.ArmsDealer));
         * map.AddEntity(new NPCData(14, 1, NPCType.GeneralTrader));
         * map.AddEntity(new NPCData(8, 4, NPCType.Gadgeteer));
         * map.AddEntity(new NPCData(20, 1, NPCType.PotionSeller));
         * map.AddEntity(new NPCData(22, 4, NPCType.Clothier));
         * map.AddEntity(new NPCData(10, 13, NPCType.EggsDealer));
         */
        //map.AddEntity(new BossData(10, 13, BossType.VoidBoss));


        if (WorldManager.instance.NumCompletedWorlds() == 0)
        {
            map.AddEntity(new ItemObjectData(6, 1, ObjectType.Item, "Biosample"));
            map.AddEntity(new ItemObjectData(7, 1, ObjectType.Item, "Slime Egg"));
        }

        if (WorldManager.instance.NumCompletedWorlds() == 0)
        {
            //map.AddEntity(new ItemObjectData(6, 1, ObjectType.Item, "Snowzooka"));
        }
        //map.AddEntity(new MinibossData(15, 10, map.Data.minibossType));
        //map.AddEntity(new EnemyData(15, 10, EnemyType.Sporby));

        if (WorldManager.instance.NumCompletedWorlds() == 0)
        {
            /*
             * map.AddEntity(new ItemObjectData(8, 1, ObjectType.Item, "ForceFieldGadget"));
             * map.AddEntity(new ItemObjectData(9, 1, ObjectType.Item, "NovaGadget"));
             * map.AddEntity(new ItemObjectData(10, 1, ObjectType.Item, "HookShot"));
             * map.AddEntity(new ItemObjectData(10, 1, ObjectType.Item, "HookShot"));
             * map.AddEntity(new ItemObjectData(11, 1, ObjectType.Item, "PortalGadget"));
             * map.AddEntity(new ItemObjectData(12, 1, ObjectType.Item, "Teleporter"));
             * map.AddEntity(new ItemObjectData(13, 1, ObjectType.Item, "CaptureGadget"));
             */
        }

        foreach (EntityData eData in roomData.entityData)
        {
            if (eData == null)
            {
                continue;
            }
            map.AddEntity(eData);
        }
        //Post process the map based on probabilistic tiles and such
        PostProcessing(map, data);

        return(map);
    }
    public static Map GenerateMap(MapData data)
    {
        Map map = new Map(data);

        RoomData[,] rooms = new RoomData[data.sizeX, data.sizeY];

        Vector2i startRoom;
        Vector2i endRoom;
        int      randomX = Random.Range(0, map.sizeX);

        int[] depths = new int[map.sizeX];


        if (data.baseDepth < data.sizeY)
        {
            for (int i = 0; i < depths.Length; i++)
            {
                depths[i] = data.baseDepth + (Random.Range(-data.depthVariance, data.depthVariance));
            }
            Debug.Log("Random X: " + randomX);
            startRoom = new Vector2i(randomX, depths[randomX]);
        }
        else
        {
            for (int i = 0; i < depths.Length; i++)
            {
                depths[i] = data.sizeY;
            }

            startRoom = new Vector2i(randomX, map.sizeY - 1);
        }

        RoomData[,] roomPath = RoomMap(map.sizeX, map.sizeY, startRoom, out endRoom);

        if (data.hasMiniboss)
        {
            Debug.Log("Has miniboss");
            roomPath[endRoom.x, endRoom.y].roomType = RoomType.MinibossRoom;
        }
        SurfaceLayer temp;

        for (int x = 0; x < map.sizeX; x++)
        {
            for (int y = 0; y < map.sizeY; y++)
            {
                if (y < depths[x])
                {
                    temp = SurfaceLayer.Inner;
                }
                else if (y > depths[x])
                {
                    temp = SurfaceLayer.Above;
                }
                else
                {
                    temp = SurfaceLayer.Surface;
                }



                if (roomPath[x, y] != null)
                {
                    if (roomPath[x, y].roomType == RoomType.MinibossRoom)
                    {
                        rooms[x, y] = RoomDatabase.GetRoom(RoomType.MinibossRoom);
                    }
                    else
                    {
                        rooms[x, y] = RoomDatabase.GetRoom(roomPath[x, y].roomType, temp);
                    }
                }
                else
                {
                    rooms[x, y] = RoomDatabase.GetRoom(RoomType.SideRoom, temp);
                }

                foreach (EntityData eData in rooms[x, y].entityData)
                {
                    if (eData == null)
                    {
                        continue;
                    }
                    map.AddEntity(eData);
                }
            }
        }

        map.SetTileMap(RoomsToMap(rooms, data.sizeX, data.sizeY));

        //TODO Turn room array into map



        AddBounds(map);

        Debug.Log("Start room: " + startRoom.x + ", " + startRoom.y);
        Vector2i door = AddDoorTile(map, endRoom.x, endRoom.y);

        map.SetTile(door.x, door.y, TileType.Door);
        map.exitTile = door;
        //Debug.Log("Door tile " + door);
        map.startTile = GetStartTile(map, startRoom.x, startRoom.y);


        if (data.mapType != MapType.Ship && data.mapType != MapType.BossMap)
        {
            //PopulateMap(map);

            //PopulateBoss(map);
            AddChests(map);
            //AddFauna(map);
            //AddFallingRock(map);

            //PopulateBoss(map);
        }


        //Post process the map based on probabilistic tiles and such
        PostProcessing(map, data);


        return(map);
    }