public static ArenaState TestArena(Entity baseMech1, Entity baseMech2) { var arenaMap = Map.Create(new RogueSharp.MapCreation.BorderOnlyMapCreationStrategy <Map>(15, 15)); var mapEntities = new List <Entity>() { baseMech1, baseMech2 }; ArenaState arena = new ArenaState(mapEntities, "test", arenaMap, new PathFinder(arenaMap), 0); arena.PlaceEntityNear(baseMech1, 5, 5); arena.PlaceEntityNear(baseMech2, 10, 10); return(arena); }
private static ArenaState BuildArena(int width, int height, string mapID, IEnumerable <Entity> entities, int level) { if (!seedsToMaps.ContainsKey(mapID)) { var map = Map.Create(new RogueSharp.MapCreation.RandomRoomsMapCreationStrategy <Map>(width, height, 2000, 9, 5, new DotNetRandom(Int32.Parse(mapID)))); var pathFinder = new PathFinder(map); seedsToMaps[mapID] = new Tuple <IMap, PathFinder>(map, pathFinder); } var mapEntities = new List <Entity>(); foreach (var e in entities) { mapEntities.Add(e.DeepCopy()); } ArenaState arena = new ArenaState(mapEntities, mapID, seedsToMaps[mapID].Item1, seedsToMaps[mapID].Item2, level); var openCells = arena.ArenaMap.GetAllCells().Where(c => c.IsWalkable).ToList(); var placementRand = new DotNetRandom(Int32.Parse(mapID)); foreach (var e in mapEntities) { while (!e.HasComponentOfType <Component_Position>()) { var cell = openCells[placementRand.Next(openCells.Count - 1)]; Component_AI ai = e.GetComponentOfType <Component_AI>(); if (ai != null && !ArenaBuilder.InScanRangeOfPlayer(arena.Player, e, cell)) { arena.PlaceEntityNear(e, cell.X, cell.Y); ai.DeterminePatrolPath(arena, placementRand); } else if (ai == null) { arena.PlaceEntityNear(e, cell.X, cell.Y); } } } return(arena); }