本文整理汇总了C#中Tile.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.SetPosition方法的具体用法?C# Tile.SetPosition怎么用?C# Tile.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.SetPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(int height, int width, Texture2D baseTexture)
{
matrix = new Tile[height][];
for (int i = 0; i < height; i++)
{
matrix[i] = new Tile[width];
for (int j = 0; j < width; j++)
{
Tile tmpTile = new Tile(baseTexture);
tmpTile.SetPosition(j * 100, i * 100);
matrix[i][j] = tmpTile;
}
}
}
示例2: SetBackgroundTile
public void SetBackgroundTile(Tile tile)
{
for (short row = 0; row < this.size.height; row++)
{
for (short col = 0; col < this.size.width; col++)
{
Tile newTile = new Tile(tile.GetName(), tile.GetWalkable(), tile.GetBuildable());
newTile.SetPosition(col, row);
this.stageTiles.Add(newTile);
newTile.SetParentStage(this);
}
}
}
示例3: CreateRandomTiles
public void CreateRandomTiles()
{
for (int h = 0; h < this.size.height; h++)
{
for (int w = 0; w < this.size.width; w++)
{
//with the randomization of the tiles, we're going to randomize whether or not this is buildiable
int rand = JsMath.round(JsMath.random());
//int rand = (new Random()).Next(0, 1);
//check whether the random # is 0 or 1, the long way, because apparently boolean.parse won't figure it out
bool buildable = false;
if (rand == 1)
{
buildable = true;
}
Tile aTile = new Tile("", true, buildable);
aTile.SetParentStage(this);
aTile.SetPosition(w, h);
stageTiles.Add(aTile);
}
}
}
示例4: AddTile
public Tile AddTile(string name, bool walkable, bool buildable, Point tilePos)
{
// If a tile already exists at this position, destroy it (for now)...
foreach (Tile tile in this.stageTiles)
{
if (tile.GetPosition().x == tilePos.x && tile.GetPosition().y == tilePos.y)
{
//this.stageTiles.Remove(tile);
//tile.Destroy();
tile.SetBuildable(buildable);
tile.SetWalkable(walkable);
tile.SetSprite(Sprite.GetSpriteByName(name));
return tile;
}
}
// (else)
Tile newTile = new Tile(name, walkable, buildable);
newTile.SetPosition(tilePos.x, tilePos.y);
this.stageTiles.Add(newTile);
newTile.SetParentStage(this);
return newTile;
}
示例5: GenerateTiles
private void GenerateTiles()
{
for (int i = 0; i< this.tiles.Length; i++) {
Tile tile = new Tile();
tile.SetPosition(new Position(i % this.width, i / this.width));
tiles[i] = tile;
}
for(int i=0; i<1000 && rooms.Count <= this.roomCount; i++)
{
int x = Random.Range(1, this.width - Room.MAX_SIZE - 1);
int w = Random.Range(Room.MIN_SIZE, Room.MAX_SIZE);
int y = Random.Range(1, this.height - Room.MAX_SIZE - 1);
int h = Random.Range(Room.MIN_SIZE, Room.MAX_SIZE);
Room room = new Room (this, x, x + w, y, y + h);
room.Digging ();
}
for (int y=1; y<height-1; y++) {
for (int x=1; x<width-1; x++) {
if(1 == x%2 && 1 == y%2 && 0 == GetTileGroupID(x, y)) {
Maze maze = new Maze (this);
maze.Digging (Maze.DirectionType.West, x, y);
}
}
}
foreach (Room room in rooms) {
room.Connect();
}
bool delete = true;
while(delete) {
delete = false;
for (int y=1; y<height-1; y++) {
for (int x=1; x<width-1; x++) {
if(0 != GetTileGroupID(x, y))
{
int count = 0;
for (int dy = -1; dy <= 1; dy += 2)
{
if (0 == GetTileGroupID(x, y + dy))
{
count++;
}
}
for (int dx = -1; dx <= 1; dx += 2)
{
if (0 == GetTileGroupID(x + dx, y))
{
count++;
}
}
if(3 <= count)
{
tiles_[x + y * width] = 0;
delete = true;
}
}
}
}
}
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
if(0 == this.GetTileGroupID(x, y))
{
int count = 0;
count += GetTileGroupID(x-1, y-1);
count += GetTileGroupID(x, y-1);
count += GetTileGroupID(x+1, y-1);
count += GetTileGroupID(x+1, y);
count += GetTileGroupID(x+1, y+1);
count += GetTileGroupID(x, y+1);
count += GetTileGroupID(x-1, y+1);
count += GetTileGroupID(x-1, y);
if(0 != count)
{
Wall wall = new Wall();
wall.SetPosition(new Position(x, y));
}
}
}
}
start = rooms [root ["start_room"].AsInt].GetRandomPosition ();
}