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


C# Tile.GetLength方法代码示例

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


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

示例1: GenerateLevel

    public override void GenerateLevel()
    {
        DungeonRectangle rect = new DungeonRectangle(new Vector2(0, 0), new Vector2(width, height));

        rect.StartSplitting(Rooms);

        Tile[,] map = new Tile[(int)rect.Size.x, (int)rect.Size.y];

        for (int x = 0; x < map.GetLength(0); x++)
        {
            for (int y = 0; y < map.GetLength(1); y++)
            {
                map[x, y] = new Tile()
                {
                    TileNumber = 1
                };
            }
        }

        foreach (Vector2 vect in rect.Visualize())
        {
            map[(int)Mathf.Abs(vect.x), (int)Mathf.Abs(vect.y)].TileNumber = 0;
        }

        this.map = map;

        this.Obstacles.Add(1);
    }
开发者ID:stijnhero,项目名称:Game,代码行数:28,代码来源:Dungeon.cs

示例2: Execute

		public void Execute(Tile[,] tiles, Organism organism)
		{
			var newX = organism.Tile.Coordinate.X;
			var newY = organism.Tile.Coordinate.Y;

			switch (_Direction)
			{
				case Direction.Left:
					newX--;
					break;
				case Direction.Right:
					newX++;
					break;
				case Direction.Up:
					newY--;
					break;
				case Direction.Down:
					newY++;
					break;
			}

			if (newX < 0 || newY < 0 || newX >= tiles.GetLength(0) || newY >= tiles.GetLength(1))
				return;

			tiles[newX, newY].Organism = organism;
		}
开发者ID:JacobRichardt,项目名称:PolkaDotted.EvolveOrDie,代码行数:26,代码来源:Move.cs

示例3: Update

        public void Update(Tile[,] Tiles)
        {
            //
                //Check if the entity is lit up and/or visible
                //
                int tilex = (int)(Position.X / 10);
                int tiley = (int)(Position.Y / 10);

                if (tilex >= 0 && tilex + 1 < Tiles.GetLength(0)
                    && tiley >= 0 && tiley + 1 < Tiles.GetLength(1))
                {
                    float averageBrightness = (Tiles[tilex, tiley].Brightness
                        + Tiles[tilex + 1, tiley].Brightness
                        + Tiles[tilex, tiley + 1].Brightness
                        + Tiles[tilex + 1, tiley + 1].Brightness)
                            / 4f;

                    Brightness = averageBrightness;

                    IsVisible = Tiles[tilex, tiley].IsVisible
                        || Tiles[tilex + 1, tiley].IsVisible
                        || Tiles[tilex, tiley + 1].IsVisible
                        || Tiles[tilex + 1, tiley + 1].IsVisible;
                }
        }
开发者ID:EoinF,项目名称:TheOtherDarkWorld,代码行数:25,代码来源:FloorItem.cs

示例4: makeLine

	// Generate a line from one coordinate to another
	// You can ask for it to be totaly walls or totally floor, based on the bool
	// False: Walls
	// True: Floor
	public static void makeLine(Tile[,] map, Coord begin, Coord end, bool applyFloor) {

		// Assert in range
		if( begin.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) ||
		    end.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) )
			return;
		
		int startX = begin.x;
		int endX = end.x;
		int startY = begin.y;
		int endY = end.y;


		// Find the linear spacing appropriate from point
		// including the endpoint
		int lengthX = Math.Abs( endX - startX );

		var linspace = new List<Double>();
			linspace = LinSpace (startY, endY, lengthX, true).ToList ();

		// Now it's time to actually put our money where our mouth is
		for(int i = startX; i < endX; i++) {
			int j = (int) linspace[i] ;
			map[i,j].property = applyFloor ? TileType.Floor1 : TileType.OuterWall1;
		}

		// Phew! Thought this one was so easy, didn't cha!?

		return;
	}
开发者ID:starrodkirby86,项目名称:Better-Game-App,代码行数:34,代码来源:RoomUtilityFunctions.cs

