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 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); } } }