Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public override bool interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir)
 {
     if (player.health < player.maxHealth && player.payStamina(staminaCost))
     {
         player.heal(heal);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 public override bool interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir)
 {
     if (resource.interactOn(tile, level, xt, yt, player, attackDir))
     {
         count--;
         return true;
     }
     return false;
 }
Exemplo n.º 4
0
 public override bool interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir)
 {
     if (sourceTiles.Contains((TileID)tile.id))
     {
         var tt = Tile.tiles[(byte)targetTile];
         level.setTile(xt, yt, tt, 0);
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 public override bool interact(Player player, Entity entity, int attackDir)
 {
     if (entity is Furniture)
     {
         Furniture f = (Furniture)entity;
         f.take(player);
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
        public InventoryMenu(Player player)
        {
            this.player = player;

            if (player.activeItem != null)
            {
                player.inventory.items.add(0, player.activeItem);
                player.activeItem = null;
            }
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
        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.pickaxe && tool.level == 4) {
				if (player.payStamina(4 - tool.level)) {
					hurt(level, xt, yt, random.nextInt(10) + (tool.level) * 5 + 10);
					return true;
				}
			}
		}
		return false;
	}
Exemplo n.º 9
0
 public void deductCost(Player player)
 {
     for (int i = 0; i < costs.size(); i++)
     {
         Item item = costs.get(i);
         if (item is ResourceItem)
         {
             ResourceItem ri = (ResourceItem)item;
             player.inventory.removeResource(ri.resource, ri.count);
         }
     }
 }
Exemplo n.º 10
0
        public CraftingMenu(List<Recipe> recipes, Player player)
        {
            this.player = player;

            for (int i = 0; i < recipes.size(); i++)
            {
                recipes.get(i).checkCanCraft(player);
            }

            this.recipes = new List<Recipe>(recipes.OrderByDescending(x=>x.canCraft));
            //this.recipes.Sort(new RecipeSorter());
        }
Exemplo n.º 11
0
 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.pickaxe)
         {
             if (player.payStamina(6 - tool.level))
             {
                 hurt(level, xt, yt, 1);
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 12
0
 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.dirt, 0);
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 13
0
 public void checkCanCraft(Player player)
 {
     for (int i = 0; i < costs.size(); i++)
     {
         Item item = costs.get(i);
         if (item is ResourceItem)
         {
             ResourceItem ri = (ResourceItem)item;
             if (!player.inventory.hasResources(ri.resource, ri.count))
             {
                 canCraft = false;
                 return;
             }
         }
     }
     canCraft = true;
 }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
 public override void tick()
 {
     if (shouldTake != null)
     {
         if (shouldTake.activeItem is PowerGloveItem)
         {
             remove();
             shouldTake.inventory.add(0, shouldTake.activeItem);
             shouldTake.activeItem = new FurnitureItem(this);
         }
         shouldTake = null;
     }
     if (pushDir == 0) move(0, +1);
     if (pushDir == 1) move(0, -1);
     if (pushDir == 2) move(-1, 0);
     if (pushDir == 3) move(+1, 0);
     pushDir = -1;
     if (pushTime > 0) pushTime--;
 }
Exemplo n.º 16
0
 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;
 }
Exemplo n.º 17
0
 public virtual bool use(Player player, int attackDir)
 {
     return false;
 }
Exemplo n.º 18
0
 public virtual bool interact(Player player, Item item, int attackDir)
 {
     return item.interact(player, this, attackDir);
 }
Exemplo n.º 19
0
 public void take(Player player)
 {
     Sound.pickup.play();
     player.score++;
     item.onTake(this);
     remove();
 }
Exemplo n.º 20
0
 public virtual bool interact(Player player, Entity entity, int attackDir)
 {
     return false;
 }
Exemplo n.º 21
0
 public virtual bool interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir)
 {
     return false;
 }
Exemplo n.º 22
0
 public override bool use(Player player, int attackDir)
 {
     player.game.setMenu(new CraftingMenu(Crafting.ovenRecipes, player));
     return true;
 }
Exemplo n.º 23
0
 public virtual bool interact(Level level, int xt, int yt, Player player, Item item, int attackDir)
 {
     return false;
 }
Exemplo n.º 24
0
 public override void craft(Player player)
 {
     player.inventory.add(0, new ResourceItem(resource, 1));
 }
Exemplo n.º 25
0
 public void take(Player player)
 {
     shouldTake = player;
 }
Exemplo n.º 26
0
 public abstract void craft(Player player);
Exemplo n.º 27
0
 public override bool use(Player player, int attackDir)
 {
     player.game.setMenu(new ContainerMenu(player, "Chest", inventory));
     return true;
 }
Exemplo n.º 28
0
 public ContainerMenu(Player player, string title, Inventory container)
 {
     this.player = player;
     this.title = title;
     this.container = container;
 }
Exemplo n.º 29
0
        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);
            }
        }
Exemplo n.º 30
0
 public virtual bool use(Level level, int xt, int yt, Player player, int attackDir)
 {
     return false;
 }