protected Device(LogicalPlayerIndex logicalPlayerIndex, DeviceType type, int index) { Type = type; _index = index; mapping = new Dictionary<MappingButtons, ButtonState>(); ThumbStickRight = new ThumbstickState(); ThumbStickLeft = new ThumbstickState(); rumbles = new Rumble[4]; for (int i = 0; i < rumbles.Length; i++) { rumbles[i] = new Rumble(0); } RumbleAssignation(); }
public new bool performAction(string action, Farmer who, Location tileLocation) { if (action == null || !who.IsLocalPlayer) { return(false); } string[] strArguments = action.Split(' '); string command = strArguments[0]; switch (command) { case "Carpenter": if (who.getTileY() > tileLocation.Y) { carpenters(tileLocation); } return(true); case "Door": if (strArguments.Length > 1 && !Game1.eventUp) { for (int index = 1; index < strArguments.Length; ++index) { if (who.getFriendshipHeartLevelForNPC(strArguments[index]) >= 2 || Game1.player.mailReceived.Contains("doorUnlock" + strArguments[index])) { Rumble.rumble(0.1f, 100f); if (!Game1.player.mailReceived.Contains("doorUnlock" + strArguments[index])) { Game1.player.mailReceived.Add("doorUnlock" + strArguments[index]); } openDoor(tileLocation, true); return(false); } } if (strArguments.Length == 2 && Game1.getCharacterFromName(strArguments[1], false) != null) { NPC characterFromName = Game1.getCharacterFromName(strArguments[1], false); Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:DoorUnlock_NotFriend_" + (characterFromName.Gender == 0 ? "Male" : "Female"), (object)characterFromName.displayName)); return(true); } else if (Game1.getCharacterFromName(strArguments[1], false) != null && Game1.getCharacterFromName(strArguments[2], false) != null) { NPC characterFromName1 = Game1.getCharacterFromName(strArguments[1], false); NPC characterFromName2 = Game1.getCharacterFromName(strArguments[2], false); Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:DoorUnlock_NotFriend_Couple", (object)characterFromName1.displayName, (object)characterFromName2.displayName)); return(true); } else if (Game1.getCharacterFromName(strArguments[1], false) != null) { NPC characterFromName = Game1.getCharacterFromName(strArguments[1], false); Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:DoorUnlock_NotFriend_" + (characterFromName.Gender == 0 ? "Male" : "Female"), (object)characterFromName.displayName)); return(true); } } else { openDoor(tileLocation, true); return(false); } break; case "Message": Game1.drawDialogueNoTyping(Game1.content.LoadString("Strings\\StringsFromMaps:" + strArguments[1].Replace("\"", ""))); return(true); } return(false); }
public void hid_setRumbleOn(Rumble a) { /*Still not totally sure how it works, maybe something like this instead? * 3 - duration_right * 4 - power_right * 5 - duration_left * 6 - power_left */ if (((uint)a & 0x30) > 0) { HIDBuffer[3] = 0xfe; HIDBuffer[5] = 0xfe; if (((uint)a & 0x10) > 0) { HIDBuffer[4] = 0;//low mode off HIDBuffer[6] = 0xff;//high mode on } else { HIDBuffer[6] = 0;//high mode off HIDBuffer[4] = 0xff;//low mode on } HID_Command(HIDBuffer, PS3Controller.OUTPUT_REPORT_BUFFER.Length + 2); } }
public void StopRumble(IRumbleSession session) { Rumble.StopRumble(session); }
public override void update(GameTime time, GameLocation location) { base.currentLocation = location; mutex.Update(location); squeezingThroughGate = false; faceTowardFarmer = false; faceTowardFarmerTimer = -1; Sprite.loop = rider != null && !rider.hidden; if (rider != null && (bool)rider.hidden) { return; } if (rider != null && rider.isAnimatingMount) { rider.showNotCarrying(); } if ((bool)mounting) { if (rider == null || !rider.IsLocalPlayer) { return; } if (rider.mount != null) { mounting.Value = false; rider.isAnimatingMount = false; rider = null; Halt(); farmerPassesThrough = false; return; } if (rider.Position.X < (float)(GetBoundingBox().X + 16 - 4)) { rider.position.X += 4f; } else if (rider.Position.X > (float)(GetBoundingBox().X + 16 + 4)) { rider.position.X -= 4f; } if (rider.getStandingY() < GetBoundingBox().Y - 4) { rider.position.Y += 4f; } else if (rider.getStandingY() > GetBoundingBox().Y + 4) { rider.position.Y -= 4f; } if (rider.yJumpOffset >= -8 && rider.yJumpVelocity <= 0f) { Halt(); Sprite.loop = true; base.currentLocation.characters.Remove(this); rider.mount = this; rider.freezePause = -1; mounting.Value = false; rider.isAnimatingMount = false; rider.canMove = true; if (FacingDirection == 1) { rider.xOffset += 8f; } } } else if ((bool)dismounting) { if (rider == null || !rider.IsLocalPlayer) { Halt(); return; } if (rider.isAnimatingMount) { rider.faceDirection(FacingDirection); } Vector2 targetPosition = new Vector2(dismountTile.X * 64f + 32f - (float)(rider.GetBoundingBox().Width / 2), dismountTile.Y * 64f + 4f); if (Math.Abs(rider.Position.X - targetPosition.X) > 4f) { if (rider.Position.X < targetPosition.X) { rider.position.X += Math.Min(4f, targetPosition.X - rider.Position.X); } else if (rider.Position.X > targetPosition.X) { rider.position.X += Math.Max(-4f, targetPosition.X - rider.Position.X); } } if (Math.Abs(rider.Position.Y - targetPosition.Y) > 4f) { if (rider.Position.Y < targetPosition.Y) { rider.position.Y += Math.Min(4f, targetPosition.Y - rider.Position.Y); } else if (rider.Position.Y > targetPosition.Y) { rider.position.Y += Math.Max(-4f, targetPosition.Y - rider.Position.Y); } } if (rider.yJumpOffset >= 0 && rider.yJumpVelocity <= 0f) { rider.position.Y += 8f; rider.position.X = targetPosition.X; int tries = 0; while (rider.currentLocation.isCollidingPosition(rider.GetBoundingBox(), Game1.viewport, isFarmer: true, 0, glider: false, rider) && tries < 6) { tries++; rider.position.Y -= 4f; } if (tries == 6) { rider.Position = base.Position; dismounting.Value = false; rider.isAnimatingMount = false; rider.freezePause = -1; rider.canMove = true; return; } dismount(); } } else if (rider == null && FacingDirection != 2 && Sprite.CurrentAnimation == null && Game1.random.NextDouble() < 0.002) { Sprite.loop = false; switch (FacingDirection) { case 0: Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(25, Game1.random.Next(250, 750)), new FarmerSprite.AnimationFrame(14, 10) }); break; case 1: Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(21, 100), new FarmerSprite.AnimationFrame(22, 100), new FarmerSprite.AnimationFrame(23, 400), new FarmerSprite.AnimationFrame(24, 400), new FarmerSprite.AnimationFrame(23, 400), new FarmerSprite.AnimationFrame(24, 400), new FarmerSprite.AnimationFrame(23, 400), new FarmerSprite.AnimationFrame(24, 400), new FarmerSprite.AnimationFrame(23, 400), new FarmerSprite.AnimationFrame(22, 100), new FarmerSprite.AnimationFrame(21, 100) }); break; case 3: Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(21, 100, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(22, 100, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(23, 100, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(24, 400, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(23, 400, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(24, 400, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(23, 400, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(24, 400, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(23, 400, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(22, 100, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(21, 100, secondaryArm: false, flip: true) }); break; } } else if (rider != null) { if (FacingDirection != rider.FacingDirection || ridingAnimationDirection != FacingDirection) { Sprite.StopAnimation(); faceDirection(rider.FacingDirection); } bool num = (rider.movementDirections.Any() && rider.CanMove) || rider.position.Field.IsInterpolating(); SyncPositionToRider(); if (num && Sprite.CurrentAnimation == null) { AnimatedSprite.endOfAnimationBehavior mountFootstep = delegate { if (rider != null) { string a = rider.currentLocation.doesTileHaveProperty((int)rider.getTileLocation().X, (int)rider.getTileLocation().Y, "Type", "Back"); if (!(a == "Stone")) { if (a == "Wood") { if (rider.ShouldHandleAnimationSound()) { rider.currentLocation.localSoundAt("woodyStep", getTileLocation()); } if (rider == Game1.player) { Rumble.rumble(0.1f, 50f); } } else { if (rider.ShouldHandleAnimationSound()) { rider.currentLocation.localSoundAt("thudStep", getTileLocation()); } if (rider == Game1.player) { Rumble.rumble(0.3f, 50f); } } } else { if (rider.ShouldHandleAnimationSound()) { rider.currentLocation.localSoundAt("stoneStep", getTileLocation()); } if (rider == Game1.player) { Rumble.rumble(0.1f, 50f); } } } }; if (FacingDirection == 1) { Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(8, 70), new FarmerSprite.AnimationFrame(9, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(10, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(11, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(12, 70), new FarmerSprite.AnimationFrame(13, 70) }); } else if (FacingDirection == 3) { Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(8, 70, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(9, 70, secondaryArm: false, flip: true, mountFootstep), new FarmerSprite.AnimationFrame(10, 70, secondaryArm: false, flip: true, mountFootstep), new FarmerSprite.AnimationFrame(11, 70, secondaryArm: false, flip: true, mountFootstep), new FarmerSprite.AnimationFrame(12, 70, secondaryArm: false, flip: true), new FarmerSprite.AnimationFrame(13, 70, secondaryArm: false, flip: true) }); } else if (FacingDirection == 0) { Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(15, 70), new FarmerSprite.AnimationFrame(16, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(17, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(18, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(19, 70), new FarmerSprite.AnimationFrame(20, 70) }); } else if (FacingDirection == 2) { Sprite.setCurrentAnimation(new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(1, 70), new FarmerSprite.AnimationFrame(2, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(3, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(4, 70, secondaryArm: false, flip: false, mountFootstep), new FarmerSprite.AnimationFrame(5, 70), new FarmerSprite.AnimationFrame(6, 70) }); } ridingAnimationDirection = FacingDirection; } if (!num) { Sprite.StopAnimation(); faceDirection(rider.FacingDirection); } } if (FacingDirection == 3) { drawOffset.Set(Vector2.Zero); } else { drawOffset.Set(new Vector2(-16f, 0f)); } flip = FacingDirection == 3; base.update(time, location); }
public PluginLoader() { if (!_loaded) { switch (ObjectManager.Player.ChampionName.ToLower()) { case "ahri": var ahri = new Ahri(); _loaded = true; break; case "akali": var akali = new Akali(); _loaded = true; break; case "anivia": var anivia = new Anivia(); break; case "cassiopeia": var cassiopeia = new Cassiopeia(); _loaded = true; break; case "ashe": var ashe = new Ashe(); _loaded = true; break; case "azir": var azir = new Azir(); _loaded = true; break; case "chogath": var chogath = new Chogath(); _loaded = true; break; case "corki": var corki = new Corki(); _loaded = true; break; case "ekko": var ekko = new Ekko(); _loaded = true; break; case "ezreal": var ezreal = new Ezreal(); _loaded = true; break; case "irelia": var irelia = new Irelia(); _loaded = true; break; case "jinx": var jinx = new Jinx(); _loaded = true; break; case "karthus": var karthus = new Karthus(); _loaded = true; break; case "katarina": var katarina = new Katarina(); _loaded = true; break; case "kogmaw": var kogMaw = new KogMaw(); _loaded = true; break; case "lissandra": var lissandra = new Lissandra(); _loaded = true; break; case "lucian": var lucian = new Lucian(); _loaded = true; break; case "jayce": var jayce = new Jayce(); _loaded = true; break; case "orianna": var orianna = new Orianna(); _loaded = true; break; case "rumble": var rumble = new Rumble(); _loaded = true; break; case "syndra": var syndra = new Syndra(); _loaded = true; break; case "vayne": var vayne = new Vayne(); _loaded = true; break; case "viktor": var viktor = new Viktor(); _loaded = true; break; case "vladimir": var vladimir = new Vladimir(); _loaded = true; break; case "urgot": var urgot = new Urgot(); _loaded = true; break; case "zyra": var zyra = new Zyra(); _loaded = true; break; //case "veigar": // var veigar = new Veigar(); // _loaded = true; // break; case "zed": var zed = new Zed(); _loaded = true; break; default: Notifications.AddNotification(ObjectManager.Player.ChampionName + " not supported!!", 10000); break; } } }
public override void update(GameTime time) { if (this.sparkleText != null && this.sparkleText.update(time)) { this.sparkleText = (SparklingText)null; } if ((double)this.everythingShakeTimer > 0.0) { this.everythingShakeTimer = this.everythingShakeTimer - (float)time.ElapsedGameTime.Milliseconds; this.everythingShake = new Vector2((float)Game1.random.Next(-10, 11) / 10f, (float)Game1.random.Next(-10, 11) / 10f); if ((double)this.everythingShakeTimer <= 0.0) { this.everythingShake = Vector2.Zero; } } if (this.fadeIn) { this.scale = this.scale + 0.05f; if ((double)this.scale >= 1.0) { this.scale = 1f; this.fadeIn = false; } } else if (this.fadeOut) { if ((double)this.everythingShakeTimer > 0.0 || this.sparkleText != null) { return; } this.scale = this.scale - 0.05f; if ((double)this.scale <= 0.0) { this.scale = 0.0f; this.fadeOut = false; if ((double)this.distanceFromCatching > 0.899999976158142 && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).pullFishFromWater(this.whichFish, this.fishSize, this.fishQuality, (int)this.difficulty, this.treasureCaught, this.perfect); } else { if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).doneFishing(Game1.player, true); } Game1.player.completelyStopAnimatingOrDoingAction(); } Game1.exitActiveMenu(); Game1.setRichPresence("location", (object)Game1.currentLocation.Name); } } else { if (Game1.random.NextDouble() < (double)this.difficulty * (this.motionType == 2 ? 20.0 : 1.0) / 4000.0 && (this.motionType != 2 || (double)this.bobberTargetPosition == -1.0)) { float num1 = 548f - this.bobberPosition; float bobberPosition = this.bobberPosition; float num2 = Math.Min(99f, this.difficulty + (float)Game1.random.Next(10, 45)) / 100f; this.bobberTargetPosition = this.bobberPosition + (float)Game1.random.Next(-(int)bobberPosition, (int)num1) * num2; } if (this.motionType == 4) { this.floaterSinkerAcceleration = Math.Max(this.floaterSinkerAcceleration - 0.01f, -1.5f); } else if (this.motionType == 3) { this.floaterSinkerAcceleration = Math.Min(this.floaterSinkerAcceleration + 0.01f, 1.5f); } if ((double)Math.Abs(this.bobberPosition - this.bobberTargetPosition) > 3.0 && (double)this.bobberTargetPosition != -1.0) { this.bobberAcceleration = (float)(((double)this.bobberTargetPosition - (double)this.bobberPosition) / ((double)Game1.random.Next(10, 30) + (100.0 - (double)Math.Min(100f, this.difficulty)))); this.bobberSpeed = this.bobberSpeed + (float)(((double)this.bobberAcceleration - (double)this.bobberSpeed) / 5.0); } else { this.bobberTargetPosition = this.motionType == 2 || Game1.random.NextDouble() >= (double)this.difficulty / 2000.0 ? -1f : this.bobberPosition + (Game1.random.NextDouble() < 0.5 ? (float)Game1.random.Next(-100, -51) : (float)Game1.random.Next(50, 101)); } if (this.motionType == 1 && Game1.random.NextDouble() < (double)this.difficulty / 1000.0) { this.bobberTargetPosition = this.bobberPosition + (Game1.random.NextDouble() < 0.5 ? (float)Game1.random.Next(-100 - (int)this.difficulty * 2, -51) : (float)Game1.random.Next(50, 101 + (int)this.difficulty * 2)); } this.bobberTargetPosition = Math.Max(-1f, Math.Min(this.bobberTargetPosition, 548f)); this.bobberPosition = this.bobberPosition + (this.bobberSpeed + this.floaterSinkerAcceleration); if ((double)this.bobberPosition > 532.0) { this.bobberPosition = 532f; } else if ((double)this.bobberPosition < 0.0) { this.bobberPosition = 0.0f; } this.bobberInBar = (double)this.bobberPosition + 16.0 <= (double)this.bobberBarPos - 32.0 + (double)this.bobberBarHeight && (double)this.bobberPosition - 16.0 >= (double)this.bobberBarPos - 32.0; if ((double)this.bobberPosition >= (double)(548 - this.bobberBarHeight) && (double)this.bobberBarPos >= (double)(568 - this.bobberBarHeight - 4)) { this.bobberInBar = true; } int num3 = this.buttonPressed ? 1 : 0; this.buttonPressed = Game1.oldMouseState.LeftButton == ButtonState.Pressed || Game1.isOneOfTheseKeysDown(Game1.oldKBState, Game1.options.useToolButton) || Game1.options.gamepadControls && (Game1.oldPadState.IsButtonDown(Buttons.X) || Game1.oldPadState.IsButtonDown(Buttons.A)); if (num3 == 0 && this.buttonPressed) { Game1.playSound("fishingRodBend"); } float num4 = this.buttonPressed ? -0.25f : 0.25f; if (this.buttonPressed && (double)num4 < 0.0 && ((double)this.bobberBarPos == 0.0 || (double)this.bobberBarPos == (double)(568 - this.bobberBarHeight))) { this.bobberBarSpeed = 0.0f; } if (this.bobberInBar) { num4 *= this.whichBobber == 691 ? 0.3f : 0.6f; if (this.whichBobber == 691) { this.bobberBarSpeed = (double)this.bobberPosition + 16.0 >= (double)this.bobberBarPos + (double)(this.bobberBarHeight / 2) ? this.bobberBarSpeed + 0.2f : this.bobberBarSpeed - 0.2f; } } float bobberBarPos = this.bobberBarPos; this.bobberBarSpeed = this.bobberBarSpeed + num4; this.bobberBarPos = this.bobberBarPos + this.bobberBarSpeed; if ((double)this.bobberBarPos + (double)this.bobberBarHeight > 568.0) { this.bobberBarPos = (float)(568 - this.bobberBarHeight); this.bobberBarSpeed = (float)(-(double)this.bobberBarSpeed * 2.0 / 3.0 * (this.whichBobber == 692 ? 0.100000001490116 : 1.0)); if ((double)bobberBarPos + (double)this.bobberBarHeight < 568.0) { Game1.playSound("shiny4"); } } else if ((double)this.bobberBarPos < 0.0) { this.bobberBarPos = 0.0f; this.bobberBarSpeed = (float)(-(double)this.bobberBarSpeed * 2.0 / 3.0); if ((double)bobberBarPos > 0.0) { Game1.playSound("shiny4"); } } bool flag = false; if (this.treasure) { float treasureAppearTimer = this.treasureAppearTimer; this.treasureAppearTimer = this.treasureAppearTimer - (float)time.ElapsedGameTime.Milliseconds; if ((double)this.treasureAppearTimer <= 0.0) { if ((double)this.treasureScale < 1.0 && !this.treasureCaught) { if ((double)treasureAppearTimer > 0.0) { this.treasurePosition = (double)this.bobberBarPos > 274.0 ? (float)Game1.random.Next(8, (int)this.bobberBarPos - 20) : (float)Game1.random.Next(Math.Min(528, (int)this.bobberBarPos + this.bobberBarHeight), 500); Game1.playSound("dwop"); } this.treasureScale = Math.Min(1f, this.treasureScale + 0.1f); } flag = (double)this.treasurePosition + 16.0 <= (double)this.bobberBarPos - 32.0 + (double)this.bobberBarHeight && (double)this.treasurePosition - 16.0 >= (double)this.bobberBarPos - 32.0; if (flag && !this.treasureCaught) { this.treasureCatchLevel = this.treasureCatchLevel + 0.0135f; this.treasureShake = new Vector2((float)Game1.random.Next(-2, 3), (float)Game1.random.Next(-2, 3)); if ((double)this.treasureCatchLevel >= 1.0) { Game1.playSound("newArtifact"); this.treasureCaught = true; } } else if (this.treasureCaught) { this.treasureScale = Math.Max(0.0f, this.treasureScale - 0.1f); } else { this.treasureShake = Vector2.Zero; this.treasureCatchLevel = Math.Max(0.0f, this.treasureCatchLevel - 0.01f); } } } if (this.bobberInBar) { this.distanceFromCatching = this.distanceFromCatching + 1f / 500f; this.reelRotation = this.reelRotation + 0.3926991f; this.fishShake.X = (float)Game1.random.Next(-10, 11) / 10f; this.fishShake.Y = (float)Game1.random.Next(-10, 11) / 10f; this.barShake = Vector2.Zero; Rumble.rumble(0.1f, 1000f); if (BobberBar.unReelSound != null) { BobberBar.unReelSound.Stop(AudioStopOptions.Immediate); } if (Game1.soundBank != null && (BobberBar.reelSound == null || BobberBar.reelSound.IsStopped || BobberBar.reelSound.IsStopping)) { BobberBar.reelSound = Game1.soundBank.GetCue("fastReel"); } if (BobberBar.reelSound != null && !BobberBar.reelSound.IsPlaying && !BobberBar.reelSound.IsStopping) { BobberBar.reelSound.Play(); } } else if (!flag || this.treasureCaught || this.whichBobber != 693) { if (!this.fishShake.Equals(Vector2.Zero)) { Game1.playSound("tinyWhip"); this.perfect = false; Rumble.stopRumbling(); } this.fishSizeReductionTimer = this.fishSizeReductionTimer - time.ElapsedGameTime.Milliseconds; if (this.fishSizeReductionTimer <= 0) { this.fishSize = Math.Max(this.minFishSize, this.fishSize - 1); this.fishSizeReductionTimer = 800; } if (Game1.player.fishCaught != null && Game1.player.fishCaught.Count != 0 || Game1.currentMinigame != null) { this.distanceFromCatching = this.distanceFromCatching - (this.whichBobber == 694 ? 1f / 500f : 3f / 1000f); } this.reelRotation = this.reelRotation - 3.141593f / Math.Max(10f, 200f - Math.Abs(this.bobberPosition - (this.bobberBarPos + (float)(this.bobberBarHeight / 2)))); this.barShake.X = (float)Game1.random.Next(-10, 11) / 10f; this.barShake.Y = (float)Game1.random.Next(-10, 11) / 10f; this.fishShake = Vector2.Zero; if (BobberBar.reelSound != null) { BobberBar.reelSound.Stop(AudioStopOptions.Immediate); } if (Game1.soundBank != null && (BobberBar.unReelSound == null || BobberBar.unReelSound.IsStopped)) { BobberBar.unReelSound = Game1.soundBank.GetCue("slowReel"); BobberBar.unReelSound.SetVariable("Pitch", 600f); } if (BobberBar.unReelSound != null && !BobberBar.unReelSound.IsPlaying && !BobberBar.unReelSound.IsStopping) { BobberBar.unReelSound.Play(); } } this.distanceFromCatching = Math.Max(0.0f, Math.Min(1f, this.distanceFromCatching)); if (Game1.player.CurrentTool != null) { Game1.player.CurrentTool.tickUpdate(time, Game1.player); } if ((double)this.distanceFromCatching <= 0.0) { this.fadeOut = true; this.everythingShakeTimer = 500f; Game1.playSound("fishEscape"); if (BobberBar.unReelSound != null) { BobberBar.unReelSound.Stop(AudioStopOptions.Immediate); } if (BobberBar.reelSound != null) { BobberBar.reelSound.Stop(AudioStopOptions.Immediate); } } else if ((double)this.distanceFromCatching >= 1.0) { this.everythingShakeTimer = 500f; Game1.playSound("jingle1"); this.fadeOut = true; if (BobberBar.unReelSound != null) { BobberBar.unReelSound.Stop(AudioStopOptions.Immediate); } if (BobberBar.reelSound != null) { BobberBar.reelSound.Stop(AudioStopOptions.Immediate); } if (this.perfect) { this.sparkleText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\UI:BobberBar_Perfect"), Color.Yellow, Color.White, false, 0.1, 1500, -1, 500); if (Game1.isFestival()) { Game1.CurrentEvent.perfectFishing(); } } else if (this.fishSize == this.maxFishSize) { this.fishSize = this.fishSize - 1; } } } if ((double)this.bobberPosition < 0.0) { this.bobberPosition = 0.0f; } if ((double)this.bobberPosition <= 548.0) { return; } this.bobberPosition = 548f; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { rumble = new Rumble(this); Components.Add(rumble); beatDetector = new BeatDetector(this); Components.Add(beatDetector); spriteBatch = new SpriteBatch(this.GraphicsDevice); blank = Content.Load<Texture2D>("blank"); // TODO: use this.Content to load your game content here }
private static void OnLoadingComplete() { if (ObjectManager.Player == null) { return; } buff.OnGameLoad(); try { switch (GameObjects.Player.CharacterName) { case "Jayce": Jayce.OnGameLoad(); break; case "DrMundo": DrMundo.OnGameLoad(); break; case "Veigar": veigar.OnGameLoad(); break; case "MonkeyKing": Wukong.OnGameLoad(); break; case "Lux": lux.OnGameLoad(); break; case "MissFortune": MF.OnGameLoad(); break; case "Ivern": ivern.OnGameLoad(); break; case "Trundle": Trundle.OnGameLoad(); break; case "Warwick": Warwick.OnGameLoad(); break; case "Ryze": ryze.OnGameLoad(); break; case "RekSai": RekSai.OnGameLoad(); break; case "Taliyah": Taliyah.OnGameLoad(); break; case "Gangplank": gankplank.OnGameLoad(); break; case "Tryndamere": Tryndamere.OnGameLoad(); break; case "Anivia": Anivia.OnGameLoad(); break; case "Garen": Garen.OnGameLoad(); break; case "Gwen": Gwen.OnGameLoad(); break; case "Illaoi": Illaoi.OnGameLoad(); break; case "Mordekaiser": Mordekaiser.OnGameLoad(); break; case "Rumble": Rumble.OnGameLoad(); break; case "XinZhao": XinZhao.OnGameLoad(); break; case "Renekton": Renekton.OnGameLoad(); break; case "Chogath": Chogath.OnGameLoad(); break; case "Urgot": Urgot.OnGameLoad(); break; case "Kayle": Kayle.OnGameLoad(); break; default: Game.Print("<font color='#b756c5' size='25'>SimpleAIO Does Not Support :" + ObjectManager.Player.CharacterName + "</font>"); Console.WriteLine("Not Supported " + ObjectManager.Player.CharacterName); break; } } catch (Exception ex) { Game.Print("Error in loading"); Console.WriteLine("Error in loading :"); Console.WriteLine(ex); } }
public static void takeDamage(this Farmer farmer, DamageSource source, int damage, bool overrideParry, Farmer damager) { if (Game1.eventUp || farmer.FarmerSprite.isPassingOut()) { return; } if (source == DamageSource.THORNS) { overrideParry = true; } bool playerParryable = farmer.CurrentTool != null && farmer.CurrentTool is MeleeWeapon weapon && weapon.isOnSpecial && weapon.type == 3 && !overrideParry; bool playerDamageable = farmer.CanBeDamaged(); if (playerParryable) { Rumble.rumble(0.75f, 150f); farmer.currentLocation.playSound("parry"); } else { if (!playerDamageable) { return; } int effectiveResilience = 0; if (source != DamageSource.THORNS && source != DamageSource.STORM) { effectiveResilience = farmer.resilience; damage += Game1.random.Next(Math.Min(-1, -damage / 8), Math.Max(1, damage / 8)); if (farmer.CurrentTool is MeleeWeapon) { effectiveResilience += (int)(farmer.CurrentTool as MeleeWeapon).addedDefense; } if (effectiveResilience >= damage * 0.5f) { effectiveResilience -= (int)(effectiveResilience * Game1.random.Next(3) / 10f); } } if (damager != null && farmer.isWearingRing(839) && source != DamageSource.THORNS) { int multiplier = farmer.GetEffectsOfRingMultiplier(839); int damageToMonster = Math.Max(1, (int)Math.Floor(damage * 0.2)) * multiplier; NetworkUtils.SendDamageToPlayer(damager, DamageSource.THORNS, damageToMonster, farmer.UniqueMultiplayerID); } if (farmer.isWearingRing(524) && !Game1.buffsDisplay.hasBuff(21) && Game1.random.NextDouble() < (0.9 - (farmer.health / 100f)) / (3 - farmer.LuckLevel / 10) + ((farmer.health <= 15) ? 0.2 : 0.0)) { farmer.currentLocation.playSound("yoba"); Game1.buffsDisplay.addOtherBuff(new Buff(21)); return; } Rumble.rumble(0.75f, 150f); damage = Math.Max(1, damage - effectiveResilience); farmer.health = Math.Max(0, farmer.health - damage); if (farmer.health <= 0 && farmer.GetEffectsOfRingMultiplier(863) > 0 && !farmer.hasUsedDailyRevive.Value) { Game1.player.startGlowing(new Color(255, 255, 0), border: false, 0.25f); DelayedAction.functionAfterDelay(delegate { farmer.stopGlowing(); }, 500); Game1.playSound("yoba"); for (int i = 0; i < 13; i++) { float xPos = Game1.random.Next(-32, 33); farmer.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Rectangle(114, 46, 2, 2), 200f, 5, 1, new Vector2(xPos + 32f, -96f), flicker: false, flipped: false, 1f, 0f, Color.White, 4f, 0f, 0f, 0f) { attachedCharacter = farmer, positionFollowsAttachedCharacter = true, motion = new Vector2(xPos / 32f, -3f), delayBeforeAnimationStart = i * 50, alphaFade = 0.001f, acceleration = new Vector2(0f, 0.1f) }); } farmer.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Rectangle(157, 280, 28, 19), 2000f, 1, 1, new Vector2(-20f, -16f), flicker: false, flipped: false, 1E-06f, 0f, Color.White, 4f, 0f, 0f, 0f) { attachedCharacter = farmer, positionFollowsAttachedCharacter = true, alpha = 0.1f, alphaFade = -0.01f, alphaFadeFade = -0.00025f }); farmer.health = (int)Math.Min(farmer.maxHealth, farmer.maxHealth * 0.5f + farmer.GetEffectsOfRingMultiplier(863)); farmer.hasUsedDailyRevive.Value = true; } if (source != DamageSource.THORNS) { farmer.currentLocation.debris.Add(new Debris(damage, new Vector2(farmer.getStandingX() + 8, farmer.getStandingY()), Color.Red, 1f, farmer)); } else { farmer.currentLocation.debris.Add(new Debris(damage, new Vector2(farmer.getStandingX() + 8, farmer.getStandingY()), new Color(255, 130, 0), 1f, farmer)); } farmer.currentLocation.playSound("ow"); } }
private static bool damageMonster_prefix(GameLocation __instance, ref bool __result, Microsoft.Xna.Framework.Rectangle areaOfEffect, int minDamage, int maxDamage, bool isBomb, float knockBackModifier, int addedPrecision, float critChance, float critMultiplier, bool triggerMonsterInvincibleTimer, Farmer who) { bool didAnyDamage = false; for (int i = __instance.characters.Count - 1; i >= 0; i--) { Monster monster; if (i < __instance.characters.Count && (monster = (__instance.characters[i] as Monster)) != null && monster.IsMonster && monster.Health > 0 && monster.GetBoundingBox().Intersects(areaOfEffect) && !monster.IsInvisible && !monster.isInvincible()) { bool isDagger = who != null && who.CurrentTool != null && who.CurrentTool is MeleeWeapon && (who.CurrentTool as MeleeWeapon).type == 1; didAnyDamage = true; monster.doEmote(20, true); if (Game1.currentLocation == __instance) { Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 8.0), (float)(200 + Game1.random.Next(-50, 50))); } Microsoft.Xna.Framework.Rectangle monsterBox = monster.GetBoundingBox(); Vector2 trajectory = Utility.getAwayFromPlayerTrajectory(monsterBox, who); if (knockBackModifier > 0f) { trajectory *= knockBackModifier; } else { trajectory = new Vector2(monster.xVelocity, monster.yVelocity); } if (monster.Slipperiness == -1) { trajectory = Vector2.Zero; } bool crit = false; if (who != null && who.CurrentTool != null && monster.hitWithTool(who.CurrentTool)) { return(false); } if (who.professions.Contains(25)) { critChance += critChance * 0.5f; } int damageAmount; if (maxDamage >= 0) { damageAmount = Game1.random.Next(minDamage, maxDamage + 1); if (who != null && Game1.random.NextDouble() < (double)(critChance + (float)who.LuckLevel * (critChance / 40f))) { crit = true; __instance.playSound("crit", NetAudio.SoundContext.Default); } damageAmount = (crit ? ((int)((float)damageAmount * critMultiplier)) : damageAmount); damageAmount = Math.Max(1, damageAmount + ((who != null) ? (who.attack * 3) : 0)); if (who != null && who.professions.Contains(24)) { damageAmount = (int)Math.Ceiling((double)((float)damageAmount * 1.1f)); } if (who != null && who.professions.Contains(26)) { damageAmount = (int)Math.Ceiling((double)((float)damageAmount * 1.15f)); } if (who != null && crit && who.professions.Contains(29)) { damageAmount *= 3; } damageAmount = monster.takeDamage(damageAmount, (int)trajectory.X, (int)trajectory.Y, isBomb, (double)addedPrecision / 10.0, who); if (damageAmount == -1) { __instance.debris.Add(new Debris("Miss", 1, new Vector2((float)monsterBox.Center.X, (float)monsterBox.Center.Y), Color.LightGray, 1f, 0f)); } else { __instance.debris.Filter((Debris d) => d.toHover == null || !d.toHover.Equals(monster) || d.nonSpriteChunkColor.Equals(Color.Yellow) || d.timeSinceDoneBouncing <= 900f); __instance.debris.Add(new Debris(damageAmount, new Vector2((float)(monsterBox.Center.X + 16), (float)monsterBox.Center.Y), crit ? Color.Yellow : new Color(255, 130, 0), crit ? (1f + (float)damageAmount / 300f) : 1f, monster)); } if (triggerMonsterInvincibleTimer) { monster.setInvincibleCountdown(450 / (isDagger ? 3 : 2)); } } else { damageAmount = -2; monster.setTrajectory(trajectory); if (monster.Slipperiness > 10) { monster.xVelocity /= 2f; monster.yVelocity /= 2f; } } if (monster.Health <= 0) { if (!__instance.isFarm) { who.checkForQuestComplete(null, 1, 1, null, monster.Name, 4, -1); } if (who != null && who.leftRing.Value != null) { who.leftRing.Value.onMonsterSlay(monster, __instance, who); } if (who != null && who.rightRing.Value != null) { who.rightRing.Value.onMonsterSlay(monster, __instance, who); } if (who != null && !__instance.isFarm && (!(monster is GreenSlime) || (monster as GreenSlime).firstGeneration)) { if (who.IsLocalPlayer) { Game1.stats.monsterKilled(monster.Name); } else if (Game1.IsMasterGame) { who.queueMessage(25, Game1.player, new object[] { monster.Name }); } } __instance.monsterDrop(monster, monsterBox.Center.X, monsterBox.Center.Y, who); if (who != null && !__instance.isFarm) { who.gainExperience(4, monster.ExperienceGained); } Stats stats = Game1.stats; uint monstersKilled = stats.MonstersKilled; stats.MonstersKilled = monstersKilled + 1u; monster.farmerPassesThrough = true; } if (damageAmount > 0 && who != null && damageAmount > 1 && Game1.player.CurrentTool != null && Game1.player.CurrentTool.Name.Equals("Dark Sword") && Game1.random.NextDouble() < 0.08) { who.health = Math.Min(who.maxHealth, Game1.player.health + damageAmount / 2); __instance.debris.Add(new Debris(damageAmount / 2, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who)); __instance.playSound("healSound", NetAudio.SoundContext.Default); } } } __result = didAnyDamage; return(false); }
public bool tick(GameTime time) { Rumble.update(time.ElapsedGameTime.Milliseconds); Game1.player.Stamina = Game1.player.MaxStamina; for (int i = Game1.screenOverlayTempSprites.Count - 1; i >= 0; i--) { if (Game1.screenOverlayTempSprites[i].update(time)) { Game1.screenOverlayTempSprites.RemoveAt(i); } } if (Game1.activeClickableMenu != null) { Game1.updateActiveMenu(time); } if (timerToStart > 0) { Game1.player.faceDirection(3); timerToStart -= time.ElapsedGameTime.Milliseconds; if (timerToStart <= 0) { Game1.playSound("whistle"); } } else if (showResultsTimer >= 0) { int num = showResultsTimer; showResultsTimer -= time.ElapsedGameTime.Milliseconds; if (num > 11000 && showResultsTimer <= 11000) { Game1.playSound("smallSelect"); } if (num > 9000 && showResultsTimer <= 9000) { Game1.playSound("smallSelect"); } if (num > 7000 && showResultsTimer <= 7000) { if (perfections > 0) { score += perfections * 10; perfectionBonus = perfections * 10; if (fishCaught >= 3 && perfections >= 3) { perfectionBonus += score; score *= 2; } Game1.playSound("newArtifact"); } else { Game1.playSound("smallSelect"); } } if (num > 5000 && showResultsTimer <= 5000) { if (score >= 10) { Game1.playSound("reward"); starTokensWon = (score + 5) / 10 * 6; Game1.player.festivalScore += starTokensWon; } else { Game1.playSound("fishEscape"); } } if (showResultsTimer <= 0) { Game1.globalFadeToClear(); return(true); } } else if (!gameDone) { gameEndTimer -= time.ElapsedGameTime.Milliseconds; if (gameEndTimer <= 0 && Game1.activeClickableMenu == null && (!Game1.player.UsingTool || (Game1.player.CurrentTool as FishingRod).isFishing)) { (Game1.player.CurrentTool as FishingRod).doneFishing(Game1.player); (Game1.player.CurrentTool as FishingRod).tickUpdate(time, Game1.player); Game1.player.completelyStopAnimatingOrDoingAction(); Game1.playSound("whistle"); gameEndTimer = 1000; gameDone = true; } } else if (gameDone && gameEndTimer > 0) { gameEndTimer -= time.ElapsedGameTime.Milliseconds; if (gameEndTimer <= 0) { Game1.globalFadeToBlack(gameDoneAfterFade, 0.01f); Game1.exitActiveMenu(); Game1.player.forceCanMove(); } } return(exit); }
private static bool CuddleMonster(GameLocation location, Rectangle areaOfEffect, int minDamage, int maxDamage, bool isBomb, float knockBackModifier, int addedPrecision, float critChance, float critMultiplier, bool triggerMonsterInvincibleTimer, Character who, Farmer leader) { bool didAnyDamage = false; for (int i = location.characters.Count - 1; i >= 0; i--) { Monster monster; if (i < location.characters.Count && (monster = (location.characters[i] as Monster)) != null && monster.IsMonster && monster.Health > 0 && monster.GetBoundingBox().Intersects(areaOfEffect) && !monster.IsInvisible && !monster.isInvincible()) { didAnyDamage = true; monster.doEmote(20, true); if (Game1.currentLocation == location) { Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 8.0), (float)(200 + Game1.random.Next(-50, 50))); } Rectangle monsterBox = monster.GetBoundingBox(); Vector2 trajectory = Helper.GetAwayFromCharacterTrajectory(monsterBox, who); if (knockBackModifier > 0f) { trajectory *= knockBackModifier; } else { trajectory = new Vector2(monster.xVelocity, monster.yVelocity); } if (monster.Slipperiness == -1) { trajectory = Vector2.Zero; } bool crit = false; int damageAmount; if (maxDamage >= 0) { damageAmount = Game1.random.Next(minDamage, maxDamage + 1); if (who != null && Game1.random.NextDouble() < (double)(critChance + (float)leader.LuckLevel * (critChance / 40f))) { crit = true; location.playSound("crit", NetAudio.SoundContext.Default); } damageAmount = (crit ? ((int)((float)damageAmount * critMultiplier)) : damageAmount); damageAmount = Math.Max(1, damageAmount + ((who != null) ? (leader.attack * 3) : 0)); damageAmount = monster.takeDamage(damageAmount, (int)trajectory.X, (int)trajectory.Y, isBomb, (double)addedPrecision / 10.0, leader); if (damageAmount == -1) { location.debris.Add(new Debris("Miss", 1, new Vector2((float)monsterBox.Center.X, (float)monsterBox.Center.Y), Color.LightGray, 1f, 0f)); } else { location.debris.Filter((Debris d) => d.toHover == null || !d.toHover.Equals(monster) || d.nonSpriteChunkColor.Equals(Color.Yellow) || d.timeSinceDoneBouncing <= 900f); location.debris.Add(new Debris(damageAmount, new Vector2((float)(monsterBox.Center.X + 16), (float)monsterBox.Center.Y), crit ? Color.Yellow : new Color(255, 130, 0), crit ? (1f + (float)damageAmount / 300f) : 1f, monster)); } if (triggerMonsterInvincibleTimer) { monster.setInvincibleCountdown(450 / 2); } } else { damageAmount = -2; monster.setTrajectory(trajectory); if (monster.Slipperiness > 10) { monster.xVelocity /= 2f; monster.yVelocity /= 2f; } } if (monster.Health <= 0) { if (!location.IsFarm) { leader.checkForQuestComplete(null, 1, 1, null, monster.Name, 4, -1); } if (leader != null && !location.IsFarm && (!(monster is GreenSlime) || (monster as GreenSlime).firstGeneration.Value)) { if (leader.IsLocalPlayer) { ++Game1.stats.MonstersKilled; Game1.stats.monsterKilled(monster.Name); } else if (Game1.IsMasterGame) { leader.queueMessage(25, Game1.player, new object[] { monster.Name }); } } location.monsterDrop(monster, monsterBox.Center.X, monsterBox.Center.Y, leader); Stats stats = Game1.stats; uint monstersKilled = stats.MonstersKilled; stats.MonstersKilled = monstersKilled + 1u; monster.farmerPassesThrough = true; } } } return(didAnyDamage); }
// Token: 0x06000D8E RID: 3470 RVA: 0x001128FC File Offset: 0x00110AFC public override void update(GameTime time) { if (this.sparkleText != null && this.sparkleText.update(time)) { this.sparkleText = null; } if (this.everythingShakeTimer > 0f) { this.everythingShakeTimer -= (float)time.ElapsedGameTime.Milliseconds; this.everythingShake = new Vector2((float)Game1.random.Next(-10, 11) / 10f, (float)Game1.random.Next(-10, 11) / 10f); if (this.everythingShakeTimer <= 0f) { this.everythingShake = Vector2.Zero; } } if (this.fadeIn) { this.scale += 0.05f; if (this.scale >= 1f) { this.scale = 1f; this.fadeIn = false; } } else if (this.fadeOut) { if (this.everythingShakeTimer > 0f || this.sparkleText != null) { return; } this.scale -= 0.05f; if (this.scale <= 0f) { this.scale = 0f; this.fadeOut = false; if (this.distanceFromCatching > 0.9f && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).pullFishFromWater(this.whichFish, this.fishSize, this.fishQuality, (int)this.difficulty, this.treasureCaught, this.perfect); } else { if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).doneFishing(Game1.player, true); } Game1.player.completelyStopAnimatingOrDoingAction(); } Game1.exitActiveMenu(); } } else { if (Game1.random.NextDouble() < (double)(this.difficulty * (float)((this.motionType == 2) ? 20 : 1) / 4000f) && (this.motionType != 2 || this.bobberTargetPosition == -1f)) { float spaceBelow = 548f - this.bobberPosition; float spaceAbove = this.bobberPosition; float percent = Math.Min(99f, this.difficulty + (float)Game1.random.Next(10, 45)) / 100f; this.bobberTargetPosition = this.bobberPosition + (float)Game1.random.Next(-(int)spaceAbove, (int)spaceBelow) * percent; } if (this.motionType == 4) { this.floaterSinkerAcceleration = Math.Max(this.floaterSinkerAcceleration - 0.01f, -1.5f); } else if (this.motionType == 3) { this.floaterSinkerAcceleration = Math.Min(this.floaterSinkerAcceleration + 0.01f, 1.5f); } if (Math.Abs(this.bobberPosition - this.bobberTargetPosition) > 3f && this.bobberTargetPosition != -1f) { this.bobberAcceleration = (this.bobberTargetPosition - this.bobberPosition) / ((float)Game1.random.Next(10, 30) + (100f - Math.Min(100f, this.difficulty))); this.bobberSpeed += (this.bobberAcceleration - this.bobberSpeed) / 5f; } else if (this.motionType != 2 && Game1.random.NextDouble() < (double)(this.difficulty / 2000f)) { this.bobberTargetPosition = this.bobberPosition + (float)((Game1.random.NextDouble() < 0.5) ? Game1.random.Next(-100, -51) : Game1.random.Next(50, 101)); } else { this.bobberTargetPosition = -1f; } if (this.motionType == 1 && Game1.random.NextDouble() < (double)(this.difficulty / 1000f)) { this.bobberTargetPosition = this.bobberPosition + (float)((Game1.random.NextDouble() < 0.5) ? Game1.random.Next(-100 - (int)this.difficulty * 2, -51) : Game1.random.Next(50, 101 + (int)this.difficulty * 2)); } this.bobberTargetPosition = Math.Max(-1f, Math.Min(this.bobberTargetPosition, 548f)); this.bobberPosition += this.bobberSpeed + this.floaterSinkerAcceleration; if (this.bobberPosition > 532f) { this.bobberPosition = 532f; } else if (this.bobberPosition < 0f) { this.bobberPosition = 0f; } this.bobberInBar = (this.bobberPosition + 16f <= this.bobberBarPos - 32f + (float)this.bobberBarHeight && this.bobberPosition - 16f >= this.bobberBarPos - 32f); if (this.bobberPosition >= (float)(548 - this.bobberBarHeight) && this.bobberBarPos >= (float)(568 - this.bobberBarHeight - 4)) { this.bobberInBar = true; } bool arg_56C_0 = this.buttonPressed; this.buttonPressed = (Game1.oldMouseState.LeftButton == ButtonState.Pressed || Game1.isOneOfTheseKeysDown(Game1.oldKBState, Game1.options.useToolButton) || (Game1.options.gamepadControls && (Game1.oldPadState.IsButtonDown(Buttons.X) || Game1.oldPadState.IsButtonDown(Buttons.A)))); if (!arg_56C_0 && this.buttonPressed) { Game1.playSound("fishingRodBend"); } float gravity = this.buttonPressed ? -0.25f : 0.25f; if (this.buttonPressed && gravity < 0f && (this.bobberBarPos == 0f || this.bobberBarPos == (float)(568 - this.bobberBarHeight))) { this.bobberBarSpeed = 0f; } if (this.bobberInBar) { gravity *= ((this.whichBobber == 691) ? 0.3f : 0.6f); if (this.whichBobber == 691) { if (this.bobberPosition + 16f < this.bobberBarPos + (float)(this.bobberBarHeight / 2)) { this.bobberBarSpeed -= 0.2f; } else { this.bobberBarSpeed += 0.2f; } } } float oldPos = this.bobberBarPos; this.bobberBarSpeed += gravity; this.bobberBarPos += this.bobberBarSpeed; if (this.bobberBarPos + (float)this.bobberBarHeight > 568f) { this.bobberBarPos = (float)(568 - this.bobberBarHeight); this.bobberBarSpeed = -this.bobberBarSpeed * 2f / 3f * ((this.whichBobber == 692) ? 0.1f : 1f); if (oldPos + (float)this.bobberBarHeight < 568f) { Game1.playSound("shiny4"); } } else if (this.bobberBarPos < 0f) { this.bobberBarPos = 0f; this.bobberBarSpeed = -this.bobberBarSpeed * 2f / 3f; if (oldPos > 0f) { Game1.playSound("shiny4"); } } bool treasureInBar = false; if (this.treasure) { float oldTreasureAppearTimer = this.treasureAppearTimer; this.treasureAppearTimer -= (float)time.ElapsedGameTime.Milliseconds; if (this.treasureAppearTimer <= 0f) { if (this.treasureScale < 1f && !this.treasureCaught) { if (oldTreasureAppearTimer > 0f) { this.treasurePosition = (float)((this.bobberBarPos > 274f) ? Game1.random.Next(8, (int)this.bobberBarPos - 20) : Game1.random.Next(Math.Min(528, (int)this.bobberBarPos + this.bobberBarHeight), 500)); Game1.playSound("dwop"); } this.treasureScale = Math.Min(1f, this.treasureScale + 0.1f); } treasureInBar = (this.treasurePosition + 16f <= this.bobberBarPos - 32f + (float)this.bobberBarHeight && this.treasurePosition - 16f >= this.bobberBarPos - 32f); if (treasureInBar && !this.treasureCaught) { this.treasureCatchLevel += 0.0135f; this.treasureShake = new Vector2((float)Game1.random.Next(-2, 3), (float)Game1.random.Next(-2, 3)); if (this.treasureCatchLevel >= 1f) { Game1.playSound("newArtifact"); this.treasureCaught = true; } } else if (this.treasureCaught) { this.treasureScale = Math.Max(0f, this.treasureScale - 0.1f); } else { this.treasureShake = Vector2.Zero; this.treasureCatchLevel = Math.Max(0f, this.treasureCatchLevel - 0.01f); } } } if (this.bobberInBar) { this.distanceFromCatching += 0.002f; this.reelRotation += 0.3926991f; this.fishShake.X = (float)Game1.random.Next(-10, 11) / 10f; this.fishShake.Y = (float)Game1.random.Next(-10, 11) / 10f; this.barShake = Vector2.Zero; Rumble.rumble(0.1f, 1000f); if (BobberBar.unReelSound != null) { BobberBar.unReelSound.Stop(AudioStopOptions.Immediate); } if (Game1.soundBank != null && (BobberBar.reelSound == null || BobberBar.reelSound.IsStopped || BobberBar.reelSound.IsStopping)) { BobberBar.reelSound = Game1.soundBank.GetCue("fastReel"); } if (BobberBar.reelSound != null && !BobberBar.reelSound.IsPlaying && !BobberBar.reelSound.IsStopping) { BobberBar.reelSound.Play(); } } else if (!treasureInBar || this.treasureCaught || this.whichBobber != 693) { if (!this.fishShake.Equals(Vector2.Zero)) { Game1.playSound("tinyWhip"); this.perfect = false; Rumble.stopRumbling(); } this.fishSizeReductionTimer -= time.ElapsedGameTime.Milliseconds; if (this.fishSizeReductionTimer <= 0) { this.fishSize = Math.Max(this.minFishSize, this.fishSize - 1); this.fishSizeReductionTimer = 800; } if ((Game1.player.fishCaught != null && Game1.player.fishCaught.Count != 0) || Game1.currentMinigame != null) { this.distanceFromCatching -= ((this.whichBobber == 694) ? 0.002f : 0.003f); } float distanceAway = Math.Abs(this.bobberPosition - (this.bobberBarPos + (float)(this.bobberBarHeight / 2))); this.reelRotation -= 3.14159274f / Math.Max(10f, 200f - distanceAway); this.barShake.X = (float)Game1.random.Next(-10, 11) / 10f; this.barShake.Y = (float)Game1.random.Next(-10, 11) / 10f; this.fishShake = Vector2.Zero; if (BobberBar.reelSound != null) { BobberBar.reelSound.Stop(AudioStopOptions.Immediate); } if (Game1.soundBank != null && (BobberBar.unReelSound == null || BobberBar.unReelSound.IsStopped)) { BobberBar.unReelSound = Game1.soundBank.GetCue("slowReel"); BobberBar.unReelSound.SetVariable("Pitch", 600f); } if (BobberBar.unReelSound != null && !BobberBar.unReelSound.IsPlaying && !BobberBar.unReelSound.IsStopping) { BobberBar.unReelSound.Play(); } } this.distanceFromCatching = Math.Max(0f, Math.Min(1f, this.distanceFromCatching)); if (Game1.player.CurrentTool != null) { Game1.player.CurrentTool.tickUpdate(time, Game1.player); } if (this.distanceFromCatching <= 0f) { this.fadeOut = true; this.everythingShakeTimer = 500f; Game1.playSound("fishEscape"); if (BobberBar.unReelSound != null) { BobberBar.unReelSound.Stop(AudioStopOptions.Immediate); } if (BobberBar.reelSound != null) { BobberBar.reelSound.Stop(AudioStopOptions.Immediate); } } else if (this.distanceFromCatching >= 1f) { this.everythingShakeTimer = 500f; Game1.playSound("jingle1"); this.fadeOut = true; if (BobberBar.unReelSound != null) { BobberBar.unReelSound.Stop(AudioStopOptions.Immediate); } if (BobberBar.reelSound != null) { BobberBar.reelSound.Stop(AudioStopOptions.Immediate); } if (this.perfect) { this.sparkleText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\UI:BobberBar_Perfect", new object[0]), Color.Yellow, Color.White, false, 0.1, 1500, -1, 500); if (Game1.isFestival()) { Game1.CurrentEvent.perfectFishing(); } } else if (this.fishSize == this.maxFishSize) { this.fishSize--; } } } if (this.bobberPosition < 0f) { this.bobberPosition = 0f; } if (this.bobberPosition > 548f) { this.bobberPosition = 548f; } }
public Joycon() { rumble_obj = new Rumble(160, 320, 0); }
public override void Bind(Entity entity, Main main, bool creating = false) { Main.Config settings = main.Settings; Transform transform = entity.GetOrCreate <Transform>("Transform"); entity.CannotSuspend = true; PlayerFactory.Instance = entity; this.SetMain(entity, main); FPSInput input = new FPSInput(); input.EnabledWhenPaused = false; entity.Add("Input", input); Player player = entity.GetOrCreate <Player>("Player"); AnimatedModel firstPersonModel = entity.GetOrCreate <AnimatedModel>("FirstPersonModel"); firstPersonModel.Serialize = false; AnimatedModel model = entity.GetOrCreate <AnimatedModel>("Model"); model.Serialize = false; model.Filename.Value = "Models\\joan"; model.CullBoundingBox.Value = false; firstPersonModel.Filename.Value = "Models\\joan-firstperson"; firstPersonModel.CullBoundingBox.Value = false; AnimationController anim = entity.GetOrCreate <AnimationController>("AnimationController"); RotationController rotation = entity.GetOrCreate <RotationController>("Rotation"); BlockPredictor predictor = entity.GetOrCreate <BlockPredictor>("BlockPredictor"); Jump jump = entity.GetOrCreate <Jump>("Jump"); RollKickSlide rollKickSlide = entity.GetOrCreate <RollKickSlide>("RollKickSlide"); Vault vault = entity.GetOrCreate <Vault>("Vault"); WallRun wallRun = entity.GetOrCreate <WallRun>("WallRun"); VoxelTools voxelTools = entity.GetOrCreate <VoxelTools>("VoxelTools"); Footsteps footsteps = entity.GetOrCreate <Footsteps>("Footsteps"); FallDamage fallDamage = entity.GetOrCreate <FallDamage>("FallDamage"); CameraController cameraControl = entity.GetOrCreate <CameraController>("CameraControl"); FPSCamera fpsCamera = entity.GetOrCreate <FPSCamera>("FPSCamera"); fpsCamera.Enabled.Value = false; Rumble rumble = entity.GetOrCreate <Rumble>("Rumble"); Property <Vector3> floor = new Property <Vector3>(); transform.Add(new Binding <Vector3>(floor, () => transform.Position + new Vector3(0, player.Character.Height * -0.5f, 0), transform.Position, player.Character.Height)); AkGameObjectTracker.Attach(entity, floor); predictor.Add(new Binding <Vector3>(predictor.FootPosition, floor)); predictor.Add(new Binding <Vector3>(predictor.LinearVelocity, player.Character.LinearVelocity)); predictor.Add(new Binding <float>(predictor.Rotation, rotation.Rotation)); predictor.Add(new Binding <float>(predictor.MaxSpeed, player.Character.MaxSpeed)); predictor.Add(new Binding <float>(predictor.JumpSpeed, player.Character.JumpSpeed)); predictor.Add(new Binding <bool>(predictor.IsSupported, player.Character.IsSupported)); jump.Add(new TwoWayBinding <bool>(player.Character.IsSupported, jump.IsSupported)); jump.Add(new TwoWayBinding <bool>(player.Character.HasTraction, jump.HasTraction)); jump.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, jump.LinearVelocity)); jump.Add(new TwoWayBinding <BEPUphysics.Entities.Entity>(jump.SupportEntity, player.Character.SupportEntity)); jump.Add(new TwoWayBinding <Vector3>(jump.SupportVelocity, player.Character.SupportVelocity)); jump.Add(new Binding <Vector2>(jump.AbsoluteMovementDirection, player.Character.MovementDirection)); jump.Add(new Binding <WallRun.State>(jump.WallRunState, wallRun.CurrentState)); jump.Add(new Binding <float>(jump.Rotation, rotation.Rotation)); jump.Add(new Binding <Vector3>(jump.Position, transform.Position)); jump.Add(new Binding <Vector3>(jump.FloorPosition, floor)); jump.Add(new Binding <float>(jump.MaxSpeed, player.Character.MaxSpeed)); jump.Add(new Binding <float>(jump.JumpSpeed, player.Character.JumpSpeed)); jump.Add(new Binding <float>(jump.Mass, player.Character.Mass)); jump.Add(new Binding <float>(jump.LastRollKickEnded, rollKickSlide.LastRollKickEnded)); jump.Add(new Binding <Voxel>(jump.WallRunMap, wallRun.WallRunVoxel)); jump.Add(new Binding <Direction>(jump.WallDirection, wallRun.WallDirection)); jump.Add(new CommandBinding <Voxel, Voxel.Coord, Direction>(jump.WalkedOn, footsteps.WalkedOn)); jump.Add(new CommandBinding(jump.DeactivateWallRun, (Action)wallRun.Deactivate)); jump.Add(new CommandBinding <float>(jump.FallDamage, fallDamage.ApplyJump)); jump.Predictor = predictor; jump.Bind(model); jump.Add(new TwoWayBinding <Voxel>(wallRun.LastWallRunMap, jump.LastWallRunMap)); jump.Add(new TwoWayBinding <Direction>(wallRun.LastWallDirection, jump.LastWallDirection)); jump.Add(new TwoWayBinding <bool>(rollKickSlide.CanKick, jump.CanKick)); jump.Add(new TwoWayBinding <float>(player.Character.LastSupportedSpeed, jump.LastSupportedSpeed)); wallRun.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, wallRun.LinearVelocity)); wallRun.Add(new TwoWayBinding <Vector3>(transform.Position, wallRun.Position)); wallRun.Add(new TwoWayBinding <bool>(player.Character.IsSupported, wallRun.IsSupported)); wallRun.Add(new CommandBinding(wallRun.LockRotation, (Action)rotation.Lock)); wallRun.Add(new CommandBinding <float>(wallRun.UpdateLockedRotation, rotation.UpdateLockedRotation)); vault.Add(new CommandBinding(wallRun.Vault, delegate() { vault.Go(); })); wallRun.Predictor = predictor; wallRun.Add(new Binding <float>(wallRun.Height, player.Character.Height)); wallRun.Add(new Binding <float>(wallRun.JumpSpeed, player.Character.JumpSpeed)); wallRun.Add(new Binding <float>(wallRun.MaxSpeed, player.Character.MaxSpeed)); wallRun.Add(new TwoWayBinding <float>(rotation.Rotation, wallRun.Rotation)); wallRun.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, wallRun.AllowUncrouch)); wallRun.Add(new TwoWayBinding <bool>(player.Character.HasTraction, wallRun.HasTraction)); wallRun.Add(new Binding <float>(wallRun.LastWallJump, jump.LastWallJump)); player.Add(new Binding <WallRun.State>(player.Character.WallRunState, wallRun.CurrentState)); input.Bind(rollKickSlide.RollKickButton, settings.RollKick); rollKickSlide.Add(new Binding <bool>(rollKickSlide.EnableCrouch, player.EnableCrouch)); rollKickSlide.Add(new Binding <float>(rollKickSlide.Rotation, rotation.Rotation)); rollKickSlide.Add(new Binding <bool>(rollKickSlide.IsSwimming, player.Character.IsSwimming)); rollKickSlide.Add(new Binding <bool>(rollKickSlide.IsSupported, player.Character.IsSupported)); rollKickSlide.Add(new Binding <Vector3>(rollKickSlide.FloorPosition, floor)); rollKickSlide.Add(new Binding <float>(rollKickSlide.Height, player.Character.Height)); rollKickSlide.Add(new Binding <float>(rollKickSlide.MaxSpeed, player.Character.MaxSpeed)); rollKickSlide.Add(new Binding <float>(rollKickSlide.JumpSpeed, player.Character.JumpSpeed)); rollKickSlide.Add(new Binding <Vector3>(rollKickSlide.SupportVelocity, player.Character.SupportVelocity)); rollKickSlide.Add(new TwoWayBinding <bool>(wallRun.EnableEnhancedWallRun, rollKickSlide.EnableEnhancedRollSlide)); rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, rollKickSlide.AllowUncrouch)); rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.Crouched, rollKickSlide.Crouched)); rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, rollKickSlide.EnableWalking)); rollKickSlide.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, rollKickSlide.LinearVelocity)); rollKickSlide.Add(new TwoWayBinding <Vector3>(transform.Position, rollKickSlide.Position)); rollKickSlide.Predictor = predictor; rollKickSlide.Bind(model); rollKickSlide.VoxelTools = voxelTools; rollKickSlide.Add(new CommandBinding(rollKickSlide.DeactivateWallRun, (Action)wallRun.Deactivate)); rollKickSlide.Add(new CommandBinding(rollKickSlide.Footstep, footsteps.Footstep)); rollKickSlide.Add(new CommandBinding(rollKickSlide.LockRotation, (Action)rotation.Lock)); SoundKiller.Add(entity, AK.EVENTS.STOP_PLAYER_SLIDE_LOOP); vault.Add(new Binding <Vector3>(vault.Position, transform.Position)); vault.Add(new Binding <Vector3>(vault.FloorPosition, floor)); vault.Add(new Binding <float>(vault.MaxSpeed, player.Character.MaxSpeed)); vault.Add(new Binding <WallRun.State>(vault.WallRunState, wallRun.CurrentState)); vault.Add(new CommandBinding(vault.LockRotation, (Action)rotation.Lock)); vault.Add(new CommandBinding(vault.DeactivateWallRun, (Action)wallRun.Deactivate)); vault.Add(new CommandBinding <WallRun.State>(vault.ActivateWallRun, delegate(WallRun.State state) { wallRun.Activate(state); })); vault.Add(new TwoWayBinding <float>(player.Character.LastSupportedSpeed, vault.LastSupportedSpeed)); vault.Add(new CommandBinding <float>(vault.FallDamage, fallDamage.Apply)); vault.Bind(model); vault.Predictor = predictor; vault.Add(new TwoWayBinding <float>(rotation.Rotation, vault.Rotation)); vault.Add(new TwoWayBinding <bool>(player.Character.IsSupported, vault.IsSupported)); vault.Add(new TwoWayBinding <bool>(player.Character.HasTraction, vault.HasTraction)); vault.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, vault.LinearVelocity)); vault.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, vault.EnableWalking)); vault.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, vault.AllowUncrouch)); vault.Add(new TwoWayBinding <bool>(player.Character.Crouched, vault.Crouched)); vault.Add(new Binding <float>(vault.Radius, player.Character.Radius)); rotation.Add(new TwoWayBinding <Vector2>(rotation.Mouse, input.Mouse)); rotation.Add(new Binding <bool>(rotation.Rolling, rollKickSlide.Rolling)); rotation.Add(new Binding <bool>(rotation.Kicking, rollKickSlide.Kicking)); rotation.Add(new Binding <Vault.State>(rotation.VaultState, vault.CurrentState)); rotation.Add(new Binding <WallRun.State>(rotation.WallRunState, wallRun.CurrentState)); voxelTools.Add(new Binding <float>(voxelTools.Height, player.Character.Height)); voxelTools.Add(new Binding <float>(voxelTools.SupportHeight, player.Character.SupportHeight)); voxelTools.Add(new Binding <Vector3>(voxelTools.Position, transform.Position)); anim.Add(new Binding <bool>(anim.IsSupported, player.Character.IsSupported)); anim.Add(new Binding <WallRun.State>(anim.WallRunState, wallRun.CurrentState)); anim.Add(new Binding <bool>(anim.EnableWalking, player.Character.EnableWalking)); anim.Add(new Binding <bool>(anim.Crouched, player.Character.Crouched)); anim.Add(new Binding <Vector3>(anim.LinearVelocity, player.Character.LinearVelocity)); anim.Add(new Binding <Vector2>(anim.Movement, input.Movement)); anim.Add(new Binding <Vector2>(anim.Mouse, input.Mouse)); anim.Add(new Binding <float>(anim.Rotation, rotation.Rotation)); anim.Add(new Binding <Voxel>(anim.WallRunMap, wallRun.WallRunVoxel)); anim.Add(new Binding <Direction>(anim.WallDirection, wallRun.WallDirection)); anim.Add(new Binding <bool>(anim.IsSwimming, player.Character.IsSwimming)); anim.Add(new Binding <bool>(anim.Kicking, rollKickSlide.Kicking)); anim.Add(new Binding <Vector3>(anim.SupportVelocity, player.Character.SupportVelocity)); anim.Add ( new Binding <bool> ( anim.EnableLean, () => player.Character.EnableWalking.Value && player.Character.IsSupported.Value && input.Movement.Value.Y > 0.5f, player.Character.EnableWalking, player.Character.IsSupported, input.Movement ) ); anim.Bind(model); // Camera control model.UpdateWorldTransforms(); cameraControl.Add(new Binding <Vector2>(cameraControl.Mouse, input.Mouse)); cameraControl.Add(new Binding <float>(cameraControl.Lean, x => x * (float)Math.PI * 0.05f, anim.Lean)); cameraControl.Add(new Binding <Vector3>(cameraControl.LinearVelocity, player.Character.LinearVelocity)); cameraControl.Add(new Binding <float>(cameraControl.MaxSpeed, player.Character.MaxSpeed)); cameraControl.Add(new Binding <Matrix>(cameraControl.CameraBone, model.GetBoneTransform("Camera"))); cameraControl.Add(new Binding <Matrix>(cameraControl.HeadBone, model.GetBoneTransform("ORG-head"))); cameraControl.Add(new Binding <Matrix>(cameraControl.ModelTransform, model.Transform)); cameraControl.Add(new Binding <float>(cameraControl.BaseCameraShakeAmount, () => MathHelper.Clamp((player.Character.LinearVelocity.Value.Length() - (player.Character.MaxSpeed * 2.5f)) / (player.Character.MaxSpeed * 4.0f), 0, 1), player.Character.LinearVelocity, player.Character.MaxSpeed)); cameraControl.Offset = model.GetBoneTransform("Camera").Value.Translation - model.GetBoneTransform("ORG-head").Value.Translation; float heightOffset = 0.1f; #if VR if (main.VR) { heightOffset = 0.4f; } #endif cameraControl.Offset += new Vector3(0, heightOffset, 0); rumble.Add(new Binding <float>(rumble.CameraShake, cameraControl.TotalCameraShake)); rumble.Add(new CommandBinding <float>(fallDamage.Rumble, rumble.Go)); rumble.Add(new CommandBinding <float>(player.Rumble, rumble.Go)); rumble.Add(new CommandBinding <float>(rollKickSlide.Rumble, rumble.Go)); firstPersonModel.Add(new Binding <bool>(firstPersonModel.Enabled, x => !x, cameraControl.ThirdPerson)); model.Add(new NotifyBinding(delegate() { if (cameraControl.ThirdPerson) { model.UnsupportedTechniques.Remove(Technique.Clip); model.UnsupportedTechniques.Remove(Technique.Render); } else { model.UnsupportedTechniques.Add(Technique.Clip); model.UnsupportedTechniques.Add(Technique.Render); } }, cameraControl.ThirdPerson)); Lemma.Console.Console.AddConCommand(new Console.ConCommand("third_person", "Toggle third-person view (WARNING: EXPERIMENTAL)", delegate(Console.ConCommand.ArgCollection args) { cameraControl.ThirdPerson.Value = !cameraControl.ThirdPerson; })); entity.Add(new CommandBinding(entity.Delete, delegate() { Lemma.Console.Console.RemoveConCommand("third_person"); })); #if DEVELOPMENT ModelAlpha debugCylinder = new ModelAlpha(); debugCylinder.Filename.Value = "AlphaModels\\cylinder"; debugCylinder.Add(new Binding <Matrix>(debugCylinder.Transform, transform.Matrix)); debugCylinder.Serialize = false; debugCylinder.Alpha.Value = 0.25f; debugCylinder.Add(new Binding <bool>(debugCylinder.Enabled, cameraControl.ThirdPerson)); debugCylinder.Add(new Binding <Vector3>(debugCylinder.Scale, delegate() { return(new Vector3(player.Character.Radius * 2.0f, player.Character.Height, player.Character.Radius * 2.0f)); }, player.Character.Height, player.Character.Radius)); entity.Add(debugCylinder); #endif // When rotation is locked, we want to make sure the player can't turn their head // 180 degrees from the direction they're facing #if VR if (main.VR) { input.MaxY.Value = input.MinY.Value = 0; } else #endif input.Add(new Binding <float>(input.MaxY, () => rotation.Locked ? (float)Math.PI * 0.3f : (float)Math.PI * 0.4f, rotation.Locked)); input.Add(new Binding <float>(input.MinX, () => rotation.Locked ? rotation.Rotation + ((float)Math.PI * -0.4f) : 0.0f, rotation.Rotation, rotation.Locked)); input.Add(new Binding <float>(input.MaxX, () => rotation.Locked ? rotation.Rotation + ((float)Math.PI * 0.4f) : 0.0f, rotation.Rotation, rotation.Locked)); input.Add(new NotifyBinding(delegate() { input.Mouse.Changed(); }, rotation.Locked)); // Make sure the rotation locking takes effect even if the player doesn't move the mouse // Setup rendering properties model.Materials = firstPersonModel.Materials = new Model.Material[3]; // Hoodie and shoes model.Materials[0] = new Model.Material { SpecularIntensity = 0.0f, SpecularPower = 1.0f, }; // Hands model.Materials[1] = new Model.Material { SpecularIntensity = 0.3f, SpecularPower = 2.0f, }; // Pants and skin model.Materials[2] = new Model.Material { SpecularIntensity = 0.5f, SpecularPower = 20.0f, }; firstPersonModel.Bind(model); // Third person model only gets rendered for shadows. No regular rendering or reflections. model.UnsupportedTechniques.Add(Technique.Clip); model.UnsupportedTechniques.Add(Technique.Render); // First-person model only used for regular rendering. No shadows or reflections. firstPersonModel.UnsupportedTechniques.Add(Technique.Shadow); firstPersonModel.UnsupportedTechniques.Add(Technique.Clip); // Build UI UIRenderer ui = new UIRenderer(); ui.DrawOrder.Value = -1; ui.EnabledWhenPaused = true; ui.EnabledInEditMode = false; entity.Add("UI", ui); input.Add(new Binding <float>(input.MouseSensitivity, settings.MouseSensitivity)); input.Add(new Binding <bool>(input.InvertMouseX, settings.InvertMouseX)); input.Add(new Binding <bool>(input.InvertMouseY, settings.InvertMouseY)); input.Add(new Binding <PCInput.PCInputBinding>(input.LeftKey, settings.Left)); input.Add(new Binding <PCInput.PCInputBinding>(input.RightKey, settings.Right)); input.Add(new Binding <PCInput.PCInputBinding>(input.BackwardKey, settings.Backward)); input.Add(new Binding <PCInput.PCInputBinding>(input.ForwardKey, settings.Forward)); model.StartClip("Idle", 0, true, AnimatedModel.DefaultBlendTime); // Set up AI agent Agent agent = entity.GetOrCreate <Agent>(); agent.Add(new TwoWayBinding <float>(player.Health, agent.Health)); agent.Add(new Binding <Vector3>(agent.Position, () => transform.Position.Value + new Vector3(0, player.Character.Height * -0.5f, 0), transform.Position, player.Character.Height)); agent.Add(new Binding <bool>(agent.Loud, () => player.Character.MovementDirection.Value.LengthSquared() > 0 && !player.Character.Crouched, player.Character.Crouched)); entity.Add(new CommandBinding(player.Die, delegate() { Session.Recorder.Event(main, "Die"); if (agent.Killed || Agent.Query(transform.Position, 0.0f, 10.0f, x => x != agent) != null) { Session.Recorder.Event(main, "Killed"); AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_DEATH, entity); main.Spawner.RespawnDistance = Spawner.KilledRespawnDistance; main.Spawner.RespawnInterval = Spawner.KilledRespawnInterval; } entity.Add(new Animation(new Animation.Execute(entity.Delete))); })); player.EnabledInEditMode = false; Action updateFallSound = delegate() { float speed = player.Character.LinearVelocity.Value.Length(); float maxSpeed = player.Character.MaxSpeed * 1.25f; float value; if (speed > maxSpeed) { value = (speed - maxSpeed) / (maxSpeed * 2.0f); } else { value = 0.0f; } AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_PLAYER_FALL, value); }; updateFallSound(); AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_FALL, entity); player.Add(new NotifyBinding(updateFallSound, player.Character.LinearVelocity)); SoundKiller.Add(entity, AK.EVENTS.STOP_PLAYER_FALL); player.Add(new TwoWayBinding <Matrix>(transform.Matrix, player.Character.Transform)); model.Add(new Binding <Matrix>(model.Transform, delegate() { const float leanAmount = (float)Math.PI * 0.1f; return(Matrix.CreateTranslation(0, (player.Character.Height * -0.5f) - player.Character.SupportHeight, 0) * Matrix.CreateRotationZ(anim.Lean * leanAmount) * Matrix.CreateRotationY(rotation.Rotation) * transform.Matrix); }, transform.Matrix, rotation.Rotation, player.Character.Height, player.Character.SupportHeight, anim.Lean)); firstPersonModel.Add(new Binding <Matrix>(firstPersonModel.Transform, model.Transform)); firstPersonModel.Add(new Binding <Vector3>(firstPersonModel.Scale, model.Scale)); WallRun.State[] footstepWallrunStates = new[] { WallRun.State.Left, WallRun.State.Right, WallRun.State.Straight, WallRun.State.None, }; footsteps.Add(new Binding <bool>(footsteps.SoundEnabled, () => !player.Character.Crouched && footstepWallrunStates.Contains(wallRun.CurrentState) || (player.Character.IsSupported && player.Character.EnableWalking), player.Character.IsSupported, player.Character.EnableWalking, wallRun.CurrentState, player.Character.Crouched)); footsteps.Add(new Binding <Vector3>(footsteps.Position, transform.Position)); footsteps.Add(new Binding <float>(footsteps.Rotation, rotation.Rotation)); footsteps.Add(new Binding <float>(footsteps.CharacterHeight, player.Character.Height)); footsteps.Add(new Binding <float>(footsteps.SupportHeight, player.Character.SupportHeight)); footsteps.Add(new Binding <bool>(footsteps.IsSupported, player.Character.IsSupported)); footsteps.Add(new Binding <bool>(footsteps.IsSwimming, player.Character.IsSwimming)); footsteps.Add(new CommandBinding <float>(footsteps.Damage, agent.Damage)); footsteps.Add(new CommandBinding <Voxel, Voxel.Coord, Direction>(wallRun.WalkedOn, footsteps.WalkedOn)); model.Trigger("Run", 0.16f, footsteps.Footstep); model.Trigger("Run", 0.58f, footsteps.Footstep); model.Trigger("WallRunLeft", 0.16f, footsteps.Footstep); model.Trigger("WallRunLeft", 0.58f, footsteps.Footstep); model.Trigger("WallRunRight", 0.16f, footsteps.Footstep); model.Trigger("WallRunRight", 0.58f, footsteps.Footstep); model.Trigger("WallRunStraight", 0.16f, footsteps.Footstep); model.Trigger("WallRunStraight", 0.58f, footsteps.Footstep); model.Trigger("TurnLeft", 0.15f, footsteps.Footstep); model.Trigger("TurnRight", 0.15f, footsteps.Footstep); model.Trigger("TopOut", 1.0f, new Command { Action = delegate() { AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_GRUNT, entity); } }); main.UI.IsMouseVisible.Value = false; SkinnedModel.Clip sprintAnimation = model["Sprint"], runAnimation = model["Run"]; // Movement binding player.Add(new Binding <Vector2>(player.Character.MovementDirection, delegate() { Vector2 movement = input.Movement; if (movement.LengthSquared() == 0.0f) { return(Vector2.Zero); } Matrix matrix = Matrix.CreateRotationY(rotation.Rotation); Vector2 forwardDir = new Vector2(matrix.Forward.X, matrix.Forward.Z); Vector2 rightDir = new Vector2(matrix.Right.X, matrix.Right.Z); return(-(forwardDir * movement.Y) - (rightDir * movement.X)); }, input.Movement, rotation.Rotation)); player.Character.Crouched.Value = true; player.Character.AllowUncrouch.Value = true; // Fall damage fallDamage.Add(new Binding <bool>(fallDamage.IsSupported, player.Character.IsSupported)); fallDamage.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, fallDamage.LinearVelocity)); fallDamage.Add(new TwoWayBinding <float>(player.Health, fallDamage.Health)); fallDamage.Add(new CommandBinding <BEPUphysics.BroadPhaseEntries.Collidable, ContactCollection>(player.Character.Collided, fallDamage.Collided)); fallDamage.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, fallDamage.EnableWalking)); fallDamage.Add(new TwoWayBinding <bool>(player.EnableMoves, fallDamage.EnableMoves)); fallDamage.Add(new TwoWayBinding <bool>(fallDamage.Landing, rotation.Landing)); fallDamage.Add(new CommandBinding(fallDamage.LockRotation, (Action)rotation.Lock)); fallDamage.Add(new CommandBinding <float>(fallDamage.PhysicsDamage, agent.Damage)); fallDamage.Bind(model); BlockCloud blockCloud = entity.GetOrCreate <BlockCloud>("BlockCloud"); blockCloud.Scale.Value = 0.5f; blockCloud.Add(new Binding <Vector3>(blockCloud.Position, () => transform.Position.Value + new Vector3(0, player.Character.Height + player.Character.LinearVelocity.Value.Y, 0), transform.Position, player.Character.Height, player.Character.LinearVelocity)); blockCloud.Blocks.ItemAdded += delegate(int index, Entity.Handle block) { Entity e = block.Target; if (e != null) { e.Serialize = false; PhysicsBlock.CancelPlayerCollisions(e.Get <PhysicsBlock>()); } }; PointLight blockLight = entity.Create <PointLight>(); blockLight.Add(new Binding <Vector3>(blockLight.Position, blockCloud.AveragePosition)); blockLight.Add(new Binding <bool, int>(blockLight.Enabled, x => x > 0, blockCloud.Blocks.Length)); blockLight.Attenuation.Value = 20.0f; blockLight.Add(new Binding <Vector3, Voxel.t>(blockLight.Color, delegate(Voxel.t t) { switch (t) { case Voxel.t.GlowBlue: return(new Vector3(0.8f, 0.9f, 1.2f)); case Voxel.t.GlowYellow: return(new Vector3(1.2f, 1.2f, 0.8f)); default: return(Vector3.One); } }, blockCloud.Type)); // Swim up input.Bind(player.Character.SwimUp, settings.Jump); // Jumping input.Bind(settings.Jump, PCInput.InputState.Down, delegate() { if (player.EnableMoves && player.Character.EnableWalking && vault.CurrentState.Value == Vault.State.None && !rollKickSlide.Rolling && !rollKickSlide.Kicking) { jump.Go(); } }); // Wall-run, vault, predictive input.Bind(settings.Parkour, PCInput.InputState.Down, delegate() { if (player.EnableMoves && player.Character.EnableWalking && !(player.Character.Crouched && player.Character.IsSupported) && vault.CurrentState.Value == Vault.State.None) { bool didSomething = false; if (predictor.PossibilityCount > 0) { // In slow motion, prefer left and right wall-running if (!(didSomething = wallRun.Activate(WallRun.State.Left))) { if (!(didSomething = wallRun.Activate(WallRun.State.Right))) { if (!(didSomething = vault.Go())) { didSomething = wallRun.Activate(WallRun.State.Straight); } } } } else { // In normal mode, prefer straight wall-running if (!(didSomething = vault.Go())) { if (!(didSomething = wallRun.Activate(WallRun.State.Straight))) { if (!(didSomething = wallRun.Activate(WallRun.State.Left))) { didSomething = wallRun.Activate(WallRun.State.Right); } } } } if (!didSomething && blockCloud.Blocks.Length > 0) { player.SlowMotion.Value = true; predictor.ClearPossibilities(); predictor.PredictPlatforms(); predictor.PredictWalls(); } } }); input.Bind(settings.Parkour, PCInput.InputState.Up, delegate() { wallRun.Deactivate(); if (blockCloud.Blocks.Length > 0) { player.SlowMotion.Value = false; } }); input.Bind(settings.RollKick, PCInput.InputState.Down, delegate() { if (player.EnableMoves && player.Character.EnableWalking) { rollKickSlide.Go(); } }); input.Bind(settings.RollKick, PCInput.InputState.Up, delegate() { if (!rollKickSlide.Rolling && !rollKickSlide.Kicking) { player.Character.AllowUncrouch.Value = true; } }); // Special ability /* * input.Bind(settings.SpecialAbility, PCInput.InputState.Down, delegate() * { * Voxel.GlobalRaycastResult hit = Voxel.GlobalRaycast(main.Camera.Position, main.Camera.Forward, main.Camera.FarPlaneDistance, null); * if (hit.Voxel != null && hit.Voxel.GetType() != typeof(DynamicVoxel)) * { * VoxelRip.Go(hit.Voxel, hit.Coordinate.Value, 7, delegate(List<DynamicVoxel> results) * { * foreach (DynamicVoxel v in results) * { * v.IsAffectedByGravity.Value = false; * v.LinearVelocity.Value = hit.Voxel.GetAbsoluteVector(hit.Normal.GetVector()) * 7.0f + new Vector3((float)this.random.NextDouble() * 2.0f - 1.0f, (float)this.random.NextDouble() * 2.0f - 1.0f, (float)this.random.NextDouble() * 2.0f - 1.0f); + } + }); + } + }); */ // Player data bindings entity.Add(new PostInitialization { delegate() { Entity dataEntity = PlayerDataFactory.Instance; PlayerData playerData = dataEntity.Get <PlayerData>(); // HACK. Overwriting the property rather than binding the two together. Oh well. // This is because I haven't written a two-way list binding. footsteps.RespawnLocations = playerData.RespawnLocations; // Bind player data properties entity.Add(new TwoWayBinding <float>(WorldFactory.Instance.Get <World>().CameraShakeAmount, cameraControl.CameraShakeAmount)); entity.Add(new TwoWayBinding <bool>(playerData.EnableRoll, rollKickSlide.EnableRoll)); entity.Add(new TwoWayBinding <bool>(playerData.EnableCrouch, player.EnableCrouch)); entity.Add(new TwoWayBinding <bool>(playerData.EnableKick, rollKickSlide.EnableKick)); entity.Add(new TwoWayBinding <bool>(playerData.EnableWallRun, wallRun.EnableWallRun)); entity.Add(new TwoWayBinding <bool>(playerData.EnableWallRunHorizontal, wallRun.EnableWallRunHorizontal)); entity.Add(new TwoWayBinding <bool>(playerData.EnableEnhancedWallRun, wallRun.EnableEnhancedWallRun)); entity.Add(new TwoWayBinding <bool>(playerData.EnableMoves, player.EnableMoves)); entity.Add(new TwoWayBinding <float>(playerData.MaxSpeed, player.Character.MaxSpeed)); entity.Add(new TwoWayBinding <Voxel.t>(playerData.CloudType, blockCloud.Type)); Phone phone = dataEntity.GetOrCreate <Phone>("Phone"); entity.Add ( new Binding <bool> ( phone.CanReceiveMessages, () => player.Character.IsSupported && !player.Character.IsSwimming && !player.Character.Crouched, player.Character.IsSupported, player.Character.IsSwimming, player.Character.Crouched ) ); PhoneNote.Attach(main, entity, player, model, input, phone, player.Character.EnableWalking, playerData.PhoneActive, playerData.NoteActive); PlayerUI.Attach(main, entity, ui, player.Health, rotation.Rotation, playerData.NoteActive, playerData.PhoneActive); } }); fpsCamera.Add(new Binding <Vector2>(fpsCamera.Mouse, input.Mouse)); fpsCamera.Add(new Binding <Vector2>(fpsCamera.Movement, input.Movement)); input.Bind(fpsCamera.SpeedMode, settings.Parkour); input.Bind(fpsCamera.Up, settings.Jump); fpsCamera.Add(new Binding <bool>(fpsCamera.Down, input.GetKey(Keys.LeftControl))); Lemma.Console.Console.AddConCommand(new ConCommand("noclip", "Toggle free camera mode", delegate(ConCommand.ArgCollection args) { bool freeCameraMode = !fpsCamera.Enabled; fpsCamera.Enabled.Value = freeCameraMode; cameraControl.Enabled.Value = !freeCameraMode; firstPersonModel.Enabled.Value = !freeCameraMode; model.Enabled.Value = !freeCameraMode; ui.Enabled.Value = !freeCameraMode; player.Character.EnableWalking.Value = !freeCameraMode; player.EnableMoves.Value = !freeCameraMode; if (freeCameraMode) { player.Character.Body.BecomeKinematic(); } else { player.Character.Body.BecomeDynamic(player.Character.Mass); } if (freeCameraMode) { AkSoundEngine.PostEvent(AK.EVENTS.STOP_PLAYER_BREATHING_SOFT, entity); } else { transform.Position.Value = main.Camera.Position; } })); entity.Add(new CommandBinding(entity.Delete, delegate() { Lemma.Console.Console.RemoveConCommand("noclip"); if (fpsCamera.Enabled) // Movement is disabled. Re-enable it. { player.Character.EnableWalking.Value = true; player.EnableMoves.Value = true; } })); }
public override void update(GameTime time) { Reposition(); if (sparkleText != null && sparkleText.update(time)) { sparkleText = null; } if (everythingShakeTimer > 0f) { everythingShakeTimer -= time.ElapsedGameTime.Milliseconds; everythingShake = new Vector2((float)Game1.random.Next(-10, 11) / 10f, (float)Game1.random.Next(-10, 11) / 10f); if (everythingShakeTimer <= 0f) { everythingShake = Vector2.Zero; } } if (fadeIn) { scale += 0.05f; if (scale >= 1f) { scale = 1f; fadeIn = false; } } else if (fadeOut) { if (everythingShakeTimer > 0f || sparkleText != null) { return; } scale -= 0.05f; if (scale <= 0f) { scale = 0f; fadeOut = false; int bait = ((Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod && (Game1.player.CurrentTool as FishingRod).attachments[0] != null) ? ((int)(Game1.player.CurrentTool as FishingRod).attachments[0].parentSheetIndex) : (-1)); bool caughtDouble = !bossFish && bait == 774 && Game1.random.NextDouble() < 0.25 + Game1.player.DailyLuck / 2.0; if (distanceFromCatching > 0.9f && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).pullFishFromWater(whichFish, fishSize, fishQuality, (int)difficulty, treasureCaught, perfect, fromFishPond, caughtDouble); } else { Game1.player.completelyStopAnimatingOrDoingAction(); if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).doneFishing(Game1.player, consumeBaitAndTackle: true); } } Game1.exitActiveMenu(); Game1.setRichPresence("location", Game1.currentLocation.Name); } } else { if (Game1.random.NextDouble() < (double)(difficulty * (float)((motionType != 2) ? 1 : 20) / 4000f) && (motionType != 2 || bobberTargetPosition == -1f)) { float spaceBelow = 548f - bobberPosition; float spaceAbove = bobberPosition; float percent = Math.Min(99f, difficulty + (float)Game1.random.Next(10, 45)) / 100f; bobberTargetPosition = bobberPosition + (float)Game1.random.Next(-(int)spaceAbove, (int)spaceBelow) * percent; } if (motionType == 4) { floaterSinkerAcceleration = Math.Max(floaterSinkerAcceleration - 0.01f, -1.5f); } else if (motionType == 3) { floaterSinkerAcceleration = Math.Min(floaterSinkerAcceleration + 0.01f, 1.5f); } if (Math.Abs(bobberPosition - bobberTargetPosition) > 3f && bobberTargetPosition != -1f) { bobberAcceleration = (bobberTargetPosition - bobberPosition) / ((float)Game1.random.Next(10, 30) + (100f - Math.Min(100f, difficulty))); bobberSpeed += (bobberAcceleration - bobberSpeed) / 5f; } else if (motionType != 2 && Game1.random.NextDouble() < (double)(difficulty / 2000f)) { bobberTargetPosition = bobberPosition + (float)((Game1.random.NextDouble() < 0.5) ? Game1.random.Next(-100, -51) : Game1.random.Next(50, 101)); } else { bobberTargetPosition = -1f; } if (motionType == 1 && Game1.random.NextDouble() < (double)(difficulty / 1000f)) { bobberTargetPosition = bobberPosition + (float)((Game1.random.NextDouble() < 0.5) ? Game1.random.Next(-100 - (int)difficulty * 2, -51) : Game1.random.Next(50, 101 + (int)difficulty * 2)); } bobberTargetPosition = Math.Max(-1f, Math.Min(bobberTargetPosition, 548f)); bobberPosition += bobberSpeed + floaterSinkerAcceleration; if (bobberPosition > 532f) { bobberPosition = 532f; } else if (bobberPosition < 0f) { bobberPosition = 0f; } bobberInBar = bobberPosition + 12f <= bobberBarPos - 32f + (float)bobberBarHeight && bobberPosition - 16f >= bobberBarPos - 32f; if (bobberPosition >= (float)(548 - bobberBarHeight) && bobberBarPos >= (float)(568 - bobberBarHeight - 4)) { bobberInBar = true; } bool num = buttonPressed; buttonPressed = Game1.oldMouseState.LeftButton == ButtonState.Pressed || Game1.isOneOfTheseKeysDown(Game1.oldKBState, Game1.options.useToolButton) || (Game1.options.gamepadControls && (Game1.oldPadState.IsButtonDown(Buttons.X) || Game1.oldPadState.IsButtonDown(Buttons.A))); if (!num && buttonPressed) { Game1.playSound("fishingRodBend"); } float gravity = (buttonPressed ? (-0.25f) : 0.25f); if (buttonPressed && gravity < 0f && (bobberBarPos == 0f || bobberBarPos == (float)(568 - bobberBarHeight))) { bobberBarSpeed = 0f; } if (bobberInBar) { gravity *= ((whichBobber == 691) ? 0.3f : 0.6f); if (whichBobber == 691) { if (bobberPosition + 16f < bobberBarPos + (float)(bobberBarHeight / 2)) { bobberBarSpeed -= 0.2f; } else { bobberBarSpeed += 0.2f; } } } float oldPos = bobberBarPos; bobberBarSpeed += gravity; bobberBarPos += bobberBarSpeed; if (bobberBarPos + (float)bobberBarHeight > 568f) { bobberBarPos = 568 - bobberBarHeight; bobberBarSpeed = (0f - bobberBarSpeed) * 2f / 3f * ((whichBobber == 692) ? 0.1f : 1f); if (oldPos + (float)bobberBarHeight < 568f) { Game1.playSound("shiny4"); } } else if (bobberBarPos < 0f) { bobberBarPos = 0f; bobberBarSpeed = (0f - bobberBarSpeed) * 2f / 3f; if (oldPos > 0f) { Game1.playSound("shiny4"); } } bool treasureInBar = false; if (treasure) { float oldTreasureAppearTimer = treasureAppearTimer; treasureAppearTimer -= time.ElapsedGameTime.Milliseconds; if (treasureAppearTimer <= 0f) { if (treasureScale < 1f && !treasureCaught) { if (oldTreasureAppearTimer > 0f) { treasurePosition = ((bobberBarPos > 274f) ? Game1.random.Next(8, (int)bobberBarPos - 20) : Game1.random.Next(Math.Min(528, (int)bobberBarPos + bobberBarHeight), 500)); Game1.playSound("dwop"); } treasureScale = Math.Min(1f, treasureScale + 0.1f); } treasureInBar = treasurePosition + 12f <= bobberBarPos - 32f + (float)bobberBarHeight && treasurePosition - 16f >= bobberBarPos - 32f; if (treasureInBar && !treasureCaught) { treasureCatchLevel += 0.0135f; treasureShake = new Vector2(Game1.random.Next(-2, 3), Game1.random.Next(-2, 3)); if (treasureCatchLevel >= 1f) { Game1.playSound("newArtifact"); treasureCaught = true; } } else if (treasureCaught) { treasureScale = Math.Max(0f, treasureScale - 0.1f); } else { treasureShake = Vector2.Zero; treasureCatchLevel = Math.Max(0f, treasureCatchLevel - 0.01f); } } } if (bobberInBar) { distanceFromCatching += 0.002f; reelRotation += (float)Math.PI / 8f; fishShake.X = (float)Game1.random.Next(-10, 11) / 10f; fishShake.Y = (float)Game1.random.Next(-10, 11) / 10f; barShake = Vector2.Zero; Rumble.rumble(0.1f, 1000f); if (unReelSound != null) { unReelSound.Stop(AudioStopOptions.Immediate); } if (Game1.soundBank != null && (reelSound == null || reelSound.IsStopped || reelSound.IsStopping)) { reelSound = Game1.soundBank.GetCue("fastReel"); } if (reelSound != null && !reelSound.IsPlaying && !reelSound.IsStopping) { reelSound.Play(); } } else if (!treasureInBar || treasureCaught || whichBobber != 693) { if (!fishShake.Equals(Vector2.Zero)) { Game1.playSound("tinyWhip"); perfect = false; Rumble.stopRumbling(); } fishSizeReductionTimer -= time.ElapsedGameTime.Milliseconds; if (fishSizeReductionTimer <= 0) { fishSize = Math.Max(minFishSize, fishSize - 1); fishSizeReductionTimer = 800; } if ((Game1.player.fishCaught != null && Game1.player.fishCaught.Count() != 0) || Game1.currentMinigame != null) { distanceFromCatching -= ((whichBobber == 694 || beginnersRod) ? 0.002f : 0.003f); } float distanceAway = Math.Abs(bobberPosition - (bobberBarPos + (float)(bobberBarHeight / 2))); reelRotation -= (float)Math.PI / Math.Max(10f, 200f - distanceAway); barShake.X = (float)Game1.random.Next(-10, 11) / 10f; barShake.Y = (float)Game1.random.Next(-10, 11) / 10f; fishShake = Vector2.Zero; if (reelSound != null) { reelSound.Stop(AudioStopOptions.Immediate); } if (Game1.soundBank != null && (unReelSound == null || unReelSound.IsStopped)) { unReelSound = Game1.soundBank.GetCue("slowReel"); unReelSound.SetVariable("Pitch", 600); } if (unReelSound != null && !unReelSound.IsPlaying && !unReelSound.IsStopping) { unReelSound.Play(); } } distanceFromCatching = Math.Max(0f, Math.Min(1f, distanceFromCatching)); if (Game1.player.CurrentTool != null) { Game1.player.CurrentTool.tickUpdate(time, Game1.player); } if (distanceFromCatching <= 0f) { fadeOut = true; everythingShakeTimer = 500f; Game1.playSound("fishEscape"); handledFishResult = true; if (unReelSound != null) { unReelSound.Stop(AudioStopOptions.Immediate); } if (reelSound != null) { reelSound.Stop(AudioStopOptions.Immediate); } } else if (distanceFromCatching >= 1f) { everythingShakeTimer = 500f; Game1.playSound("jingle1"); fadeOut = true; handledFishResult = true; if (unReelSound != null) { unReelSound.Stop(AudioStopOptions.Immediate); } if (reelSound != null) { reelSound.Stop(AudioStopOptions.Immediate); } if (perfect) { sparkleText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\UI:BobberBar_Perfect"), Color.Yellow, Color.White, rainbow: false, 0.1, 1500); if (Game1.isFestival()) { Game1.CurrentEvent.perfectFishing(); } } else if (fishSize == maxFishSize) { fishSize--; } } } if (bobberPosition < 0f) { bobberPosition = 0f; } if (bobberPosition > 548f) { bobberPosition = 548f; } }
public bool tick(GameTime time) { Rumble.update((float)time.ElapsedGameTime.Milliseconds); this.location.UpdateWhenCurrentLocation(time); this.location.updateEvenIfFarmerIsntHere(time, false); Game1.player.Stamina = (float)Game1.player.MaxStamina; Game1.player.Update(time, this.location); for (int i = Game1.screenOverlayTempSprites.Count - 1; i >= 0; i--) { if (Game1.screenOverlayTempSprites[i].update(time)) { Game1.screenOverlayTempSprites.RemoveAt(i); } } if (Game1.activeClickableMenu != null) { Game1.updateActiveMenu(time); } if (this.timerToStart > 0) { Game1.player.faceDirection(3); this.timerToStart -= time.ElapsedGameTime.Milliseconds; if (this.timerToStart <= 0) { Game1.playSound("whistle"); } } else if (this.showResultsTimer >= 0) { int arg_10C_0 = this.showResultsTimer; this.showResultsTimer -= time.ElapsedGameTime.Milliseconds; if (arg_10C_0 > 11000 && this.showResultsTimer <= 11000) { Game1.playSound("smallSelect"); } if (arg_10C_0 > 9000 && this.showResultsTimer <= 9000) { Game1.playSound("smallSelect"); } if (arg_10C_0 > 7000 && this.showResultsTimer <= 7000) { if (this.perfections > 0) { this.score += this.perfections * 10; this.perfectionBonus = this.perfections * 10; if (this.fishCaught >= 3 && this.perfections >= 3) { this.perfectionBonus += this.score; this.score *= 2; } Game1.playSound("newArtifact"); } else { Game1.playSound("smallSelect"); } } if (arg_10C_0 > 5000 && this.showResultsTimer <= 5000) { if (this.score >= 10) { Game1.playSound("reward"); this.starTokensWon = (this.score + 5) / 10 * 6; Game1.player.festivalScore += this.starTokensWon; } else { Game1.playSound("fishEscape"); } } if (this.showResultsTimer <= 0) { Game1.globalFadeToClear(null, 0.02f); return(true); } } else if (!this.gameDone) { this.gameEndTimer -= time.ElapsedGameTime.Milliseconds; if (this.gameEndTimer <= 0 && Game1.activeClickableMenu == null && (!Game1.player.UsingTool || (Game1.player.CurrentTool as FishingRod).isFishing)) { if (Game1.player.usingTool) { this.receiveLeftClick(0, 0, true); if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is FishingRod) { (Game1.player.CurrentTool as FishingRod).doneFishing(Game1.player, false); } } Game1.player.completelyStopAnimatingOrDoingAction(); Game1.playSound("whistle"); this.gameEndTimer = 1000; this.gameDone = true; } } else if (this.gameDone && this.gameEndTimer > 0) { this.gameEndTimer -= time.ElapsedGameTime.Milliseconds; if (this.gameEndTimer <= 0) { Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.gameDoneAfterFade), 0.01f); Game1.exitActiveMenu(); Game1.player.forceCanMove(); } } return(this.exit); }
protected void StartRumble(Rumble _rumble) { player.StartRumble(_rumble); // Modify to call Rumble Manager later }