public static IServiceCollection AddAreaMap(this IServiceCollection services) =>
        services.AddSingleton(p =>
        {
            var options = p.GetOptions <TimelineAreaOptions>();

            return(AreaMap.From(options.Types));
        });
Ejemplo n.º 2
0
        /// <summary>
        /// Travels to a level that is in the map cache. If the input index does not exist nothing will happen
        /// </summary>
        public void GotoExistingLevel(int idx, bool spawnAtEntrance = false)
        {
            if (idx < 0 || idx >= mapCache.Count)
            {
                return;
            }

            // cache the current map so that it will be used when the player returns
            if (currentMap != null && !mapCache.Contains(currentMap))
            {
                mapCache.Add(currentMap);
            }

            if (currentMap != null)
            {
                CleanUpMap(currentMap);
            }

            currentMap = mapCache[idx];
            mapIdx     = idx;

            // re-register the entities. player can be spawned at either entrance or exit
            Vector2 playerSpawn = spawnAtEntrance ? currentMap.entranceLoc : currentMap.exitLoc;

            SpawnPlayer(playerSpawn);
            foreach (var e in currentMap.levelEntities)
            {
                engine.RegisterEntity(e);
            }
        }
        public static bool TryMapToPointInMap(this AreaMap areaMap, Point point, out Point relativePoint)
        {
            try
            {
                var relativePosition = point - areaMap.LevelOrigin;
                var rows             = areaMap.Map.GetLength(0);
                if (rows == 0)
                {
                    relativePoint = null;
                    return(false);
                }
                var columns = areaMap.Map[0].GetLength(0);
                if (relativePosition.X < columns && relativePosition.Y < rows)
                {
                    relativePoint = relativePosition;
                    return(true);
                }
            }
            catch (ArithmeticException)
            {
            }

            relativePoint = null;
            return(false);
        }
Ejemplo n.º 4
0
 public Map(string path, TextureManager textures)
 {
     areamap    = new AreaMap <MapObject>();
     mapobjects = new Dictionary <Point, MapObject>();
     lastTiles  = new MapObject[0];
     this.Load(path, textures);
 }
Ejemplo n.º 5
0
    public static int GetAreaId(Vector3 position)
    {
        int x = Math.Min(AreaMap.MapWidth, Math.Max(0, AreaMap.CoordinateToIndex((int)position.x)));
        int y = Math.Min(AreaMap.MapWidth, Math.Max(0, AreaMap.CoordinateToIndex((int)position.z)));

        return(AreaMap.AreaIds[x][y]);
    }
Ejemplo n.º 6
0
 public TestQueryContext(AreaMap area, IJsonFormat jsonFormat, IQueryDb queryDb, TestQueryNotifier notifier)
 {
     _area       = area;
     _jsonFormat = jsonFormat;
     _queryDb    = queryDb;
     _notifier   = notifier;
 }
Ejemplo n.º 7
0
        public static void MoveToDurance2()
        {
            PC me = new PC();

            AreaMap map = new AreaMap(me.Area);

            map.Initialize();

            Pather p = new Pather(map, new WalkingReducer(5, 13));

            p.FindPathToWaypoint(me.Position);

            Pathing.Mover m = new Pathing.Mover(p);
            m.Move(Reduction.WalkingReduction);

            GameObject waypoint = new GameObject(p.LastPresetUsed);

            Game.Print("About to click the WP");
            me.Interact(waypoint);
            while (!Game.GetUIState(UIState.WaypointPanel))
            {
                Thread.Sleep(50);
            }

            waypoint.Interact(AreaLevel.DuranceOfHateLevel2);

            while (me.Area != AreaLevel.DuranceOfHateLevel2)
            {
                Thread.Sleep(100);
            }
            //Thread.Sleep(50000); //init delay
        }
