示例#1
0
 public static bool ScytheForage(StardewValley.Object o, StardewValley.Tool t, StardewValley.GameLocation loc)
 {
     if (o.isSpawnedObject && !o.questItem && o.isForage(loc))
     {
         var    who     = t.getLastFarmerToUse();
         var    vector  = o.TileLocation;
         int    quality = o.quality;
         Random random  = new Random((int)StardewValley.Game1.uniqueIDForThisGame / 2 + (int)StardewValley.Game1.stats.DaysPlayed + (int)vector.X + (int)vector.Y * 777);
         if (who.professions.Contains(16))
         {
             quality = 4;
         }
         else if (random.NextDouble() < (double)((float)who.ForagingLevel / 30))
         {
             quality = 2;
         }
         else if (random.NextDouble() < (double)((float)who.ForagingLevel / 15))
         {
             quality = 1;
         }
         who.gainExperience(2, 7);
         StardewValley.Game1.createObjectDebris(o.ParentSheetIndex, (int)vector.X, (int)vector.Y, -1, quality, 1, loc);
         StardewValley.Game1.stats.ItemsForaged += 1;
         if (who.professions.Contains(13) && random.NextDouble() < 0.2)
         {
             StardewValley.Game1.createObjectDebris(o.ParentSheetIndex, (int)vector.X, (int)vector.Y, -1, quality, 1, loc);
             who.gainExperience(2, 7);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 public static bool ScytheForage(StardewValley.Object o, StardewValley.Tool t, StardewValley.GameLocation loc)
 {
     if (o.isSpawnedObject && !o.questItem && o.isForage(loc))
     {
         var who    = t.getLastFarmerToUse();
         var vector = o.TileLocation;
         // For objects stored in GameLocation.Objects, the TileLocation is not always set.
         // So determine its location by looping trough all such objects.
         if (vector.X == 0 && vector.Y == 0)
         {
             foreach (System.Collections.Generic.KeyValuePair <Microsoft.Xna.Framework.Vector2, StardewValley.Object> pair in loc.Objects.Pairs)
             {
                 if (pair.Value.Equals(o))
                 {
                     vector = pair.Key;
                     break;
                 }
             }
         }
         int    quality = o.quality;
         Random random  = new Random((int)StardewValley.Game1.uniqueIDForThisGame / 2 + (int)StardewValley.Game1.stats.DaysPlayed + (int)vector.X + (int)vector.Y * 777);
         if (who.professions.Contains(16))
         {
             quality = 4;
         }
         else if (random.NextDouble() < (double)((float)who.ForagingLevel / 30))
         {
             quality = 2;
         }
         else if (random.NextDouble() < (double)((float)who.ForagingLevel / 15))
         {
             quality = 1;
         }
         who.gainExperience(2, 7);
         StardewValley.Game1.createObjectDebris(o.ParentSheetIndex, (int)vector.X, (int)vector.Y, -1, quality, 1, loc);
         StardewValley.Game1.stats.ItemsForaged += 1;
         if (who.professions.Contains(13) && random.NextDouble() < 0.2)
         {
             StardewValley.Game1.createObjectDebris(o.ParentSheetIndex, (int)vector.X, (int)vector.Y, -1, quality, 1, loc);
             who.gainExperience(2, 7);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }