Exemplo n.º 1
0
 public void plantModdedCrop(ModularSeeds seeds)
 {
     if (this.modularCrop != null)
     {
         return;
     }
     this.modularCrop = new ModularCrop(this.TextureSheet.getHelper(), seeds.ParentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, seeds.cropDataFilePath, seeds.cropTextureFilePath, seeds.cropObjectTextureFilePath, seeds.cropObjectDataFilePath);
     Game1.player.reduceActiveItemByOne();
     Game1.playSound("dirtyHit");
 }
Exemplo n.º 2
0
        public static void makeCropInformationString(Item I)
        {
            (I as PlanterBox).cropInformationString = "";

            if ((I as PlanterBox).crop != null)
            {
                Crop c = (I as PlanterBox).crop;
                (I as PlanterBox).cropInformationString = "false" + "/" + (I as PlanterBox).normalCropSeedIndex + "/" + (I as PlanterBox).TileLocation.X + "/" + (I as PlanterBox).TileLocation.Y + "/" + c.currentPhase.Value + "/" + c.dayOfCurrentPhase.Value + "/" + c.fullyGrown.Value;;
            }

            if ((I as PlanterBox).modularCrop != null)
            {
                ModularCrop m = (I as PlanterBox).modularCrop;
                (I as PlanterBox).cropInformationString = "true" + "/" + m.seedIndex + "/" + (I as PlanterBox).TileLocation.X + "/" + (I as PlanterBox).TileLocation.Y + "/" + m.dataFileName + "/" + m.spriteSheetName + "/" + m.cropObjectTexture + "/" + m.cropObjectData + "/" + m.currentPhase + "/" + m.dayOfCurrentPhase + "/" + m.fullyGrown;
            }
        }
Exemplo n.º 3
0
        public static bool harvestModularCrop(ModularCrop c, int xTile, int yTile, int fertilizer, JunimoHarvester junimoHarvester = null)
        {
            int    amountToHarvest = 1;
            Random r = new Random(xTile + yTile + c.rowInSpriteSheet);

            if (c.minHarvest > 1)
            {
                for (int i = c.minHarvest; i <= c.maxHarvest; i++)
                {
                    int   chanceAgainst = r.Next(0, 100);
                    float chanceFor     = (float)c.chanceForExtraCrops + (Game1.player.farmingLevel * .03f);
                    if (chanceFor > chanceAgainst)
                    {
                        amountToHarvest++;
                    }
                }
            }

            Item I       = (Item) new ModularCropObject(c.spriteSheet.getHelper(), c.indexOfHarvest, amountToHarvest, c.cropObjectTexture, c.cropObjectData);
            int  howMuch = 3;

            if (Game1.player.addItemToInventoryBool(I, false))
            {
                Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
                Game1.player.animateOnce(279 + Game1.player.facingDirection);
                //  StardustCore.Utilities.animateOnce(Game1.player, 279 + Game1.player.facingDirection, 10f, 6, null, false, false, false);

                Game1.player.canMove = true;
                Game1.playSound("harvest");
                DelayedAction.playSoundAfterDelay("coin", 260);
                if (c.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));
                }
                else
                {
                    c.currentPhase = c.regrowAfterHarvest;
                }
                Game1.player.gainExperience(2, howMuch * amountToHarvest);
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public ModularCrop parseCropInfo(int seedIndex)
        {
            ModularCrop c = new ModularCrop();
           // Log.AsyncC(this.cropDataFilePath);
            Dictionary<int, string> dictionary = ModCore.ModHelper.Content.Load<Dictionary<int, string>>(Path.Combine(Utilities.EntensionsFolderName, this.cropDataFilePath)); //Game1.content.Load<Dictionary<int, string>>("Data\\Crops");

            if (dictionary.ContainsKey(seedIndex))
            {
                string[] array = dictionary[seedIndex].Split(new char[]
                {
                    '/'
                });
                string[] array2 = array[0].Split(new char[]
                {
                    ' '
                });
                for (int i = 0; i < array2.Length; i++)
                {
                    c.phaseDays.Add(Convert.ToInt32(array2[i]));
                }
                c.phaseDays.Add(99999);
                string[] array3 = array[1].Split(new char[]
                {
                    ' '
                });
                for (int j = 0; j < array3.Length; j++)
                {
                    c.seasonsToGrowIn.Add(array3[j]);
                }
                c.rowInSpriteSheet = Convert.ToInt32(array[2]);
                c.indexOfHarvest = Convert.ToInt32(array[3]);
                c.regrowAfterHarvest = Convert.ToInt32(array[4]);
                c.harvestMethod = Convert.ToInt32(array[5]);
                string[] array4 = array[6].Split(new char[]
                {
                    ' '
                });
                if (array4.Length != 0 && array4[0].Equals("true"))
                {
                    c.minHarvest = Convert.ToInt32(array4[1]);
                    c.maxHarvest = Convert.ToInt32(array4[2]);
                    c.maxHarvestIncreasePerFarmingLevel = Convert.ToInt32(array4[3]);
                    c.chanceForExtraCrops = Convert.ToDouble(array4[4]);
                }
                c.raisedSeeds = Convert.ToBoolean(array[7]);
                string[] array5 = array[8].Split(new char[]
                {
                    ' '
                });
                if (array5.Length != 0 && array5[0].Equals("true"))
                {
                    List<Color> list = new List<Color>();
                    for (int k = 1; k < array5.Length; k += 3)
                    {
                        list.Add(new Color((int)Convert.ToByte(array5[k]), (int)Convert.ToByte(array5[k + 1]), (int)Convert.ToByte(array5[k + 2])));
                    }
                    Random random = new Random(seedIndex * 1000 + Game1.timeOfDay + Game1.dayOfMonth);
                    c.tintColor = list[random.Next(list.Count)];
                    c.programColored = true;
                }
                c.flip = (Game1.random.NextDouble() < 0.5);
            }
            if (c.rowInSpriteSheet == 23)
            {
                c.whichForageCrop = seedIndex;
            }

            return c;
        }