示例5: BuildFluff

    private float Width; //width (X) of map

    #endregion Fields

    #region Methods

    //Builds all the fluff
    public void BuildFluff(Tile [,] gd, float scale)
    {
        //Prep variables
        Fluff = new GameObject();
        Fluff.name = "Fluff";
        Fluff.transform.position = new Vector3(0f, 0f, 0f);
        Grid = gd;
        Scale = scale;
        Width = gd.GetLength(0);
        Height = gd.GetLength(1);

        //Loop through the grid, adding fluff spots as appropriate
        for (int i = 1; i < Width - 1; i++)
        {
            for (int j = 1; j < Height - 1; j++)
            {
                //Check walls
                if (Grid[i, j].getType() == "Rock")
                {
                    AddWallLight(i, j);
                }

                //Check floors
                if (Grid[i, j].getType() == "Floor")
                {
                    //AddCornerLight(i, j); not fully functional yet
                    AddParticles(i, j);
                }
            }
        }
    }
开发者ID:mattgor123,项目名称:CS355-Robo-Clean-5000,代码行数:38,代码来源:FluffBuilder.cs

示例6: IsFulfilled

		public bool IsFulfilled(Tile[,] tiles, Organism organism)
		{
			var absoluteX = organism.Tile.Coordinate.X + _X;
			var absoluteY = organism.Tile.Coordinate.Y + _Y;

			if (absoluteX < 0 || absoluteY < 0 || absoluteX >= tiles.GetLength(0) || absoluteY >= tiles.GetLength(1))
				return false;

			return tiles[absoluteX, absoluteY].IsPassable;
		}
开发者ID:JacobRichardt,项目名称:PolkaDotted.EvolveOrDie,代码行数:10,代码来源:IsTilePassable.cs

示例7: ConvertToList

    public static List<Tile> ConvertToList(Tile[,] array)
    {
        var r = new List<Tile>();

        var w = array.GetLength(0);
        var h = array.GetLength(1);
        for(int i = 0; i < w; i++)
            for(int j = 0; j < h; j++)
                r.Add (array[i,j]);

        return r;
    }
开发者ID:jt7777,项目名称:avmemo,代码行数:12,代码来源:Grid.cs

示例8: init

 public void init(BoardManager boardMan, Tile[,] board) {
     emptyTiles = new List<Tile>();
     bm = boardMan;
     gemFolder = new GameObject();
     gemFolder.name = "Gems";        // The name of a game object is visible in the hHerarchy pane.
     gems = new List<Gem>();
     gemType = 1;
     for (int x=0; x<board.GetLength(0); x++) {
         for (int y=0; y<board.GetLength(1); y++) {
             emptyTiles.Add(board[x, y]);
         }
     }
 }
开发者ID:severhale,项目名称:Marble-Mayhem,代码行数:13,代码来源:GemManager.cs

示例9: ConvertToNodeMap

 private Node[,] ConvertToNodeMap(Tile[,] board)
 {
     Node[,] nodemap = new Node[board.GetLength(0), board.GetLength(1)];
     int count = 0;
     for (int xIndex = 0; xIndex < board.GetLength(0); xIndex++)
     {
         for (int yIndex = 0; yIndex < board.GetLength(1); yIndex++)
         {
             nodemap[xIndex, yIndex] = new Node(board[xIndex, yIndex], xIndex, yIndex) {Id = count};
             count++;
         }
     }
     return nodemap;
 }
开发者ID:jimfim,项目名称:vindinium-bot,代码行数:14,代码来源:DefaultMapBuilder.cs

