コード例 #1
0
        public Location GetRandomEnterLocation(EnterDirection enterDir, DeepWoodsRandom random)
        {
            int x, y;

            if (enterDir == EnterDirection.FROM_BOTTOM || enterDir == EnterDirection.FROM_TOP)
            {
                x = random.GetRandomValue(Settings.Map.MinCornerDistanceForEnterLocation, this.mapWidth - Settings.Map.MinCornerDistanceForEnterLocation);
                if (enterDir == EnterDirection.FROM_BOTTOM)
                {
                    y = this.mapHeight - 1;
                }
                else
                {
                    y = 0;
                }
            }
            else
            {
                y = random.GetRandomValue(Settings.Map.MinCornerDistanceForEnterLocation, this.mapHeight - Settings.Map.MinCornerDistanceForEnterLocation);
                if (enterDir == EnterDirection.FROM_RIGHT)
                {
                    x = this.mapWidth - 1;
                }
                else
                {
                    x = 0;
                }
            }
            return(new Location(x, y));
        }
コード例 #2
0
        private void CreateSpace()
        {
            if (!Game1.IsMasterGame)
            {
                throw new ApplicationException("Illegal call to DeepWoods.CreateSpace in client.");
            }

            var random = new DeepWoodsRandom(this, this.Seed ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ Game1.random.Next());

            if (!this.isLichtungSetByAPI.Value)
            {
                this.isLichtung.Value = this.level.Value >= Settings.Level.MinLevelForClearing && !(this.Parent?.isLichtung ?? true) && random.CheckChance(Settings.Luck.Clearings.ChanceForClearing);
            }

            if (!this.isMapSizeSetByAPI.Value)
            {
                if (this.isLichtung.Value)
                {
                    this.mapWidth.Value        = Game1.random.Next(Settings.Map.MinMapWidth, Settings.Map.MaxMapWidthForClearing);
                    this.mapHeight.Value       = Game1.random.Next(Settings.Map.MinMapWidth, Settings.Map.MaxMapWidthForClearing);
                    this.lichtungHasLake.Value = random.GetRandomValue(Settings.Luck.Clearings.Perks) == LichtungStuff.Lake;
                }
                else
                {
                    this.mapWidth.Value  = Game1.random.Next(Settings.Map.MinMapWidth, Settings.Map.MaxMapWidth);
                    this.mapHeight.Value = Game1.random.Next(Settings.Map.MinMapHeight, Settings.Map.MaxMapHeight);
                }
            }

            this.EnterLocation = this.level.Value == 1 ? Settings.Map.RootLevelEnterLocation : new DeepWoodsSpaceManager(this.mapWidth.Value, this.mapHeight.Value).GetRandomEnterLocation(this.EnterDir, random);
        }
コード例 #3
0
 private int GetRandomFoodType(DeepWoods deepWoods)
 {
     if (random == null)
     {
         random = new DeepWoodsRandom(deepWoods, (deepWoods?.Seed ?? Game1.random.Next()) ^ Game1.currentGameTime.TotalGameTime.Milliseconds ^ (int)this.tile.X ^ (int)this.tile.Y);
     }
     return(random.GetRandomValue(Settings.Objects.GingerBreadHouse.FootItems));
 }
コード例 #4
0
        private void ClearAndAddStuff()
        {
            if (!Game1.IsMasterGame)
            {
                return;
            }

            ClearStuff();
            AddStuff();

            if (Settings.Performance.GrassDensity < 100)
            {
                var terrainFeatures         = deepWoods.terrainFeatures;
                var terrainFeatureLocations = new List <Vector2>(terrainFeatures.Keys);
                foreach (var location in terrainFeatureLocations)
                {
                    if (terrainFeatures[location] is Grass && (Settings.Performance.GrassDensity < random.GetRandomValue(1, 100)))
                    {
                        terrainFeatures.Remove(location);
                    }
                }
            }
        }