public void Execute(MapModel mapModel) { foreach (var x in ObjectChipPointList) { mapModel.ObjectChipModel.Set(x.Point.X, x.Point.Y, x.ObjectChip); } }
public MapModel AddDoorsAndObjectives(MapModel mapModel, int numberDoorsToAdd, int cluesPerDoorMax) { var manager = mapModel.DoorAndClueManager; var numberDoors = 0; while (numberDoors < numberDoorsToAdd) { var doorName = "door" + numberDoors.ToString(); var cluesToPlace = cluesPerDoorMax; var edgeToPlaceDoor = GetRandomEdgeInMap(mapModel.FullMap); var allowedRoomsForClues = manager.GetValidRoomsToPlaceClueForDoor(edgeToPlaceDoor); //Doors are triggered by a chain of objectives manager.PlaceDoor(new DoorRequirements(edgeToPlaceDoor, doorName, 1)); var cluesPlaced = 0; var lastLock = doorName; while (cluesPlaced < cluesToPlace) { var objectiveName = "obj-" + doorName + "-" + cluesPlaced.ToString(); manager.PlaceObjective(new ObjectiveRequirements(allowedRoomsForClues.RandomElementUsing(random), objectiveName, 1, new List<string> { lastLock })); cluesPlaced++; lastLock = objectiveName; } var roomForObjectiveClue = allowedRoomsForClues.RandomElementUsing(random); manager.AddCluesToExistingObjective(lastLock, new List<int> { roomForObjectiveClue }); numberDoors++; } return mapModel; }
public ObjectChipModel(MapModel parent, ObjectChipPack[] objectChipPack) { _parent = parent; _objectData = new Dictionary<Point, ObjectChip>(); _objectData = objectChipPack.ToDictionary(x => new Point(x.X, x.Y), x => new ObjectChip(x)); }
public Task Update(MapModel map) { SQLiteAsyncConnection connection = new SQLiteAsyncConnection(SQLiteConfiguration.ConnectionString); _dataSources.Remove(_dataSources.First(source => source.ID.Equals(map.ID))); _dataSources.Add(map); return connection.UpdateAsync(map); }
public MapCommand(MapModel model, MapSelect mapSelect) { var mapCommand = mapSelect.GetSelectPointArray().Select(p => new MapChipPoint(p, model.MapChipModel.Get(p))); var objCommand = mapSelect.GetSelectPointArray().Select(p => new ObjectChipPoint(p, model.ObjectChipModel.Get(p))); MapChipCommand = new MapChipCommand(mapCommand); ObjectChipCommand = new ObjectChipCommand(objCommand); }
public void Draw(MapModel model, int x, int y, MapSelect mapSelect) { //IDが0の場合は何もしない if (_selected.ID != 0) { model.ObjectChipModel.Set(x, y, _selected); } }
public void IntegrationTestMapModelCanBeBuiltWithAStartVertexInACycle() { var connectivityMap = BuildStandardTestMap(); var mapModel = new MapModel(connectivityMap, 7); Assert.AreEqual(7, mapModel.StartVertex); Assert.AreEqual(2, mapModel.StartVertexNoCycleMap); }
public void EmptyPathReturnedWhenNonExistentVertexUsed() { var connectivityMap = BuildStandardTestMap(); var model = new MapModel(connectivityMap, 1); var shortestPath = model.GetPathBetweenVerticesInReducedMap(1, 20); CollectionAssert.AreEqual(shortestPath.ToList(), new List<Connection>()); }
public MapCommand(MapModel model, Clipboard clipBoard) { var pasteArea = clipBoard.GetPasteSelectArea(model); var mapCommand = pasteArea.Select(p => new MapChipPoint(p, model.MapChipModel.Get(p))).ToArray(); var objCommand = pasteArea.Select(p => new ObjectChipPoint(p, model.ObjectChipModel.Get(p))).ToArray(); MapChipCommand = new MapChipCommand(mapCommand); ObjectChipCommand = new ObjectChipCommand(objCommand); }
public void DoLockClueStressTest(int numberOfNodes, double branchingRatio, bool visualise) { var graphGenerator = new GraphGenerator(random); var randomMap = graphGenerator.GenerateConnectivityMapNoCycles(numberOfNodes, branchingRatio); var mapModel = new MapModel(randomMap, 0); if (visualise) VisualiseConnectivityGraph(mapModel); }
public MapInfo(MapInfoBuilder builder) { rooms = builder.Rooms; roomToLevelMapping = builder.RoomLevelMapping; map = builder.FullConnectivityMap; startRoom = builder.StartRoom; doors = builder.Doors; model = new MapModel(map, startRoom); BuildRoomIndices(); }
public MapChipModel(MapModel parent, MapChipPack[] mapChipPack) { _parent = parent; _mapChipList = new MapChip[parent.MapCellHeight, parent.MapCellWidth]; for (int i = 0; i < mapChipPack.Length; i++) { var y = i / parent.MapCellWidth; var x = i % parent.MapCellWidth; _mapChipList[y, x] = new MapChip(mapChipPack[i]); } }
public void ClueKnowsWhichRoomsItCanBePlacedIn() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; var clue = doorManager.PlaceDoorAndClue(new DoorRequirements(new Connection(2, 10), "lock0"), 2); CollectionAssert.AreEquivalent(new List<int>(new int []{2, 7, 8, 9}), clue.PossibleClueRoomsInFullMap); }
public void DoorKnowsItsLocationOnNonReducedMap() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoorAndClue(new DoorRequirements(new Connection(2, 10), "lock0"), 2); var door = doorManager.GetDoorById("lock0"); Assert.AreEqual(new Connection(9, 10), door.DoorConnectionFullMap); }
public MapInteraction getInteraction(MapModel mm, int x, int y) { MapInteraction mi = new MapInteraction(); if(mm.map[x,y] == "Rest") { mi.hasDialog = true; mi.dialog = "Would you like to rest?"; } else if(mm.map[x,y] == "Quest") { mi.hasDialog = true; mi.dialog = "What quest would you like to do?"; } else if (mm.map[x, y] == "DungeonMaster") { mi = new DungeonSelectInteraction(); mi.hasDialog = true; mi.hasOptions = true; mi.dialog = "What dungeon would you like to go to?"; mi.options = new List<MapOption>(); if (isDungeonUnlocked("Emergence Cavern")) { mi.options.Add(new MapOption() { text = "Emergence Cavern", value = "Emergence Cavern" }); } if (isDungeonUnlocked("Emergence Cavern B2")) { mi.options.Add(new MapOption() { text = "Emergence Cavern F2", value = "Emergence Cavern F2" }); } ((DungeonSelectInteraction)mi).maxPartySize = 3; } else if (mm.map[x, y] == "ClassTrainer") { mi = new ClassTrainerInteraction(); mi.hasDialog = true; mi.hasOptions = true; mi.dialog = "Please select the characters you want to change classes for."; mi.options = new List<MapOption>(); List<string> characters = getCharacters(); foreach (string c in characters) { mi.options.Add(new MapOption() { text = c, value = c }); } List<string> classes = getClasses(); foreach (string c in classes) { ((ClassTrainerInteraction)mi).classes.Add(new MapOption() { text = c, value = c }); } } return mi; }
public void MapWithLockedDoorAndNoCluesIsNotSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoorAndClues(new DoorRequirements(new Connection(10, 11), "lock0"), new List<int>()); GraphSolver solver = new GraphSolver(mapModel); Assert.IsFalse(solver.MapCanBeSolved()); }
public void Draw(MapModel model, int x, int y, MapSelect mapSelect) { if (mapSelect.Contains(x, y)) { //�͈͂�h��Ԃ� DrawArea(model, mapSelect); } else { //���łɓ����`�b�v���u����Ă���ꍇ��Draw��s��Ȃ� var chip = _mapChipLibrary.GetByID(_selected); model.MapChipModel.Set(x, y, chip); } }
public void build(MapModel map){ int[,] barrier = new int[map.field.GetLength(0), map.field.GetLength(1)]; for (int i = 0; i < barrier.GetLength (0); ++i) { for (int j = 0; j < barrier.GetLength (0); ++j) { int n = testIJ (map.field, i, j, MapStore.Around.Up) | testIJ (map.field, i, j, MapStore.Around.Down) | testIJ (map.field, i, j, MapStore.Around.Left) | testIJ (map.field, i, j, MapStore.Around.Right); // Debug.Log ("i" +i+ "j"+ j+":"+n); barrier [i, j] = n; } } map.barrier = barrier; }
private void VisualiseConnectivityGraph(MapModel graphModel) { var visualiser = new DoorClueGraphvizExport(graphModel); visualiser.OutputFullGraph("bsptree-full"); try { var graphVizLocation = Game.Config.Entries[Config.GraphVizLocation]; GraphVizUtils.RunGraphVizPNG(graphVizLocation, "bsptree-full"); GraphVizUtils.DisplayPNGInChildWindow("bsptree-full"); } catch (Exception) { LogFile.Log.LogEntryDebug("Can't find graphViz in config file", LogDebugLevel.High); } }
/// <summary> /// Model����N���b�v�{�[�h�ɑI��͈͂�R�s�[���� /// </summary> /// <param name="mapModel"></param> public void Copy(MapModel mapModel) { var mapSelect = mapModel.MapSelect; _mapChip = new MapChip[mapSelect.Height, mapSelect.Width]; _objectChip = new ObjectChip[mapSelect.Height, mapSelect.Width]; foreach (var p in mapSelect.GetSelectPointArray()) { var x = p.X - mapSelect.StartX; var y = p.Y - mapSelect.StartY; _mapChip[y, x] = mapModel.MapChipModel.Get(p).Clone(); _objectChip[y, x] = mapModel.ObjectChipModel.Get(p).Clone(); } }
public MapInteraction getInteraction(MapModel mm, int x, int y) { MapInteraction mi = new MapInteraction(); if (mm.map[x, y] == "Exit") { mi = new DungeonSelectInteraction(); mi.hasDialog = true; mi.hasOptions = true; mi.dialog = "Would you like to leave this dungeon?"; mi.options = new List<MapOption>(); mi.options.Add(new MapOption() { text = "Yes", value = "Ensemble Village" }); mi.options.Add(new MapOption() { text = "No", value = "" }); ((DungeonSelectInteraction)mi).isExit = true; } return mi; }
public MapCommand(Point point, MapModel model, MapSelect mapSelect) { //�lj��ꏊ���I��͈͂Ȃ�A���͈̔͂�L�^�����R�}���h�� if (mapSelect.Contains(point)) { var mapCommand = mapSelect.GetMapChipList(model.MapChipModel); var objCommand = mapSelect.GetObjectChipList(model.ObjectChipModel); MapChipCommand = new MapChipCommand(mapCommand); ObjectChipCommand = new ObjectChipCommand(objCommand); } else { MapChipCommand = new MapChipCommand(point, model.MapChipModel.Get(point)); ObjectChipCommand = new ObjectChipCommand(point, model.ObjectChipModel.Get(point)); } }
public void MapWithLockedDoorAndRecursivelyLockedTwoCluesIsSolvable() { var map = BuildStandardTestMap(); var startVertex = 1; var mapModel = new MapModel(map, startVertex); var doorManager = mapModel.DoorAndClueManager; doorManager.PlaceDoorAndClues(new DoorRequirements(new Connection(10, 11), "lock0"), new List<int>(new int[] { 6 })); doorManager.PlaceDoorAndClues(new DoorRequirements(new Connection(5, 6), "lock1"), new List<int>(new int[] { 4 })); GraphSolver solver = new GraphSolver(mapModel); Assert.IsTrue(solver.MapCanBeSolved()); }
public void PathBetweenVerticesIsEquivalentWhenTravelledInEitherDirection() { var connectivityMap = BuildStandardTestMap(); var model = new MapModel(connectivityMap, 1); var shortestPath = model.GetPathBetweenVerticesInReducedMap(15, 1).ToList(); var expectedPath = new List<Connection>(new Connection[] { new Connection(1, 2), new Connection(2, 10), new Connection(10, 11), new Connection(11, 13), new Connection(13, 15) }); //Expect to get back the same connections in a different order CollectionAssert.AreEquivalent(shortestPath, expectedPath); }
public void TemplatedMapTest() { StandardGameSetup(); //int seedToUse = 150; //Game.Random = new Random(seedToUse); Game.Random = new Random(); bool testGraphics = false; bool multiLevelDungeon = false; bool storyDungeon = true; if (testGraphics) { TestGraphics(); } else { if (multiLevelDungeon) GenerateMultiLevelDungeon(); else if(storyDungeon) GenerateStoryDungeon(); else { //Setup a single test level MapGeneratorTemplated templateGen = new MapGeneratorTemplated(); //Map templateMap = templateGen.GenerateMap2(); Map templateMap = templateGen.GenerateMapBranchRooms(); int levelNo = Game.Dungeon.AddMap(templateMap); LogFile.Log.LogEntryDebug("Player start: " + Game.Dungeon.Levels[Game.Dungeon.Player.LocationLevel].PCStartLocation, LogDebugLevel.High); //Extract connectivity map var graphModel = new MapModel(templateGen.ConnectivityMap, 0); VisualiseConnectivityGraph(graphModel); } } RunGame(); }
public bool DoLockClueStressTest(int numberOfNodes, double branchingRatio, int numberOfDoors, int numberOfCluesPerDoor, bool visualise) { var graphGenerator = new GraphGenerator(random); var randomMap = graphGenerator.GenerateConnectivityMapNoCycles(numberOfNodes, branchingRatio); var doorAndClueTester = new DoorAndObjectiveGenerator(random); var mapModel = new MapModel(randomMap, 0); if (visualise) VisualiseConnectivityGraph(mapModel); doorAndClueTester.AddDoorsAndObjectives(mapModel, numberOfDoors, numberOfCluesPerDoor); if (visualise) VisualiseConnectivityGraphWithDoors(mapModel); var mapTester = new GraphSolver(mapModel); return mapTester.MapCanBeSolved(); }
public MapModel AddDoorsAndClues(MapModel mapModel, int numberDoorsToAdd, int cluesPerDoorMax) { var manager = mapModel.DoorAndClueManager; var numberDoors = 0; while (numberDoors < numberDoorsToAdd) { var doorName = "door" + numberDoors.ToString(); var cluesToPlace = cluesPerDoorMax; var edgeToPlaceDoor = GetRandomEdgeInMap(mapModel.FullMap); var allowedRoomsForClues = manager.GetValidRoomsToPlaceClueForDoor(edgeToPlaceDoor); manager.PlaceDoor(new DoorRequirements(edgeToPlaceDoor, doorName, cluesToPlace)); for(int i = 0; i < cluesToPlace; i++) manager.AddCluesToExistingDoor(doorName, new List<int> { allowedRoomsForClues.RandomElementUsing(random) }); numberDoors++; } return mapModel; }
protected override async void LoadState( Object navigationParameter, Dictionary<String, Object> pageState) { ObservableCollection<MapModel> maps = await _mapDataAccess.GetSources(DataSourceType.Sqlite); _map = maps.First(); _mapLocationAccess.MapId = _map.ID; _mapLocations = await _mapLocationAccess.GetSources(DataSourceType.Sqlite); DefaultViewModel["Focused"] = false; DefaultViewModel["Linkable"] = false; DefaultViewModel["Markable"] = false; DefaultViewModel["UnMarkable"] = false; DefaultViewModel["FolderSelected"] = false; DefaultViewModel["MapLocationFolders"] = _mapLocationFolders; SetLocations(_mapLocations); MapView.ViewChangeEnded += MapViewViewChangeEnded; _searchPane.QuerySubmitted += SearchPaneQuerySubmitted; _searchPane.SuggestionsRequested += SearchPaneSuggestionsRequested; }
public void MapModel_IsTargetInRange_InValid_Defender_Should_Fail() { // Arrange var map = new MapModel(); map.MapXAxiesCount = 3; map.MapYAxiesCount = 3; map.MapGridLocation = new MapModelLocation[map.MapXAxiesCount, map.MapYAxiesCount]; var PlayerList = new List <PlayerInfoModel>(); var Character = new CharacterModel(); PlayerList.Add(new PlayerInfoModel(Character)); PlayerList.Add(new PlayerInfoModel(Character)); PlayerList.Add(new PlayerInfoModel(Character)); var Monster = new MonsterModel(); PlayerList.Add(new PlayerInfoModel(Monster)); PlayerList.Add(new PlayerInfoModel(Monster)); PlayerList.Add(new PlayerInfoModel(Monster)); map.PopulateMapModel(PlayerList); var start = map.GetPlayerAtLocation(0, 0); var end = map.GetPlayerAtLocation(1, 0); // Person next to them.... var CharacterBogus = new CharacterModel(); // Act var result = map.IsTargetInRange(start, new PlayerInfoModel(CharacterBogus)); // Reset // Assert Assert.AreEqual(false, result); }
private void Start() { switch (MapModel.getInstance().curLevelId) { case 108u: { WdsyOpenDoor wdsyOpenDoor = base.gameObject.AddComponent <WdsyOpenDoor>(); wdsyOpenDoor.triggerTimes = this.triggerTimes; UnityEngine.Object.Destroy(this); break; } case 109u: { OpenDoor109 openDoor = base.gameObject.AddComponent <OpenDoor109>(); openDoor.triggerTimes = this.triggerTimes; UnityEngine.Object.Destroy(this); break; } case 110u: { OpenDoor110 openDoor2 = base.gameObject.AddComponent <OpenDoor110>(); openDoor2.triggerTimes = this.triggerTimes; UnityEngine.Object.Destroy(this); break; } case 111u: { OpenDoor111 openDoor3 = base.gameObject.AddComponent <OpenDoor111>(); openDoor3.triggerTimes = this.triggerTimes; UnityEngine.Object.Destroy(this); break; } } }
public void AlgorithmDefaultTest() { var controller = new GameController(); var mapModel = new MapModel { FirstRow = new FirstRow { FirstColumn = "X", SecondColumn = "", ThirdColumn = "" }, SecondRow = new SecondRow { FirstColumn = "", SecondColumn = "", ThirdColumn = "" }, ThirdRow = new ThirdRow { FirstColumn = "", SecondColumn = "", ThirdColumn = "" } }; var gameRequest = new GameRequest { ChosenAlgorithm = "Null", MapModel = mapModel, AiSign = "O" }; var result = controller.Post(gameRequest).Result; mapModel.FirstRow.SecondColumn = "O"; Assert.AreEqual(result, mapModel); }
/// <summary> /// Remove and replace the map layers and add the scale widget on top /// </summary> private void RefreshMapLayers() { foreach (var layer in Map.Layers) { if (layer != null && layer.GetType() != typeof(Mapsui.UI.Objects.MyLocationLayer)) { Device.BeginInvokeOnMainThread(() => { Map.Layers.Remove(layer); }); } } try { MapLayers = MapModel.MakeArrayOfLayers(); Device.BeginInvokeOnMainThread(() => { AddLayersToMap(); }); } catch (Exception e) { Console.WriteLine(e); } finally { Device.BeginInvokeOnMainThread(() => { Map.Widgets.Add(new Mapsui.Widgets.ScaleBar.ScaleBarWidget(Map) { TextAlignment = Mapsui.Widgets.Alignment.Center, HorizontalAlignment = Mapsui.Widgets.HorizontalAlignment.Left, VerticalAlignment = Mapsui.Widgets.VerticalAlignment.Bottom }); }); } }
protected override async void LoadState( Object navigationParameter, Dictionary <String, Object> pageState) { ObservableCollection <MapModel> maps = await _mapDataAccess.GetSources(DataSourceType.Sqlite); _map = maps.First(); _mapLocationAccess.MapId = _map.ID; _mapLocations = await _mapLocationAccess.GetSources(DataSourceType.Sqlite); DefaultViewModel["Focused"] = false; DefaultViewModel["Linkable"] = false; DefaultViewModel["Markable"] = false; DefaultViewModel["UnMarkable"] = false; DefaultViewModel["FolderSelected"] = false; DefaultViewModel["MapLocationFolders"] = _mapLocationFolders; SetLocations(_mapLocations); MapView.ViewChangeEnded += MapViewViewChangeEnded; _searchPane.QuerySubmitted += SearchPaneQuerySubmitted; _searchPane.SuggestionsRequested += SearchPaneSuggestionsRequested; }
//private MapModel map; public PatrolAI(PirateModel.PirateType pirateType, MapModel map, ModelLink modelLink, List <SpaceModel> patrolPoints, GameController gameController) : base(pirateType, map, modelLink, gameController) { // Oisín Notes: This constructor takes in a list of patrol points, which we can use to set up the patrol patrolPath = new List <SpaceModel>(); // Oisín Notes: Should be using a for loop, but for now assume that the patrol points have three points. //var thread = new Thread(() => //{ // path between point 0 and 1 patrolPath.AddRange(AStarPathfinding.GetPathToDestination(patrolPoints[0], patrolPoints[1])); // path between point 1 and 2 patrolPath.AddRange(AStarPathfinding.GetPathToDestination(patrolPoints[1], patrolPoints[2])); // path between point 2 and 0 patrolPath.AddRange(AStarPathfinding.GetPathToDestination(patrolPoints[2], patrolPoints[0])); // patrolPath should now be one continuous line of spaces. If AStar has bugs, it might break around the edges // What space of the path we're on. currentSpaceOnPath = 0; base.SpawnPirate(patrolPath[0]); //}); //thread.Start(); }
private async Task SelectedChangedAsync(Event _event) { if (SelectedEvents.All(e => e != _event)) { foreach (var report in Reports.ToArray()) { if (report.Event.Id == _event.Id) { Reports.Remove(report); } } foreach (var explosion in Explosions.ToArray()) { if (explosion.Event.Id == _event.Id) { Explosions.Remove(explosion); } } } else { var reports = await MapModel.GetReports(_event.Id); var explosions = await MapModel.GetExplosions(_event.Id); foreach (var report in reports) { Reports.Add(report); } foreach (var explosion in explosions) { Explosions.Add(explosion); } } OnPropertyChanged(nameof(LocationList)); }
static void Main(string[] args) { XDocument doc = XDocument.Load(args[0]); Console.WriteLine(doc.Element("SpoonerPlacements").Elements("Placement").ToList().Count); IEnumerable <PropModel> childList = doc.Element("SpoonerPlacements") .Elements("Placement") .Select(i => new PropModel { ModelName = i.Element("HashName").Value, IsDynamic = i.Element("Dynamic") != null && bool.Parse(i.Element("Dynamic").Value), InitialHandle = int.Parse(i.Element("InitialHandle").Value), IsFrozen = i.Element("Frozen") != null && bool.Parse(i.Element("Frozen").Value), IsVisible = i.Element("IsVisible") != null && bool.Parse(i.Element("IsVisible").Value), Position = ExtractPosition(i.Element("PositionRotation").Elements()), Rotation = ExtractRotation(i.Element("PositionRotation").Elements()), Attachment = bool.Parse(i.Element("Attachment").Attribute("isAttached").Value) ? ExtractAttachment(i.Element("Attachment")) : null }); if (!childList.Any()) { throw new InvalidDataException(); } MapModel map = new MapModel { Position = childList.First().Position, Props = childList.ToList() }; Console.WriteLine($"{map}"); MessagePackSerializer <MapModel> serializer = MessagePackSerializer.Get <MapModel>(); using (MemoryStream buffer = new MemoryStream()) { serializer.Pack(buffer, map); File.WriteAllBytes(Path.ChangeExtension(args[0], "mp"), buffer.ToArray()); } }
public Map(MapModel <LayerModel <TileModel <SpriteInfo> > > descriptor) { _actors = new WorldDictionary <string, IActor>(); _actorCollidingObjects = new WorldDictionary <IActor, List <MapObject> >(); _playerSpawnAreas = new List <Tuple <Vector, Layer> >(); _pathFinders = new Dictionary <Layer, Pathfinder>(); _mapItems = new List <MapItem>(); this.Name = descriptor.Name; this.Bounds = descriptor.Bounds; this.Dimensions = descriptor.Dimensions; this.Dark = descriptor.Dark; this.TilesetPaths = descriptor.TilesetPaths; foreach (var layerDesc in descriptor.Layers) { Layer layer = new Layer(this, layerDesc); this.AddLayer(layerDesc.Name, layer); } // Look for spawnpoints foreach (var layer in this.Layers) { for (int x = 0; x < descriptor.Dimensions.X; x++) { for (int y = 0; y < descriptor.Dimensions.Y; y++) { if (layer.GetTile(x, y) != null && layer.GetTile(x, y).Attribute is PlayerSpawnTileAttribute) { this.AddPlayerStartArea(new Vector(x * Settings.TileSize, y * Settings.TileSize), layer); } } } } }
public MapVM() { MapModel = new MapModel(); //Events = new ObservableCollection<BE.Event> { new Event { Id = 1 }, new Event { Id = 2 }, new Event { Id = 3 } }; MapModel.PropertyChanged += (sender, args) => { OnPropertyChanged(nameof(Events)); }; SelectedEvents = new ObservableCollection <Event>(); Reports = new ObservableCollection <Report>(); Explosions = new ObservableCollection <Explosion>(); Events.CollectionChanged += (sender, args) => { OnPropertyChanged(nameof(Events)); }; LocationList.CollectionChanged += (sender, args) => { OnPropertyChanged(nameof(LocationList)); }; SelectedEventsComand = new RelayCommand <Event>(SelectedChanged); }
public void ResetRoomInfo(int gen2) { for (int i = 0; i < 200; ++i) { _objects[i] = new ObjectInfo(i); } _mapId = RoomsManager.getGenV(gen2, 1); stageType = RoomsManager.getGenV(gen2, 2); _sourceToMap = -1; Map = null; LastRound = 0; _dropCounter = 0; _isBotMode = false; _hasC4 = false; _serverRound = 0; _objsSyncRound = 0; LastObjsSync = new DateTime(); LastPlayersSync = new DateTime(); BombPosition = new Half3(); if (Config.isTestMode) { Printf.warning("A room has been reseted by server."); } }
private async Task SelectedChangedAsync(Event _event) { if (SelectedEvents.All(e => e != _event)) { foreach (var report in Reports.ToArray()) { if (report.Event.Id == _event.Id) { Reports.Remove(report); } } foreach (var Hit in Hits.ToArray()) { if (Hit.Event.Id == _event.Id) { Hits.Remove(Hit); } } } else { var reports = await MapModel.GetReports(_event.Id); var hits = await MapModel.GetHits(_event.Id); foreach (var report in reports) { Reports.Add(report); } foreach (var hit in hits) { Hits.Add(hit); } } OnPropertyChanged(nameof(LocationList)); }
public void Initialize() { try { Token = UserAccess.Register(DefaultUser.Username, DefaultUser.Password); } catch (Exception) { Token = UserAccess.Login(DefaultUser.Username, DefaultUser.Password); } var userToken = JwtHelper.DecodeToken(Token); // Delete all zones var zones = ZoneAccess.GetMyZones(); foreach (var zone in zones) { ZoneAccess.DeleteMap(zone.HashId); } DefaultZone = new MapModel() { Content = "Default Content", Level = 0, Name = "newZone2134321" }; DefaultLeader = new LeaderModel() { PlayerHashId = userToken.UserId, PlayerName = userToken.Username, Points = 100 }; DefaultZone.HashId = ZoneAccess.CreateMap(DefaultZone.Name, DefaultZone.Content, DefaultZone.Level); }
public Map CreatMapItem(int row, int col, MAPTYPE type) { if (this.dicModel.ContainsKey(type)) { MapModel model = this.dicModel[type]; MapItem item = Instantiate(model.item) as MapItem; item.gameObject.SetActive(true); item.transform.SetParent(this.transform); item.transform.localScale = new Vector3(2, 2, 2); float down = MAP_HIGHT / 2 * SACLE; float left = MAP_WIDTH / 2 * SACLE; float x = col * SACLE - left; float y = row * SACLE - down; item.transform.localPosition = new Vector3(x, y); if (item != null) { item.Parse(col, row, type); Map map = new Map(row, col, item); return(map); } } return(null); }
public ActionResult GetLocations(MapModel model) { var result = new List <MapViewModel>(); var workOrders = _repository.SearchFor <SageWorkOrder>(x => x.Status == "Open" && x.AssignmentId == 0).ToList(); var tmpLocations = workOrders.Select(x => x.Location); var itemLocations = _repository.SearchFor <SageLocation>(x => tmpLocations.Contains(x.Name)).ToList(); var assignments = _repository.SearchFor <SageAssignment>(x => !string.IsNullOrEmpty(x.Employee)).OrderByDescending(x => x.ScheduleDate).ThenByDescending(x => x.StartTime).ToList(); var employees = _repository.GetAll <SageEmployee>().ToList(); foreach (var item in workOrders) { var itemLocation = itemLocations.FirstOrDefault(l => l.Name == item.Location); if (itemLocation == null) { continue; } item.Latitude = itemLocation.Latitude; item.Longitude = itemLocation.Longitude; var assignment = assignments.FirstOrDefault(x => x.WorkOrder == item.WorkOrder); if (string.IsNullOrEmpty(assignment?.Employee)) { continue; } var employee = employees.SingleOrDefault(x => x.Employee == assignment.EmployeeId); result.Add(new MapViewModel { WorkOrder = item, DateEntered = assignment.ScheduleDate, Color = employee?.Color, Employee = assignment != null ? assignment.EmployeeId : 0 }); } return(Json(result, JsonRequestBehavior.AllowGet)); }
private void VisualiseConnectivityGraph(MapModel graphModel) { var visualiser = new DoorClueGraphvizExport(graphModel); visualiser.OutputFullGraph("bsptree-full"); visualiser.OutputClueDoorGraph("bsptree-door"); visualiser.OutputDoorDependencyGraph("bsptree-dep"); try { var graphVizLocation = Game.Config.Entries[Config.GraphVizLocation]; GraphVizUtils.RunGraphVizPNG(graphVizLocation, "bsptree-full"); GraphVizUtils.DisplayPNGInChildWindow("bsptree-full"); GraphVizUtils.RunGraphVizPNG(graphVizLocation, "bsptree-door"); GraphVizUtils.DisplayPNGInChildWindow("bsptree-door"); GraphVizUtils.RunGraphVizPNG(graphVizLocation, "bsptree-dep"); GraphVizUtils.DisplayPNGInChildWindow("bsptree-dep"); } catch (Exception) { LogFile.Log.LogEntryDebug("Can't find graphViz in config file", LogDebugLevel.High); } }
/// <summary> /// Performs processing that should be performed to conclude an editing operation /// (either during initial execution, or when loading during application startup). /// Features that were created will initially get indexed via a call to <see cref="CadastralMapModel.AddToIndex"/>. /// Followed by calls to <see cref="AddReferences"/> and <see cref="PrepareForIntersect"/>. /// If the call is being made as part of an editing session (not application startup), a call to /// <see cref="CadastralMapModel.CleanEdit"/> will be made, and the edit will be saved to the database. /// </summary> protected void Complete() { // Is this method being called as part of application startup? bool isStartup = !Object.ReferenceEquals(m_Session, CadastralMapModel.Current.WorkingSession); // Index features that were created (and ensure the map extent has been // expanded to include the new features) Feature[] feats = Features; // If we're not doing startup, attempt to associate new features with database attributes (when // we're doing startup, we do all the deserialzation, then do all attribute matching in one big swoop) if (!isStartup) { AttributeData.Load(feats); MapModel.AddToIndex(feats); // Ensure user-perceived ID objects have been indexed too MapModel.AddFeatureIds(feats); } // Point referenced features to this editing operation AddReferences(); // Mark any new topological lines as "moved" so that they will be // intersected with the map PrepareForIntersect(feats); if (!isStartup) { // Ensure the map structure has been updated to account for the new data. MapModel.CleanEdit(); // Save the edit m_Session.SaveOperation(this); } }
public MapModel getMap() { MapModel mm = new MapModel(); mm.name = "Ensemble Village"; mm.map = new string[10, 10]; mm.startX = 5; mm.startY = 5; for (var x = 0; x < 10; x++) { for (var y = 0; y < 10; y++) { mm.map[x, y] = "GrassOne"; } mm.map[x, 0] = "Wall"; mm.map[x, 9] = "Wall"; if(x != 0 && x != 9) { mm.map[x, 1] = "GrassTwo"; mm.map[x, 8] = "GrassThree"; } } for (var y = 0; y < 10; y++) { if (y != 0 && y != 9) { mm.map[1, y] = "GrassTwo"; mm.map[8, y] = "GrassThree"; } mm.map[0, y] = "Wall"; mm.map[9, y] = "Wall"; } mm.map[2, 2] = "Rest"; mm.map[2, 4] = "Quest"; mm.map[4, 2] = "DungeonMaster"; mm.map[6, 6] = "ClassTrainer"; mm.eventCollection = new EventClasses.MapEventCollectionModel(); return mm; }
/// <summary> /// Method invoked when manager receives load command /// </summary> /// <param name="load">Received load command</param> private void OnLoadCommand(Commands.Load load) { Debug.Assert(State == SimulationState.Connected); CurrentLoadCommand = load; State = SimulationState.Loading; Debug.Log("Preparing simulation"); try { //Check if downloading is already being processed, if true this may be a quick rerun of the simulation if (processedDownloads.Contains(load.MapUrl)) { return; } MapModel map; using (var db = DatabaseManager.Open()) { var sql = Sql.Builder.Where("name = @0", load.MapName); map = db.SingleOrDefault <MapModel>(sql); } if (map == null) { Debug.Log($"Downloading {load.MapName} from {load.MapUrl}"); map = new MapModel() { Name = load.MapName, Url = load.MapUrl, LocalPath = WebUtilities.GenerateLocalPath("Maps"), }; using (var db = DatabaseManager.Open()) { db.Insert(map); } processedDownloads.Add(map.Name); DownloadManager.AddDownloadToQueue(new Uri(map.Url), map.LocalPath, null, (success, ex) => { processedDownloads.Remove(map.Name); //Check if downloaded map is still valid in current load command if (CurrentLoadCommand.MapName != map.Name) { return; } if (ex != null) { map.Error = ex.Message; using (var db = DatabaseManager.Open()) { db.Update(map); } Debug.LogException(ex); } if (success) { LoadMapBundle(load, map.LocalPath); } else { var err = new Commands.LoadResult() { Success = false, ErrorMessage = ex.ToString(), }; var errData = PacketsProcessor.Write(err); var message = MessagesPool.Instance.GetMessage(errData.Length); message.AddressKey = Key; message.Content.PushBytes(errData); message.Type = DistributedMessageType.ReliableOrdered; UnicastMessage(MasterPeer.PeerEndPoint, message); } }); } else { Debug.Log($"Map {load.MapName} exists"); LoadMapBundle(load, map.LocalPath); } } catch (Exception ex) { Debug.LogException(ex); var err = new Commands.LoadResult() { Success = false, ErrorMessage = ex.ToString(), }; var errData = PacketsProcessor.Write(err); var message = MessagesPool.Instance.GetMessage(errData.Length); message.AddressKey = Key; message.Content.PushBytes(errData); message.Type = DistributedMessageType.ReliableOrdered; UnicastMessage(MasterPeer.PeerEndPoint, message); Loader.ResetLoaderScene(); } }
public bool validateDungeonSelection(MapModel mm, int x, int y, string selectedDungeon) { if (mm.map[x, y] == "DungeonMaster") { if (selectedDungeon == "Emergence Cavern") { return true; } if (selectedDungeon == "Emergence Cavern F2") { return true; } } return false; }
private static string GetMapHash(MapModel model) { return(Sha1Hash.GetSha1HashData(model.Name + model.CreatorhashId)); }
public MapInteraction getInteraction(MapModel mm, int x, int y) { MapInteraction mi = new MapInteraction(); if (mm.map[x, y] == "Rest") { mi.hasDialog = true; mi.dialog = "Would you like to rest?"; } else if (mm.map[x, y] == "Quest") { mi.hasDialog = true; mi.dialog = "What quest would you like to do?"; } else if (mm.map[x, y] == "DungeonMaster") { mi = new DungeonSelectInteraction(); mi.hasDialog = true; mi.hasOptions = true; mi.dialog = "What dungeon would you like to go to?"; mi.options = new List <MapOption>(); if (isDungeonUnlocked("Emergence Cavern")) { mi.options.Add(new MapOption() { text = "Emergence Cavern", value = "Emergence Cavern" }); } if (isDungeonUnlocked("Emergence Cavern B2")) { mi.options.Add(new MapOption() { text = "Emergence Cavern F2", value = "Emergence Cavern F2" }); } ((DungeonSelectInteraction)mi).maxPartySize = 3; } else if (mm.map[x, y] == "ClassTrainer") { mi = new ClassTrainerInteraction(); mi.hasDialog = true; mi.hasOptions = true; mi.dialog = "Please select the characters you want to change classes for."; mi.options = new List <MapOption>(); List <string> characters = getCharacters(); foreach (string c in characters) { mi.options.Add(new MapOption() { text = c, value = c }); } List <string> classes = getClasses(); foreach (string c in classes) { ((ClassTrainerInteraction)mi).classes.Add(new MapOption() { text = c, value = c }); } } return(mi); }
public void TestUpdateDifferentName() { var temp = Path.GetTempFileName(); try { File.WriteAllText(temp, "UnityFS"); long id = 12345; var existing = new MapModel() { Id = id, Name = "ExistingName", Url = "file://" + temp, LocalPath = "/local/path", Status = "Whatever", }; var request = new MapRequest() { name = "name", url = existing.Url, }; Mock.Reset(); Mock.Setup(srv => srv.Get(id, It.IsAny <string>())).Returns(existing); Mock.Setup(srv => srv.Update(It.IsAny <MapModel>())) .Callback <MapModel>(req => { Assert.AreEqual(id, req.Id); Assert.AreEqual(request.name, req.Name); Assert.AreEqual(request.url, req.Url); }) .Returns(1); MockUser.Reset(); MockDownload.Reset(); MockNotification.Reset(); var result = Browser.Put($"/maps/{id}", ctx => { ctx.JsonBody(request); }).Result; Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); Assert.That(result.ContentType.StartsWith("application/json")); var map = result.Body.DeserializeJson <MapResponse>(); Assert.AreEqual(id, map.Id); Assert.AreEqual(request.name, map.Name); Assert.AreEqual(request.url, map.Url); Assert.AreEqual(existing.Status, map.Status); // TODO: test map.PreviewUrl Mock.Verify(srv => srv.Get(id, It.IsAny <string>()), Times.Once); Mock.Verify(srv => srv.Update(It.Is <MapModel>(m => m.Id == id)), Times.Once); Mock.VerifyNoOtherCalls(); MockUser.VerifyNoOtherCalls(); MockDownload.VerifyNoOtherCalls(); MockNotification.VerifyNoOtherCalls(); } finally { File.Delete(temp); } }
public string CreateMap(MapModel mapModel) { return(_zoneService.CreateNewMap(mapModel)); }
public JsonResult List() { var mongo = new MongoHelper(); // 获取所有类别 var filter = Builders <BsonDocument> .Filter.Eq("Type", "Map"); var categories = mongo.FindMany(Constant.CategoryCollectionName, filter); var maps = mongo.FindAll(Constant.MapCollectionName); var list = new List <MapModel>(); foreach (var i in maps) { var categoryID = ""; var categoryName = ""; if (i.Contains("Category") && !i["Category"].IsBsonNull && !string.IsNullOrEmpty(i["Category"].ToString())) { var doc = categories.Where(n => n["_id"].ToString() == i["Category"].ToString()).FirstOrDefault(); if (doc != null) { categoryID = doc["_id"].ToString(); categoryName = doc["Name"].ToString(); } } var builder = new StringBuilder(); if (i["Url"].IsBsonDocument) // 立体贴图 { builder.Append($"{i["Url"]["PosX"].AsString};"); builder.Append($"{i["Url"]["NegX"].AsString};"); builder.Append($"{i["Url"]["PosY"].AsString};"); builder.Append($"{i["Url"]["NegY"].AsString};"); builder.Append($"{i["Url"]["PosZ"].AsString};"); builder.Append($"{i["Url"]["NegZ"].AsString};"); } else // 其他贴图 { builder.Append(i["Url"].AsString); } var info = new MapModel { ID = i["ID"].AsObjectId.ToString(), Name = i["Name"].AsString, CategoryID = categoryID, CategoryName = categoryName, TotalPinYin = i["TotalPinYin"].ToString(), FirstPinYin = i["FirstPinYin"].ToString(), Type = i["Type"].AsString, Url = builder.ToString().TrimEnd(';'), CreateTime = i["CreateTime"].ToUniversalTime(), UpdateTime = i["UpdateTime"].ToUniversalTime(), Thumbnail = i["Thumbnail"].ToString() }; list.Add(info); } list = list.OrderByDescending(o => o.UpdateTime).ToList(); return(Json(new { Code = 200, Msg = "获取成功!", Data = list })); }
public abstract void SendMap(MapModel map);
public void TestAddRemoteUrlDownloadFail() { long id = 123; var request = new MapRequest() { name = "remote", url = "https://github.com/lgsvl/simulator/releases/download/2019.04/lgsvlsimulator-win64-2019.04.zip", }; var uri = new Uri(request.url); var path = Path.Combine(Config.PersistentDataPath, "Map_" + Guid.NewGuid().ToString()); var downloaded = new MapModel() { Name = request.name, Url = request.url, Status = "Invalid", Id = id, }; Mock.Reset(); Mock.Setup(srv => srv.Add(It.IsAny <MapModel>())) .Callback <MapModel>(req => { Assert.AreEqual(request.name, req.Name); Assert.AreEqual(request.url, req.Url); }) .Returns(id); Mock.Setup(srv => srv.Get(id, It.IsAny <string>())).Returns(downloaded); Mock.Setup(srv => srv.Update(It.IsAny <MapModel>())).Returns(1); MockUser.Reset(); MockDownload.Reset(); MockDownload.Setup(srv => srv.AddDownload(uri, It.IsAny <string>(), It.IsAny <Action <int> >(), It.IsAny <Action <bool> >())) .Callback <Uri, string, Action <int>, Action <bool> >((u, localpath, update, complete) => { Assert.AreEqual(uri, u); update(100); complete(false); }); MockNotification.Reset(); MockNotification.Setup(srv => srv.Send(It.Is <string>(s => s == "MapDownload"), It.IsAny <object>(), It.IsAny <string>())); MockNotification.Setup(srv => srv.Send(It.Is <string>(s => s == "MapDownloadComplete"), It.IsAny <object>(), It.IsAny <string>())); var result = Browser.Post($"/maps", ctx => { ctx.JsonBody(request); }).Result; Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); Assert.That(result.ContentType.StartsWith("application/json")); var map = result.Body.DeserializeJson <MapResponse>(); Assert.AreEqual(id, map.Id); Assert.AreEqual(downloaded.Name, map.Name); Assert.AreEqual(downloaded.Url, map.Url); Assert.AreEqual("Downloading", map.Status); Mock.Verify(srv => srv.Add(It.Is <MapModel>(m => m.Name == request.name)), Times.Once); Mock.Verify(srv => srv.Get(id, It.IsAny <string>()), Times.Once); Mock.Verify(srv => srv.Update(It.Is <MapModel>(m => m.Name == downloaded.Name)), Times.Once); Mock.VerifyNoOtherCalls(); MockUser.VerifyNoOtherCalls(); MockNotification.Verify(srv => srv.Send(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()), Times.Exactly(2)); MockNotification.VerifyNoOtherCalls(); MockDownload.Verify(srv => srv.AddDownload(uri, It.IsAny <string>(), It.IsAny <Action <int> >(), It.IsAny <Action <bool> >()), Times.Once); MockDownload.VerifyNoOtherCalls(); }
public void CreateImage() { var mapDef = new MapModel() { Name = "Bot Test Map", ColorDefinition = new MapColorDefinition(), Cols = 64, Rows = 64, Id = 6, Description = "", Teams = 4, MaxPlayers = 2 }; var dc = new MapColorDefinitionDefaultColors(); var sizeRows = mapDef.ColorDefinitionRows + mapDef.Rows; var sizeCols = mapDef.ColorDefinitionCols > mapDef.Cols?mapDef.ColorDefinitionCols:mapDef.Cols; var myMap = new Bitmap(sizeCols, sizeRows); #region ColorSet myMap.SetPixel(0, 0, GetColor(dc.Block)); myMap.SetPixel(1, 0, GetColor(dc.NonBuild)); myMap.SetPixel(2, 0, GetColor(dc.BuildTeam1)); myMap.SetPixel(3, 0, GetColor(dc.BuildTeam2)); myMap.SetPixel(4, 0, GetColor(dc.BuildTeam3)); myMap.SetPixel(5, 0, GetColor(dc.BuildTeam4)); myMap.SetPixel(6, 0, GetColor(dc.Path1Team1Start)); myMap.SetPixel(6, 1, GetColor(dc.Path1Team1Way)); myMap.SetPixel(6, 2, GetColor(dc.Path1Team1end)); myMap.SetPixel(7, 0, GetColor(dc.Path2Team1Start)); myMap.SetPixel(7, 1, GetColor(dc.Path2Team1Way)); myMap.SetPixel(7, 2, GetColor(dc.Path2Team1end)); myMap.SetPixel(8, 0, GetColor(dc.Path3Team1Start)); myMap.SetPixel(8, 1, GetColor(dc.Path3Team1Way)); myMap.SetPixel(8, 2, GetColor(dc.Path3Team1end)); myMap.SetPixel(9, 0, GetColor(dc.Path4Team1Start)); myMap.SetPixel(9, 1, GetColor(dc.Path4Team1Way)); myMap.SetPixel(9, 2, GetColor(dc.Path4Team1end)); myMap.SetPixel(10, 0, GetColor(dc.Path1Team2Start)); myMap.SetPixel(10, 1, GetColor(dc.Path1Team2Way)); myMap.SetPixel(10, 2, GetColor(dc.Path1Team2end)); myMap.SetPixel(11, 0, GetColor(dc.Path2Team2Start)); myMap.SetPixel(11, 1, GetColor(dc.Path2Team2Way)); myMap.SetPixel(11, 2, GetColor(dc.Path2Team2end)); myMap.SetPixel(12, 0, GetColor(dc.Path3Team2Start)); myMap.SetPixel(12, 1, GetColor(dc.Path3Team2Way)); myMap.SetPixel(12, 2, GetColor(dc.Path3Team2end)); myMap.SetPixel(13, 0, GetColor(dc.Path4Team2Start)); myMap.SetPixel(13, 1, GetColor(dc.Path4Team2Way)); myMap.SetPixel(13, 2, GetColor(dc.Path4Team2end)); myMap.SetPixel(14, 0, GetColor(dc.Path1Team3Start)); myMap.SetPixel(14, 1, GetColor(dc.Path1Team3Way)); myMap.SetPixel(14, 2, GetColor(dc.Path1Team3end)); myMap.SetPixel(15, 0, GetColor(dc.Path2Team3Start)); myMap.SetPixel(15, 1, GetColor(dc.Path2Team3Way)); myMap.SetPixel(15, 2, GetColor(dc.Path2Team3end)); myMap.SetPixel(16, 0, GetColor(dc.Path3Team3Start)); myMap.SetPixel(16, 1, GetColor(dc.Path3Team3Way)); myMap.SetPixel(16, 2, GetColor(dc.Path3Team3end)); myMap.SetPixel(17, 0, GetColor(dc.Path4Team3Start)); myMap.SetPixel(17, 1, GetColor(dc.Path4Team3Way)); myMap.SetPixel(17, 2, GetColor(dc.Path4Team3end)); myMap.SetPixel(18, 0, GetColor(dc.Path1Team4Start)); myMap.SetPixel(18, 1, GetColor(dc.Path1Team4Way)); myMap.SetPixel(18, 2, GetColor(dc.Path1Team4end)); myMap.SetPixel(19, 0, GetColor(dc.Path2Team4Start)); myMap.SetPixel(19, 1, GetColor(dc.Path2Team4Way)); myMap.SetPixel(19, 2, GetColor(dc.Path2Team4end)); myMap.SetPixel(20, 0, GetColor(dc.Path3Team4Start)); myMap.SetPixel(20, 1, GetColor(dc.Path3Team4Way)); myMap.SetPixel(20, 2, GetColor(dc.Path3Team4end)); myMap.SetPixel(21, 0, GetColor(dc.Path4Team4Start)); myMap.SetPixel(21, 1, GetColor(dc.Path4Team4Way)); myMap.SetPixel(21, 2, GetColor(dc.Path4Team4end)); #endregion //BuildBorder for (var x = 0; x < mapDef.Rows; x++) { for (var y = 3; y < mapDef.Cols + 3; y++) { if ((x == 0 || x == mapDef.Rows - 1) || (y == 3 || y == mapDef.Cols - 1 + 3)) { myMap.SetPixel(x, y, GetColor(dc.Block)); } } } if (!Directory.Exists("exportImage")) { Directory.CreateDirectory("exportImage"); } mapDef.FileName = "exportImage\\" + mapDef.Id + "_map.png"; myMap.Save(mapDef.FileName, ImageFormat.Png); File.WriteAllText("exportImage\\" + mapDef.Id + "_map.json", JsonConvert.SerializeObject(mapDef)); }
public void Updatemap(MapModel mapModel) { _zoneService.UpdateMap(mapModel); }
public JsonResult List() { var mongo = new MongoHelper(); // 获取所有类别 var filter = Builders <BsonDocument> .Filter.Eq("Type", "Map"); var categories = mongo.FindMany(Constant.CategoryCollectionName, filter).ToList(); var docs = new List <BsonDocument>(); if (ConfigHelper.EnableAuthority) { var user = UserHelper.GetCurrentUser(); if (user != null) { var filter1 = Builders <BsonDocument> .Filter.Eq("UserID", user.ID); if (user.Name == "Administrator") { var filter2 = Builders <BsonDocument> .Filter.Exists("UserID"); var filter3 = Builders <BsonDocument> .Filter.Not(filter2); filter1 = Builders <BsonDocument> .Filter.Or(filter1, filter3); } docs = mongo.FindMany(Constant.MapCollectionName, filter1).SortBy(n => n["Name"]).ToList(); } } else { docs = mongo.FindAll(Constant.MapCollectionName).SortBy(n => n["Name"]).ToList(); } var list = new List <MapModel>(); foreach (var i in docs) { var categoryID = ""; var categoryName = ""; if (i.Contains("Category") && !i["Category"].IsBsonNull && !string.IsNullOrEmpty(i["Category"].ToString())) { var doc = categories.Where(n => n["_id"].ToString() == i["Category"].ToString()).FirstOrDefault(); if (doc != null) { categoryID = doc["_id"].ToString(); categoryName = doc["Name"].ToString(); } } var builder = new StringBuilder(); if (i["Url"].IsBsonDocument) // 立体贴图 { builder.Append($"{i["Url"]["PosX"].AsString};"); builder.Append($"{i["Url"]["NegX"].AsString};"); builder.Append($"{i["Url"]["PosY"].AsString};"); builder.Append($"{i["Url"]["NegY"].AsString};"); builder.Append($"{i["Url"]["PosZ"].AsString};"); builder.Append($"{i["Url"]["NegZ"].AsString};"); } else // 其他贴图 { builder.Append(i["Url"].AsString); } var info = new MapModel { ID = i["ID"].AsObjectId.ToString(), Name = i["Name"].AsString, CategoryID = categoryID, CategoryName = categoryName, TotalPinYin = i["TotalPinYin"].ToString(), FirstPinYin = i["FirstPinYin"].ToString(), Type = i["Type"].AsString, Url = builder.ToString().TrimEnd(';'), CreateTime = i["CreateTime"].ToUniversalTime(), UpdateTime = i["UpdateTime"].ToUniversalTime(), Thumbnail = i["Thumbnail"].ToString() }; list.Add(info); } return(Json(new { Code = 200, Msg = "Get Successfully!", Data = list })); }
public override void __Init__(Api_req_SortieBattle reqBattle, enumMapWarType warType, BattleFormationKinds1 formationId, MapModel map, bool lastCell, bool isBoss, bool changeableDeck) { _changeable_deck = changeableDeck; base.__Init__(reqBattle, warType, formationId, map, null, lastCell, isBoss); switch (warType) { case enumMapWarType.Normal: case enumMapWarType.AirBattle: DebugBattleMaker.SerializeDayBattle(_battleData); break; case enumMapWarType.Midnight: DebugBattleMaker.SerializeNightBattle(_battleData); break; case enumMapWarType.Night_To_Day: DebugBattleMaker.SerializeNightBattle(_battleData); break; } }
public virtual void __Init__(Api_req_SortieBattle reqBattle, enumMapWarType warType, BattleFormationKinds1 formationId, MapModel map, bool lastCell, bool isBoss, bool changeableDeck) { _changeable_deck = changeableDeck; base.__Init__(reqBattle, warType, formationId, map, null, lastCell, isBoss); }