Ejemplo n.º 8
0
        public virtual ActionResult Create(AddOrUpdateAreaMap areaMapModel)
        {
            if (ModelState.IsValid)
            {
                var areamap = new AreaMap()
                {
                    AreaName   = areaMapModel.AreaName,
                    AreaTypeId = areaMapModel.AreaTypeId,
                    MapPoints  = new List <MapPoint>()
                };
                foreach (var areamapMapPoint in areaMapModel.MapPoints)
                {
                    if (db.MapPoints.Any(a =>
                                         a.LatMap.CompareTo(areamapMapPoint.LatMap) == 0 || a.LngMap.CompareTo(areamapMapPoint.LngMap) == 0))
                    {
                        return(Json("محیط انتخاب شده تداخل دارد"));
                    }
                    var mapPoint = new MapPoint()
                    {
                        LatMap = areamapMapPoint.LatMap,
                        LngMap = areamapMapPoint.LngMap
                    };
                    areamap.MapPoints.Add(mapPoint);
                }

                db.AreaMaps.Add(areamap);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(Json(areaMapModel));
        }
Ejemplo n.º 9
0
        static public void SetRectRoomArea(ref AreaMap new_map, ref AreaMapType template)
        {
            Rectangle room_rect = Rectangle.Empty; // origin of room to be created, in tiles

            int room_x_max = 0;
            int room_y_max = 0;

            MakeRectUntil(ref room_rect, ref new_map, ref template, 100); // <------------ rects made

            if (Globals.roomFail)
            {
                return;
            }

            // add room to AreaMap room list
            new_map.RoomList.Add(new Room(MapGenHelper.roomCounter, room_rect));

            room_x_max = (room_rect.X + room_rect.Width);
            room_y_max = (room_rect.Y + room_rect.Height);

            // minimum room x tile coordinate index to maximum room x tile index, inclusive
            for (int x = room_rect.X; x < room_x_max; x++)
            {
                for (int y = room_rect.Y; y < room_y_max; y++) // same, with y
                {
                    MakePreRoomSqr(ref new_map.MSGrid[y][x], MapGenHelper.roomCounter);
                    new_map.RoomList[MapGenHelper.roomCounter].AllSquares.Add(new Point(x, y));
                }
            }

            //roomMakeFail = false;
        }
Ejemplo n.º 10
0
        static public void MakeRoom(ref AreaMap new_map, ref AreaMapType template)
        {
            RoomTypes room_type = RoomTypes.NULL;

            // loads a random RoomTypes into local var room_typr and returns room_index;
            // room_index matches a room in List<MapRoomTypes> in AreaMap
            template.currRoomTypeIndex = GetRoomTypeProb(ref template, ref room_type);

            switch (room_type)
            {
            case RoomTypes.RECTANGLE:
                SetRectRoomArea(ref new_map, ref template);
                if (Globals.roomFail)
                {
                    break;
                }

                foreach (Point sqr in new_map.RoomList[MapGenHelper.roomCounter].AllSquares)
                {
                    MapGenHelper.PreToRoomOrWall(ref new_map, sqr, MapGenHelper.roomCounter);
                }

                SetRoomBarrier(ref new_map, ref template, MapGenHelper.roomCounter);
                MakeRoomArea(ref new_map, ref template);
                MapGenHelper.roomCounter++;

                break;
            }
        }
Ejemplo n.º 11
0
        public void RegionalMap_CorrectlyFiresOnRegionCompletedEvent()
        {
            SubRegion fakeSubRegion = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0],
                                                    new FighterType[0], new BattlefieldConfiguration(new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, MagicType.Fire))));

            Region fakeRegion = new Region(WorldRegion.Fields, new BattleMove[0], new List <SubRegion> {
                fakeSubRegion
            });

            _logger.Subscribe(fakeRegion, EventType.RegionCompleted);

            AreaMap <Region, WorldRegion> fakeRegionalMap =
                new AreaMap <Region, WorldRegion>(fakeRegion, new MapPath <Region, WorldRegion>(fakeRegion));

            fakeRegionalMap.Advance(new MockDecisionManager(new GodRelationshipManager()), new TestTeam());

            List <EventLog> logs = _logger.Logs;

            Assert.AreEqual(1, logs.Count);

            EventLog log = logs[0];

            Assert.AreEqual(EventType.RegionCompleted, log.Type);

            RegionCompletedEventArgs e = log.E as RegionCompletedEventArgs;

            Assert.AreEqual(fakeRegion, e?.CompletedRegion);
        }
 public TriggerMineRockScene(AreaMap map, PlayerModel player, RockModel model)
 {
     this.map           = map;
     this.model         = model;
     this.player        = player;
     this.integrityLeft = new Random().Next(4, 6);
 }
