public Tile[][] BuildLayout(ImageBank imageBank, double unitWidth)
    {
        List <Room> rooms      = this.BuildRooms(imageBank, unitWidth);
        int         columnSpan = 30;

        Room[][] occupancy = this.FixPositionsForRoom(rooms, columnSpan);
        return(MergeRoomsInToSingleTileGrid(occupancy, occupancy.Length, columnSpan));
    }
        private ImageBank convertToImageBankObject(DataRow dr)
        {
            ImageBank imageBank = new ImageBank();

            imageBank.Id           = dr.Field <int>("ID");
            imageBank.PropertyName = dr["PropertyName"].ToString();
            imageBank.Category     = dr["Category"].ToString();
            imageBank.ImageData    = "";
            imageBank.ImagePath    = dr["ImagePath"].ToString();
            return(imageBank);
        }
Beispiel #3
0
    public void ComputeRoomDimensionsBasisImageList(ImageBank imageBank, double unitWidth)
    {
        //Compute the total perimeter needed
        ImageContainer t = imageList;
        double         totalPerimeterNeeded       = 0;
        double         largestImageContainerWidth = 0;

        while (t != null)
        {
            totalPerimeterNeeded += t.getWidth();
            if (t.getWidth() > largestImageContainerWidth)
            {
                largestImageContainerWidth = t.getWidth();
            }
            t = t.getNext();
        }


        // 3 units will be reserved for the opening
        if (largestImageContainerWidth < 3 * unitWidth)
        {
            largestImageContainerWidth = 3 * unitWidth;
        }
        int p = Units(totalPerimeterNeeded + 3 * unitWidth, unitWidth);
        int l = Units(largestImageContainerWidth, unitWidth);

        bool randomizeWidth = (Random.value > 0.5);
        int  min            = 6;
        int  max            = 12;

        if (randomizeWidth)
        {
            width  = Random.Range(l, LargestWidth + 1);
            height = (p - 2 * width) / 2 + Random.Range(min, max);
            if (height < min)
            {
                height = min;
            }
        }
        else
        {
            height = Random.Range(l, LargestWidth + 1);
            width  = (p - 2 * height) / 2 + Random.Range(min, max);
            if (width < min)
            {
                width = min;
            }
        }

        if (width < min || height < min)
        {
            Debug.Log("wrong dimension");
        }
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
//		ReadTileMapFile("Assets/Script/Generation/tilemap.csv");//relative to the project

//		Album album=GenerateFictitiousAlbum(20);
        Album          album          = DataScan.currentAlbum;
        double         maxFrameWidth  = TileLength * 1.5;
        double         maxFrameHeight = TileLength;
        ImageBank      imageBank      = new ImageBank(album, maxFrameWidth, maxFrameHeight);
        LayoutStrategy layoutStrategy = new BlockLayoutStrategy();

        this.tileGrid = layoutStrategy.BuildLayout(imageBank, TileLength);
        this.rows     = this.tileGrid.Length;
        this.columns  = this.tileGrid[0].Length;
        MakeHoleInTheFirst3Tiles();
        BuildFromTilemap();
    }
        public ImageBank GetAll()
        {
            try
            {
                Logger.LogInfo("Get: Image Bank master process start");
                ImageBank imageBank = new ImageBank();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(SELECT_ALL);
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    imageBank = convertToImageBankObject(dr);
                }
                Logger.LogInfo("Get: Image Bank master process completed.");
                return(imageBank);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
    private List <Room> BuildRooms(ImageBank imageBank, double unitWidth)
    {
        List <Room> rooms = new List <Room>();

        while (imageBank.getTotalContainers() > 0)
        {
            int            imagesForThisRoom = Random.Range(5, 10);
            ImageContainer imageList         = null;
            if (imagesForThisRoom > imageBank.getTotalContainers())
            {
                imagesForThisRoom = imageBank.getTotalContainers();
                imageList         = imageBank.PopAll();
            }
            else
            {
                imageList = imageBank.PopImageContainers(imagesForThisRoom);
            }
            Room room = new Room();
            room.SetImageList(imageList, imagesForThisRoom);
            room.ComputeRoomDimensionsBasisImageList(imageBank, unitWidth);
            rooms.Add(room);
        }
        return(rooms);
    }
Beispiel #7
0
 public static Texture2D GetRandomTexture(System.Random random, ImageBank ib)
 {
     return(ib.GetTexture(random.Next(ib.GetSize())));
 }