Ejemplo n.º 1
0
        private void AddWinterStuffToClearing(IDeepWoodsLocation deepWoodsLocation)
        {
            // Winter tree with presents

            Random random = new Random(deepWoodsLocation.Seed ^ SALT ^ Game1.random.Next());

            int borderDist = Math.Min(12, Math.Min(deepWoodsLocation.MapSize.Item1, deepWoodsLocation.MapSize.Item2) / 2 - 1);

            int numPresents = random.Next(6, 16);

            var largeTerrainFeatures = (deepWoodsLocation as GameLocation).largeTerrainFeatures;
            var terrainFeatures      = (deepWoodsLocation as GameLocation).terrainFeatures;

            largeTerrainFeatures.Add(new WinterTree(new Vector2(deepWoodsLocation.MapSize.Item1 / 2 + random.Next(-3, 0), deepWoodsLocation.MapSize.Item2 / 2 + random.Next(-3, 0))));

            for (int i = 0; i < numPresents; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item1 - borderDist),
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item2 - borderDist)
                    );
                if (!IsAreaFree(deepWoodsLocation as GameLocation, location, 1, 1))
                {
                    continue;
                }
                terrainFeatures[location] = new WinterPresent(random.Next());
            }
        }
Ejemplo n.º 2
0
        private bool FillClearingWithEvenMoreThings(IDeepWoodsLocation deepWoodsLocation)
        {
            if (!deepWoodsLocation.IsClearing || deepWoodsLocation.IsCustomMap)
            {
                return(false);
            }

            var random = new Random(deepWoodsLocation.Seed ^ SALT);

            // 10% chance +- 20% from luck
            if ((random.NextDouble() * 10.0) < (1.0 + Game1.player.team.sharedDailyLuck + deepWoodsLocation.LuckLevel))
            {
                if (Game1.currentSeason == "winter")
                {
                    AddWinterStuffToClearing(deepWoodsLocation);
                }
                else if (Game1.currentSeason == "fall")
                {
                    AddFallStuffToClearing(deepWoodsLocation);
                }
                else if (Game1.currentSeason == "summer")
                {
                    AddSummerStuffToClearing(deepWoodsLocation);
                }
                else if (Game1.currentSeason == "spring")
                {
                    AddSpringStuffToClearing(deepWoodsLocation);
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void AddFallStuffToClearing(IDeepWoodsLocation deepWoodsLocation)
        {
            // Huge pumpkins with scary deco

            Random random = new Random(deepWoodsLocation.Seed ^ SALT ^ Game1.random.Next());

            int borderDist = Math.Min(8, Math.Min(deepWoodsLocation.MapSize.Item1, deepWoodsLocation.MapSize.Item2) / 2 - 1);

            int numBigPumpkins   = random.Next(1, 4);
            int numSmallPumpkins = random.Next(10, 20);
            int numDecorations   = random.Next(10, 20);

            var objects         = (deepWoodsLocation as GameLocation).objects;
            var resourceClumps  = deepWoodsLocation.ResourceClumps;
            var terrainFeatures = (deepWoodsLocation as GameLocation).terrainFeatures;

            for (int i = 0; i < numBigPumpkins; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item1 - borderDist),
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item2 - borderDist)
                    );
                if (!IsAreaFree(deepWoodsLocation as GameLocation, location, 3, 3))
                {
                    continue;
                }
                resourceClumps.Add(new GiantCrop(276, location));
            }

            for (int i = 0; i < numSmallPumpkins; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item1 - borderDist),
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item2 - borderDist)
                    );
                if (!IsAreaFree(deepWoodsLocation as GameLocation, location, 1, 1))
                {
                    continue;
                }
                objects[location] = new StardewValley.Object(276, 1, false, -1, GetRandomObjectQuality(random))
                {
                    IsSpawnedObject = true
                };
            }

            for (int i = 0; i < numDecorations; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item1 - borderDist),
                    random.Next(borderDist, deepWoodsLocation.MapSize.Item2 - borderDist)
                    );
                if (!IsAreaFree(deepWoodsLocation as GameLocation, location, 1, 1))
                {
                    continue;
                }
                terrainFeatures[location] = new FallDecoration(random.Next());
            }
        }
