Esempio n. 1
0
        protected void AddIntrudeStep(T map, CheckIntrudeBoundsEvent check)
        {
            //TODO: remove this magic number
            int       intrudeStatus = 33;
            MapStatus status;

            if (map.Map.Status.TryGetValue(intrudeStatus, out status))
            {
                MapCheckState destChecks = status.StatusStates.GetWithDefault <MapCheckState>();
                destChecks.CheckEvents.Add(check);
            }
            else
            {
                status = new MapStatus(intrudeStatus);
                status.LoadFromData();
                MapCheckState checkState = status.StatusStates.GetWithDefault <MapCheckState>();
                checkState.CheckEvents.Add(check);
                map.Map.Status.Add(intrudeStatus, status);
            }
        }
Esempio n. 2
0
        public override void Apply(T map)
        {
            if (!ItemThemes.CanPick)
            {
                return;
            }

            if (!MobThemes.CanPick)
            {
                return;
            }

            Rect bounds = new Rect(0, 0, map.Width, map.Height);

            //determine the number of free tiles to put items on; trim the maximum item spawn accordingly (maximum <= 1/2 of free tiles)
            //determine the number of free tiles to put mobs on; trim the maximum mob spawn accordingly (maximum <= 1/2 of free tiles)
            List <Loc> itemTiles = new List <Loc>();
            int        mobSpace  = 0;

            for (int x = bounds.X; x < bounds.X + bounds.Size.X; x++)
            {
                for (int y = bounds.Y; y < bounds.Y + bounds.Size.Y; y++)
                {
                    Loc testLoc = new Loc(x, y);
                    if (!map.TileBlocked(testLoc))
                    {
                        if (!map.HasTileEffect(new Loc(x, y)) && !map.PostProcGrid[x][y].Status[(int)PostProcType.Panel] && !map.PostProcGrid[x][y].Status[(int)PostProcType.Item])
                        {
                            bool hasItem = false;
                            foreach (MapItem item in map.Items)
                            {
                                if (item.TileLoc == testLoc)
                                {
                                    hasItem = true;
                                    break;
                                }
                            }
                            if (!hasItem)
                            {
                                itemTiles.Add(testLoc);
                            }
                        }
                        bool hasMob = false;
                        foreach (Team team in map.AllyTeams)
                        {
                            foreach (Character testChar in team.EnumerateChars())
                            {
                                if (testChar.CharLoc == testLoc)
                                {
                                    hasMob = true;
                                    break;
                                }
                            }
                        }
                        foreach (Team team in map.MapTeams)
                        {
                            foreach (Character testChar in team.EnumerateChars())
                            {
                                if (testChar.CharLoc == testLoc)
                                {
                                    hasMob = true;
                                    break;
                                }
                            }
                        }
                        if (!hasMob)
                        {
                            mobSpace++;
                        }
                    }
                }
            }

            //choose which item theme to work with
            ItemTheme chosenItemTheme = ItemThemes.Pick(map.Rand);

            //the item spawn list in this class dictates the items available for spawning
            //it will be queried for items that match the theme selected
            List <MapItem> chosenItems = chosenItemTheme.GenerateItems(map, Items);

            //place the items
            for (int ii = 0; ii < chosenItems.Count; ii++)
            {
                if (itemTiles.Count > 0)
                {
                    MapItem item      = new MapItem(chosenItems[ii]);
                    int     randIndex = map.Rand.Next(itemTiles.Count);
                    ((IPlaceableGenContext <MapItem>)map).PlaceItem(itemTiles[randIndex], item);
                    itemTiles.RemoveAt(randIndex);
                }
            }



            //the mob theme will be selected randomly
            MobTheme chosenMobTheme = MobThemes.Pick(map.Rand);

            //the mobs in this class are the ones that would be available when the game wants to spawn things outside of the floor's spawn list
            //it will be queried for monsters that match the theme provided
            List <MobSpawn> chosenMobs = chosenMobTheme.GenerateMobs(map, Mobs);

            //cover the room in a check that holds all of the monsters, and covers the room's bounds
            CheckIntrudeBoundsEvent check = new CheckIntrudeBoundsEvent();

            check.Bounds = bounds;
            {
                RevealAllEvent reveal = new RevealAllEvent();
                check.Effects.Add(reveal);

                GiveMapStatusSingleEvent statusEvent = new GiveMapStatusSingleEvent(30, 0);
                check.Effects.Add(statusEvent);

                MonsterHouseMapEvent house = new MonsterHouseMapEvent();
                house.Bounds = bounds;

                foreach (MobSpawn mob in chosenMobs)
                {
                    MobSpawn copyMob = mob.Copy();
                    if (map.Rand.Next(ALT_COLOR_ODDS) == 0)
                    {
                        copyMob.BaseForm.Skin = 1;
                    }
                    house.Mobs.Add(copyMob);
                }
                check.Effects.Add(house);
            }

            AddIntrudeStep(map, check);
        }
