当前位置: 首页>>代码示例>>C#>>正文


C# Grid.Fill方法代码示例

本文整理汇总了C#中Grid.Fill方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.Fill方法的具体用法?C# Grid.Fill怎么用?C# Grid.Fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grid的用法示例。


在下文中一共展示了Grid.Fill方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GridRun_ValidCells_ReturnsTrue

        public void GridRun_ValidCells_ReturnsTrue()
        {
            var inputCells = new List<Cell>();

            // row 0
            inputCells.Add(new Cell(ColourEnum.Blue, ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Red, ColourEnum.Blue, ColourEnum.Yellow));
            inputCells.Add(new Cell(ColourEnum.Blue, ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Blue, ColourEnum.Red, ColourEnum.Blue));

            // row 1
            inputCells.Add(new Cell(ColourEnum.Red, ColourEnum.Blue, ColourEnum.Red, ColourEnum.Blue));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Blue, ColourEnum.Yellow, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Blue));

            // row 2
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Blue, ColourEnum.Blue, ColourEnum.Yellow));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Blue));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Blue, ColourEnum.Blue, ColourEnum.Red));

            // row 3
            inputCells.Add(new Cell(ColourEnum.Blue, ColourEnum.Red, ColourEnum.Blue, ColourEnum.Yellow));
            inputCells.Add(new Cell(ColourEnum.Yellow, ColourEnum.Blue, ColourEnum.Blue, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Blue, ColourEnum.Yellow, ColourEnum.Red, ColourEnum.Red));
            inputCells.Add(new Cell(ColourEnum.Red, ColourEnum.Blue, ColourEnum.Yellow, ColourEnum.Blue));

            var grid = new Grid(6, true);
            grid.Fill(inputCells);

            grid.Print();

            Assert.IsTrue(grid.IsComplete());
        }
开发者ID:seankenny,项目名称:Game,代码行数:35,代码来源:GameTests.cs

示例2: TownQuarter

        /// <summary>
        /// Creates new town quarter as map fragment. Generates roads, buildings, etc.
        /// </summary>
        /// <param name="size">Size of quarter without joining interface</param>
        /// <param name="degree">Number of quarter's interfaces (joining streets)</param>
        public TownQuarter(ActionGame game, Vector2 size, int degree)
        {
            owner = EmptyTownQuarterOwner.Instance;

            this.game = game;
            interfaces = new List<TownQuarterInterface>(degree);
            if (nameRepository.Count > 0)
            {
                Random rand = new Random();
                int nameIndex = rand.Next(0, nameRepository.Count - 1);
                Name = nameRepository[nameIndex];
                nameRepository.RemoveAt(nameIndex);
            }
            else
            {
                Name = emptyName;
            }

            int xSize = (int)Math.Floor(size.X / SquareWidth);
            int ySize = (int)Math.Floor(size.Y / SquareWidth);
            bitmapSize = new System.Drawing.Size(xSize, ySize);
            mapBitmap = new MapFillType[bitmapSize.Width * bitmapSize.Height];
            for (int i = 0; i < mapBitmap.Length; i++)
                mapBitmap[i] = MapFillType.Empty;
            spaceGrid = new Grid(bitmapSize.Width, bitmapSize.Height, GridFiledWidth, GridFiledWidth);

            try
            {
                Generate(degree);
            }
            catch (Exception ex)
            {
                if (Name != emptyName)
                {
                    nameRepository.Add(Name);
                }
                throw ex;
            }
            spaceGrid.Fill(GetAllSolidObjects());
        }
开发者ID:havri,项目名称:ActionGame,代码行数:45,代码来源:TownQuarter.cs

