示例#1
0
        public static void ProcessScytheHarvest(Crop crop, int xTile, int yTile,
                                                StardewValley.TerrainFeatures.HoeDirt soil, StardewValley.Characters.JunimoHarvester junimoHarvester)
        {
            Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame);

            // extra luck fix - num *= 2;
            if (random.NextDouble() < (double)((float)Game1.player.LuckLevel / 1500f) + Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
            {
                int num = random.Next(1, 3);
                for (int i = 0; i < num; i++)
                {
                    if (junimoHarvester == null)
                    {
                        Game1.createObjectDebris(crop.indexOfHarvest, xTile, yTile, -1, random.Next(0, 2), 1f, null);
                    }
                    else
                    {
                        junimoHarvester.tryToAddItemToHut(new StardewValley.Object(crop.indexOfHarvest, 1, false, -1, 0));
                    }
                }
                if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation))
                {
                    Game1.playSound("dwoop");
                }
            }

            // experience fix
            if (junimoHarvester == null)
            {
                int   experienceBase = Convert.ToInt32(Game1.objectInformation[crop.indexOfHarvest].Split(new char[] { '/' })[1]);
                float experience     = (float)(16.0 * Math.Log(0.018 * (double)experienceBase + 1.0, 2.7182818284590451));
                Game1.player.gainExperience(0, (int)Math.Round((double)experience));
            }

            // sunflower seeds fix
            if (crop.indexOfHarvest == 421)
            {
                int indexOfHarvest = 431;
                int num            = random.Next(1, 3);
                for (int i = 0; i < num; i++)
                {
                    if (junimoHarvester == null)
                    {
                        Game1.createObjectDebris(indexOfHarvest, xTile, yTile, -1, 0, 1f, null);
                    }
                    else
                    {
                        junimoHarvester.tryToAddItemToHut(new StardewValley.Object(indexOfHarvest, 1, false, -1, 0));
                    }
                }
            }
        }
示例#2
0
        private void on_post_render_event(object sender, EventArgsMouseStateChanged e)
        {
            if (Game1.activeClickableMenu != null)
            {
                terrain = null;
                return;
            }

            if (terrain != null && ButtonState.Pressed.Equals(e.PriorState.RightButton) && ButtonState.Released.Equals(e.NewState.RightButton))
            {
                this.Monitor.Log("removed terrain");
                terrain = null;
            }

            Vector2 vector2 = (double)Game1.mouseCursorTransparency == 0.0 ? Game1.player.GetToolLocation(false) : new Vector2((float)(Game1.getOldMouseX() + Game1.viewport.X), (float)(Game1.getOldMouseY() + Game1.viewport.Y));

            if (Game1.currentLocation != null)
            {
                Vector2 index = new Vector2((float)((Game1.getOldMouseX() + Game1.viewport.X) / Game1.tileSize), (float)((Game1.getOldMouseY() + Game1.viewport.Y) / Game1.tileSize));

                SerializableDictionary <Vector2, StardewValley.TerrainFeatures.TerrainFeature> terrainMap = Game1.currentLocation.terrainFeatures;
                if (terrainMap != null && terrainMap.ContainsKey(index))
                {
                    if (terrainMap[index] is StardewValley.TerrainFeatures.HoeDirt && (terrain == null || terrain != terrainMap[index]))
                    {
                        terrain = (terrainMap[index] as StardewValley.TerrainFeatures.HoeDirt);
                        StardewValley.Crop crop = terrain.crop;
                        if (crop != null)
                        {
                            String cropName          = Game1.objectInformation[crop.indexOfHarvest].Split('/')[0];
                            bool   isCropHarvestable = crop.currentPhase >= crop.phaseDays.Count - 1 && (!crop.fullyGrown || crop.dayOfCurrentPhase <= 0);

                            String cropInformation = $"\nCrop Information: \n\tname: {cropName}\n\tisHarvestable: {isCropHarvestable}";
                            foreach (System.Reflection.FieldInfo field in crop.GetType().GetFields())
                            {
                                cropInformation += $"\n\t{field.Name}: ";

                                if (field.GetValue(crop) is System.Collections.Generic.List <String> )
                                {
                                    System.Collections.Generic.List <String> asd = field.GetValue(crop) as System.Collections.Generic.List <String>;

                                    cropInformation += String.Join(", ", asd.ToArray());
                                }
                                else if (field.GetValue(crop) is System.Collections.Generic.List <Int32> )
                                {
                                    System.Collections.Generic.List <Int32> asd = field.GetValue(crop) as System.Collections.Generic.List <Int32>;
                                    cropInformation += String.Join(", ", asd.ToArray());
                                }
                                else
                                {
                                    cropInformation += $"{field.GetValue(crop).ToString()}";
                                }
                            }
                            this.Monitor.Log(cropInformation);
                        }
                    }
                    else if (!(terrainMap[index] is StardewValley.TerrainFeatures.HoeDirt))
                    {
                        terrain = null;
                    }
                }
            }
        }