public void drawCropWhenPlanterBoxHeld(PlanterBox p, SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) { spriteBatch.Draw(Game1.cropSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(Game1.player.GetBoundingBox().Center.X - Game1.tileSize / 2, (Game1.player.GetBoundingBox().Center.Y - Game1.tileSize * 4 / 3) - (Game1.tileSize * 2))), getCropSourceRect(this.crop.rowInSpriteSheet.Value, this.crop), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(p.boundingBox.Bottom + 1) / 10000f); }
public void drawCropInMenu(PlanterBox p, SpriteBatch b, Vector2 screenPosition, Color c, float roation, float scale, float layerDepth) { b.Draw(Game1.cropSpriteSheet, new Vector2(screenPosition.X, screenPosition.Y - (Game1.tileSize / 2)), new Rectangle?(this.getCropSourceRect(this.crop.rowInSpriteSheet.Value, this.crop)), Color.White, 0f, new Vector2((float)(p.defaultSourceRect.Width / 2), (float)(p.defaultSourceRect.Height / 2)), 1f * (2) * scale, SpriteEffects.None, layerDepth); }
public override bool canBePlacedHere(GameLocation l, Vector2 tile) { if ((l is FarmHouse)) { for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) { for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) { Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; vector.X += (float)(Game1.tileSize / 2); vector.Y += (float)(Game1.tileSize / 2); foreach (KeyValuePair <Vector2, StardewValley.Object> something in l.objects.Pairs) { StardewValley.Object obj = something.Value; if ((obj.GetType()).ToString().Contains("PlanterBox")) { PlanterBox current = (PlanterBox)obj; if (current.Decoration_type == 11 && current.getBoundingBox(current.TileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject.Value == null && this.getTilesWide() == 1) { bool result = true; return(result); } if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.TileLocation).Contains((int)vector.X, (int)vector.Y)) { bool result = false; return(result); } } } } } return(base.canBePlacedHere(l, tile)); } else { // Game1.showRedMessage("NOT FARMHOUSE"); for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) { for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) { Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; vector.X += (float)(Game1.tileSize / 2); vector.Y += (float)(Game1.tileSize / 2); /* * foreach (PlanterBox current in (l as FarmHouse).PlanterBox) * { * if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) * { * bool result = true; * return result; * } * if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) * { * bool result = false; * return result; * } * } */ } } return(base.canBePlacedHere(l, tile)); } }
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; }