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 override void prePhysicsUpdate(GameTime time) { base.prePhysicsUpdate(time); currentTexSwap--; if (currentTexSwap <= 0) { if (!aggro) { currentTexIndex = (currentTexIndex + 1) % Game1.texture_entity_wheelie_stand.Length; currentTex = Game1.texture_entity_wheelie_stand[currentTexIndex]; currentTexSwap = texSwapPoint; } else { if (chargingJump) { currentTexIndex++; currentTex = Game1.texture_entity_wheelie_charge_jump[(int)Math.Floor(((float)currentJumpChargeTime / maxJumpChargeTime) * Game1.texture_entity_wheelie_charge_jump.Count())]; } else if (attacking) { currentTexIndex = (currentTexIndex + 1) % Game1.texture_entity_wheelie_stand.Length; currentTex = Game1.texture_entity_wheelie_stand[currentTexIndex]; currentTexSwap = texSwapPoint; } else { currentTexIndex = (currentTexIndex + 1) % Game1.texture_entity_wheelie_run.Length; currentTex = Game1.texture_entity_wheelie_run[currentTexIndex]; currentTexSwap = texSwapPoint; } } } foreach (Entity entity in world.entities) { if (entity is Weapon) { if (Vector2.Distance(entity.location, this.location) <= 100) { spook(); } } } float distanceFromPlayer = Vector2.Distance(world.player.location, this.location); if (distanceFromPlayer <= 700 * world.player.detectionRadiousModifier) { if (Vector2.Distance(world.player.location, lastPlayerLoc) > 4 && random.NextDouble() < .05f * world.player.detectionLevel) { spook(); } lastPlayerLoc = world.player.location; } if (distanceFromPlayer >= 1000 && aggro) { aggro = false; world.decorator.ambientSoundManager.unStartle(); } if (aggro) { //Console.WriteLine(velocity.Length()); if (runSound != null && runSound.IsDisposed) { runSound = null; } if (runSound == null) { runSound = SoundManager.getSound("wheelie_walk").playWithVariance(0, 1f / distanceFromPlayer * 80, (location - world.player.location).X, SoundType.MONSTER); } if (collideBottom) { if (runSound.State == SoundState.Paused) { runSound.Resume(); } } else if (runSound.State == SoundState.Playing) { runSound.Pause(); } runSound.Volume = (float)Math.Max(Math.Min((1f / distanceFromPlayer * 10) * (velocity.Length() / 10), 1), 0); if (!chargingJump && !attacking) { timeUntilJumpOrAttack--; if (timeUntilJumpOrAttack < 0) { if (rand.NextDouble() < .7) { attacking = true; SoundManager.getSound("wheelie_prepare_shot").playWithVariance(0, 1f / distanceFromPlayer * 200, 0, SoundType.MONSTER); } else { chargingJump = true; } timeUntilJumpOrAttack = maxTimeUntilJumpOrAttack; } else if (collideLeft || collideRight) { chargingJump = true; } if (distanceFromPlayer >= 500) { float direction = 0; if (world.player.location.X < this.location.X) { direction = -1; } else if (world.player.location.X > this.location.X) { direction = 1; } walk(direction); } else if (distanceFromPlayer <= 350) { float direction = 0; if (world.player.location.X < this.location.X) { direction = 1; } else if (world.player.location.X > this.location.X) { direction = -1; } walk(direction); } } else if (chargingJump) { currentJumpChargeTime++; if (currentJumpChargeTime >= maxJumpChargeTime) { currentJumpChargeTime = 0; chargingJump = false; jump(1); } } else if (attacking) { currentAimTime--; if (currentAimTime <= 0) { EntityLaserBolt laserBolt = new EntityLaserBolt(location + new Vector2(0, -15), world, this); laserBolt.velocity += Vector2.Normalize(world.player.location - (location + new Vector2(0, -15))) * 10; laserBolt.baseDamage = 20; laserBolt.possibleAdditionalDamage = 10; world.addEntity(laserBolt); attacking = false; currentAimTime = aimTime; SoundManager.getSound("gun-fire").playWithVariance(0, 1, location.X - world.player.location.X, SoundType.MONSTER); currentAimTime = aimTime; attacking = false; } } } if (health <= 0) { world.addEntity(new ItemDropEntity(location, world, new Item_Seed(1))); /*if(!hasDroppedCraftingRecepie) * { * Game1.instance.crafting.registerRecepie(new CraftingRecepie(new Item_Spear_Fanged(1), .4f, new Item[] { new Item_Spear(1), new Item_Guardian_Fang(1) }, new int[] { 1, 1 })); * hasDroppedCraftingRecepie = true; * }*/ if (runSound != null && !runSound.IsDisposed) { runSound.Stop(); runSound.Dispose(); } world.decorator.ambientSoundManager.unStartle(); } }