Exemplo n.º 5
0
        public ModularSeeds(int which, string ObjectSpriteSheet, string ObjectDataFile, string AssociatedCropTextureFile, string AssociatedCropDataFile, string AssociatedCropObjectTexture,string AssociatedCropObjectDataFile)
        {
            if (TextureSheet == null)
            {
                TextureSheet = ModCore.ModHelper.Content.Load<Texture2D>(Path.Combine(Utilities.EntensionsFolderName, ObjectSpriteSheet));  //Game1.content.Load<Texture2D>("Revitalize\\CropsNSeeds\\Graphics\\seeds");
                texturePath = ObjectSpriteSheet;
            }
            this.serializationName = this.GetType().ToString();
            Dictionary<int, string> dictionary = ModCore.ModHelper.Content.Load<Dictionary<int, string>>(Path.Combine(Utilities.EntensionsFolderName, ObjectDataFile));//Game1.content.Load<Dictionary<int, string>>("Revitalize\\CropsNSeeds\\Data\\seeds");
            dataFilePath = ObjectDataFile;
            cropDataFilePath = AssociatedCropDataFile;
            cropTextureFilePath = AssociatedCropTextureFile;

           cropObjectDataFilePath = AssociatedCropObjectDataFile;
           cropObjectTextureFilePath = AssociatedCropObjectTexture;


            //Log.AsyncC(which);
            string[] array = dictionary[which].Split(new char[]
            {
                '/'
            });
            this.name = array[0];

            try
            {
                this.description = array[6];
                this.description += "\nGrown in ";
                ModularCrop c = parseCropInfo(which);
                int trackCount = 0;
                foreach (var v in c.seasonsToGrowIn)
                {
                    if (c.seasonsToGrowIn.Count > 1)
                    {
                        trackCount++;
                        if (trackCount != c.seasonsToGrowIn.Count) description += v + ", ";
                        else description += "and " + v;
                    }
                    else description += v;
                }
                this.description += ".\n";
                this.description += "Takes ";
                int totalDaysToGrow = 0;
                foreach (var v in c.phaseDays)
                {
                    totalDaysToGrow += v;
                }
                totalDaysToGrow -= 99999;
                this.description += Convert.ToString(totalDaysToGrow) + " days to mature.\n";

                try
                {
                    this.description += array[7];
                }
                catch (Exception e)
                {

                }
            }
            catch (Exception e)
            {
                this.description = "Some seeds! Maybe you should plant them.";
            }
            this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
            if (array[2].Equals("-1"))
            {
            }
            else
            {
                this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[]
                {
                    ' '
                })[0]);
                this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[]
                {
                    ' '
                })[1]);
                this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
                this.defaultSourceRect = this.sourceRect;
            }
            this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
            if (array[3].Equals("-1"))
            {
            }
            else
            {
                this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[]
                {
                    ' '
                })[0]);
                this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[]
                {
                    ' '
                })[1]);
                this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
                this.defaultBoundingBox = this.boundingBox;
            }
            this.updateDrawPosition();
            this.rotations = Convert.ToInt32(array[4]);
            this.price = Convert.ToInt32(array[5]);
            this.parentSheetIndex = which;

        }