Esempio n. 3
0
        public override void Apply(T map)
        {
            //TODO: move magic numbers out of here
            EffectTile spawnedChest = new EffectTile(44, true);

            List <Loc> freeTiles = ((IPlaceableGenContext <EffectTile>)map).GetAllFreeTiles();

            int randIndex = map.Rand.Next(freeTiles.Count);
            Loc chosenLoc = freeTiles[randIndex];

            ((IPlaceableGenContext <EffectTile>)map).PlaceItem(chosenLoc, spawnedChest);

            //also put a monster house here
            RandRange       amount     = new RandRange(7, 13);
            int             mobCount   = amount.Pick(map.Rand);
            List <MobSpawn> chosenMobs = new List <MobSpawn>();

            if (map.TeamSpawns.Count > 0)
            {
                for (int ii = 0; ii < mobCount; ii++)
                {
                    List <MobSpawn> exampleList = map.TeamSpawns.Pick(map.Rand).ChooseSpawns(map.Rand);
                    if (exampleList.Count > 0)
                    {
                        chosenMobs.AddRange(exampleList);
                    }
                    if (chosenMobs.Count >= mobCount)
                    {
                        break;
                    }
                }
            }

            if (chosenMobs.Count > 0)
            {
                Rect bounds = new Rect(chosenLoc - new Loc(4), new Loc(9));
                bounds = Rect.Intersect(bounds, new Rect(0, 0, map.Width, map.Height));

                for (int xx = bounds.X; xx < bounds.End.X; xx++)
                {
                    for (int yy = bounds.Y; yy < bounds.End.Y; yy++)
                    {
                        if ((xx == bounds.X || xx == bounds.End.X - 1) && (yy == bounds.Y || yy == bounds.End.Y - 1))
                        {
                            continue;
                        }

                        if (map.GetTile(new Loc(xx, yy)).TileEquivalent(map.WallTerrain))
                        {
                            map.SetTile(new Loc(xx, yy), map.RoomTerrain.Copy());
                        }
                    }
                }

                //cover the room in a check that holds all of the monsters, and covers the room's bounds
                CheckIntrudeBoundsEvent check = new CheckIntrudeBoundsEvent();
                check.Bounds = bounds;
                {
                    MonsterHouseMapEvent house = new MonsterHouseMapEvent();
                    house.Bounds = check.Bounds;
                    foreach (MobSpawn mob in chosenMobs)
                    {
                        house.Mobs.Add(mob.Copy());
                    }
                    check.Effects.Add(house);
                }

                int       intrudeStatus = 33;
                MapStatus status        = new MapStatus(intrudeStatus);
                status.LoadFromData();
                MapCheckState checkState = status.StatusStates.GetWithDefault <MapCheckState>();
                checkState.CheckEvents.Add(check);
                map.Map.Status.Add(intrudeStatus, status);
            }
        }