Ejemplo n.º 13
0
        static public void ConnectRooms(ref AreaMap new_map, ref List <List <Point> > hall_paths, int repeats)
        {
            int room_count = new_map.RoomList.Count;

            Vector4      tunnel_ends = new Vector4(); // (start X, start Y, end X, end Y)
            List <Point> path        = new List <Point>();

            for (int i = 0; i < repeats; i++)
            {
                for (int curr_room = 0; curr_room < room_count; curr_room++)
                {
                    tunnel_ends = FindClosestRoom(ref new_map, curr_room, room_count);

                    if (tunnel_ends.X == -1f)
                    {
                        return;
                    }

                    path.Clear();
                    PathFinder.Reset(ref new_map, ref tunnel_ends);
                    PathFinder.Search(ref new_map, ref path, false);

                    if (path.Count != 0)
                    {
                        hall_paths.Add(new List <Point>());
                        for (int s = 0; s < path.Count; s++)
                        {
                            hall_paths[hall_paths.Count - 1].Add(path[s]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public bool Event_DoSkillEffects(ComponentEvent e)
        {
            var skillEffects = (ECompileSkillEffects)e;

            // get all of the entities in the radius, and add them to the effected entities
            AreaMap map = Engine.instance.world.currentMap;

            Entity[] hits = map.GetAllObjectsInRadius(skillEffects.baseLocation, radius);

            // add each, but also make sure not to repeat any
            foreach (Entity hit in hits)
            {
                bool newTarget = true;
                foreach (var combat in skillEffects.combats)
                {
                    if (combat.defender == hit)
                    {
                        newTarget = false;
                    }
                }

                // the list did not contain this target yet, so add an attack for it
                if (newTarget)
                {
                    skillEffects.combats.Add(new CombatInstance(skillEffects.user, hit)
                    {
                        { "skill", owner }
                    });
                }
            }

            return(true);
        }
Ejemplo n.º 15
0
        public void DarkCastleRegion_UnlockedAfterBeatingOtherAreas()
        {
            Region fieldsRegion       = new Region(WorldRegion.Fields, new BattleMove[0], new SubRegion[0]);
            Region desertRegion       = new Region(WorldRegion.Desert, new BattleMove[0], new SubRegion[0]);
            Region casinoRegion       = new Region(WorldRegion.Casino, new BattleMove[0], new SubRegion[0]);
            Region crystalCavesRegion = new Region(WorldRegion.CrystalCaves, new BattleMove[0], new SubRegion[0]);
            Region darkCastleRegion   = new Region(WorldRegion.DarkCastle, new BattleMove[0], new SubRegion[0]);

            AreaMap <Region, WorldRegion> regionalMap = _mapManager.GetRegionalMap(fieldsRegion, desertRegion, casinoRegion, crystalCavesRegion, darkCastleRegion);

            MapGroupingItem <Region, WorldRegion> darkCastleGroupItem = regionalMap.MapPaths.First(mp => mp.To.Values.FirstOrDefault(gi => gi.Item == darkCastleRegion) != null).To.Values.First(gi => gi.Item == darkCastleRegion);

            MockDecisionManager decisionManager = new MockDecisionManager(new GodRelationshipManager());

            int i = 0;

            for (; i < 3; ++i)
            {
                Assert.True(darkCastleGroupItem.IsLocked, "Dark Castle should be locked, not all requisite areas have been completed");
                decisionManager.SetGroupingChoice(i);
                regionalMap.Advance(decisionManager, new TestTeam());
            }

            decisionManager.SetGroupingChoice(i);
            Region finalRegion = null;

            Assert.DoesNotThrow(() => finalRegion = regionalMap.Advance(decisionManager, new TestTeam()));

            Assert.False(darkCastleGroupItem.IsLocked, "Dark Castle should be unlocked, all requisite areas have been completed");

            Assert.AreEqual(darkCastleRegion, finalRegion);
        }
Ejemplo n.º 16
0
 public void Draw(AreaMap map, int round)
 {
     Console.WriteLine("Round {0}", round);
     DrawLine(map.Rooms.GetLength(0));
     for (int y = 0; y < map.Rooms.GetLength(1); y++)
     {
         Console.WriteLine();
         Console.Write('|');
         for (int x = 0; x < map.Rooms.GetLength(0); x++)
         {
             Room room = map.Rooms[x, y];
             // could maybe replace with a reference check...
             if (room.XAxis == map.AgentRoom.XAxis && room.YAxis == map.AgentRoom.YAxis)
             {
                 Console.Write('V');
             }
             else if (room.IsDirty)
             {
                 Console.Write('D');
             }
             else
             {
                 Console.Write(' ');
             }
             Console.Write('|');
         }
         DrawLine(map.Rooms.GetLength(0));
     }
     Console.WriteLine();
 }
Ejemplo n.º 17
0
        static public void ConnectDCRooms(ref AreaMap new_map, ref List <List <Point> > hall_paths, int repeats)
        {
            int room_count = MapGenHelper.disconnectedRooms.Count();

            List <Point> path = new List <Point>();

            for (int i = 0; i < repeats; i++)
            {
                for (int j = 0; j < room_count; j++)
                {
                    GetClosestRoomPath(ref new_map, MapGenHelper.disconnectedRooms[j],
                                       ref MapGenHelper.disconnectedRooms, ref path);

                    if (path.Count() > 0)
                    {
                        hall_paths.Add(new List <Point>());
                        for (int s = 0; s < path.Count; s++)
                        {
                            hall_paths[hall_paths.Count - 1].Add(path[s]);
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 18
0
        static public bool AreRoomsConnected(ref AreaMap new_map, int roomID_out, int roomID_in)
        {
            int out_count = new_map.RoomList[roomID_out].OutConnections.Count();
            int in_count  = new_map.RoomList[roomID_in].InConnections.Count();
            int min_count = 0;

            if (out_count <= in_count)
            {
                min_count = out_count;
            }
            else
            {
                min_count = in_count;
            }

            for (int connection = 0; connection < min_count; connection++)
            {
                if (new_map.RoomList[roomID_out].OutConnections[connection] == roomID_in)
                {
                    if (new_map.RoomList[roomID_in].InConnections[connection] == roomID_out)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 19
0
        public static void MoveToDurance3()
        {
            PC me = new PC();

            AreaMap map = new AreaMap(me.Area);

            map.Initialize();

            Pather p = me.GetSkillLevel(SkillType.Teleport) > 0 ? new Pather(map, new TeleportReducer(25)) : p = new Pather(map, new WalkingReducer(7, 13));

            p.FindPathToWarp(me.Position, new int[] { 67, 68 }, me.Area);

            Pathing.Mover m = new Pathing.Mover(p);
            m.OnMoverCallBack += new botNET.Pathing.Mover.MoverCallBackHandler(m_OnMoverCallBack);
            m.Move(me.GetSkillLevel(SkillType.Teleport) > 0 ? Reduction.TeleportReduction : Reduction.WalkingReduction);

            Warp warp = new Warp(p.LastPresetUsed);

            Thread.Sleep(200);

            me.Interact(warp);

            Thread.Sleep(200);

            while (me.Area != (AreaLevel)102)
            {
                me.ClickMap(ClickType.LeftDown, false, warp);
                Thread.Sleep(100);
                me.ClickMap(ClickType.LeftUp, false, warp);
                Thread.Sleep(500);
            }

            return;
        }
Ejemplo n.º 20
0
        private IAreaMap ConvertMap(int level, int[][] map, int width, int height)
        {
            var result = new AreaMap(level, () => new AreaMapCell(new GameEnvironment()), width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    result.AddObject(x, y, mapObjectsFactory.CreateFloor());

                    if (map[y][x] == MapBuilder.FilledCell)
                    {
                        var wall = mapObjectsFactory.CreateWall(TorchChance);
                        result.AddObject(x, y, wall);
                    }
                    else if (map[y][x] == MapBuilder.DoorCell)
                    {
                        var door = mapObjectsFactory.CreateDoor();
                        result.AddObject(x, y, door);
                    }
                    else if (map[y][x] == MapBuilder.TrapDoorCell)
                    {
                        var trapDoor = mapObjectsFactory.CreateTrapDoor();
                        result.AddObject(x, y, trapDoor);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 21
0
        public void UpdateCallsCellUpdateTest()
        {
            // Arrange
            var cells           = new List <Mock <IAreaMapCellInternal> >();
            var mapCellsFactory = new Func <IAreaMapCellInternal>(() =>
            {
                var environment = new Mock <IEnvironment>();
                var cell        = new Mock <IAreaMapCellInternal>();
                cell.SetupGet(c => c.Environment).Returns(environment.Object);
                cells.Add(cell);
                return(cell.Object);
            });
            var mapLightLevelProcessorMock = new Mock <IMapLightLevelProcessor>();
            var turnProvider = new Mock <ITurnProvider>();

            var map = new AreaMap(1, mapCellsFactory, 30, 20, mapLightLevelProcessorMock.Object);

            // Act
            map.Update(turnProvider.Object);

            // Assert
            foreach (var cellMock in cells)
            {
                cellMock.Verify(cell => cell.Update(It.IsAny <Point>(), UpdateOrder.Early), Times.Once);
                cellMock.Verify(cell => cell.Update(It.IsAny <Point>(), UpdateOrder.Medium), Times.Once);
                cellMock.Verify(cell => cell.Update(It.IsAny <Point>(), UpdateOrder.Late), Times.Once);
                cellMock.Verify(cell => cell.PostUpdate(map, It.IsAny <Point>()), Times.Once);
                cellMock.Verify(cell => cell.ResetDynamicObjectsState(), Times.Once);
            }

            mapLightLevelProcessorMock.Verify(processor => processor.ResetLightLevel(map), Times.Once);
            mapLightLevelProcessorMock.Verify(processor => processor.UpdateLightLevel(map), Times.Once);
            mapLightLevelProcessorMock.VerifyNoOtherCalls();
        }
Ejemplo n.º 22
0
 static public void GenerateMap(ref AreaMap current_map, ref List <string> currMapTexNames, MapSets map_set, Sizes map_size,
                                ref List <int> dcRoomList)
 {
     areaMapType = new AreaMapType();
     LoadMapSet(map_set, ref areaMapType);
     MapGenHelper.MakeMap(ref current_map, ref areaMapType, ref currMapTexNames, map_size);
     MapGenHelper.GetMapData(ref dcRoomList);
 }
Ejemplo n.º 23
0
        public virtual ActionResult DeleteConfirmed(int id)
        {
            AreaMap areaMap = db.AreaMaps.Find(id);

            db.AreaMaps.Remove(areaMap);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 24
0
        public void CorrectlyExecutesCutscene_SubRegionCompleted()
        {
            const MagicType firstBossEggType  = MagicType.Fire;
            const MagicType secondBossEggType = MagicType.Ice;

            ColorString[] firstSceneLines  = { new ColorString("foo"), new ColorString("bar") };
            SingleScene   firstSingleScene = new SingleScene(firstSceneLines);

            ColorString[] secondSceneLines  = { new ColorString("baz"), new ColorString("fwee") };
            SingleScene   secondSingleScene = new SingleScene(secondSceneLines);

            SingleScene[] scenes          = { firstSingleScene, secondSingleScene };
            Cutscene      regionACutscene = new Cutscene(scenes);

            TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType));
            SubRegion         subRegionA             = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration), regionCompletedCutscene: regionACutscene);

            TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType));
            SubRegion         subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration));

            SubRegion[] subRegions = { subRegionA, subRegionB };

            Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions);

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion));

            AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB));

            _mapManager.SetRegionalMap(regionMap);
            _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap);

            _regionManager = GetRegionManager();

            TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            target.SetHealth(1, 0);

            _humanFighter1.SetMove(_basicAttackMove, 1);
            _humanFighter1.SetMove(_runawayMove, 1);
            _humanFighter1.SetMoveTarget(target);

            _humanFighter2.SetMove(_doNothingMove);

            _chanceService.PushAttackHitsNotCrit();

            _regionManager.Battle(_battleManager, _humanTeam);

            List <MockOutputMessage> outputs = _output.GetOutputs().ToList();

            List <ColorString> allCutsceneLines = firstSceneLines.Concat(secondSceneLines).ToList();

            foreach (ColorString cutsceneLine in allCutsceneLines)
            {
                Assert.NotNull(outputs.FirstOrDefault(output => output.Message == cutsceneLine.Value + "\n" && output.Color == cutsceneLine.Color));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Cleans up the input map, in particular removing registered entites from any caches they are in
        /// </summary>
        public void CleanUpMap(AreaMap map)
        {
            DespawnEntity(player);

            foreach (var e in map.levelEntities)
            {
                engine.UnregisterEntity(e);
            }
        }
Ejemplo n.º 26
0
        public static QueryETag From(string value, AreaMap area)
        {
            if (!TryFrom(value, area, out var etag))
            {
                throw new FormatException($"Failed to parse query ETag: \"{value}\"");
            }

            return(etag);
        }
Ejemplo n.º 27
0
        public static FlowKey From(string value, AreaMap area)
        {
            if (!TryFrom(value, area, out var key))
            {
                throw new FormatException($"Failed to parse the specified key: {value}");
            }

            return(key);
        }
Ejemplo n.º 28
0
        static public void MakeMap(out AreaMap new_map, ref AreaMapTemplate template, Sizes size)
        {
            int   prev_dc_count = 0;
            Point m_size_range  = Point.Zero;

            m_size_range = Globals.GetSizeRange(MakeTarget.MAP, size);

            // get map size
            template.mapWidthTile  = rand.Next(m_size_range.X, m_size_range.Y);
            template.mapHeightTile = template.mapWidthTile;

            // load possible TileSets from template to TileSetManager
            for (int set = 0; set < template.tsNameIndices.Count(); set++)
            {
                if (!TileSetManager.CheckIfTileSetLoaded(TileSetManager.TileSetsNames[(int)template.tsNameIndices[set]]))
                {
                    TileSetManager.LoadTileSet(template.tsNameIndices[set], set);
                }
            }

            // load template into new AreaMap
            new_map = new AreaMap(ref template);

            if (new_map.areaMapType == MapTypes.ROOMS)
            {
                List <List <Point> > hall_path = new List <List <Point> >();

                RoomMaker.MakeRooms(ref new_map, ref template);
                HallMaker.ConnectRooms(ref new_map, ref hall_path, 1);
                HallMaker.MakeHalls(ref new_map, ref hall_path);

                while (!HallMaker.FloodIsConnectedCheck(ref new_map, false))
                {
                    if (prev_dc_count > 0)
                    {
                        if (prev_dc_count <= disconnectedRooms.Count())
                        {
                            break;
                        }
                    }

                    hall_path.Clear();
                    HallMaker.ConnectDCRooms(ref new_map, ref hall_path, 1);
                    HallMaker.MakeHalls(ref new_map, ref hall_path);

                    prev_dc_count = disconnectedRooms.Count();
                }
            }
            else if (new_map.areaMapType == MapTypes.OPEN)
            {
            }
            else if (new_map.areaMapType == MapTypes.ENCLOSED_ROOMS)
            {
            }

            SetStartPoint(ref new_map);
        }
Ejemplo n.º 29
0
        static public void AddRoomSqrTile(ref AreaMap current_map, ref MapSquare map_square, int x_loc, int y_loc)
        {
            int rand_TI      = 0;
            int tile_count   = map_square.MSTiles.Count();
            int sources      = 0;
            int anim_indices = 0;

            // 0: tile_sources_bg // 1: tile_sources_fg // 2: animated_indices_bg // 3: animated_indices_fg
            for (int i = 0; i < 4; i++)
            {
                addSqrIndices[i] = 0;
            }

            map_square.TileColor = Color.White;

            if (map_square.MSStates[(int)MSFlagIndex.WALL_RM_ENT] == MSFlag.ENT ||
                map_square.MSStates[(int)MSFlagIndex.WALL_RM_ENT] == MSFlag.ROOM)
            {
                addSqrIndices[(int)MSMakeIndex.TILE_BG] = (int)TileGroup.BG_ROOM_SOURCES;
                addSqrIndices[(int)MSMakeIndex.TILE_FG] = (int)TileGroup.FG_ROOM_SOURCES;
            }
            else if (map_square.MSStates[(int)MSFlagIndex.WALL_RM_ENT] == MSFlag.WALL)
            {
                addSqrIndices[(int)MSMakeIndex.TILE_BG] = (int)TileGroup.BG_WALL_SOURCES;
                addSqrIndices[(int)MSMakeIndex.TILE_FG] = (int)TileGroup.FG_WALL_SOURCES;
            }

            addSqrIndices[(int)MSMakeIndex.ANM_BG] = addSqrIndices[(int)MSMakeIndex.TILE_BG];
            addSqrIndices[(int)MSMakeIndex.ANM_FG] = addSqrIndices[(int)MSMakeIndex.TILE_FG];

            for (int i = 0; i < tile_count; i++)
            {
                sources      = addSqrIndices[i];
                anim_indices = addSqrIndices[i + 2];

                rand_TI = rand.Next(0, CurrentTileSet.TSrcs[sources].Count());

                if (current_map.IsTileAnimated(CurrentTileSet.ATIndices[anim_indices], CurrentTileSet.TSrcs[sources][rand_TI]))
                {
                    int a_t_index = CurrentTileSet.GetATIndex(CurrentTileSet, CurrentTileSet.TSrcs[anim_indices][rand_TI], sources);
                    map_square.MSTiles[i] =
                        new AnimatedTile(
                            (int)CurrentTileSet.ATIndices[sources][a_t_index].Y,
                            (int)CurrentTileSet.ATIndices[sources][a_t_index].Z,
                            CurrentTileSet.TextureName,
                            new Rectangle(CurrentTileSet.TSrcs[sources][rand_TI] * Globals.tileSize,
                                          sources * Globals.tileSize, Globals.tileSize, Globals.tileSize));
                }
                else
                {
                    map_square.MSTiles[i].TextureName = CurrentTileSet.TextureName;
                    map_square.MSTiles[i].SourceRect  =
                        new Rectangle(CurrentTileSet.TSrcs[sources][rand_TI] * Globals.tileSize,
                                      sources * Globals.tileSize, Globals.tileSize, Globals.tileSize);
                }
            }
        }
Ejemplo n.º 30
0
        private IAreaMap ConvertToAreaMap(int level, Room[][] roomsMap, int width, int height)
        {
            var map = new AreaMap(level, () => new AreaMapCell(new GameEnvironment()), width, height);

            var currentMapY = 1;

            foreach (var row in roomsMap)
            {
                var currentMapX = 1;

                foreach (var room in row)
                {
                    currentMapX++;
                    if (room.Walls[Direction.East])
                    {
                        map.AddObject(currentMapX, currentMapY, mapObjectsFactory.CreateWall(TorchChance));
                    }
                    currentMapX++;
                }

                currentMapX = 1;
                currentMapY++;

                foreach (var room in row)
                {
                    if (room.Walls[Direction.South])
                    {
                        map.AddObject(currentMapX, currentMapY, mapObjectsFactory.CreateWall(TorchChance));
                    }
                    currentMapX++;
                    map.AddObject(currentMapX, currentMapY, mapObjectsFactory.CreateWall(TorchChance));
                    currentMapX++;
                }

                currentMapY++;
            }

            for (var y = 0; y < map.Height; y++)
            {
                map.AddObject(0, y, mapObjectsFactory.CreateWall(TorchChance));
            }

            for (var x = 0; x < map.Width; x++)
            {
                map.AddObject(x, 0, mapObjectsFactory.CreateWall(TorchChance));
            }

            for (int y = 0; y < map.Height; y++)
            {
                for (int x = 0; x < map.Width; x++)
                {
                    map.AddObject(x, y, mapObjectsFactory.CreateFloor());
                }
            }

            return(map);
        }