Beispiel #1
0
        Monster CreateRandomMonster(Vector2 location)
        {
            Monster monster = null;

            if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Bat))
            {
                monster = new Bat(new Vector2());
            }
            else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Ghost))
            {
                monster = new Ghost(new Vector2());
            }
            else if (CanHazMonster(Settings.Monsters.BigSlime))
            {
                monster = new BigSlime(new Vector2(), GetSlimeLevel());
            }
            else if (CanHazMonster(Settings.Monsters.Grub))
            {
                monster = new Grub(new Vector2(), true);
            }
            else if (CanHazMonster(Settings.Monsters.Fly))
            {
                monster = new Fly(new Vector2(), true);
            }
            else if (CanHazMonster(Settings.Monsters.Brute))
            {
                monster = new ShadowBrute(new Vector2());
            }
            else if (CanHazMonster(Settings.Monsters.Golem))
            {
                monster = new RockGolem(new Vector2(), deepWoods.GetCombatLevel());
            }
            else if (CanHazMonster(Settings.Monsters.RockCrab))
            {
                monster = new RockCrab(new Vector2(), GetRockCrabType());
            }
            else
            {
                foreach (var modMonster in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().Monsters))
                {
                    if (modMonster.Item1(deepWoods, location))
                    {
                        monster = modMonster.Item2();
                        break;
                    }
                }
                if (monster == null)
                {
                    monster = new GreenSlime(new Vector2(), GetSlimeLevel());
                }
            }

            if (deepWoods.level.Value >= Settings.Level.MinLevelForBuffedMonsters && !this.random.CheckChance(Settings.Monsters.ChanceForUnbuffedMonster))
            {
                BuffMonster(monster);
            }

            return(monster);
        }
        Monster CreateRandomMonster(Vector2 location)
        {
            Monster monster = null;

            if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Bat))
            {
                monster = new Bat(new Vector2());
            }
            else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Ghost))
            {
                monster = new Ghost(new Vector2());
            }
            else if (CanHazMonster(Settings.Monsters.BigSlime))
            {
                monster = new BigSlime(new Vector2(), GetSlimeLevel());
            }
            else if (CanHazMonster(Settings.Monsters.Grub))
            {
                monster = new Grub(new Vector2(), true);
            }
            else if (CanHazMonster(Settings.Monsters.Fly))
            {
                monster = new Fly(new Vector2(), true);
            }
            else if (CanHazMonster(Settings.Monsters.Brute))
            {
                monster = new ShadowBrute(new Vector2());
            }
            else if (CanHazMonster(Settings.Monsters.Golem))
            {
                monster = new RockGolem(new Vector2(), deepWoods.GetCombatLevel());
            }
            else if (CanHazMonster(Settings.Monsters.RockCrab))
            {
                monster = new RockCrab(new Vector2(), GetRockCrabType());
            }
            else if (CanHazMonster(Settings.Monsters.Bug))
            {
                monster = new Bug(new Vector2(), 121);
                monster.isHardModeMonster.Value = true;
            }
            else if (CanHazMonster(Settings.Monsters.ArmoredBug))
            {
                monster = new Bug(new Vector2(), 121);
                monster.isHardModeMonster.Value = true;
            }
            else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.PutridGhost))
            {
                monster = new Ghost(new Vector2(), "Putrid Ghost");
            }
            else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.DustSprite))
            {
                monster = new DustSpirit(new Vector2()); new Leaper();
            }
            else if (Game1.isDarkOut() && CanHazMonster(Settings.Monsters.Spider))
            {
                monster = new Leaper(new Vector2());
            }
            else
            {
                foreach (var modMonster in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().Monsters))
                {
                    // Item1 is a mod provided function that returns true if the mod wants to spawn a custom monster at this location.
                    // Item2 is a mod provided function that returns the custom monster.
                    if (modMonster.Item1(deepWoods, location))
                    {
                        monster = modMonster.Item2();
                        break;
                    }
                }
            }

            // No other monster was selected and no mod provided a monster, default to green slime
            if (monster == null)
            {
                monster = new GreenSlime(new Vector2(), GetSlimeLevel());
            }

            if (!Settings.Monsters.DisableBuffedMonsters &&
                deepWoods.level.Value >= Settings.Level.MinLevelForBuffedMonsters &&
                !this.random.CheckChance(Settings.Monsters.ChanceForUnbuffedMonster))
            {
                BuffMonster(monster);
            }

            if (!Settings.Monsters.DisableDangerousMonsters &&
                deepWoods.level.Value >= Settings.Level.MinLevelForDangerousMonsters &&
                !this.random.CheckChance(Settings.Monsters.ChanceForNonDangerousMonster))
            {
                monster.isHardModeMonster.Value = true;
            }

            monster.faceDirection(this.random.GetRandomValue(0, 4));

            return(monster);
        }
Beispiel #3
0
        private void AddModOrGrass(Vector2 location)
        {
            // We have 4 kinds of things that a mod can add:
            // largeterrainfeatures, terrainfeatures, resourceclumps and objects.
            // To create a truly random order, we shuffle the kind of things (using lambdas in a list),
            // and then we shuffle the callbacks provided by mods.
            foreach (var action in DeepWoodsAPI.ToShuffledList(new List <Func <bool> >()
            {
                () => {
                    foreach (var modLargeTerrainFeature in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().LargeTerrainFeatures))
                    {
                        if (modLargeTerrainFeature.Item1(deepWoods, location))
                        {
                            deepWoods.largeTerrainFeatures.Add(modLargeTerrainFeature.Item2());
                            return(true);
                        }
                    }
                    return(false);
                },
                () => {
                    foreach (var modResourceClump in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().ResourceClumps))
                    {
                        if (modResourceClump.Item1(deepWoods, location))
                        {
                            deepWoods.resourceClumps.Add(modResourceClump.Item2());
                            return(true);
                        }
                    }
                    return(false);
                },
                () => {
                    foreach (var modTerrainFeature in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().TerrainFeatures))
                    {
                        if (modTerrainFeature.Item1(deepWoods, location))
                        {
                            deepWoods.terrainFeatures[location] = modTerrainFeature.Item2();
                            return(true);
                        }
                    }
                    return(false);
                },
                () => {
                    foreach (var modObject in DeepWoodsAPI.ToShuffledList(ModEntry.GetAPI().Objects))
                    {
                        if (modObject.Item1(deepWoods, location))
                        {
                            deepWoods.objects[location] = modObject.Item2();
                            return(true);
                        }
                    }
                    return(false);
                }
            }))
            {
                if (action())
                {
                    // A mod added something, return
                    return;
                }
            }

            // Mods didn't add anything, add grass
            deepWoods.terrainFeatures[location] = new LootFreeGrass(GetSeasonGrassType(), this.random.GetRandomValue(1, 3));
        }