Ejemplo n.º 1
0
        public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null)
        {
            if (this.dead)
            {
                return(junimoHarvester != null);
            }
            if (this.forageCrop)
            {
                Object @object = (Object)null;
                int    howMuch = 3;
                if (this.whichForageCrop == 1)
                {
                    @object = new Object(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(nameof(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)
                {
                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(nameof(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 Object(this.indexOfHarvest, 1, false, -1, num2));
                        }
                        else
                        {
                            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;
                        Object @object;
                        if (!this.programColored)
                        {
                            @object = new Object(this.indexOfHarvest, 1, false, -1, num2);
                        }
                        else
                        {
                            @object = (Object) new ColoredObject(this.indexOfHarvest, 1, this.tintColor);
                            int num6 = num2;
                            @object.quality = num6;
                        }
                        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;
                        Object          @object;
                        if (!this.programColored)
                        {
                            @object = new Object(this.indexOfHarvest, 1, false, -1, num2);
                        }
                        else
                        {
                            @object = (Object) new ColoredObject(this.indexOfHarvest, 1, this.tintColor);
                            int num6 = num2;
                            @object.quality = num6;
                        }
                        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(nameof(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)
                        {
                            Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, 0, 1f, (GameLocation)null);
                        }
                        else
                        {
                            junimoHarvester.tryToAddItemToHut((Item) new Object(this.indexOfHarvest, 1, false, -1, 0));
                        }
                    }
                    float num8 = (float)(16.0 * Math.Log(0.018 * (double)Convert.ToInt32(Game1.objectInformation[this.indexOfHarvest].Split('/')[1]) + 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);
        }
Ejemplo n.º 2
0
        public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null)
        {
            if ((bool)dead)
            {
                if (junimoHarvester != null)
                {
                    return(true);
                }
                return(false);
            }
            bool success = false;

            if ((bool)forageCrop)
            {
                Object o           = null;
                int    experience2 = 3;
                Random r2          = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + xTile * 1000 + yTile * 2000);
                switch ((int)whichForageCrop)
                {
                case 1:
                    o = new Object(399, 1);
                    break;

                case 2:
                    soil.shake((float)Math.PI / 48f, (float)Math.PI / 40f, (float)(xTile * 64) < Game1.player.Position.X);
                    return(false);
                }
                if (Game1.player.professions.Contains(16))
                {
                    o.Quality = 4;
                }
                else if (r2.NextDouble() < (double)((float)Game1.player.ForagingLevel / 30f))
                {
                    o.Quality = 2;
                }
                else if (r2.NextDouble() < (double)((float)Game1.player.ForagingLevel / 15f))
                {
                    o.Quality = 1;
                }
                Game1.stats.ItemsForaged += (uint)o.Stack;
                if (junimoHarvester != null)
                {
                    junimoHarvester.tryToAddItemToHut(o);
                    return(true);
                }
                if (Game1.player.addItemToInventoryBool(o))
                {
                    Vector2 initialTile2 = new Vector2(xTile, yTile);
                    Game1.player.animateOnce(279 + Game1.player.FacingDirection);
                    Game1.player.canMove = false;
                    Game1.player.currentLocation.playSound("harvest");
                    DelayedAction.playSoundAfterDelay("coin", 260);
                    if ((int)regrowAfterHarvest == -1)
                    {
                        Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(17, new Vector2(initialTile2.X * 64f, initialTile2.Y * 64f), Color.White, 7, r2.NextDouble() < 0.5, 125f));
                        Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(14, new Vector2(initialTile2.X * 64f, initialTile2.Y * 64f), Color.White, 7, r2.NextDouble() < 0.5, 50f));
                    }
                    Game1.player.gainExperience(2, experience2);
                    return(true);
                }
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588"));
            }
            else if ((int)currentPhase >= phaseDays.Count - 1 && (!fullyGrown || (int)dayOfCurrentPhase <= 0))
            {
                int numToHarvest           = 1;
                int cropQuality            = 0;
                int fertilizerQualityLevel = 0;
                if ((int)indexOfHarvest == 0)
                {
                    return(true);
                }
                Random r = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame);
                switch ((int)soil.fertilizer)
                {
                case 368:
                    fertilizerQualityLevel = 1;
                    break;

                case 369:
                    fertilizerQualityLevel = 2;
                    break;

                case 919:
                    fertilizerQualityLevel = 3;
                    break;
                }
                double chanceForGoldQuality   = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)fertilizerQualityLevel * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01;
                double chanceForSilverQuality = Math.Min(0.75, chanceForGoldQuality * 2.0);
                if (fertilizerQualityLevel >= 3 && r.NextDouble() < chanceForGoldQuality / 2.0)
                {
                    cropQuality = 4;
                }
                else if (r.NextDouble() < chanceForGoldQuality)
                {
                    cropQuality = 2;
                }
                else if (r.NextDouble() < chanceForSilverQuality || fertilizerQualityLevel >= 3)
                {
                    cropQuality = 1;
                }
                if ((int)minHarvest > 1 || (int)maxHarvest > 1)
                {
                    int max_harvest_increase = 0;
                    if (maxHarvestIncreasePerFarmingLevel.Value > 0)
                    {
                        max_harvest_increase = Game1.player.FarmingLevel / (int)maxHarvestIncreasePerFarmingLevel;
                    }
                    numToHarvest = r.Next(minHarvest, Math.Max((int)minHarvest + 1, (int)maxHarvest + 1 + max_harvest_increase));
                }
                if ((double)chanceForExtraCrops > 0.0)
                {
                    while (r.NextDouble() < Math.Min(0.9, chanceForExtraCrops))
                    {
                        numToHarvest++;
                    }
                }
                if ((int)indexOfHarvest == 771 || (int)indexOfHarvest == 889)
                {
                    cropQuality = 0;
                }
                Object harvestedItem2 = programColored ? new ColoredObject(indexOfHarvest, 1, tintColor)
                {
                    Quality = cropQuality
                } : new Object(indexOfHarvest, 1, isRecipe: false, -1, cropQuality);
                if ((int)harvestMethod == 1)
                {
                    if (junimoHarvester != null)
                    {
                        DelayedAction.playSoundAfterDelay("daggerswipe", 150, junimoHarvester.currentLocation);
                    }
                    if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                    {
                        junimoHarvester.currentLocation.playSound("harvest");
                    }
                    if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                    {
                        DelayedAction.playSoundAfterDelay("coin", 260, junimoHarvester.currentLocation);
                    }
                    if (junimoHarvester != null)
                    {
                        junimoHarvester.tryToAddItemToHut(harvestedItem2.getOne());
                    }
                    else
                    {
                        Game1.createItemDebris(harvestedItem2.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                    }
                    success = true;
                }
                else if (junimoHarvester != null || Game1.player.addItemToInventoryBool(harvestedItem2.getOne()))
                {
                    Vector2 initialTile = new Vector2(xTile, yTile);
                    if (junimoHarvester == null)
                    {
                        Game1.player.animateOnce(279 + Game1.player.FacingDirection);
                        Game1.player.canMove = false;
                    }
                    else
                    {
                        junimoHarvester.tryToAddItemToHut(harvestedItem2.getOne());
                    }
                    if (r.NextDouble() < Game1.player.team.AverageLuckLevel() / 1500.0 + Game1.player.team.AverageDailyLuck() / 1200.0 + 9.9999997473787516E-05)
                    {
                        numToHarvest *= 2;
                        if (junimoHarvester == null)
                        {
                            Game1.player.currentLocation.playSound("dwoop");
                        }
                        else if (Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                        {
                            junimoHarvester.currentLocation.playSound("dwoop");
                        }
                    }
                    else if ((int)harvestMethod == 0)
                    {
                        if (junimoHarvester == null)
                        {
                            Game1.player.currentLocation.playSound("harvest");
                        }
                        else if (Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                        {
                            junimoHarvester.currentLocation.playSound("harvest");
                        }
                        if (junimoHarvester == null)
                        {
                            DelayedAction.playSoundAfterDelay("coin", 260, Game1.player.currentLocation);
                        }
                        else if (Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), 64, junimoHarvester.currentLocation))
                        {
                            DelayedAction.playSoundAfterDelay("coin", 260, junimoHarvester.currentLocation);
                        }
                        if ((int)regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals(Game1.currentLocation)))
                        {
                            Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(17, new Vector2(initialTile.X * 64f, initialTile.Y * 64f), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f));
                            Game1.multiplayer.broadcastSprites(Game1.currentLocation, new TemporaryAnimatedSprite(14, new Vector2(initialTile.X * 64f, initialTile.Y * 64f), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f));
                        }
                    }
                    success = true;
                }
                else
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588"));
                }
                if (success)
                {
                    if ((int)indexOfHarvest == 421)
                    {
                        indexOfHarvest.Value = 431;
                        numToHarvest         = r.Next(1, 4);
                    }
                    int price = Convert.ToInt32(Game1.objectInformation[indexOfHarvest].Split('/')[1]);
                    harvestedItem2 = (programColored ? new ColoredObject(indexOfHarvest, 1, tintColor) : new Object(indexOfHarvest, 1));
                    float experience = (float)(16.0 * Math.Log(0.018 * (double)price + 1.0, Math.E));
                    if (junimoHarvester == null)
                    {
                        Game1.player.gainExperience(0, (int)Math.Round(experience));
                    }
                    for (int i = 0; i < numToHarvest - 1; i++)
                    {
                        if (junimoHarvester == null)
                        {
                            Game1.createItemDebris(harvestedItem2.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                        }
                        else
                        {
                            junimoHarvester.tryToAddItemToHut(harvestedItem2.getOne());
                        }
                    }
                    if ((int)indexOfHarvest == 262 && r.NextDouble() < 0.4)
                    {
                        Object hay_item = new Object(178, 1);
                        if (junimoHarvester == null)
                        {
                            Game1.createItemDebris(hay_item.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                        }
                        else
                        {
                            junimoHarvester.tryToAddItemToHut(hay_item.getOne());
                        }
                    }
                    else if ((int)indexOfHarvest == 771)
                    {
                        if (soil != null && soil.currentLocation != null)
                        {
                            soil.currentLocation.playSound("cut");
                        }
                        if (r.NextDouble() < 0.1)
                        {
                            Object mixedSeeds_item = new Object(770, 1);
                            if (junimoHarvester == null)
                            {
                                Game1.createItemDebris(mixedSeeds_item.getOne(), new Vector2(xTile * 64 + 32, yTile * 64 + 32), -1);
                            }
                            else
                            {
                                junimoHarvester.tryToAddItemToHut(mixedSeeds_item.getOne());
                            }
                        }
                    }
                    if ((int)regrowAfterHarvest == -1)
                    {
                        return(true);
                    }
                    fullyGrown.Value = true;
                    if (dayOfCurrentPhase.Value == (int)regrowAfterHarvest)
                    {
                        updateDrawMath(tilePosition);
                    }
                    dayOfCurrentPhase.Value = regrowAfterHarvest;
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
 // Token: 0x06000308 RID: 776 RVA: 0x0003CDAC File Offset: 0x0003AFAC
 public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null)
 {
     if (this.dead)
     {
         return(junimoHarvester != null);
     }
     if (this.forageCrop)
     {
         Object o          = null;
         int    experience = 3;
         int    fertilizer = this.whichForageCrop;
         if (fertilizer == 1)
         {
             o = new Object(399, 1, false, -1, 0);
         }
         if (Game1.player.professions.Contains(16))
         {
             o.quality = 4;
         }
         else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 30f))
         {
             o.quality = 2;
         }
         else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 15f))
         {
             o.quality = 1;
         }
         if (junimoHarvester != null)
         {
             junimoHarvester.tryToAddItemToHut(o);
             return(true);
         }
         if (Game1.player.addItemToInventoryBool(o, false))
         {
             Vector2 initialTile = 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(initialTile.X * (float)Game1.tileSize, initialTile.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(initialTile.X * (float)Game1.tileSize, initialTile.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
             }
             Game1.player.gainExperience(2, experience);
             return(true);
         }
         Game1.showRedMessage("Inventory Full");
     }
     else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0))
     {
         int numToHarvest           = 1;
         int cropQuality            = 0;
         int fertilizerQualityLevel = 0;
         if (this.indexOfHarvest == 0)
         {
             return(true);
         }
         Random r          = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame);
         int    fertilizer = soil.fertilizer;
         if (fertilizer != 368)
         {
             if (fertilizer == 369)
             {
                 fertilizerQualityLevel = 2;
             }
         }
         else
         {
             fertilizerQualityLevel = 1;
         }
         double chanceForGoldQuality   = 0.2 * (double)(Game1.player.FarmingLevel / 10) + 0.2 * (double)fertilizerQualityLevel * (double)((float)(Game1.player.FarmingLevel + 2) / 12f) + 0.01;
         double chanceForSilverQuality = Math.Min(0.75, chanceForGoldQuality * 2.0);
         if (r.NextDouble() < chanceForGoldQuality)
         {
             cropQuality = 2;
         }
         else if (r.NextDouble() < chanceForSilverQuality)
         {
             cropQuality = 1;
         }
         if (this.minHarvest > 1 || this.maxHarvest > 1)
         {
             numToHarvest = r.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel));
         }
         if (this.chanceForExtraCrops > 0.0)
         {
             while (r.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops))
             {
                 numToHarvest++;
             }
         }
         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 i = 0; i < numToHarvest; i++)
             {
                 if (junimoHarvester != null)
                 {
                     junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, cropQuality));
                 }
                 else
                 {
                     Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, cropQuality, 1f, null);
                 }
             }
             if (this.regrowAfterHarvest == -1)
             {
                 return(true);
             }
             this.dayOfCurrentPhase = this.regrowAfterHarvest;
             this.fullyGrown        = true;
         }
         else
         {
             if (junimoHarvester == null)
             {
                 Farmer arg_487_0 = Game1.player;
                 Object arg_487_1;
                 if (!this.programColored)
                 {
                     arg_487_1 = new Object(this.indexOfHarvest, 1, false, -1, cropQuality);
                 }
                 else
                 {
                     (arg_487_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = cropQuality;
                 }
                 if (!arg_487_0.addItemToInventoryBool(arg_487_1, false))
                 {
                     Game1.showRedMessage("Inventory Full");
                     return(false);
                 }
             }
             Vector2 initialTile2 = new Vector2((float)xTile, (float)yTile);
             if (junimoHarvester == null)
             {
                 Game1.player.animateOnce(279 + Game1.player.facingDirection);
                 Game1.player.canMove = false;
             }
             else
             {
                 Object arg_4FD_1;
                 if (!this.programColored)
                 {
                     arg_4FD_1 = new Object(this.indexOfHarvest, 1, false, -1, cropQuality);
                 }
                 else
                 {
                     (arg_4FD_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = cropQuality;
                 }
                 junimoHarvester.tryToAddItemToHut(arg_4FD_1);
             }
             if (r.NextDouble() < (double)((float)Game1.player.LuckLevel / 1500f) + Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
             {
                 numToHarvest *= 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(Game1.currentLocation)))
                 {
                     Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(initialTile2.X * (float)Game1.tileSize, initialTile2.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(initialTile2.X * (float)Game1.tileSize, initialTile2.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;
                 numToHarvest        = r.Next(1, 4);
             }
             for (int j = 0; j < numToHarvest - 1; j++)
             {
                 if (junimoHarvester == null)
                 {
                     Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, 0, 1f, null);
                 }
                 else
                 {
                     junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, 0));
                 }
             }
             int price = Convert.ToInt32(Game1.objectInformation[this.indexOfHarvest].Split(new char[]
             {
                 '/'
             })[1]);
             float experience2 = (float)(16.0 * Math.Log(0.018 * (double)price + 1.0, 2.7182818284590451));
             if (junimoHarvester == null)
             {
                 Game1.player.gainExperience(0, (int)Math.Round((double)experience2));
             }
             if (this.regrowAfterHarvest == -1)
             {
                 return(true);
             }
             this.dayOfCurrentPhase = this.regrowAfterHarvest;
             this.fullyGrown        = true;
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
 public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null)
 {
     if (this.dead)
     {
         return(junimoHarvester != null);
     }
     if (this.forageCrop)
     {
         Object @object    = null;
         int    howMuch    = 3;
         int    fertilizer = this.whichForageCrop;
         if (fertilizer == 1)
         {
             @object = new Object(399, 1, false, -1, 0);
         }
         if (Game1.player.professions.Contains(16))
         {
             @object.quality = 4;
         }
         else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 30f))
         {
             @object.quality = 2;
         }
         else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 15f))
         {
             @object.quality = 1;
         }
         Game1.stats.ItemsForaged += (uint)@object.Stack;
         if (junimoHarvester != null)
         {
             junimoHarvester.tryToAddItemToHut(@object);
             return(true);
         }
         if (Game1.player.addItemToInventoryBool(@object, false))
         {
             Vector2 vector = 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(vector.X * (float)Game1.tileSize, vector.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(vector.X * (float)Game1.tileSize, vector.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", new object[0]));
     }
     else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0))
     {
         int num  = 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);
         int    fertilizer = soil.fertilizer;
         if (fertilizer != 368)
         {
             if (fertilizer == 369)
             {
                 num3 = 2;
             }
         }
         else
         {
             num3 = 1;
         }
         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)
         {
             num = 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))
             {
                 num++;
             }
         }
         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 i = 0; i < num; i++)
             {
                 if (junimoHarvester != null)
                 {
                     junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, num2));
                 }
                 else
                 {
                     Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, null);
                 }
             }
             if (this.regrowAfterHarvest == -1)
             {
                 return(true);
             }
             this.dayOfCurrentPhase = this.regrowAfterHarvest;
             this.fullyGrown        = true;
         }
         else
         {
             if (junimoHarvester == null)
             {
                 Farmer arg_4C0_0 = Game1.player;
                 Object arg_4C0_1;
                 if (!this.programColored)
                 {
                     arg_4C0_1 = new Object(this.indexOfHarvest, 1, false, -1, num2);
                 }
                 else
                 {
                     (arg_4C0_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = num2;
                 }
                 if (!arg_4C0_0.addItemToInventoryBool(arg_4C0_1, false))
                 {
                     Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588", new object[0]));
                     return(false);
                 }
             }
             Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
             if (junimoHarvester == null)
             {
                 Game1.player.animateOnce(279 + Game1.player.facingDirection);
                 Game1.player.canMove = false;
             }
             else
             {
                 Object arg_536_1;
                 if (!this.programColored)
                 {
                     arg_536_1 = new Object(this.indexOfHarvest, 1, false, -1, num2);
                 }
                 else
                 {
                     (arg_536_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = num2;
                 }
                 junimoHarvester.tryToAddItemToHut(arg_536_1);
             }
             if (random.NextDouble() < (double)((float)Game1.player.LuckLevel / 1500f) + Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05)
             {
                 num *= 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(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;
                 num = random.Next(1, 4);
             }
             for (int j = 0; j < num - 1; j++)
             {
                 if (junimoHarvester == null)
                 {
                     Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, 0, 1f, null);
                 }
                 else
                 {
                     junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, 0));
                 }
             }
             int num6 = Convert.ToInt32(Game1.objectInformation[this.indexOfHarvest].Split(new char[]
             {
                 '/'
             })[1]);
             float num7 = (float)(16.0 * Math.Log(0.018 * (double)num6 + 1.0, 2.7182818284590451));
             if (junimoHarvester == null)
             {
                 Game1.player.gainExperience(0, (int)Math.Round((double)num7));
             }
             if (this.regrowAfterHarvest == -1)
             {
                 return(true);
             }
             this.dayOfCurrentPhase = this.regrowAfterHarvest;
             this.fullyGrown        = true;
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
        public bool update(GameTime time, Event e)
        {
            phaseTimer -= time.ElapsedGameTime.Milliseconds;
            steamTimer -= time.ElapsedGameTime.Milliseconds;
            cupTimer   -= time.ElapsedGameTime.Milliseconds;
            if (steamTimer <= 0)
            {
                if (e.aboveMapSprites == null)
                {
                    e.aboveMapSprites = new List <TemporaryAnimatedSprite>();
                }
                int randomX = Game1.random.Next(-48, 64);
                e.aboveMapSprites.Add(new TemporaryAnimatedSprite
                {
                    texture                 = tempText,
                    local                   = true,
                    position                = new Vector2(topLeftX + width / 2, topLeftY + height / 2) + new Vector2(-64 + randomX, 64f),
                    initialPosition         = new Vector2(topLeftX + width / 2, topLeftY + height / 2) + new Vector2(-64 + randomX, 64f),
                    motion                  = new Vector2(-0.1f, -1f),
                    alphaFade               = -0.01f,
                    alphaFadeFade           = -0.0001f,
                    alpha                   = 0.1f,
                    rotationChange          = Utility.Lerp(-0.01f, 0.01f, (float)Game1.random.NextDouble()),
                    sourceRect              = new Rectangle(472, 450, 16, 14),
                    scale                   = 4f,
                    sourceRectStartingPos   = new Vector2(472f, 450f),
                    animationLength         = 1,
                    totalNumberOfLoops      = 1,
                    interval                = 50000f,
                    layerDepth              = 1f,
                    overrideLocationDestroy = true
                });
                steamTimer = 100;
            }
            if (phaseTimer <= 0)
            {
                currentPhase++;
                phaseTimer = 99999;
                switch (currentPhase)
                {
                case 1:
                    text      = Game1.content.LoadString("Strings\\Locations:Caroline_Tea_Event1");
                    textColor = 6;
                    break;

                case 2:
                    text      = Game1.content.LoadString("Strings\\Locations:Caroline_Tea_Event2");
                    textColor = 6;
                    break;

                case 3:
                    text      = Game1.content.LoadString("Strings\\Locations:Caroline_Tea_Event3");
                    textColor = 6;
                    break;

                case 4:
                    buddy = new TemporaryAnimatedSprite
                    {
                        texture                 = tempText,
                        local                   = true,
                        position                = new Vector2(topLeftX, topLeftY) + new Vector2(213f, 170f) * 4f,
                        initialPosition         = new Vector2(topLeftX, topLeftY) + new Vector2(219f, 170f) * 4f,
                        motion                  = new Vector2(0f, -9f),
                        acceleration            = new Vector2(0f, 0.2f),
                        sourceRect              = new Rectangle(0, 242, 27, 32),
                        scale                   = 4f,
                        sourceRectStartingPos   = new Vector2(0f, 242f),
                        animationLength         = 1,
                        totalNumberOfLoops      = 1,
                        interval                = 950000f,
                        layerDepth              = 0.158f,
                        overrideLocationDestroy = true
                    };
                    setBuddyFrame(7);
                    Game1.playSound("pullItemFromWater");
                    buddyPhase = 0;
                    break;

                case 5:
                    phaseTimer = 3000;
                    break;

                default:
                    phaseTimer = 5000;
                    break;
                }
            }
            if (buddy != null)
            {
                float y = buddy.motion.Y;
                buddy.update(time);
                if (y <= 0f && buddy.motion.Y > 0f)
                {
                    buddy.layerDepth = 0.161f;
                }
                if (buddy.motion.Y > 0f && buddy.position.Y >= (float)(topLeftY + 608))
                {
                    buddy.motion.Y       = 0f;
                    buddy.acceleration.Y = 0f;
                    buddy.position.Y     = topLeftY + 608;
                    setBuddyFrame(0);
                    Game1.playSound("coin");
                    buddyPhase = 1;
                    buddyTimer = 2500;
                }
                if (buddyTimer >= 0)
                {
                    buddyTimer -= time.ElapsedGameTime.Milliseconds;
                }
                switch (buddyPhase)
                {
                case 1:
                    setBuddyFrame(buddyTimer % 1000 / 500);
                    if (buddyTimer <= 0)
                    {
                        buddyPhase = 2;
                        buddyTimer = 1500;
                        setBuddyFrame(5);
                        Game1.playSound("dwop");
                        e.aboveMapSprites.Add(new TemporaryAnimatedSprite
                        {
                            texture               = tempText,
                            local                 = true,
                            position              = buddy.position + new Vector2(-7f, -7f) * 4f,
                            initialPosition       = buddy.position + new Vector2(-7f, -7f) * 4f,
                            sourceRect            = new Rectangle(0, 384, 16, 16),
                            scale                 = 4f,
                            sourceRectStartingPos = new Vector2(0f, 384f),
                            animationLength       = 8,
                            totalNumberOfLoops    = 4,
                            interval              = 100f,
                            layerDepth            = 1f,
                            id = 777f,
                            overrideLocationDestroy = true
                        });
                    }
                    break;

                case 2:
                {
                    if (buddyTimer > 0)
                    {
                        break;
                    }
                    setBuddyFrame(6);
                    buddyPhase = 3;
                    Game1.playSound("sipTea");
                    buddyTimer = 1000;
                    for (int i = 0; i < e.aboveMapSprites.Count; i++)
                    {
                        if (e.aboveMapSprites[i].id == 777f)
                        {
                            e.aboveMapSprites.RemoveAt(i);
                            break;
                        }
                    }
                    break;
                }

                case 3:
                    if (buddyTimer <= 0)
                    {
                        setBuddyFrame(8);
                        Game1.playSound("gulp");
                        buddyPhase = 4;
                        buddyTimer = 1500;
                    }
                    break;

                case 4:
                    if (buddyTimer < 1000)
                    {
                        setBuddyFrame(9);
                    }
                    if (buddyTimer <= 0)
                    {
                        buddyPhase = 5;
                        buddyTimer = 2400;
                        Game1.playSound("dustMeep");
                        DelayedAction.playSoundAfterDelay("dustMeep", 400);
                        DelayedAction.playSoundAfterDelay("dustMeep", 800);
                        DelayedAction.playSoundAfterDelay("dustMeep", 1200);
                    }
                    break;

                case 5:
                    if (buddyTimer > 1000)
                    {
                        setBuddyFrame(2 + buddyTimer % 400 / 200);
                    }
                    else
                    {
                        setBuddyFrame(4);
                    }
                    if (buddyTimer <= 0)
                    {
                        buddyTimer = 2000;
                        buddyPhase = 6;
                        for (int j = 0; j < 30; j++)
                        {
                            Vector2 randomPositionOffset = Utility.getRandomPositionInThisRectangle(new Rectangle(-8, -8, 27, 32), Game1.random) * 4f;
                            float   xMotion = Utility.Lerp(-2f, 2f, (float)Game1.random.NextDouble());
                            e.aboveMapSprites.Add(new TemporaryAnimatedSprite
                            {
                                texture                 = tempText,
                                local                   = true,
                                position                = buddy.position + randomPositionOffset,
                                initialPosition         = buddy.position + randomPositionOffset,
                                motion                  = new Vector2(xMotion, -0.5f),
                                alphaFade               = -0.0125f,
                                alphaFadeFade           = -0.0002f,
                                alpha                   = 0.25f,
                                rotationChange          = Utility.Lerp(-0.01f, 0.01f, (float)Game1.random.NextDouble()),
                                sourceRect              = new Rectangle(472, 450, 16, 14),
                                scale                   = 4f,
                                sourceRectStartingPos   = new Vector2(472f, 450f),
                                animationLength         = 1,
                                totalNumberOfLoops      = 1,
                                interval                = 50000f,
                                layerDepth              = 1f,
                                overrideLocationDestroy = true
                            });
                        }
                        buddy      = null;
                        phaseTimer = 1;
                        Game1.playSound("fireball");
                    }
                    break;

                case 6:
                    if (buddyTimer <= 0)
                    {
                        phaseTimer = 1;
                    }
                    break;
                }
                Game1.InvalidateOldMouseMovement();
            }
            if (text != null)
            {
                e.int_useMeForAnything2   = textColor;
                e.float_useMeForAnything += time.ElapsedGameTime.Milliseconds;
                if (e.float_useMeForAnything > 80f)
                {
                    if (e.int_useMeForAnything >= text.Length)
                    {
                        if (e.float_useMeForAnything >= 2500f)
                        {
                            e.int_useMeForAnything   = 0;
                            e.float_useMeForAnything = 0f;
                            e.spriteTextToDraw       = "";
                            text       = null;
                            phaseTimer = 1;
                        }
                    }
                    else
                    {
                        e.int_useMeForAnything++;
                        e.float_useMeForAnything = 0f;
                    }
                }
                e.spriteTextToDraw = text;
            }
            if (currentPhase == 5 && phaseTimer <= 20)
            {
                e.aboveMapSprites.Clear();
                return(true);
            }
            return(false);
        }