示例10: DispatchMap

    public void DispatchMap(Tile[,] tileMap)
    {
        map.XSize = tileMap.GetLength(0);
        map.YSize = tileMap.GetLength(1);
        map.Generate();

        shadows.XSize = 28;
        shadows.YSize = 20;
        shadows.Generate();

        int texWidth = map.XSize * tileResolution;
        int texHeight = map.YSize * tileResolution;

        Texture2D texture = new Texture2D(texWidth, texHeight);

        Color[][] tiles = ChopUpTiles(tileSheetTiles);

        if (tileMap != null)
        {
            for (int x = 0; x < tileMap.GetLength(0); x++)
            {
                for (int y = 0; y < tileMap.GetLength(1); y++)
                {
                    Color[] p;

                    if (tileMap[x, y].TileNumber < tiles.Length - 1)
                    {
                        p = tiles[tileMap[x, y].TileNumber + 1];
                    }
                    else
                    {
                        int tNumber = (tileMap[x, y].TileNumber + 1) / tiles.Length;
                        p = tiles[tNumber];
                    }

                    texture.SetPixels(x * tileResolution, y * tileResolution, tileResolution, tileResolution, p);
                }
            }

            texture.wrapMode = TextureWrapMode.Clamp;
            texture.Apply();

            Material tileTexture = new Material(Shader.Find("Unlit/Texture"));
            tileTexture.mainTexture = texture;

            map.GetComponent<MeshRenderer>().materials = new Material[] { tileTexture };
        }
    }
开发者ID:stijnhero,项目名称:Game,代码行数:48,代码来源:MapRenderer.cs

示例11: autoTiler

	// You've been spooked by the spooky skeleton.

	/**
	 * This particular function just does a simple job of converting
	 * wall tiles into a more specific wall-based kind of tile. And not the bush.
	 * Please. Anything but that bush tile.
	 */
	public override void autoTiler(Tile[,] map) {
		// This is where we'll try to implement Colin's autotiling algorithm
		// A 0 == floor
		// A nonzero is a wall

		fillDictionary();

		int rows = map.GetLength (0);
		int columns = map.GetLength (1);
		for(int x = 0; x < rows; x++) {
			for(int y = 0; y < columns; y++) {
				GameObject instantiateMe;

				// Check for wall tile:
				if( map[x,y].property == TileType.OuterWall1 ) {
					// So this is supposedly a wall tile based on what
					// our ruleset has generated. Now it's time to convert
					// that to the proper autotiled item.
					instantiateMe = tileDictionary [ 0xFF ];

					int candidate = makeKey (map, new Coord(x,y));

					if(! tileDictionary.TryGetValue (candidate, out instantiateMe ) ) {
						Debug.Log ("Fringe case at " + candidate.ToString ("X2"));
						instantiateMe = tileDictionary [ 0xFF ];
					}
				}
				else if ( map[x,y].property == TileType.Floor1 ) {
					// We can make this either a regular floor or a
					// broken janky ass floor.
					if(Random.Range (0,100) > 90)
						instantiateMe = floorTile[1]; // Assumes this is broken tile
					else
						instantiateMe = floorTile[0]; // Assumes this is clear good tile
				}
				else if ( map[x,y].property == TileType.Door1 ) {
					instantiateMe = doorTile[0];
				}
				else {
					instantiateMe = tileDictionary[ 0xFF ];
				}

				GameObject instance = Instantiate(instantiateMe, new Vector3 (x, y, 0), Quaternion.identity) as GameObject;
				instance.transform.SetParent(this.transform);
			}
		}
	}
开发者ID:starrodkirby86,项目名称:Better-Game-App,代码行数:54,代码来源:TilesetMoistLucifer.cs

