private static GarbageCan CreateGarbageCan(GARBAGE_CANS id) { GarbageCan newGroup = new GarbageCan(id); newGroup.treasureList = GetTreasureList(id); return(newGroup); }
void OnTriggerExit2D(Collider2D other) { GarbageCan os = other.GetComponent <GarbageCan>(); // Other Script. if (os != null) { os.Hovering = false; overGarbageCan = false; overCorrectGarbageCan = false; } }
private static Item GetCustomTrashTreasure(GARBAGE_CANS index) { GarbageCan garbageCan = BetterGarbageCansMod.Instance.garbageCans[index]; // Possible treasure based on selected treasure group selected above. List <TrashTreasure> possibleLoot = new List <TrashTreasure>(garbageCan.treasureList) .Where(loot => loot.Enabled && loot.IsValid()) .OrderBy(loot => loot.Chance) .ThenBy(loot => loot.Id) .ToList(); if (possibleLoot.Count == 0) { BetterGarbageCansMod.Instance.Monitor.Log($" Group: {garbageCan.GarbageCanID}, No Possible Loot Found... check the logic"); } TrashTreasure treasure = possibleLoot.ChooseItem(Game1.random); int id = treasure.Id; // Lost books have custom handling -- No default lost books... but someonw might configure them if (id == 102) // LostBook Item ID { if (Game1.player.archaeologyFound == null || !Game1.player.archaeologyFound.ContainsKey(102) || Game1.player.archaeologyFound[102][0] >= 21) { possibleLoot.Remove(treasure); } Game1.showGlobalMessage("You found a lost book. The library has been expanded."); } // Create reward item Item reward; if ((id >= 516 && id <= 534) || id == 810 || id == 811) { reward = new Ring(id); } else if ((id >= 504 && id <= 515) || id == 804 || id == 806) { reward = new Boots(id); } else { int count = Game1.random.Next(treasure.MinAmount, treasure.MaxAmount); reward = (Item) new StardewValley.Object(id, count); } if (Game1.random.NextDouble() <= 0.25 && Game1.player.team.SpecialOrderRuleActive("DROP_QI_BEANS", (SpecialOrder)null)) { reward = (Item) new StardewValley.Object(890, 1); } return(reward); }
/// <summary> /// Dispose of garbage. /// </summary> private void DisposeOfGarbage(Road road) { if (hasGarbage && timeOfGarbageDropping <= DateTime.Now) { GarbageCan garbageCan = GetOrthogonallyAdjacentGarbageCanIfThereIsAny(road.GetOrigoPosition()); if (garbageCan == null) { road.PlaceAGarbageGameObjectOnTheRoadAtARandomLocation(); } hasGarbage = false; } }
void OnTriggerEnter2D(Collider2D other) { GarbageCan os = other.GetComponent <GarbageCan>(); // Other Script. if (os != null) { os.Hovering = true; overGarbageCan = true; if (other.gameObject.tag == gameObject.tag) // If tags are identical: { overCorrectGarbageCan = true; } else { overCorrectGarbageCan = false; } } }
//All the tiles get created private void LoadLevel(Map _mapData) { //In case no tile-layer was created within Tiled if (_mapData.Layers == null) { throw new System.SystemException("There is no tile-layer!"); } Layer mainLayer = _mapData.Layers[0]; _tileData = mainLayer.GetTileArray(); for (short row = 0; row < mainLayer.Width; row++) { for (short column = 0; column < mainLayer.Height; column++) { _currentTile = _tileData[column, row]; switch (_currentTile) { case 1: Ground ground = new Ground(column * _tileWidth, row * _tileHeight); AddChild(ground); break; case 2: GarbageCan garbageCan = new GarbageCan(column * _tileWidth, row * _tileHeight); AddChild(garbageCan); break; case 3: DirtyTile dirtyTile = new DirtyTile(column * _tileWidth, row * _tileHeight); AddChild(dirtyTile); break; } } } }
private void Start() { garbageCan = FindObjectOfType <GarbageCan>(); }
private static Item GetLootForDateAndCan(WorldDate date, GarbageCan can, bool hatOnly, out bool special) { // Logic from StardewValley.Locations.Town.checkAction() // as implemented in Stardew Predictor by MouseyPounds. special = false; // Handle the presence of SVE's altered town map. GarbageCan standardCan = (GarbageCan)((int)can % 100); int canValue = (int)standardCan; // Handle the special case of JojaMart/MovieTheater. bool hasTheater = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater") && !Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheaterJoja"); if ((hasTheater && can == GarbageCan.JojaMart) || (!hasTheater && can == GarbageCan.MovieTheater)) { return(null); } if (can == GarbageCan.MovieTheater) { canValue = (int)GarbageCan.JojaMart; } // Create and prewarm the random generator. int daysPlayed = date.TotalDays + 1; Random rng = new Random((int)Game1.uniqueIDForThisGame / 2 + daysPlayed + 777 + canValue * 77); int prewarm = rng.Next(0, 100); for (int i = 0; i < prewarm; i++) { rng.NextDouble(); } prewarm = rng.Next(0, 100); for (int j = 0; j < prewarm; j++) { rng.NextDouble(); } // Roll for regular items. uint trashCansChecked = Game1.stats.getStat("trashCansChecked") + 1; bool regular = trashCansChecked > 20 && rng.NextDouble() < 0.01; // Roll for the Garbage Hat. if (trashCansChecked > 20 && rng.NextDouble() < 0.002) { return(new Hat(66)); } else if (hatOnly) { return(null); } // If the regular roll failed, roll for luck and then give up. // Use today's luck for today, else a liquidated value. bool today = date == Utilities.Now(); double dailyLuck = today ? Game1.player.DailyLuck : Game1.player.hasSpecialCharm ? 0.125 : 0.1; if (!regular && !(rng.NextDouble() < 0.2 + dailyLuck)) { return(null); } // Roll for a generic or seasonal item. int itemID; bool seasonal = false; switch (rng.Next(10)) { case 1: itemID = 167; // Joja Cola break; case 2: itemID = 170; // Broken Glasses break; case 3: itemID = 171; // Broken CD break; case 4: itemID = 172; // Soggy Newspaper break; case 5: itemID = 216; // Bread break; case 6: seasonal = true; Location location = CanLocations[can]; itemID = Utility.getRandomItemFromSeason(date.Season, (location.X * 653) + (location.Y * 777) + daysPlayed, false, false); break; case 7: itemID = 403; // Field Snack break; case 8: itemID = 309 + rng.Next(3); // Acorn, Maple Seed, Pine Cone break; case 9: itemID = 153; // Green Algae break; default: itemID = 168; // Trash break; } // Roll for location-specific overrides. These do not care about // SVE, so take the standard can identity. bool locationSpecific = false; switch (standardCan) { case GarbageCan.ArchaeologyHouse: if (rng.NextDouble() < 0.2 + dailyLuck) { locationSpecific = true; if (rng.NextDouble() < 0.05) { itemID = 749; // Omni Geode } else { itemID = 535; // Geode } } break; case GarbageCan.Blacksmith: if (rng.NextDouble() < 0.2 + dailyLuck) { locationSpecific = true; itemID = 378 + (rng.Next(3) * 2); // Copper Ore, Iron Ore, Coal rng.Next(1, 5); // unused } break; case GarbageCan.Saloon: if (rng.NextDouble() < 0.2 + dailyLuck) { locationSpecific = true; if (!today) { itemID = 217; // placeholder for dish of the day } else if (Game1.dishOfTheDay != null) { itemID = Game1.dishOfTheDay.ParentSheetIndex; } } break; case GarbageCan.JoshHouse: if (rng.NextDouble() < 0.2 + dailyLuck) { locationSpecific = true; itemID = 223; // Cookie } break; case GarbageCan.JojaMart: if (rng.NextDouble() < 0.2 && !Utility.HasAnyPlayerSeenEvent(191393)) { locationSpecific = true; itemID = 167; // Joja Cola } break; case GarbageCan.MovieTheater: if (rng.NextDouble() < 0.2) { locationSpecific = true; itemID = (rng.NextDouble() < 0.25) ? 809 : 270; // Movie Ticket, Corn } break; } special = seasonal || locationSpecific; return(new SObject(itemID, 1)); }