/// <summary> /// Not yet implemented. Contact the mod author if this is something you want! /// </summary> /// <param name="season"></param> /// <returns></returns> public new ModularCropObject getRandomWildCropForSeason(string season) { ModularCropObject newThing = null; if (season == "spring" || season == "Spring") { Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); int cropListIndex = r.Next(0, ModCore.SpringWildCrops.Count - 1); newThing = ModCore.SpringWildCrops[cropListIndex]; } if (season == "summer" || season == "Summer") { Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); int cropListIndex = r.Next(0, ModCore.SummerWildCrops.Count - 1); newThing = ModCore.SummerWildCrops[cropListIndex]; } if (season == "fall" || season == "Fall") { Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); int cropListIndex = r.Next(0, ModCore.FallWildCrops.Count - 1); newThing = ModCore.FallWildCrops[cropListIndex]; } if (season == "winter" || season == "Winter") { Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina); int cropListIndex = r.Next(0, ModCore.WinterWildCrops.Count - 1); newThing = ModCore.WinterWildCrops[cropListIndex]; } return(newThing); }
public void newDay(int state, int fertilizer, int xTile, int yTile, GameLocation environment) { if (!environment.Name.Equals("Greenhouse") && (this.dead || !this.seasonsToGrowIn.Contains(Game1.currentSeason))) { this.dead = true; } else { if (state == 1) { this.dayOfCurrentPhase = this.fullyGrown ? this.dayOfCurrentPhase - 1 : Math.Min(this.dayOfCurrentPhase + 1, this.phaseDays.Count > 0 ? this.phaseDays[Math.Min(this.phaseDays.Count - 1, this.currentPhase)] : 0); if (this.dayOfCurrentPhase >= (this.phaseDays.Count > 0 ? this.phaseDays[Math.Min(this.phaseDays.Count - 1, this.currentPhase)] : 0) && this.currentPhase < this.phaseDays.Count - 1) { this.currentPhase = this.currentPhase + 1; this.dayOfCurrentPhase = 0; } while (this.currentPhase < this.phaseDays.Count - 1 && this.phaseDays.Count > 0 && this.phaseDays[this.currentPhase] <= 0) { this.currentPhase = this.currentPhase + 1; } if (this.rowInSpriteSheet == 23 && this.phaseToShow == -1 && this.currentPhase > 0) { this.phaseToShow = Game1.random.Next(1, 7); } if (environment is Farm && this.currentPhase == this.phaseDays.Count - 1 && (this.indexOfHarvest == 276 || this.indexOfHarvest == 190 || this.indexOfHarvest == 254) && new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + xTile * 2000 + yTile).NextDouble() < 0.01) { for (int index1 = xTile - 1; index1 <= xTile + 1; ++index1) { for (int index2 = yTile - 1; index2 <= yTile + 1; ++index2) { Vector2 key = new Vector2((float)index1, (float)index2); if (!environment.terrainFeatures.ContainsKey(key) || !(environment.terrainFeatures[key] is HoeDirt) || ((environment.terrainFeatures[key] as HoeDirt).crop == null || (environment.terrainFeatures[key] as HoeDirt).crop.indexOfHarvest.Value != this.indexOfHarvest)) { return; } } } for (int index1 = xTile - 1; index1 <= xTile + 1; ++index1) { for (int index2 = yTile - 1; index2 <= yTile + 1; ++index2) { Vector2 index3 = new Vector2((float)index1, (float)index2); (environment.terrainFeatures[index3] as HoeDirt).crop = (ModularCrop)null; } } (environment as Farm).resourceClumps.Add((ResourceClump) new GiantCrop(this.indexOfHarvest, new Vector2((float)(xTile - 1), (float)(yTile - 1)))); } } if (this.fullyGrown && this.dayOfCurrentPhase > 0 || (this.currentPhase < this.phaseDays.Count - 1 || this.rowInSpriteSheet != 23)) { return; } Vector2 index = new Vector2((float)xTile, (float)yTile); environment.objects.Remove(index); string season = Game1.currentSeason; switch (this.whichForageCrop) { case 495: season = "spring"; break; case 496: season = "summer"; break; case 497: season = "fall"; break; case 498: season = "winter"; break; } ModularCropObject @object = this.getRandomWildCropForSeason(season); @object.IsSpawnedObject = true; @object.CanBeGrabbed = true; environment.objects.Add(index, this.getRandomWildCropForSeason(season)); if (environment.terrainFeatures[index] == null || !(environment.terrainFeatures[index] is HoeDirt)) { return; } (environment.terrainFeatures[index] as HoeDirt).crop = (ModularCrop)null; } }
public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) { if (this.dead) { return(junimoHarvester != null); } if (this.forageCrop) { ModularCropObject @object = (ModularCropObject)null; int howMuch = 3; if (this.whichForageCrop == 1) { //@object = new ModularCropObject(399, 1, false, -1, 0); if (Game1.player.professions.Contains(16)) { @object.Quality = 4; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 30.0) { @object.Quality = 2; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 15.0) { @object.Quality = 1; } } Game1.stats.ItemsForaged += (uint)@object.Stack; if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut((Item)@object); return(true); } if (Game1.player.addItemToInventoryBool((Item)@object, false)) { Vector2 vector2 = new Vector2((float)xTile, (float)yTile); // Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; Game1.playSound("harvest"); DelayedAction.playSoundAfterDelay("coin", 260); if (this.regrowAfterHarvest == -1) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0)); Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); } Game1.player.gainExperience(2, howMuch); return(true); } Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); } else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0)) { int num1 = 1; int num2 = 0; int num3 = 0; if (this.indexOfHarvest == 0) { return(true); } Random random = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame); switch (soil.fertilizer.Value) { case 368: num3 = 1; break; case 369: num3 = 2; break; } double num4 = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)num3 * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01; double num5 = Math.Min(0.75, num4 * 2.0); if (random.NextDouble() < num4) { num2 = 2; } else if (random.NextDouble() < num5) { num2 = 1; } if (this.minHarvest > 1 || this.maxHarvest > 1) { num1 = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)); } if (this.chanceForExtraCrops > 0.0) { while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops)) { ++num1; } } if (this.harvestMethod == 1) { if (junimoHarvester == null) { DelayedAction.playSoundAfterDelay("daggerswipe", 150); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } for (int index = 0; index < num1; ++index) { if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData)); } else { AdditionalCropsFramework.Utilities.createObjectDebris((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); } //Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, (GameLocation)null); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } else { if (junimoHarvester == null) { Farmer player = Game1.player; ModularCropObject @object = new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); int num7 = 0; if (!player.addItemToInventoryBool((Item)@object, num7 != 0)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); goto label_86; } } Vector2 vector2 = new Vector2((float)xTile, (float)yTile); if (junimoHarvester == null) { // Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; } else { JunimoHarvester junimoHarvester1 = junimoHarvester; ModularCropObject @object = new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); junimoHarvester1.tryToAddItemToHut((Item)@object); } if (random.NextDouble() < (double)Game1.player.LuckLevel / 1500.0 + Game1.dailyLuck / 1200.0 + 9.99999974737875E-05) { num1 *= 2; if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("dwoop"); } } else if (this.harvestMethod == 0) { if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals((object)Game1.currentLocation))) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0)); Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); } } if (this.indexOfHarvest == 421) { this.indexOfHarvest = 431; num1 = random.Next(1, 4); } for (int index = 0; index < num1 - 1; ++index) { if (junimoHarvester == null) { AdditionalCropsFramework.Utilities.createObjectDebris((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); } else { junimoHarvester.tryToAddItemToHut((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData)); } } float num8 = (float)(16.0 * Math.Log(0.018 * (double)Convert.ToInt32(this.experienceGainWhenHarvesting + 1.0), Math.E)); if (junimoHarvester == null) { Game1.player.gainExperience(0, (int)Math.Round((double)num8)); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } } label_86: return(false); }