private void CreatePanningSpot(GameLocation location) { Random random = new Random(Game1.timeOfDay + (int)Game1.uniqueIDForThisGame / 2 + (int)Game1.stats.DaysPlayed); //List<Point> possibleTiles = openWaterTiles[location.Name]; var possibleTiles = openWaterTiles[location.Name]; if (possibleTiles.OreSpots.Count != 0) { for (int i = 0; i < 4; i++) // should only ever need to try once, but just in case... { int indx = random.Next(0, possibleTiles.OreSpots.Count); Point newOrePoint = possibleTiles.OreSpots[indx]; // Double check to make sure it's a valid point/tile if (location.isOpenWater(newOrePoint.X, newOrePoint.Y) && FishingRod.distanceToLand(newOrePoint.X, newOrePoint.Y, location) <= 0) { if (Game1.player.currentLocation.Equals(location) && config.enableSplashSounds) { location.playSound("slosh"); } location.orePanPoint.Value = newOrePoint; hasPanningSpot = true; playerPannedSpot = false; modCreatedPanningSpot[location] = true; if (i > 0) { this.Monitor.Log($"Had to loop... check data file {location}.json"); } break; } } } }
public static float GetRawTreasureChance(SFarmer who, FishingRod rod) { ConfigMain.ConfigGlobalTreasure config = ModFishing.Instance.MainConfig.GlobalTreasureSettings; // Calculate chance float chance = config.TreasureChance; chance += who.LuckLevel * config.TreasureLuckLevelEffect; chance += (float)Game1.dailyLuck * config.TreasureDailyLuckEffect; chance += config.TreasureStreakEffect * ModFishing.Instance.Api.GetStreak(who); if (rod.getBaitAttachmentIndex() == 703) { chance += config.TreasureBaitEffect; } if (rod.getBobberAttachmentIndex() == 693) { chance += config.TreasureBobberEffect; } if (who.professions.Contains(9)) { chance += config.TreasureChance; } return(Math.Min(chance, config.MaxTreasureChance)); }
public override void UpdateAfterCamera() { base.UpdateAfterCamera(); if (this.m_ActiveSlots.Count == 0 || !base.enabled) { return; } this.m_ClosestDistTemp = float.MaxValue; SlotData selectedSlotData = this.m_SelectedSlotData; this.m_SelectedSlotData = null; this.m_VisibleSlots.Clear(); foreach (SlotData slotData in this.m_ActiveSlots) { if (slotData.slot.IsBIWoundSlot()) { this.UpdateWoundSlots(slotData); } else { this.UpdateSlots(slotData); } } if (this.m_SelectedSlotData == null && Inventory3DManager.Get().IsActive() && Inventory3DManager.Get().m_ActivePocket != BackpackPocket.Left && Player.Get().GetCurrentItem(Hand.Right) && Player.Get().GetCurrentItem(Hand.Right).m_Info.IsFishingRod()) { FishingRod component = Player.Get().GetCurrentItem(Hand.Right).gameObject.GetComponent <FishingRod>(); ItemSlot y; if (!component.m_Hook) { y = component.m_HookSlot; } else { y = component.m_Hook.m_BaitSlot; } foreach (SlotData slotData2 in this.m_VisibleSlots) { if (slotData2.slot == y) { this.m_SelectedSlotData = slotData2; break; } } } if (this.m_SelectedSlotData != null) { this.m_SelectedSlotData.icon.rectTransform.localScale = Vector2.one * 2f; if (this.m_SelectedSlotData.add_icon) { this.m_SelectedSlotData.add_icon.rectTransform.localScale = Vector2.one * 0.5f; } Color color = this.m_SelectedSlotData.icon.color; color.a *= 1.5f; this.m_SelectedSlotData.icon.color = color; } if (this.m_SelectedSlotData != selectedSlotData) { HUDItem.Get().OnChangeSelectedSlot(this.m_SelectedSlotData); } }
//if player pulled sapphire, add flag. not done in getFish() cus mod compatibility private static void FishingRod_PullFishFromWater_PostFix(ref FishingRod __instance, int whichFish, int fishSize, int fishQuality, int fishDifficulty, bool treasureCaught, bool wasPerfect, bool fromFishPond, bool caughtDouble, string itemCategory) { if (whichFish == CachedSapphireID) { Game1.player.mailReceived.Add(FLAGSAPPHIRE); } }
public override void performOrePanTenMinuteUpdate(Random r) { if (Game1.MasterPlayer.mailReceived.Contains("ccFishTank") && orePanPoint.Value.Equals(Point.Zero) && r.NextDouble() < 0.5) { int tries = 0; Point p; while (true) { if (tries >= 6) { return; } p = new Point(r.Next(4, 15), r.Next(45, 70)); if (isOpenWater(p.X, p.Y) && FishingRod.distanceToLand(p.X, p.Y, this) <= 1 && getTileIndexAt(p, "Buildings") == -1) { break; } tries++; } if (Game1.player.currentLocation.Equals(this)) { playSound("slosh"); } orePanPoint.Value = p; } else if (!orePanPoint.Value.Equals(Point.Zero) && r.NextDouble() < 0.1) { orePanPoint.Value = Point.Zero; } }
public static void Postfix(FishingRod __instance, ref int __result) { if (__instance.hasEnchantmentOfType <MoreLuresEnchantment>()) { ++__result; } }
public static void Postfix(FishingRod __instance, Farmer who) { if (!__instance.isReeling && !__instance.isFishing && who.UsingTool && __instance.castedButBobberStillInAir) { UseControllerInput(__instance, who); } }
public static void After_playerCaughtFishEndFunction(FishingRod __instance, Farmer ___lastUser, int ___whichFish, int ___fishQuality, string ___itemCategory) { if (___lastUser.IsLocalPlayer && !Game1.isFestival() && !__instance.fromFishPond) { if (___itemCategory == "Object") { SObject fish = new SObject(___whichFish, 1, isRecipe: false, -1, ___fishQuality); if (___whichFish == GameLocation.CAROLINES_NECKLACE_ITEM) { fish.questItem.Value = true; } if (___whichFish == 79 || ___whichFish == 842) { fish = ___lastUser.currentLocation.tryToCreateUnseenSecretNote(___lastUser); if (fish == null) { return; } } if (__instance.caughtDoubleFish) { fish.Stack = 2; } QuestEssentialsMod.QuestApi.CheckForQuestComplete(new FishMessage(___lastUser, fish)); } } }
public static void playerCaughtFishEndFunction(int extraData) { context.Monitor.Log($"caught fish end"); fishCaught = true; fishQuality = Game1.random.Next(0, 5); lastUser.Halt(); lastUser.armOffset = Vector2.Zero; recordSize = lastUser.caughtFish(whichFish, fishSize, false, caughtDoubleFish ? 2 : 1); lastUser.faceDirection(2); if (FishingRod.isFishBossFish(whichFish)) { Game1.showGlobalMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:FishingRod.cs.14068")); string name = Game1.objectInformation[whichFish].Split(new char[] { '/' })[4]; context.Helper.Reflection.GetField <Multiplayer>(Game1.game1, "multiplayer").GetValue().globalChatInfoMessage("CaughtLegendaryFish", new string[] { Game1.player.Name, name }); return; } if (recordSize) { sparklingText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:FishingRod.cs.14069"), Color.LimeGreen, Color.Azure, false, 0.1, 2500, -1, 500, 1f); lastUser.currentLocation.localSound("newRecord"); return; } lastUser.currentLocation.localSound("fishSlap"); }
public static void UpdateProbabilities(FishingRod rod) { if (rod.isFishing) { if (_isFirstTimeOfFishing) { Logger.Log("Examine fishing probability"); _isFirstTimeOfFishing = false; GameLocation location = Game1.currentLocation; Rectangle rectangle = new Rectangle(location.fishSplashPoint.X * 64, location.fishSplashPoint.Y * 64, 64, 64); Rectangle value = new Rectangle((int)rod.bobber.X - 80, (int)rod.bobber.Y - 80, 64, 64); bool flag = rectangle.Intersects(value); int clearWaterDistance = Reflection.GetField <int>(rod, "clearWaterDistance").GetValue(); _fishingDictionary = GetFishes(location, rod.attachments[0]?.ParentSheetIndex ?? -1, clearWaterDistance + (flag ? 1 : 0), Game1.player, InstanceHolder.Config.MorePreciseProbabilities ? InstanceHolder.Config.TrialOfExamine : 1); } } else { _isFirstTimeOfFishing = true; _fishingDictionary = null; } }
public override void performTenMinuteUpdate(int timeOfDay) { base.performTenMinuteUpdate(timeOfDay); Random r = new Random(timeOfDay + (int)Game1.uniqueIDForThisGame / 2 + (int)Game1.stats.DaysPlayed); if (fishSplashPoint.Value.Equals(Point.Zero) && r.NextDouble() < 1.0 && curtainOpenPercent >= 1f) { for (int tries = 0; tries < 2; tries++) { Point p = new Point(r.Next(9, 21), r.Next(7, 12)); if (!isOpenWater(p.X, p.Y)) { continue; } int toLand = FishingRod.distanceToLand(p.X, p.Y, this); if (toLand > 1 && toLand < 5) { if (Game1.player.currentLocation.Equals(this)) { playSound("waterSlosh"); } fishSplashPoint.Value = p; break; } } } else if (!fishSplashPoint.Value.Equals(Point.Zero) && r.NextDouble() < 0.25) { fishSplashPoint.Value = Point.Zero; } }
public void ActionPressed(GameController gController) { if (gController.GetBarSelectedStack()._nbItem == 0 || gController.GetBarSelectedStack()._item.GetType() != typeof(FishingRod)) { return; } FishingRod rod = (FishingRod)gController.GetBarSelectedStack()._item; if (!_fishing) { _coroutine = gController.StartCoroutine(Fishing(gController.IsRaining(), (int)gController.GetHour(), rod.Bait, rod.BonusBait)); } else { gController.StopCoroutine(_coroutine); if (_hooking) { _succesEvent.Invoke(_fish); } else { _failEvent.Invoke(); } _fish = null; _hooking = false; _fishing = false; } }
// Start is called before the first frame update void Start() { goldManager = goldManagerObject.GetComponent <Gold_Manager>(); fishingRod = fishingRodObject.GetComponent <FishingRod>(); goldAmt = GameObject.Find("Current Gold").GetComponent <Text>(); upgradeButtons = new Button[] { rodButton.GetComponent <Button>(), lineButton.GetComponent <Button>(), hookButton.GetComponent <Button>(), lureButton.GetComponent <Button>() }; upgradeCosts = new Text[] { rodButton.transform.Find("cost").GetComponent <Text>(), lineButton.transform.Find("cost").GetComponent <Text>(), hookButton.transform.Find("cost").GetComponent <Text>(), lureButton.transform.Find("cost").GetComponent <Text>() }; for (int i = 0; i < upgradeCosts.Length; i++) { upgradeCosts[i].text = $"${UpgradeLevels.GetUpgrade((UpgradeLevels.Types)i, upgradeIndices[i]).cost}"; } }
private static bool GetFishPrefix(Farm __instance, float millisecondsAfterNibble, int bait, int waterDepth, Farmer who, double baitPotency, ref SObject __result) { if (!ModEntry.IsSmallBeachFarm(who?.currentLocation)) { return(false); } // get tile being fished FishingRod rod = who.CurrentTool as FishingRod; if (rod == null) { return(false); } Point tile = new Point((int)(rod.bobber.X / Game1.tileSize), (int)(rod.bobber.Y / Game1.tileSize)); // get ocean fish if (ModEntry.IsOceanTile(__instance, tile.X, tile.Y)) { __result = __instance.getFish(millisecondsAfterNibble, bait, waterDepth, who, baitPotency, "Beach"); ModEntry.StaticMonitor.VerboseLog($"Fishing ocean tile at ({rod.bobber.X / Game1.tileSize}, {rod.bobber.Y / Game1.tileSize})."); return(false); } // get default riverlands fish ModEntry.StaticMonitor.VerboseLog($"Fishing river tile at ({rod.bobber.X / Game1.tileSize}, {rod.bobber.Y / Game1.tileSize})."); return(true); }
/********* ** Private methods *********/ /// <summary>The method to call after <see cref="FishingRod.attachmentSlots"/>.</summary> private static void After_AttachmentSlots(FishingRod __instance, ref int __result) { if (__instance.hasEnchantmentOfType <MoreLuresEnchantment>()) { ++__result; } }
private void OverridePullFishEvent(FishingRod rod) { // Make sure the pullFishFromWaterEvent has a value (it should) if (!(this._pullFishField?.GetValue(rod) is NetEventBinary pullFishEvent)) { return; } // Try to get the event field if (!(this._netEventOnEvent?.GetValue(pullFishEvent) is AbstractNetEvent1 <byte[]> .Event eventField)) { return; } // Remove all the handlers from the event foreach (Delegate method in eventField.GetInvocationList()) { if (method is AbstractNetEvent1 <byte[]> .Event handler) { pullFishEvent.onEvent -= handler; } else { ModFishing.Instance.Monitor.Log($"Failed to remove {method} ({method.Method.Name}) from {nameof(AbstractNetEvent1<byte[]>.onEvent)}.", LogLevel.Warn); } } // Add a new event handler pullFishEvent.AddReaderHandler(reader => this.DoPullFishFromWater(rod, ModFishing.Instance.Helper.Reflection.GetField <Farmer>(rod, "lastUser").GetValue(), reader)); ModFishing.Instance.Monitor.Log("Events overridden for fishing rod", LogLevel.Trace); }
static void Main(string[] args) { /* * SmsObserver smsObserver = new SmsObserver(); * EmailObserver emailObserver = new EmailObserver(); * ISubject subject = new PublishProjectSubject(); * subject.Update += new UpdateHandler(smsObserver.SendSms); * subject.Update += emailObserver.SendEmail; * subject.Nodify(); */ // 钓鱼 // 1.初始化鱼竿 FishingRod fishingRod = new FishingRod(); // 2.声明垂钓者 FishingMan jiangTaiGong = new FishingMan("姜太公"); // 3.分配鱼竿 jiangTaiGong.FishingRod = fishingRod; // 4.注册观察者 //fishingRod.FishingEvent += new FishingEventHandler().HandleEvent(); // 5.循环钓鱼 while (jiangTaiGong.FishCount < 5) { jiangTaiGong.Fishing(); Console.WriteLine("------------------------------"); Thread.Sleep(TimeSpan.FromSeconds(1)); } Console.ReadKey(); }
public override void performTenMinuteUpdate(int timeOfDay) { base.performTenMinuteUpdate(timeOfDay); Random random = new Random(timeOfDay + (int)Game1.uniqueIDForThisGame / 2 + (int)Game1.stats.DaysPlayed); // Fishing if (this.fishSplashPoint.Value.Equals(Point.Zero) && random.NextDouble() < type.Behavior.FishingSplashChance) { for (int index = 0; index < 2; ++index) { Point point = new Point(random.Next(0, this.map.GetLayer("Back").LayerWidth), random.Next(0, this.map.GetLayer("Back").LayerHeight)); if (this.isOpenWater(point.X, point.Y)) { int land = FishingRod.distanceToLand(point.X, point.Y, this); if (land > 1 && land <= 5) { if (Game1.player.currentLocation.Equals((object)this)) { Game1.playSound("waterSlosh"); } this.fishSplashPoint.Value = point; this.fishSplashAnimation = new TemporaryAnimatedSprite(51, new Vector2((float)(point.X * Game1.tileSize), (float)(point.Y * Game1.tileSize)), Color.White, 10, false, 80f, 999999, -1, -1f, -1, 0); break; } } } } }
private void PrintInternalDebugValues() { if (!(Game1.player.CurrentTool is FishingRod)) { return; } FishingRod r = Game1.player.CurrentTool as FishingRod; // I don't use multiline string because I want it all to be aligned in the log output instead of // subsequent print lines not having the log header at the front of the line. log.Silly(); log.Silly($"UPDATE {FishForMe.logSVValuesCount}"); log.Silly("--Game--"); log.Silly($"activeClickableMenu: {Game1.activeClickableMenu}"); log.Silly($"currentMinigame: {Game1.currentMinigame}"); log.Silly(); log.Silly("--Player--"); log.Silly($"canMove: {Game1.player.canMove}"); log.Silly(); log.Silly("--Rod--"); log.Silly($"castedButBobberStillInAir: {r.castedButBobberStillInAir}"); log.Silly($"fishCaught: {r.fishCaught}"); log.Silly($"hit: {r.hit}"); log.Silly($"inUse(): {r.inUse()}"); log.Silly($"isCasting: {r.isCasting}"); log.Silly($"isFishing: {r.isFishing}"); log.Silly($"isNibbling: {r.isNibbling}"); log.Silly($"isReeling: {r.isReeling}"); log.Silly($"isTimingCast: {r.isTimingCast}"); log.Silly($"pullingOutOfWater: {r.pullingOutOfWater}"); log.Silly($"showingTreasure: {r.showingTreasure}"); log.Silly($"timeUntilFishingBite: {r.timeUntilFishingBite}"); log.Silly($"fishingBiteAccumulator: {r.fishingBiteAccumulator}"); log.Silly($"treasureCaught: {r.treasureCaught}"); if (inFishingMenu) { log.Silly(); log.Silly("--Window--"); FieldInfo[] fif = typeof(FishForMe).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); foreach (var prop in fif) { if (prop.FieldType.IsGenericType) { if (prop.FieldType.GetGenericTypeDefinition() == typeof(IReflectedField <>)) { MethodInfo gv = prop.FieldType.GetMethod("GetValue"); if (gv != null) { log.Silly($"{prop.Name}: {gv.Invoke(prop.GetValue(this), null)}"); } } } } } log.Silly($"END UPDATE {FishForMe.logSVValuesCount}"); log.Silly(); FishForMe.logSVValuesCount++; }
public dynamic getReplacement() { FishingRod replacement = new FishingRod(1); replacement.upgradeLevel = -1; replacement.attachments = this.attachments; return(replacement); }
public object getReplacement() { FishingRod replacement = new FishingRod(1); replacement.upgradeLevel = -1; replacement.attachments = attachments; return(replacement); }
// Use this for initialization void Start() { SoundManager = GameObject.Find("SoundManager"); Angel = transform.parent.gameObject.transform.parent.gameObject. transform.parent.gameObject.transform.parent.gameObject. transform.parent.gameObject; myFishingRod = Angel.GetComponent <FishingRod>(); }
public static bool Fishrod_Name(FishingRod __instance, ref string __result) { if (__instance.UpgradeLevel == 9) { __result = ModEntry.ModHelper.Translation.Get("radioactiveRod.name"); return(false); } return(true); }
public static bool Fishrod_DisplayName(FishingRod __instance, ref string __result) { if (__instance.UpgradeLevel == 9) { __result = __instance.Name; return(false); } return(true); }
public void EquipRod(FishingRod rod) { FishingRod oldRod = _rodSlot.EquipRod(rod); if (oldRod != null) { //TODO - What happens if cannot add bait to inventory // bool success = AddItem(rod); } }
public PrePullFishFromWaterEvent(FishingRod rod, int whichFish, int fishSize, int fishQuality, int fishDifficulty, bool treasureCaught, bool wasPerfect) { Rod = rod; WhichFish = whichFish; FishSize = fishSize; FishQuality = fishQuality; FishDifficulty = fishDifficulty; TreasureCaught = treasureCaught; WasPerfect = wasPerfect; }
public static bool FishingRod_Draw_Prefix(FishingRod __instance, ref string ___itemCategory, ref int ___whichFish) { if (___itemCategory == "Object" && !Game1.objectInformation.ContainsKey(___whichFish)) { SMonitor.Log($"FishingRod.draw: whichFish {___whichFish} does not exist in objectInformation", LogLevel.Warn); ___whichFish = Game1.objectInformation.Keys.First(); SMonitor.Log($"FishingRod.draw: trying to recover by setting whichFish to {___whichFish}", LogLevel.Warn); } return(true); }
public void LoadNextUnlockedFishingRod() { activefishingRodNode = activefishingRodNode.Next; if (activefishingRodNode == null) { activefishingRodNode = GameMaster.player.unlockedRods.First; } activeFishingRod = activefishingRodNode.Value; LoadRegionPanel(ActiveRegion); }
public void LoadPreviousUnlockedFishingRod() { activefishingRodNode = activefishingRodNode.Previous; if (activefishingRodNode == null) { activefishingRodNode = GameMaster.player.unlockedRods.Last; } activeFishingRod = activefishingRodNode.Value; LoadFishingRodPanel(activeFishingRod); }
//Awake is called after the object creation private void Awake() { GameMaster.LoadUser(); ActiveRegionNode = GameMaster.player.unlockedRegions.First; ActiveRegion = ActiveRegionNode.Value; activefishingRodNode = GameMaster.player.unlockedRods.First; activeFishingRod = activefishingRodNode.Value; Debug.Log(ActiveRegion.name); }