本文整理汇总了C#中Level.add方法的典型用法代码示例。如果您正苦于以下问题:C# Level.add方法的具体用法?C# Level.add怎么用?C# Level.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: harvest
private void harvest(Level level, int x, int y)
{
int age = level.getData(x, y);
int count = random.nextInt(2);
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.seeds), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
count = 0;
if (age == 50)
{
count = random.nextInt(3) + 2;
}
else if (age >= 40)
{
count = random.nextInt(2) + 1;
}
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.wheat), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
level.setTile(x, y, Tile.dirt, 0);
}
示例2: interact
public override bool interact(Level level, int xt, int yt, Player player, Item item, int attackDir)
{
if (item is ToolItem)
{
ToolItem tool = (ToolItem)item;
if (tool.type == ToolType.shovel)
{
if (player.payStamina(4 - tool.level))
{
level.setTile(xt, yt, Tile.hole, 0);
level.add(new ItemEntity(new ResourceItem(Resource.dirt), xt * 16 + random.nextInt(10) + 3, yt * 16 + random.nextInt(10) + 3));
Sound.monsterHurt.play();
return true;
}
}
if (tool.type == ToolType.hoe)
{
if (player.payStamina(4 - tool.level))
{
level.setTile(xt, yt, Tile.farmland, 0);
Sound.monsterHurt.play();
return true;
}
}
}
return false;
}
示例3: hurt
public override void hurt(Level level, int x, int y, Mob source, int dmg, int attackDir)
{
int count = random.nextInt(2) + 1;
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
level.setTile(x, y, Tile.grass, 0);
}
示例4: interact
public override bool interact(Level level, int x, int y, Player player, Item item, int attackDir)
{
if (item is ToolItem)
{
ToolItem tool = (ToolItem)item;
if (tool.type == ToolType.shovel)
{
if (player.payStamina(4 - tool.level))
{
level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
level.add(new ItemEntity(new ResourceItem(Resource.flower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
level.setTile(x, y, Tile.grass, 0);
return true;
}
}
}
return false;
}
示例5: hurt
public override void hurt(Level level, int x, int y, Mob source, int dmg, int attackDir)
{
int damage = level.getData(x, y) + dmg;
level.add(new SmashParticle(x * 16 + 8, y * 16 + 8));
level.add(new TextParticle("" + dmg, x * 16 + 8, y * 16 + 8, ColorHelper.get(-1, 500, 500, 500)));
if (damage >= 10)
{
int count = random.nextInt(2) + 1;
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.cactusFlower), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
level.setTile(x, y, Tile.sand, 0);
}
else
{
level.setData(x, y, damage);
}
}
示例6: interactOn
public override bool interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir)
{
if (tile.mayPass(level, xt, yt, furniture))
{
furniture.x = xt * 16 + 8;
furniture.y = yt * 16 + 8;
level.add(furniture);
placed = true;
return true;
}
return false;
}
示例7: hurt
public void hurt(Level level, int x, int y, int dmg)
{
int damage = level.getData(x, y) + 1;
level.add(new SmashParticle(x * 16 + 8, y * 16 + 8));
level.add(new TextParticle("" + dmg, x * 16 + 8, y * 16 + 8, ColorHelper.get(-1, 500, 500, 500)));
if (dmg > 0)
{
int count = random.nextInt(2);
if (damage >= random.nextInt(10) + 3)
{
level.setTile(x, y, Tile.dirt, 0);
count += 2;
}
else
{
level.setData(x, y, damage);
}
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(toDrop), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
}
}
示例8: resetGame
public void resetGame()
{
playerDeadTime = 0;
wonTimer = 0;
gameTime = 0;
hasWon = false;
levels = new Level[5];
currentLevel = 3;
levels[4] = new Level(128, 128, 1, null);
levels[3] = new Level(128, 128, 0, levels[4]);
levels[2] = new Level(128, 128, -1, levels[3]);
levels[1] = new Level(128, 128, -2, levels[2]);
levels[0] = new Level(128, 128, -3, levels[1]);
level = levels[currentLevel];
player = new Player(this, input);
player.findStartPos(level);
level.add(player);
for (int i = 0; i < 5; i++)
{
levels[i].trySpawn(5000);
}
}
示例9: changeLevel
public void changeLevel(int dir)
{
level.remove(player);
currentLevel += dir;
level = levels[currentLevel];
player.x = (player.x >> 4) * 16 + 8;
player.y = (player.y >> 4) * 16 + 8;
level.add(player);
}
示例10: interact
public override bool interact(Level level, int xt, int yt, Player player, Item item, int attackDir)
{
if (item is ToolItem)
{
ToolItem tool = (ToolItem)item;
if (tool.type == ToolType.shovel)
{
if (player.payStamina(5))
{
// level.setTile(xt, yt, Tile.infiniteFall, 0);
int count = random.nextInt(2) + 1;
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.cloud), xt * 16 + random.nextInt(10) + 3, yt * 16 + random.nextInt(10) + 3));
}
return true;
}
}
}
return false;
}
示例11: hurt
private void hurt(Level level, int x, int y, int dmg)
{
{
int count = random.nextInt(10) == 0 ? 1 : 0;
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.apple), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
}
int damage = level.getData(x, y) + dmg;
level.add(new SmashParticle(x * 16 + 8, y * 16 + 8));
level.add(new TextParticle("" + dmg, x * 16 + 8, y * 16 + 8, ColorHelper.get(-1, 500, 500, 500)));
if (damage >= 20)
{
int count = random.nextInt(2) + 1;
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.wood), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
count = random.nextInt(random.nextInt(4) + 1);
for (int i = 0; i < count; i++)
{
level.add(new ItemEntity(new ResourceItem(Resource.acorn), x * 16 + random.nextInt(10) + 3, y * 16 + random.nextInt(10) + 3));
}
level.setTile(x, y, Tile.grass, 0);
}
else
{
level.setData(x, y, damage);
}
}