// Tile adding calculation
public void CollectTile(int x, int y)
{
// If we're in bounds
if (x >= 0 && x < Game_Main.Xmax)
{
// Compare the texture if it's dirt then run this routine
if (Level.tiles[x, y].Texture == Level.tiles[0, 0].Texture)
{
GlobalVaribles.Dirt++;
GlobalVaribles.Cash += 1;
}
if (Level.tiles[x, y].Texture == Level.tiles[1, 0].Texture)
{
GlobalVaribles.Tin++;
GlobalVaribles.Cash += 3;
}
if (Level.tiles[x, y].Texture == Level.tiles[2, 0].Texture)
{
GlobalVaribles.Gold++;
GlobalVaribles.Cash += 5;
}
if (Level.tiles[x, y].Texture == Level.tiles[3, 0].Texture)
{
GlobalVaribles.Diamond++;
GlobalVaribles.Cash += 10;
}
if (Level.tiles[x, y].Texture == Level.tiles[4, 0].Texture)
{
GlobalVaribles.Wood++;
}
// Remove the tile
Level.tiles[x, y].Texture = null;
// Set it as passable
Level.tiles[x, y].Collision = TileCollision.Passable;
}
}
public void CollectTile(int x, int y)
{
// If we're in bounds
if (x >= 0 && x < Game_Main.Xmax)
{
// Compare the texture if it's dirt then run this routine
if (Level.tiles[x, y].Texture == Level.tiles[0, 0].Texture)
{
GlobalVaribles.Dirt++;
GlobalVaribles.Cash += 1;
}
if (Level.tiles[x, y].Texture == Level.tiles[1, 0].Texture)
{
GlobalVaribles.Tin++;
GlobalVaribles.Cash += 3;
}
if (Level.tiles[x, y].Texture == Level.tiles[2, 0].Texture)
{
GlobalVaribles.Gold++;
GlobalVaribles.Cash += 5;
}
if (Level.tiles[x, y].Texture == Level.tiles[3, 0].Texture)
{
GlobalVaribles.Diamond++;
GlobalVaribles.Cash += 10;
}
if (Level.tiles[x, y].Texture == Level.tiles[4, 0].Texture)
{
GlobalVaribles.Wood++;
}
// Remove the tile
Level.tiles[x, y].Texture = null;
// Set it as passable
Level.tiles[x, y].Collision = TileCollision.Passable;
}
}
So the it no longer checks for tiles OUT SIDE the bounds of the map, Game_Main.Xmax, is where I have the MAX LENGTH of my random level generator, and I just used that to get the bounds, Not too shabby! Now when I resize the map it'll go with it :).
Also, subscribe to this or reply to the posts so I know people are taking an interest!
Also, subscribe to this or reply to the posts so I know people are taking an interest!
No comments:
Post a Comment