示例3: FixRoads

						public static List<GPoint> FixRoads (Grid g, List<GPoint> rVHplusO, Vector2 blockSize)
						{
								//we will need to create a temporary grid that contains all of the new points
								//then iterate through it by the blocksize as done earlier
								//for each intersection check if there is a road to the left or down
								//if there is one left, then create a vertical road as done earlier
								//if there is one down, then create a horizontal road as done earlier
								//also create an intersection at the point
								List<GPoint> fixedRoads = new List<GPoint> ();
								Grid tG = new Grid (g);
								tG.Fill (GPoint.PType.TILE_GRASS);
								tG.UpdatePoints (rVHplusO);
								for (float ix=1.0f; ix<tG.GetXYMax().x; ix+=blockSize.x) {
										//iterate up by blocksize
										for (float iy=1.0f; iy<tG.GetXYMax().y; iy+=blockSize.y) {
												//iterate right by blocksize
												//set the scan point to the current position on the grid
												ScanPoint sp1 = new ScanPoint (new Vector2 (ix, iy));
												//move the scanpoint to the left and check if is anything but background
												if (!tG.GetPoint (sp1.VirtualMove (Direction.w)).IsBackgroundTile ()) {
														//create a vertical road blocksize.y units long
														//probably going to do this with a for loop
														fixedRoads.Add (new GPoint (sp1.Position (), GPoint.PType.TILE_ROADI));
														fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x, sp1.Position ().y + blockSize.y), GPoint.PType.TILE_ROADI));
														for (float iy2 = 1.0f; iy2<blockSize.y; iy2+=1.0f) {
																fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x, sp1.Position ().y + iy2), GPoint.PType.TILE_ROADV));
														}
												}
												if (!tG.GetPoint (sp1.VirtualMove (Direction.s)).IsBackgroundTile ()) {
														//create a horizontal road blocksize.x units long
														//probably going to do this with a for loop
														fixedRoads.Add (new GPoint (sp1.Position (), GPoint.PType.TILE_ROADI));
														fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x + blockSize.x, sp1.Position ().y), GPoint.PType.TILE_ROADI));
														for (float ix2 = 1.0f; ix2<blockSize.x; ix2+=1.0f) {
																fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x + ix2, sp1.Position ().y), GPoint.PType.TILE_ROADH));
														}
												}
										}
								}
								return fixedRoads;
						}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:41,代码来源:CityMaker.cs

示例4: FillTarget

 public void FillTarget(Grid<Tile> target, Point2 offset)
 {
     target.Fill(new Tile(), 0, 0, target.Width, target.Height);
 }
开发者ID:SirePi,项目名称:duality,代码行数:4,代码来源:DummyTileDrawSource.cs

示例5: CopySelect

		[Test] public void CopySelect()
		{
			Grid<int> sourceGrid = new Grid<int>(4, 4);
			Grid<string> targetGrid = new Grid<string>(4, 4);
			sourceGrid.Fill(7, 1, 1, 2, 2);
			targetGrid.Fill("Keep", 0, 0, 2, 2);
			sourceGrid.CopyTo(targetGrid, selector: (i, s) => s != "Keep" ? i.ToString() : s);
			CollectionAssert.AreEqual(new[] { 
				"Keep", "Keep", "0", "0",
				"Keep", "Keep", "7", "0",
				"0",	"7",	"7", "0",
				"0",	"0",	"0", "0" }, targetGrid);
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:13,代码来源:GridTest.cs

示例6: CopyConvert

		[Test] public void CopyConvert()
		{
			Grid<int> sourceGrid = new Grid<int>(4, 4);
			Grid<float> targetGrid = new Grid<float>(4, 4);
			sourceGrid.Fill(7, 1, 1, 2, 2);
			sourceGrid.CopyTo(targetGrid);
			CollectionAssert.AreEqual(new[] { 
				0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 7.0f, 7.0f, 0.0f,
				0.0f, 7.0f, 7.0f, 0.0f,
				0.0f, 0.0f, 0.0f, 0.0f }, targetGrid);
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:12,代码来源:GridTest.cs

示例7: Fill

		[Test] public void Fill()
		{
			Grid<int> grid = new Grid<int>(4, 4);
			grid.Fill(7, 1, 1, 2, 2);
			CollectionAssert.AreEqual(new[] { 
				0, 0, 0, 0,
				0, 7, 7, 0,
				0, 7, 7, 0,
				0, 0, 0, 0 }, grid);
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:10,代码来源:GridTest.cs


注:本文中的Grid.Fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。