public override void onUse(WorldBase world, Item harvestTool, Vector2 location, TileType tileType, Entity user)
        {
            base.onUse(world, harvestTool, location, tileType, user);

            if (HarvestDictionary.hasGhostForTile(tileType))
            {
                world.placeTile(HarvestDictionary.getGhostForTile(tileType), location);
            }
            else
            {
                world.placeTile(TileTypeReferencer.AIR, location);
            }


            ItemDropper[] drops = HarvestDictionary.getHarvestsForTile(tileType);
            foreach (ItemDropper dropper in drops)
            {
                dropper.drop(world, harvestTool, location);
            }

            for (int i = 0; i < 7; i++)
            {
                world.addEntity(new ParticleTileBreak(location, world, new Vector2(), tileType, 150));
            }
        }
Example #2
0
        public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager)
        {
            int consumed = 0;

            TileType currentTile = world.getBlock(location);

            if (currentTile != null && !currentTile.tags.Contains(TagReferencer.Climbeable) && !currentTile.tags.Contains(TagReferencer.Teleporter))
            {
                consumed = 1;
                world.placeTile(TileTypeReferencer.LADDER, location);
            }


            return(consumed);
        }
        public override void onUse(WorldBase world, Item harvestTool, Vector2 location, TileType tileType, Entity user)
        {
            base.onUse(world, harvestTool, location, tileType, user);
            if (user is PlayerBase)
            {
                bool destroy = false;

                PlayerBase player = ((PlayerBase)user);
                if (player.cards[0] != null)
                {
                    int chargeParticleCount = player.cardCharges - player.cards[0].charges;
                    player.cards[0].charges = player.cardCharges;
                    for (int i = 0; i < chargeParticleCount; i++)
                    {
                        world.addEntity(new ParticleRecharge(location, world, new Vector2(0, -1), 75));
                    }

                    if (player.cards[0] is CardHealthRegen)
                    {
                        destroy = true;
                    }
                }
                if (player.cards[1] != null)
                {
                    int chargeParticleCount = player.cardCharges - player.cards[1].charges;
                    player.cards[1].charges = player.cardCharges;
                    for (int i = 0; i < chargeParticleCount; i++)
                    {
                        world.addEntity(new ParticleRecharge(location, world, new Vector2(0, -1), 75));
                    }

                    if (player.cards[1] is CardHealthRegen)
                    {
                        destroy = true;
                    }
                }

                if (destroy)
                {
                    world.placeTile(TileTypeReferencer.AIR, location);
                    for (int i = 0; i < 7; i++)
                    {
                        world.addEntity(new ParticleTileBreak(location, world, new Vector2(), tileType, 150));
                    }
                }
            }
        }
        public override void onUse(WorldBase world, Item harvestTool, Vector2 location, TileType tileType, Entity user)
        {
            base.onUse(world, harvestTool, location, tileType, user);
            Random rand = new Random();

            world.placeTile(TileTypeReferencer.AIR, location);

            Item dropped = treasures[rand.Next(treasures.Count)];

            ItemDropper drop = new ItemDropper();

            drop.registerNewDrop(dropped.clone(dropped.uses), null, dropped.uses, 1);
            drop.drop(world, harvestTool, location);

            for (int i = 0; i < 7; i++)
            {
                world.addEntity(new ParticleTileBreak(location, world, new Vector2(), tileType, 150));
            }
        }