示例12: autoTiler

	// You've been spooked by the spooky skeleton.

	/**
	 * This particular function just does a simple job of converting
	 * wall tiles into a more specific wall-based kind of tile. And not the bush.
	 * Please. Anything but that bush tile.
	 */
	public override void autoTiler(Tile[,] map) {
		// This is where we'll try to implement Colin's autotiling algorithm
		// A 0 == floor
		// A nonzero is a wall

		int rows = map.GetLength (0);
		int columns = map.GetLength (1);
		for(int x = 0; x < rows; x++) {
			for(int y = 0; y < columns; y++) {
				GameObject instantiateMe;

				// Check for wall tile:
				if( map[x,y].property == TileType.OuterWall1 ) {
					// For Flood Fill, we don't need to worry about weird things like that.
					instantiateMe = wallTiles[0];
				}
				else if ( map[x,y].property == TileType.Floor1 ) {
					// If that tile is marked, then we should denote the highlighted tile.
					// Otherwise, we're good.
					if(map[x,y].mark != 0)
						instantiateMe = floorTile[1];
					else
						instantiateMe = floorTile[0];
				}
				else if ( map[x,y].property == TileType.Door1 ) {
					instantiateMe = doorTile[0];
				}
				else {
					instantiateMe = wallTiles[0];
				}

				GameObject instance = Instantiate(instantiateMe, new Vector3 (x, y, 0), Quaternion.identity) as GameObject;
				instance.transform.SetParent(this.transform);
			}
		}
	}
开发者ID:starrodkirby86,项目名称:Better-Game-App,代码行数:43,代码来源:TilesetFloodFill.cs

示例13: SetBaseLevel

        private static void SetBaseLevel(Tile[,] tiles)
        {
            int width = tiles.GetLength(0);
            int height = tiles.GetLength(1);
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {

                    if (x == 0 || y == 0 || x == width - 1 || y == height - 1)
                    {
                        tiles[x, y] = new Tile(Tile.BlockName.SolidWall, x * Map.TileSize, y * Map.TileSize);
                    }
                    else
                    {

                        tiles[x, y] = new Tile(Tile.BlockName.Grass, x * Map.TileSize, y * Map.TileSize);
                    }
                }
            }
        }
开发者ID:kralle333,项目名称:TankGame,代码行数:21,代码来源:MapGenerator.cs

示例14: Decorate

 private static void Decorate(Tile[,] tiles)
 {
     int width = tiles.GetLength(0);
     int height = tiles.GetLength(1);
     for (int i = 0; i < random.Next(height) + height; i++)
     {
         int xRect = random.Next(1, width - 3);
         int yRect = random.Next(1, height - 3);
         int rectWidth = random.Next(2, Math.Min(4, width - xRect));
         int rectHeight = random.Next(2, Math.Min(4, height - yRect));
         for (int x = xRect; x < xRect + rectWidth; x++)
         {
             for (int y = yRect; y < yRect + rectHeight; y++)
             {
                 tiles[x, y].SetType(Tile.BlockName.TallGrass);
             }
         }
     }
     for (int triesToRemove = random.Next(width)+width; triesToRemove > 0;triesToRemove-- )
     {
         int xRect = random.Next(1, width - 3);
         int yRect = random.Next(1, height - 3);
         if(tiles[xRect,yRect].Name == Tile.BlockName.BreakableWall)
         {
             tiles[xRect, yRect].SetType(Tile.BlockName.Grass);
         }
     }
 }
开发者ID:kralle333,项目名称:TankGame,代码行数:28,代码来源:MapGenerator.cs

示例15: makeRectangle

	// Generate a rectangle starting from the topleft point to the bottomright point
	// You can ask for it to be totally walls or totally floor, based on the bool
	// False: Walls
	// True: Floor
	public static void makeRectangle(Tile[,] map, Coord topLeft, Coord bottomRight, bool applyFloor) {

		// Assert that topLeft and bottomRight are in range
		if( topLeft.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) ||
			bottomRight.isOOB (map.GetLength(0), map.GetLength (1), Direction.Stop) )
			return;

		int startX = topLeft.x;
		int endX = bottomRight.x;
		int startY = bottomRight.y;
		int endY = topLeft.y;

		for(int i = startX; i < endX; i++) {
			for(int j = startY; j < endY; j++) {
				map[i,j].property = applyFloor ? TileType.Floor1 : TileType.OuterWall1;
			}
		}

		return;

	}
开发者ID:starrodkirby86,项目名称:Better-Game-App,代码行数:25,代码来源:RoomUtilityFunctions.cs


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