Exemplo n.º 6
0
        public void dayUpdate()
        {
            if (ModCore.ModConfig.removeCropsDayofDying == false)
            {
                if (this.crop != null)
                {
                    if (this.crop.dead.Value)
                    {
                        this.crop = null;
                    }
                }
            }

            if (this.modularCrop != null)
            {
                if (this.modularCrop.dead)
                {
                    this.modularCrop = null;
                }
            }


            if (this.selfWatering == true || (this.thisLocation.IsOutdoors && Game1.isRaining))
            {
                this.isWatered = true;
                this.animationManager.setAnimation("Watered", 0);
            }


            if (this.isWatered == true)
            {
                if (this.crop != null)
                {
                    Utilities.cropNewDay(this, this.crop, 1, 0, (int)this.TileLocation.X, (int)this.TileLocation.Y, this.thisLocation);
                }

                if (this.modularCrop != null)
                {
                    Utilities.cropNewDayModded(this, this.modularCrop, 1, 0, (int)this.TileLocation.X, (int)this.TileLocation.Y, this.thisLocation);
                }
                if (this.selfWatering == false)
                {
                    this.isWatered = false;
                    this.animationManager.setAnimation("Default", 0);
                }
            }
            else //if planterbox isn't watered
            {
                if (this.crop != null)
                {
                    Utilities.cropNewDay(this, this.crop, 0, 0, (int)this.TileLocation.X, (int)this.TileLocation.Y, this.thisLocation);
                }

                if (this.modularCrop != null)
                {
                    Utilities.cropNewDayModded(this, this.modularCrop, 0, 0, (int)this.TileLocation.X, (int)this.TileLocation.Y, this.thisLocation);
                }
                if (this.selfWatering == false)
                {
                    this.isWatered = false;
                    this.animationManager.setAnimation("Default", 0);
                }
            }
            //Update ticks occ
            if (ModCore.ModConfig.removeCropsDayofDying == true)
            {
                if (this.crop != null)
                {
                    if (this.crop.dead.Value)
                    {
                        this.crop = null;
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override bool clicked(StardewValley.Farmer who)
        {
            int range = 2;

            if (StardustCore.Utilities.isWithinRange(range, this.TileLocation) == false)
            {
                return(false);
            }

            if (StardustCore.Utilities.isWithinDirectionRange(Game1.player.FacingDirection, range, this.TileLocation))
            {
                if (Game1.player.CurrentItem != null)
                {
                    if (Game1.player.getToolFromName(Game1.player.CurrentItem.Name) is StardewValley.Tools.WateringCan)
                    {
                        this.isWatered = true;
                        this.animationManager.setAnimation("Watered", 0);
                        return(false);
                    }
                }

                if (Game1.player.CurrentItem != null)
                {
                    if (Game1.player.CurrentItem is StardewValley.Tools.MeleeWeapon || Game1.player.CurrentItem is StardewValley.Tools.Sword)
                    {
                        if (this.modularCrop != null)
                        {
                            if (this.modularCrop.dead == true)
                            {
                                this.modularCrop = null;
                                return(false);
                            }
                        }
                        if (this.crop != null)
                        {
                            if (this.crop.dead.Value == true)
                            {
                                this.crop = null;
                                return(false);
                            }
                        }
                    }
                }
            }



            if (removable == false)
            {
                return(false);
            }
            //   Game1.showRedMessage("THIS IS CLICKED!!!");
            Game1.haltAfterCheck = false;
            if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject.Value == null)
            {
                //  Game1.showRedMessage("Why1?");
                return(false);
            }
            if (this.heldObject.Value == null && (who.ActiveObject == null || !(who.ActiveObject is PlanterBox)))
            {
                if (Game1.player.currentLocation is FarmHouse)
                {
                    //   Game1.showRedMessage("Why2?");
                    // this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero);
                    Utilities.addItemToInventoryAndCleanTrackedList(this);
                    this.flaggedForPickUp = true;
                    this.thisLocation     = null;
                    this.locationsName    = "";
                    return(true);
                }
                else
                {
                    // return true;

                    this.flaggedForPickUp = true;

                    //  this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero);
                    Utilities.addItemToInventoryAndCleanTrackedList(this);
                    //  this.heldObject.performRemoveAction(this.TileLocation, who.currentLocation);
                    //   this.heldObject = null;
                    Game1.playSound("coin");
                    this.thisLocation  = null;
                    this.locationsName = "";
                    return(true);
                }
            }
            if (this.heldObject.Value != null && who.addItemToInventoryBool(this.heldObject.Value, false))
            {
                // Game1.showRedMessage("Why3?");
                this.heldObject.Value.performRemoveAction(this.TileLocation, who.currentLocation);
                this.heldObject.Value = null;
                Utilities.addItemToInventoryAndCleanTrackedList(this);
                Game1.playSound("coin");
                this.thisLocation  = null;
                this.locationsName = "";
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false)
        {
            var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();

            if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                // Game1.showRedMessage("YOOO");
                //do some stuff when the right button is down
                // rotate();
                if (Game1.player.ActiveObject != null)
                {
                    if (Game1.player.ActiveObject is ModularSeeds || Game1.player.ActiveObject.getCategoryName() == "Modular Seeds")
                    {
                        this.plantModdedCrop((Game1.player.ActiveObject as ModularSeeds));
                        // Log.AsyncO("Modded seeds");
                    }
                    // Log.AsyncO(Game1.player.CurrentItem.getCategoryName());
                    if (Game1.player.CurrentItem.getCategoryName() == "Seed" || Game1.player.CurrentItem.getCategoryName() == "seed")
                    {
                        this.plantRegularCrop();
                        // Log.AsyncY("regular seeds");
                    }
                }
                if (this.crop != null)
                {
                    if (Utilities.isCropFullGrown(this.crop) == true)
                    {
                        //this.crop.harvest();
                        bool f = Utilities.harvestCrop(this.crop, (int)this.TileLocation.X, (int)this.TileLocation.Y, 0);
                        if (f == true && this.crop.regrowAfterHarvest.Value == -1)
                        {
                            this.crop = null;
                        }
                    }
                }
                if (this.modularCrop != null)
                {
                    if (this.modularCrop.isFullyGrown() == true)
                    {
                        bool f = Utilities.harvestModularCrop(this.modularCrop, (int)this.TileLocation.X, (int)this.TileLocation.Y, 0);
                        if (f == true)
                        {
                            //this.modularCrop = null;
                            if (f == true && this.modularCrop.regrowAfterHarvest == -1)
                            {
                                this.modularCrop = null;
                            }

                            return(true);
                        }
                        else
                        {
                            // Log.AsyncC("failed to harvest crop. =/");
                        }
                    }
                }
                return(true);
            }
            else
            {
                //Game1.showRedMessage("CRY");
            }

            if (justCheckingForActivity)
            {
                return(true);
            }
            if (this.ParentSheetIndex == 1402)
            {
                Game1.activeClickableMenu = new Billboard(false);
            }
            return(this.clicked(who)); //check for left clicked action.
        }
Exemplo n.º 9
0
        public static void cropNewDayModded(PlanterBox p, ModularCrop c, int state, int fertilizer, int xTile, int yTile, GameLocation environment)
        {
            if (p.greenHouseEffect == false)
            {
                if ((c.dead || !c.seasonsToGrowIn.Contains(Game1.currentSeason)))
                {
                    c.dead = true;
                }
            }

            if (state == 1)
            {
                c.dayOfCurrentPhase++;



                //c.dayOfCurrentPhase = c.fullyGrown ? c.dayOfCurrentPhase - 1 : Math.Min(c.dayOfCurrentPhase + 1, c.phaseDays.Count > 0 ? c.phaseDays[Math.Min(c.phaseDays.Count - 1, c.currentPhase)] : 0);
                if (c.dayOfCurrentPhase >= (c.phaseDays.Count > 0 ? c.phaseDays[Math.Min(c.phaseDays.Count - 1, c.currentPhase)] : 0) && c.currentPhase < c.phaseDays.Count - 1)
                {
                    c.currentPhase      = c.currentPhase + 1;
                    c.dayOfCurrentPhase = 0;
                }



                while (c.currentPhase < c.phaseDays.Count - 1 && c.phaseDays.Count > 0 && c.phaseDays[c.currentPhase] <= 0)
                {
                    c.currentPhase = c.currentPhase + 1;
                }
                if (c.rowInSpriteSheet == 23 && c.phaseToShow == -1 && c.currentPhase > 0)
                {
                    c.phaseToShow = Game1.random.Next(1, 7);
                }
                if (c.currentPhase == c.phaseDays.Count - 1 && (c.indexOfHarvest == 276 || c.indexOfHarvest == 190 || c.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 != c.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 = (Crop)null;
                        }
                    }
                    // (environment as Farm).resourceClumps.Add((ResourceClump)new GiantCrop(c.indexOfHarvest, new Vector2((float)(xTile - 1), (float)(yTile - 1))));
                }
            }
            if (c.fullyGrown && c.dayOfCurrentPhase > 0 || (c.currentPhase < c.phaseDays.Count - 1 || c.rowInSpriteSheet != 23))
            {
                return;
            }
            Vector2 index = new Vector2((float)xTile, (float)yTile);

            environment.objects.Remove(index);
            string season = Game1.currentSeason;

            switch (c.whichForageCrop)
            {
            case 495:
                season = "spring";
                break;

            case 496:
                season = "summer";
                break;

            case 497:
                season = "fall";
                break;

            case 498:
                season = "winter";
                break;
            }



            if (environment.terrainFeatures[index] == null || !(environment.terrainFeatures[index] is HoeDirt))
            {
                return;
            }
            (environment.terrainFeatures[index] as HoeDirt).crop = (Crop)null;
        }