public EntityCentipedeHead(Vector2 location, WorldBase world) : base(location, world) { aggro = false; this.width = 30; this.height = 30; tex = Game1.texture_monsterpede_head[0]; health = 150; this.walkSpeed = .15f; this.location += new Vector2(0, -100); int bodySegmentSpacing = (int)(width * .9f); int numSegments = 3 + rand.Next(3); health += numSegments * 10; Entity last = this; for (int i = 0; i < numSegments; i++) { EntityCentipedeBody bodySegment = new EntityCentipedeBody(location + new Vector2(i * bodySegmentSpacing, 0), world, last); last = bodySegment; bodySegment.currentTex = i % Game1.texture_monsterpede_body.Length; world.addEntity(bodySegment); } EntityCentipedeEnd endSegment = new EntityCentipedeEnd(location + new Vector2(numSegments * bodySegmentSpacing, 0), world, last); world.addEntity(endSegment); this.frictionMultiplier = .3f; }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); int used = 0; if (user is Player) { Player player = (Player)user; if (player.state.actionPermitted(STATE_ACTIONS.THROW)) { Entities.Projectiles.EntitySpear spear = new Entities.Projectiles.EntitySpear(user.location + new Vector2(0, -15), world, user); spear.velocity += Vector2.Normalize(location - user.location) * 15; world.addEntity(spear); used++; player.state.decorate(spear); player.state.submitStateAction(STATE_ACTIONS.THROW); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); } } else { Entities.Projectiles.EntitySpear spear = new Entities.Projectiles.EntitySpear(user.location + new Vector2(0, -15), world, user); spear.velocity += Vector2.Normalize(location - user.location) * 15; world.addEntity(spear); used++; SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); } return(used); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); bool showUse = true; foreach (UsableEntity ue in user.world.useableEntities) { if (ue is EntityRopeSegment && ue.getUseBounds().Intersects(user.getCollisionBox())) { EntityRopeSegment currentRopeSegment = (EntityRopeSegment)ue; int numRecoveredRopes = 0; while (currentRopeSegment.child != null) { world.killEntity(currentRopeSegment); numRecoveredRopes++; currentRopeSegment = currentRopeSegment.child; } world.killEntity(currentRopeSegment); world.addEntity(new ItemDropEntity(user.location, world, new Item_Rope((int)((float)numRecoveredRopes * .75f)))); break; } if (ue is EntityBetterRopeSegment && ue.getUseBounds().Intersects(user.getCollisionBox())) { showUse = false; EntityBetterRopeSegment currentRopeSegment = (EntityBetterRopeSegment)ue; int numRecoveredRopes = 0; while (currentRopeSegment.child != null) { world.killEntity(currentRopeSegment); numRecoveredRopes++; currentRopeSegment = currentRopeSegment.child; } currentRopeSegment = (EntityBetterRopeSegment)ue; while (currentRopeSegment.parent != null) { world.killEntity(currentRopeSegment); numRecoveredRopes++; currentRopeSegment = currentRopeSegment.parent; } world.killEntity(currentRopeSegment); world.addEntity(new ItemDropEntity(user.location, world, new Item_Rope((int)((float)numRecoveredRopes * .75f)))); break; } } if (showUse) { user.speechManager.addSpeechBubble(Game1.texture_item_rope); } return(0); }
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)); } }
public static void createBloodSpray(Vector2 location, WorldBase world, Vector2 direction, Random rand, int duration, int basecount, int addition) { for (int i = 0; i < basecount + rand.Next(addition) + basecount; i++) { world.addEntity(new ParticleBlood(location, world, -Vector2.Normalize(direction), 150)); } }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); int used = 0; Item_Arrow item_arrow = (Item_Arrow)user.inventory.getItemOfType(new Item_Arrow(1)); if (item_arrow != null) { user.inventory.consume(item_arrow, 1); EntityArrow arrow = new EntityArrow(user.location + new Vector2(0, -15), world, user); arrow.velocity += Vector2.Normalize(location - user.location) * 30; world.addEntity(arrow); used = 1; SoundManager.getSound("bow-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); } else { user.speechManager.addSpeechBubble(Game1.texture_entity_arrow); } return(used); }
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 int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); Entities.EntitySnare snare = new Entities.EntitySnare(user.location + new Vector2(0, -15), world, user); world.addEntity(snare); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); return(1); }
public override void use(WorldBase world, Vector2 location, Entity user) { world.killEntity(this); Random rand = new Random(); foreach (Item item in items) { ItemDropEntity drop = new ItemDropEntity(location, world, item); drop.velocity += new Vector2(rand.Next(1) - 2, -rand.Next(10)); world.addEntity(drop); } }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); Point selPoint = world.worldLocToTileLoc(location); Vector2 fireLoc = new Vector2(selPoint.X * Chunk.tileDrawWidth + Chunk.tileDrawWidth / 2, selPoint.Y * Chunk.tileDrawWidth + Chunk.tileDrawWidth / 2); EntityFire fire = new EntityFire(fireLoc, world); world.addEntity(fire); return(1); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); /*EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(user.location + new Vector2(0, 20), world, user); * macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; * world.addEntity(macuhatilSlash);*/ if (user is Player) { Player player = (Player)user; if (player.state.actionPermitted(STATE_ACTIONS.SWING)) { int dir = -1; if (player.facing > 0) { dir = 1; } EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(user.location + new Vector2(dir * 35, 20), world, user); macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; player.state.decorate(macuhatilSlash); world.addEntity(macuhatilSlash); player.state.submitStateAction(STATE_ACTIONS.SWING); SoundManager.getSound("sword-slash").playWithVariance(-.5f, .2f, 0, SoundType.MONSTER); } } else { EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(user.location + new Vector2(0, 20), world, user); macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; world.addEntity(macuhatilSlash); SoundManager.getSound("sword-slash").playWithVariance(-.5f, .2f, 0, SoundType.MONSTER); } return(0); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); if (user.collideBottom) { EntitySeed seed = new EntitySeed(user.location, world); world.addEntity(seed); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); return(1); } return(0); }
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)); } }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { int consumed = 0; if (inputManager.isDown()) { TileType selectedBlock = user.world.getBlock(location); if (selectedBlock != null && (selectedBlock.tags.Contains(TagReferencer.SOLID))) { if (!inputManager.wasDown() || !user.world.worldLocToTileLoc(location).Equals(harvestLocation)) { harvestLocation = user.world.worldLocToTileLoc(location); ticksHarvesting = 0; maxTicksHarvestingTime = selectedBlock.harvestTicks; } if (ticksHarvesting == 0) { SoundManager.getSound(selectedBlock.blockBreakSound).playWithVariance(0, .05f, 0, SoundType.MONSTER); } ticksHarvesting++; if (ticksHarvesting > selectedBlock.harvestTicks - 1) { user.world.placeTile(TileTypeReferencer.AIR, location); ticksHarvesting = 0; for (int i = 0; i < 7; i++) { world.addEntity(new ParticleTileBreak(location, world, new Vector2(), selectedBlock, 150)); consumed = 1; } } } } else { ticksHarvesting = 0; } return(consumed); }
public override void use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager manager) { if (manager.click()) { if (charges > 0) { SoundManager.getSound("card-use-" + (level - 1)).playWithVariance(0, .5f, 0, SoundType.MONSTER); EntitySticky sticky = new EntitySticky(user.location + new Vector2(0, -15), world); sticky.radious = (int)level + 1; sticky.timeBeforeExplosion = 16; sticky.velocity += Vector2.Normalize(location - user.location) * 22; world.addEntity(sticky); charges--; } else { user.speechManager.addSpeechBubble(Game1.texture_item_charmstone); } } }
public void drop(WorldBase world, Item harvestTool, Vector2 location) { for (int n = 0; n < droppedItem.Count; n++) { int accum = 0; for (int i = 0; i < dropTries[n]; i++) { if ((tools[n] == null || tools[n].GetType().Equals(harvestTool.GetType())) && rand.NextDouble() < probabilities[n]) { accum++; } } if (accum > 0) { ItemDropEntity dropper = new ItemDropEntity(location /* + new Vector2(Chunk.tileDrawWidth / 2, -Chunk.tileDrawWidth / 2)*/, world, droppedItem[n].clone(accum)); dropper.velocity += new Vector2(rand.Next(1) - 2, -rand.Next(10)); world.addEntity(dropper); } } }
public override void onUse(WorldBase world, Item harvestTool, Vector2 location, TileType tileType, Entity user) { base.onUse(world, harvestTool, location, tileType, user); Vector2 lampSpawnLoc = location + new Vector2(Chunk.tileDrawWidth / 2, -Chunk.tileDrawWidth); bool canSpawn = true; foreach (Entity entity in world.entities) { if (entity is EntityLamp && Vector2.Distance(lampSpawnLoc, entity.location) < Chunk.tileDrawWidth) { canSpawn = false; break; } } if (canSpawn) { world.addEntity(new EntityLamp(lampSpawnLoc, world)); } }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); int used = 0; Item_Bullet item_bullet = (Item_Bullet)user.inventory.getItemOfType(new Item_Bullet(1)); if (item_bullet != null) { user.inventory.consume(item_bullet, 1); EntityLaserBolt laserBolt = new EntityLaserBolt(user.location + new Vector2(0, -15), world, user); laserBolt.velocity += Vector2.Normalize(location - user.location) * 30; world.addEntity(laserBolt); used = 1; SoundManager.getSound("gun-fire").playWithVariance(0, 1, 0, SoundType.MONSTER); } return(used); }
public WormHead(Vector2 location, WorldBase world) : base(location, world) { location = location + new Vector2(0, 200);//The worm isn't interesting unless buried in the earth width = 40; height = 40; walkSpeed = .5f; wasPlayerCollidingBottomLastRound = false; latchLoc = resting; int bodySegmentSpacing = (int)(width * .9f); int numSegments = 8 + rand.Next(8); health += numSegments * 10; Entity last = this; for (int i = 0; i < numSegments; i++) { WormBodySegment bodySegment = new WormBodySegment(location + new Vector2(i * bodySegmentSpacing, 0), world, last); last = bodySegment; world.addEntity(bodySegment); } currentTex = Game1.texture_worm_head[0]; windMultiplier = 0; }
public virtual void update(GameTime time) { foreach (SortedList <float, StatusEffect> statusList in statusEffects.Values) { List <float> removeKeys = new List <float>(); foreach (StatusEffect effect in statusList.Values) { effect.update(this); if (effect.timeRemaining <= 0) { removeKeys.Add(effect.potency); } } foreach (float fl in removeKeys) { statusList.Remove(fl); } } StatusEffect healthRegen = getEffect(StatusEffect.status.HEALTHREGEN); float healthRegenAmt = 0; if (healthRegen != null) { healthRegenAmt = healthRegen.potency; if (rand.NextDouble() < .1f) { ParticleHealth particle = new ParticleHealth(location, world, new Vector2(0, 0), 30); world.addEntity(particle); } for (int i = 0; i < rand.Next((int)(healthRegenAmt) / 3); i++) { ParticleHealth particle = new ParticleHealth(location, world, new Vector2(0, 0), 30); world.addEntity(particle); } } StatusEffect poison = getEffect(StatusEffect.status.POISON); float poisonamt = 0; if (poison != null) { poisonamt = poison.potency; } spawnPoisonParticles(poisonamt); ticksExisted++; if (collideBottom && velocity.Y > 0) { velocity = new Vector2(velocity.X, 0); } if (collideLeft && velocity.X < 0) { velocity = new Vector2(0, velocity.Y); } if (collideRight && velocity.X > 0) { velocity = new Vector2(0, velocity.Y); } if (collideTop && velocity.Y < 0) { velocity = new Vector2(velocity.X, 0); } if (collideBottom) { framesCollidingBottom++; } else { framesCollidingBottom = 0; } prePhysicsUpdate(time); performPhysics(time); if (health <= 0) { world.killEntity(this); } remainingDamageImmunityTime--; }
public FindGirlCutscene(WorldBase returnTo) : base("Content\\Cutscene\\FindGirlCutscene\\cutsceneFindSisterWorld", returnTo) { decorator.ambientSoundManager.requestMusicStop(); SoundEffect music = content.Load <SoundEffect>("Sounds/Music/boy_finds_sister_0"); musicInstance = music.CreateInstance(); musicInstance.Volume = MetaData.audioSettingMusic; //set up the next world EntityGirl girl = new EntityGirl(new Vector2(100, ((World)returnTo).noise.octavePerlin1D(100) * returnTo.decorator.getTerrainMultiplier() * Chunk.tileDrawWidth), returnTo); girl.touchedPlayer = true; returnTo.addEntity(girl); cutsceneDuration = 800; cameraCommands.Add(new MovementCommand(new Vector2(200, 0), new Vector2(200, 0), 650));//pause on the scene to let the player process it animatedPlayer = new AnimatedEntity(); animatedSister = new AnimatedEntity(); animatedEntities.Add(animatedPlayer); animatedEntities.Add(animatedSister); animatedPlayer.animations.Add(new Animation(150, 150, new Texture2D[] { Game1.player_default_animations.standTex }, true)); animatedPlayer.animations[0].drawFlipped = true; animatedPlayer.movement.Add(new MovementCommand(new Vector2(0, 27), new Vector2(0, 27), 150)); animatedPlayer.animations.Add(new Animation(7 * 7, 100, Game1.player_default_animations.runTex, true)); animatedPlayer.animations[1].drawFlipped = true; animatedPlayer.movement.Add(new MovementCommand(new Vector2(0, 27), new Vector2(140, 27), 100)); animatedPlayer.animations.Add(new Animation(75, content.loadTextureRange("Cutscene/FindGirlCutscene/player_hug_", 3), false)); animatedPlayer.animations[2].drawFlipped = true; animatedPlayer.movement.Add(new MovementCommand(new Vector2(140, 27), new Vector2(140, 27), 75)); animatedPlayer.animations.Add(new Animation(100, new Texture2D[] { content.Load <Texture2D>("Cutscene/FindGirlCutscene/player_hug_3") }, false)); animatedPlayer.animations[3].drawFlipped = true; animatedPlayer.movement.Add(new MovementCommand(new Vector2(140, 27), new Vector2(140, 27), 100)); animatedPlayer.animations.Add(new Animation(7 * 7, 150, Game1.player_default_animations.runTex, true)); animatedPlayer.animations[4].drawFlipped = true; animatedPlayer.movement.Add(new MovementCommand(new Vector2(140, 27), new Vector2(475, 27), 150)); animatedSister.animations.Add(new Animation(150, 150, new Texture2D[] { Game1.player_girl_animations.standTex }, true)); animatedSister.animations[0].drawFlipped = false; animatedSister.movement.Add(new MovementCommand(new Vector2(300, 25), new Vector2(300, 25), 150)); animatedSister.animations.Add(new Animation(7 * 7, 100, Game1.player_girl_animations.runTex, true)); animatedSister.animations[1].drawFlipped = false; animatedSister.movement.Add(new MovementCommand(new Vector2(300, 25), new Vector2(160, 25), 100)); animatedSister.animations.Add(new Animation(75, content.loadTextureRange("Cutscene/FindGirlCutscene/girl_hug_", 3), false)); animatedSister.animations[2].drawFlipped = false; animatedSister.movement.Add(new MovementCommand(new Vector2(160, 25), new Vector2(160, 25), 75)); animatedSister.animations.Add(new Animation(100, new Texture2D[] { content.Load <Texture2D>("Cutscene/FindGirlCutscene/girl_hug_3") }, false)); animatedSister.animations[3].drawFlipped = false; animatedSister.movement.Add(new MovementCommand(new Vector2(160, 25), new Vector2(160, 25), 100)); animatedSister.animations.Add(new Animation(7 * 7, 200, Game1.player_girl_animations.runTex, true)); animatedSister.animations[4].drawFlipped = true; animatedSister.movement.Add(new MovementCommand(new Vector2(160, 25), new Vector2(475, 25), 200)); for (int i = 0; i < 300; i++) { ParticleArbitrary particle = new ParticleArbitrary(new Vector2(-10 + rand.Next(20), 50 - rand.Next(40)), this, new Vector2((float)rand.NextDouble(), 0), 300, Game1.texture_particle_blood); particle.width = 4; particle.height = 4; particle.gravityMultiplier = (float)rand.NextDouble() * -.4f; particle.startColor = groundColor; particle.endColor = groundColor; this.addEntity(particle); } }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { int consumed = 0; if (inputManager.isDown()) { TileType selectedBlock = user.world.getBlock(user.location); if (selectedBlock != null && (selectedBlock.TILEID == TileTypeReferencer.REACTIVE_TRUNK_0.TILEID || selectedBlock.TILEID == TileTypeReferencer.REACTIVE_TRUNK_1.TILEID)) { if (!inputManager.wasDown() || !user.world.worldLocToTileLoc(user.location).Equals(harvestLocation)) { harvestLocation = user.world.worldLocToTileLoc(user.location); ticksHarvesting = 0; maxTicksHarvestingTime = selectedBlock.harvestTicks; } if (ticksHarvesting == 0) { SoundManager.getSound(selectedBlock.blockBreakSound).playWithVariance(0, .05f, 0, SoundType.MONSTER); } ticksHarvesting++; if (ticksHarvesting > selectedBlock.harvestTicks) { //user.world.useBlock(user.location, user, this); ticksHarvesting = 0; consumed = 1; for (int x = -3; x <= 3; x++) { for (int y = -7; y <= 0; y++) { Vector2 potentialTrunkLoc = user.location + new Vector2(x * Chunk.tileDrawWidth, y * Chunk.tileDrawWidth); TileType potentialTrunk = user.world.getBlock(potentialTrunkLoc); if (potentialTrunk != null && (potentialTrunk.Equals(TileTypeReferencer.REACTIVE_TRUNK_0) || potentialTrunk.Equals(TileTypeReferencer.REACTIVE_TRUNK_1))) { world.useBlock(potentialTrunkLoc, user, this); } } } } /*else * { * world.useBlock(user.location, user, this); * }*/ } else { if (!inputManager.wasDown()) { base.use(user, world, location, time, inputManager); if (user is Player) { Player player = (Player)user; if (player.state.actionPermitted(STATE_ACTIONS.THROW)) { Entities.Projectiles.EntityAxe axe = new Entities.Projectiles.EntityAxe(user.location + new Vector2(0, -15), world, user); axe.velocity += Vector2.Normalize(location - user.location) * 15; world.addEntity(axe); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); consumed = 1; player.state.decorate(axe); player.state.submitStateAction(STATE_ACTIONS.THROW); } } else { Entities.Projectiles.EntityAxe axe = new Entities.Projectiles.EntityAxe(user.location + new Vector2(0, -15), world, user); axe.velocity += Vector2.Normalize(location - user.location) * 15; world.addEntity(axe); SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); consumed = 1; } /*Entities.Projectiles.EntityAxe axe = new Entities.Projectiles.EntityAxe(user.location + new Vector2(0, -15), world, user); * axe.velocity += Vector2.Normalize(location - user.location) * 15; * world.addEntity(axe); * * SoundManager.getSound("spear-throw").playWithVariance(0, .2f, 0, SoundType.MONSTER); * consumed = 1;*/ } } } else { ticksHarvesting = 0; } return(consumed); }
public override void use(WorldBase world, Vector2 location, Entity user) { world.killEntity(this); world.addEntity(new ItemDropEntity(location, world, new Item_Snare(1))); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { base.use(user, world, location, time, inputManager); Item_Rope item_rope = (Item_Rope)user.inventory.getItemOfType(new Item_Rope(1)); if (!prevOrigin.Equals(user.location) || !prevTarget.Equals(location)) { //recalculate the grappling hook trajectory hookWouldBeAnchored = false; ropeIntermediaryPoints.Clear(); hookWouldBeAnchoredAt = 0; ropeThatWouldBeConsumed = 0; if (item_rope != null) { Vector2 position = user.location + new Vector2(0, -5); Vector2 velocity = Vector2.Normalize(location - user.location) * 25; float ropeIncrementDistance = 2.5f; ropeIntermediaryPoints.Add(position); int ropeCount = item_rope.uses; for (int i = 0; i < ropeCount * 2 + 10; i++) { TileType tileIn = world.getBlock(position); if (tileIn != null) { velocity += new Vector2(0, .5f) * ropeIncrementDistance; velocity *= .975f; position += velocity * ropeIncrementDistance; ropeIntermediaryPoints.Add(position); if (tileIn.tags.Contains(TagReferencer.SOLID) && !hookWouldBeAnchored) { hookWouldBeAnchored = true; hookWouldBeAnchoredAt = i + 1; ropeThatWouldBeConsumed = hookWouldBeAnchoredAt / 2; ropeSegmentsInGreen = ropeCount * 2; } } else { //the rope has extended off the map; simply stop calculating. break; } } } } if (!inputManager.isDown() && inputManager.wasDown() && item_rope != null) { if (hookWouldBeAnchored && ropeThatWouldBeConsumed <= item_rope.uses) { EntityBetterRopeSegment previousRopeSegment = new EntityBetterRopeSegment(ropeIntermediaryPoints[0], world, null); previousRopeSegment.isAnchor = true; world.addEntity(previousRopeSegment); EntityBetterRopeSegment nthRopeSegment = null; for (int i = 1; i < hookWouldBeAnchoredAt; i++) { nthRopeSegment = new EntityBetterRopeSegment(ropeIntermediaryPoints[i], world, previousRopeSegment); previousRopeSegment.child = nthRopeSegment; world.addEntity(nthRopeSegment); previousRopeSegment = nthRopeSegment; } previousRopeSegment.isAnchor = true; user.inventory.consume(item_rope, ropeThatWouldBeConsumed); SoundManager.getSound("grappling-hook").playWithVariance(0, .2f, 0, SoundType.MONSTER); } else { //do a flash? } } drawing = inputManager.isDown(); if (inputManager.isDown() && !inputManager.wasDown() && item_rope == null) { user.speechManager.addSpeechBubble(new SpeechBubble(Game1.texture_item_rope)); } prevOrigin = user.location; prevTarget = location; return(0); }
public override int use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager inputManager) { if (inputManager.isDown()) { TileType selectedBlock = user.world.getBlock(user.location); TileType belowBlock = user.world.getBlock(location); if (selectedBlock != null && (selectedBlock.TILEID == TileTypeReferencer.REACTIVE_BUSH_0.TILEID || selectedBlock.TILEID == TileTypeReferencer.REACTIVE_BUSH_0.TILEID)) { if (!inputManager.wasDown() || !user.world.worldLocToTileLoc(user.location).Equals(harvestLocation)) { harvestLocation = user.world.worldLocToTileLoc(user.location); ticksHarvesting = 0; maxTicksHarvestingTime = selectedBlock.harvestTicks; } if (selectedBlock.tags.Contains(TagReferencer.Harvest)) { if (ticksHarvesting == 0) { SoundManager.getSound(selectedBlock.blockBreakSound).playWithVariance(0, .05f, 0, SoundType.MONSTER); } ticksHarvesting++; if (ticksHarvesting > selectedBlock.harvestTicks - 1) { //user.world.useBlock(user.location, user, this); user.world.placeTile(TileTypeReferencer.AIR, user.location); ItemDropEntity dropper = new ItemDropEntity(user.location, world, new Item_Spud(1)); Random random = new Random(); dropper.velocity += new Vector2(random.Next(1) - 2, -random.Next(10)); world.addEntity(dropper); ticksHarvesting = 0; for (int i = 0; i < 7; i++) { world.addEntity(new ParticleTileBreak(user.location, world, new Vector2(), selectedBlock, 150)); } } } } else if (location.Y > user.location.Y + Chunk.tileDrawWidth / 2 && belowBlock != null && belowBlock.tags.Contains(TagReferencer.SOLID)) { if (!inputManager.wasDown() || !user.world.worldLocToTileLoc(location).Equals(harvestLocation)) { harvestLocation = user.world.worldLocToTileLoc(location); ticksHarvesting = 0; maxTicksHarvestingTime = belowBlock.harvestTicks; } if (ticksHarvesting == 0) { SoundManager.getSound(belowBlock.blockBreakSound).playWithVariance(0, .05f, 0, SoundType.MONSTER); } ticksHarvesting++; if (ticksHarvesting > belowBlock.harvestTicks - 1) { user.world.placeTile(TileTypeReferencer.AIR, location); ticksHarvesting = 0; for (int i = 0; i < 7; i++) { world.addEntity(new ParticleTileBreak(location, world, new Vector2(), belowBlock, 150)); } return(1); } } else { ticksHarvesting = 0; } } else { ticksHarvesting = 0; } return(0); }
public override void use(PlayerBase user, WorldBase world, Vector2 location, GameTime time, BinaryInputManager manager) { if (manager.click()) { if (charges > 0) { SoundManager.getSound("card-use-" + (level - 1)).playWithVariance(0, .5f, 0, SoundType.MONSTER); Vector2 teleportLoc = new Vector2(); Vector2 preTeleportLoc = user.location; if (location.X < user.location.X) { teleportLoc = new Vector2(user.location.X - level * 2 * Chunk.tileDrawWidth - Chunk.tileDrawWidth * 3, user.location.Y); TileType teleportTo = world.getBlock(teleportLoc); while (teleportTo != null && teleportTo.tags.Contains(TagReferencer.SOLID)) { teleportLoc += new Vector2(Chunk.tileDrawWidth, 0); teleportTo = world.getBlock(teleportLoc); } user.location = teleportLoc; charges--; } else if (location.X > user.location.X) { teleportLoc = new Vector2(user.location.X + level * 2 * Chunk.tileDrawWidth + Chunk.tileDrawWidth * 3, user.location.Y); TileType teleportTo = world.getBlock(teleportLoc); while (teleportTo != null && teleportTo.tags.Contains(TagReferencer.SOLID)) { teleportLoc += new Vector2(-Chunk.tileDrawWidth, 0); teleportTo = world.getBlock(teleportLoc); } user.location = teleportLoc; charges--; } for (int i = 0; i < 7; i++) { ParticleArbitrary teleportParticle = new ParticleArbitrary(preTeleportLoc + (teleportLoc - preTeleportLoc) * (float)i / 7, world, new Vector2(), (int)(75 * (1 - 1f / (i + 1))), ((Player)user).texture_run[0]); if (preTeleportLoc.X < teleportLoc.X) { teleportParticle.flip = true; } teleportParticle.gravityMultiplier = 0; teleportParticle.endColor = teleportParticle.endColor * .01f; world.addEntity(teleportParticle); } if (user.inventory.getItemOfType(new Item_Macuhatil(1)) != null) { for (int i = 0; i < 7; i++) { ParticleArbitrary teleportParticle = new ParticleArbitrary(preTeleportLoc + (teleportLoc - preTeleportLoc) * (float)i / 7 + new Vector2(0, -10), world, new Vector2(), (int)(75 * (1 - 1f / (i + 1))), Game1.texture_item_macuhatil); teleportParticle.gravityMultiplier = -.1f; teleportParticle.endColor = Color.Red; world.addEntity(teleportParticle); EntityMacuhatilSlash macuhatilSlash = new EntityMacuhatilSlash(preTeleportLoc + (teleportLoc - preTeleportLoc) * (float)i / 7, world, user); macuhatilSlash.velocity += Vector2.Normalize(location - user.location) * .1f; world.addEntity(macuhatilSlash); SoundManager.getSound("sword-slash").playWithVariance(-.5f, .4f, 0, SoundType.MONSTER); } } else if (user.inventory.getItemOfType(new Item_Sword(1)) != null) { for (int i = 0; i < 7; i++) { ParticleArbitrary teleportParticle = new ParticleArbitrary(preTeleportLoc + (teleportLoc - preTeleportLoc) * (float)i / 7 + new Vector2(0, -10), world, new Vector2(), (int)(75 * (1 - 1f / (i + 1))), Game1.texture_item_sword); teleportParticle.gravityMultiplier = -.1f; teleportParticle.endColor = Color.Red; world.addEntity(teleportParticle); EntitySwordSlash swordSlash = new EntitySwordSlash(preTeleportLoc + (teleportLoc - preTeleportLoc) * (float)i / 7, world, user); swordSlash.canUnlockWarrior = true; swordSlash.velocity += Vector2.Normalize(location - user.location) * .1f; world.addEntity(swordSlash); SoundManager.getSound("sword-slash").playWithVariance(0f, .4f, 0, SoundType.MONSTER); } } } else { user.speechManager.addSpeechBubble(Game1.texture_item_charmstone); } } else if (manager.isDown()) { if (charges > 0) { Vector2 teleportLoc = new Vector2(); Vector2 preTeleportLoc = user.location; if (location.X < user.location.X) { teleportLoc = new Vector2(user.location.X - level * 2 * Chunk.tileDrawWidth - Chunk.tileDrawWidth * 3, user.location.Y); TileType teleportTo = world.getBlock(teleportLoc); while (teleportTo != null && teleportTo.tags.Contains(TagReferencer.SOLID)) { teleportLoc += new Vector2(Chunk.tileDrawWidth, 0); teleportTo = world.getBlock(teleportLoc); } } else if (location.X > user.location.X) { teleportLoc = new Vector2(user.location.X + level * 2 * Chunk.tileDrawWidth + Chunk.tileDrawWidth * 3, user.location.Y); TileType teleportTo = world.getBlock(teleportLoc); while (teleportTo != null && teleportTo.tags.Contains(TagReferencer.SOLID)) { teleportLoc += new Vector2(-Chunk.tileDrawWidth, 0); teleportTo = world.getBlock(teleportLoc); } } ParticleArbitrary teleportParticle = new ParticleArbitrary(preTeleportLoc + (teleportLoc - preTeleportLoc), world, new Vector2(), 7, ((Player)user).texture_run[0]); if (preTeleportLoc.X < teleportLoc.X) { teleportParticle.flip = true; } teleportParticle.gravityMultiplier = 0; teleportParticle.startColor = Color.Lerp(teleportParticle.startColor, Color.White, .5f); teleportParticle.endColor = teleportParticle.endColor * .01f; world.addEntity(teleportParticle); } } }