public void TestProcessAdventurerMoveForwardToBlockedCell() { char move = 'A'; List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - N - AADADAGGA", "A - Sara - 2 - 0 - N - AADADAGGA", "A - Mara - 2 - 2 - E - AADADAGGA", "A - Fara - 2 - 3 - S - AADADAGGA", "A - Tara - 0 - 1 - O - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[0], map, move); Assert.AreEqual(1, map.Adventurers[0].X); Assert.AreEqual(1, map.Adventurers[0].Y); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[1], map, move); Assert.AreEqual(2, map.Adventurers[1].X); Assert.AreEqual(0, map.Adventurers[1].Y); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[2], map, move); Assert.AreEqual(2, map.Adventurers[2].X); Assert.AreEqual(2, map.Adventurers[2].Y); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[3], map, move); Assert.AreEqual(2, map.Adventurers[3].X); Assert.AreEqual(3, map.Adventurers[3].Y); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[4], map, move); Assert.AreEqual(0, map.Adventurers[4].X); Assert.AreEqual(1, map.Adventurers[4].Y); }
public void pillageCity() { cityPillage.SetActive(false); cityRansom.SetActive(false); cityRetreat.SetActive(false); cityMenuButtons(true); closeDialogue(PanelType.city); MapManagement.createBattleScene(curInteractedParty, Player.mainParty.battlefieldTypes); }
public void pillageTown() { townMenuButtons(true); townPillage.SetActive(false); townRansom.SetActive(false); townRetreat.SetActive(false); MapManagement.createBattleScene(curInteractedParty, Player.mainParty.battlefieldTypes); closeDialogue(PanelType.town); }
public void TestAdventurerCanNotMoveForwardToCellOccupiedByOtherAdventurer() { List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - O - AADADAGGA", "A - Sara - 0 - 1 - N - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); Assert.IsFalse(AdventurerManagement.AdventurerCanMoveForward(map?.Adventurers[0], map)); }
public void TestAdventurerCanMoveForwardToFreeCell() { List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - S - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); Assert.IsTrue(AdventurerManagement.AdventurerCanMoveForward(map?.Adventurers[0], map)); }
public void TestCreateMapWithNullInitialData() { List <string> lines = null; Map map = MapManagement.CreateMapWithInitialData(lines); Assert.NotNull(map); Assert.AreEqual(0, map?.Width); // map width = 0 Assert.AreEqual(0, map?.Height); // map height = 0 Assert.IsNull(map?.Cells); // no cells in the map Assert.IsNull(map?.Adventurers); // no adventurers in the map }
public void TestProcessAdventurerTurnRight() { char move = 'D'; List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - N - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[0], map, move); Assert.AreEqual(Orientation.E, map.Adventurers[0].Orientation); }
public void TestSaveSimulation() { string path = @".\Data\Simulation_Results.txt"; List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - S - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); MapManagement.SimulateTreasureSearch(map); Assert.AreEqual(Messages.FileSavedOK + path, FileManagement.SaveSimulation(map, path)); }
//获取图层选择的选择框中的图层的名字 private void barEditItem1_EditValueChanged(object sender, EventArgs e) { try { string strLayerName = this.barEditItem1.EditValue.ToString(); pCurrentLayer = MapManagement.GetLayerByName(pMap, strLayerName) as IFeatureLayer; pEngineEditLayers.SetTargetLayer(pCurrentLayer, 0); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "异常"); } }
public void TestProcessAdventurerMoveForwardToFreeCell() { char move = 'A'; List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - S - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[0], map, move); Assert.AreEqual(1, map.Adventurers[0].X); Assert.AreEqual(2, map.Adventurers[0].Y); }
public void TestCreateMapWithInitialData() { List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - S - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); Assert.NotNull(map); Assert.AreEqual(2, map?.Cells?.FindAll(c => c.Type == CellType.Mountain)?.Count); // 2 mountains Assert.AreEqual(2, map?.Cells?.FindAll(c => c.Type == CellType.Treasure)?.Count); // 2 treasures Assert.AreEqual(8, map?.Cells?.FindAll(c => c.Type == CellType.Neutral)?.Count); // 8 neutral cells Assert.AreEqual(1, map?.Adventurers?.Count); // 1 adventurer }
public void TestAdventurerCanNotMoveForwardToCellOutOfMapEdges() { List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 0 - N - AADADAGGA", "A - Sara - 0 - 3 - S - AADADAGGA", "A - Fara - 0 - 1 - O - AADADAGGA", "A - Tara - 2 - 1 - E - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); Assert.IsFalse(AdventurerManagement.AdventurerCanMoveForward(map?.Adventurers[0], map)); Assert.IsFalse(AdventurerManagement.AdventurerCanMoveForward(map?.Adventurers[1], map)); Assert.IsFalse(AdventurerManagement.AdventurerCanMoveForward(map?.Adventurers[2], map)); Assert.IsFalse(AdventurerManagement.AdventurerCanMoveForward(map?.Adventurers[3], map)); }
public void TestSimulateTreasureSearch() { List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 1 - S - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); MapManagement.SimulateTreasureSearch(map); Assert.AreEqual(0, map?.Adventurers[0].X); Assert.AreEqual(3, map?.Adventurers[0].Y); Assert.AreEqual(Orientation.S, map?.Adventurers[0].Orientation); Assert.AreEqual(3, map?.Adventurers[0].CollectedTreasure); }
public void TestProcessAdventurerMoveForwardToTreasureCell() { char move = 'A'; List <string> lines = new List <string> { "C - 3 - 4", "M - 1 - 0", "M - 2 - 1", "T - 0 - 3 - 2", "T - 1 - 3 - 3", "A - Lara - 1 - 2 - S - AADADAGGA" }; Map map = MapManagement.CreateMapWithInitialData(lines); AdventurerManagement.ProcessAdventurerMove(map.Adventurers[0], map, move); Assert.AreEqual(1, map.Adventurers[0].X); Assert.AreEqual(3, map.Adventurers[0].Y); Assert.AreEqual(1, map.Adventurers[0].CollectedTreasure); Assert.AreEqual(2, map.Cells.FirstOrDefault(c => c.X == 1 && c.Y == 3)?.TreasureAmount); }
public void ambushNPC() { makeSurePanel.SetActive(false); int rand = (int)UnityEngine.Random.Range(1, 100); Debug.Log(rand); if (ambushR >= rand) { closeDialogue(PanelType.NPC); MapManagement.createBattleScene(curInteractedParty, Player.mainParty.battlefieldTypes); } else { npcAmbush.GetComponent <Button>().interactable = false; } } //TODO: based on INT
static void Main() { string mapFilePath = string.Empty; while (!File.Exists(mapFilePath)) { Console.WriteLine(Messages.EnterMapFilePath); mapFilePath = Console.ReadLine(); } (bool dataAreValid, string msg) = FileManagement.DataLinesAreValid(mapFilePath); if (dataAreValid) { msg = MapManagement.Process(mapFilePath); } Console.WriteLine(msg); Console.ReadKey(); }
private void Awake() { finishedLoading = false; mapManagement = this; if (cities == null) { cities = new List <City>(); } if (towns == null) { towns = new List <Town>(); } if (parties == null) { parties = new List <Party>(); } if (objectives == null) { objectives = new List <Objective>(); } }
public void attackNPC() { makeSurePanel.SetActive(false); closeDialogue(PanelType.NPC); MapManagement.createBattleScene(curInteractedParty, Player.mainParty.battlefieldTypes); }
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { pEngineEditor = new EngineEditorClass(); MapManagement.EngineEditor = pEngineEditor; pEngineEditTask = pEngineEditor as IEngineEditTask; pEngineEditLayers = pEngineEditor as IEngineEditLayers; pMap = Variable.pMapFrm.mainMapControl.Map; pActiveView = pMap as IActiveView; pLayerlist = MapManagement.GetMapLayers(pMap); try { if (pLayerlist == null || pLayerlist.Count == 0) { MessageBox.Show("请在主视图中加载编辑图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } for (int i = 0; i < pLayerlist.Count; i++) { ((DevExpress.XtraEditors.Repository.RepositoryItemComboBox) this.barEditItem1.Edit).Items.Add(pLayerlist[i].Name); } this.barEditItem1.EditValue = ((DevExpress.XtraEditors.Repository.RepositoryItemComboBox) this.barEditItem1.Edit).Items[0]; pMap.ClearSelection(); pActiveView.Refresh(); //设置数据管理中要素管理未开始编辑状态,图层选择、添加要素、选择编辑要素、要素属性编辑、结束编辑等功能变成正常状态,使得可以操作。 barEditItem1.Enabled = true; barButtonItem12.Enabled = true; barButtonItem14.Enabled = true; barButtonItem13.Enabled = true; barButtonItem15.Enabled = true; barButtonItem4.Enabled = true; barButtonItem20.Enabled = true; barButtonItem22.Enabled = true; barButtonItem21.Enabled = true; barButtonItem23.Enabled = true; if (pEngineEditor.EditState != esriEngineEditState.esriEngineStateNotEditing) { return; } if (pCurrentLayer == null) { return; } IDataset pDataSet = pCurrentLayer.FeatureClass as IDataset; IWorkspace pWorkspace = pDataSet.Workspace; if (pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) { pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; } else { pEngineEditor.EditSessionMode = esriEngineEditSessionMode.esriEngineEditSessionModeVersioned; } pEngineEditTask = pEngineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask"); pEngineEditor.CurrentTask = pEngineEditTask; pEngineEditor.EnableUndoRedo(true); pEngineEditor.StartEditing(pWorkspace, pMap); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常"); } }