Ejemplo n.º 4
0
        private void AddSpringStuffToClearing(IDeepWoodsLocation deepWoodsLocation)
        {
            // Flower field with bee houses and honey

            Random random = new Random(deepWoodsLocation.Seed ^ SALT ^ Game1.random.Next());

            int flowerBorderDist   = Math.Min(8, Math.Min(deepWoodsLocation.MapSize.Item1, deepWoodsLocation.MapSize.Item2) / 2 - 1);
            int beeHouseBorderDist = Math.Min(10, Math.Min(deepWoodsLocation.MapSize.Item1, deepWoodsLocation.MapSize.Item2) / 2 - 1);

            int numBeeHouses = random.Next(4, 9);
            int numFlowers   = random.Next(16, 36);
            int numGrass     = random.Next(30, 60);

            var objects         = (deepWoodsLocation as GameLocation).objects;
            var terrainFeatures = (deepWoodsLocation as GameLocation).terrainFeatures;

            for (int i = 0; i < numBeeHouses; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(beeHouseBorderDist, deepWoodsLocation.MapSize.Item1 - beeHouseBorderDist),
                    random.Next(beeHouseBorderDist, deepWoodsLocation.MapSize.Item2 - beeHouseBorderDist)
                    );
                if (objects.ContainsKey(location) || terrainFeatures.ContainsKey(location))
                {
                    continue;
                }
                objects[location] = CreateBeeHouse(location);
            }

            for (int i = 0; i < numFlowers; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(flowerBorderDist, deepWoodsLocation.MapSize.Item1 - flowerBorderDist),
                    random.Next(flowerBorderDist, deepWoodsLocation.MapSize.Item2 - flowerBorderDist)
                    );
                if (objects.ContainsKey(location) || terrainFeatures.ContainsKey(location))
                {
                    continue;
                }
                terrainFeatures[location] = CreateFlower(GetRandomFlowerType(random), location);
            }

            for (int i = 0; i < numGrass; i++)
            {
                Vector2 location = new Vector2(
                    random.Next(flowerBorderDist, deepWoodsLocation.MapSize.Item1 - flowerBorderDist),
                    random.Next(flowerBorderDist, deepWoodsLocation.MapSize.Item2 - flowerBorderDist)
                    );
                if (objects.ContainsKey(location) || terrainFeatures.ContainsKey(location))
                {
                    continue;
                }
                terrainFeatures[location] = new Grass(Grass.springGrass, random.Next(1, 3));
            }
        }
Ejemplo n.º 5
0
        private bool ShouldAddSeasonableObjectHere(IDeepWoodsLocation deepWoodsLocation, Vector2 location)
        {
            if (deepWoodsLocation.IsClearing || deepWoodsLocation.IsCustomMap)
            {
                return(false);
            }

            currentLuck = deepWoodsLocation.LuckLevel;
            if (currentSeed != deepWoodsLocation.Seed || currentRandom == null)
            {
                currentRandom = new Random(deepWoodsLocation.Seed ^ SALT);
                currentSeed   = deepWoodsLocation.Seed;
            }

            // 20% chance (no luck modifier)
            return(currentRandom.NextDouble() < 0.2);
        }
Ejemplo n.º 6
0
        private bool LoadCustomMap(IDeepWoodsLocation deepWoodsLocation)
        {
            if (deepWoodsLocation.Level % 2 == 1)
            {
                return(false);
            }

            deepWoodsLocation.IsClearing = false;
            (deepWoodsLocation as GameLocation).IsOutdoors = false;

            Map map = Helper.Content.Load <Map>("ExampleMap.tbin", ContentSource.ModFolder);

            deepWoodsLocation.MapSize = Tuple.Create(map.DisplayWidth / 64, map.DisplayHeight / 64);
            (deepWoodsLocation as GameLocation).Map = map;

            deepWoodsLocation.EnterLocation = new Location(CustomMapEnterLocation.X + 1, CustomMapEnterLocation.Y + 1);

            if (deepWoodsLocation.ParentDeepWoods is IDeepWoodsLocation parent)
            {
                deepWoodsAPI.AddExitLocation(
                    deepWoodsLocation,
                    null,
                    CustomMapEnterLocation);
            }

            if (deepWoodsLocation.Exits.FirstOrDefault() is IDeepWoodsExit firstExit)
            {
                deepWoodsAPI.AddExitLocation(
                    deepWoodsLocation,
                    firstExit,
                    CustomMapExitLocation);
            }

            foreach (var exit in deepWoodsLocation.Exits)
            {
                exit.Location = new Location(CustomMapExitLocation.X - 1, CustomMapExitLocation.Y - 1);
            }

            return(true);
        }
Ejemplo n.º 7
0
 public void RemoveExitLocation(IDeepWoodsLocation deepWoodsLocation, Location tile)
 {
     DeepWoodsManager.RemoveExitLocation(deepWoodsLocation as DeepWoods, tile);
 }
Ejemplo n.º 8
0
 public void AddExitLocation(IDeepWoodsLocation deepWoodsLocation, IDeepWoodsExit exit, Location tile)
 {
     DeepWoodsManager.AddExitLocation(deepWoodsLocation as DeepWoods, tile, exit as DeepWoodsExit);
 }
Ejemplo n.º 9
0
 private void AddSummerStuffToClearing(IDeepWoodsLocation deepWoodsLocation)
 {
     // We just do the spring stuff here
     AddSpringStuffToClearing(deepWoodsLocation);
 }