public void SpawnCharacter_WithIdentityThatHasACostumeGeneratesSpawnKeybindUsingCostume() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[1]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[1].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; character.ActiveIdentity = new Identity("Spyder", HeroVirtualTabletop.Library.Enumerations.IdentityType.Costume); rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); string result = sr.ReadLine(); string valid = string.Format("Y \"target_enemy_near$$nop$$spawn_npc Model_Statesman {0} [{1}]$$target_name {0} [{1}]$$load_costume {2}\"", character.Name, character.RosterCrowd.Name, character.ActiveIdentity.Surface); Assert.AreEqual(valid, result); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void SpawnCharacter_WithMultipleIdentitiesGeneratesSpawnKeybindUsingSpecifiedActiveIdentity() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[1]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[1].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; character.ActiveIdentity = new HeroVirtualTabletop.Identities.Identity("Panzer", HeroVirtualTabletop.Library.Enumerations.IdentityType.Costume); character.ActiveIdentity = new HeroVirtualTabletop.Identities.Identity("Spyder", HeroVirtualTabletop.Library.Enumerations.IdentityType.Costume); rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); string result = sr.ReadLine(); Assert.IsTrue(result.Contains(string.Format("spawn_npc Model_Statesman {0} [{1}]$$target_name {0} [{1}]$$load_costume {2}", character.Name, character.RosterCrowd.Name, character.ActiveIdentity.Surface))); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void GenerateAndDisplay(CrowdMemberModel character, List <string> attackingCharacterNames, bool showAttackMenu, bool isSequenceView = false, bool isSweepAttackInProgress = false, bool showAttackSpreadMenu = false) { Character = character; AttackingCharacterNames = attackingCharacterNames; ShowAttackMenu = showAttackMenu; IsSequenceViewActive = isSequenceView; IsSweepAttackInProgress = isSweepAttackInProgress; ShowAttackSpreadMenu = showAttackSpreadMenu; GenerateAndDisplay(); ContextCommandFileWatcher.EnableRaisingEvents = true; }
public void GenerateMenu() { CrowdMemberModel character = Character; string fileCharacterMenu = Path.Combine(Module.Shared.Settings.Default.CityOfHeroesGameDirectory, Constants.GAME_DATA_FOLDERNAME, Constants.GAME_TEXTS_FOLDERNAME, Constants.GAME_LANGUAGE_FOLDERNAME, Constants.GAME_MENUS_FOLDERNAME, Constants.GAME_CHARACTER_MENU_FILENAME); var assembly = Assembly.GetExecutingAssembly(); var resourceName = "Module.HeroVirtualTabletop.Resources.character.mnu"; List <string> menuFileLines = new List <string>(); using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { menuFileLines.Add(line); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < menuFileLines.Count - 1; i++) { if (menuFileLines[i].StartsWith("Option \"Abort\"") && !IsSequenceViewActive) { continue; } if (menuFileLines[i].StartsWith("Option \"Execute Sweep\"") && !IsSweepAttackInProgress) { continue; } sb.AppendLine(menuFileLines[i]); } if (character.OptionGroups != null && character.OptionGroups.Count > 0) { foreach (var optionGroup in character.OptionGroups) { sb.AppendLine(string.Format("Menu \"{0}\"", optionGroup.Name)); sb.AppendLine("{"); foreach (ICharacterOption option in optionGroup.Options) { string whiteSpaceReplacedOptionGroupName = optionGroup.Name.Replace(" ", Constants.SPACE_REPLACEMENT_CHARACTER); string whiteSpaceReplacedOptionName = option.Name.Replace(" ", Constants.SPACE_REPLACEMENT_CHARACTER); sb.AppendLine(string.Format("Option \"{0}\" \"bind_save_file {1}{2}{3}.txt\"", option.Name, whiteSpaceReplacedOptionGroupName, Constants.DEFAULT_DELIMITING_CHARACTER, whiteSpaceReplacedOptionName)); } sb.AppendLine("}"); } } sb.AppendLine(menuFileLines[menuFileLines.Count - 1]); File.WriteAllText( fileCharacterMenu, sb.ToString() ); System.Threading.Thread.Sleep(200); // Delay so that the file write completes before calling the pop menu } }
public void TestInitialize() { abilityEditorViewModel = new AbilityEditorViewModel(busyServiceMock.Object, unityContainerMock.Object, messageBoxServiceMock.Object, resourceRepositoryMock.Object, eventAggregatorMock.Object); character = new CrowdMemberModel("Spyder"); //this.abilityEditorViewModel.CurrentAbility = new AnimatedAbility("Ability"); this.abilityEditorViewModel.Owner = character; this.abilityEditorViewModel.AnimationAdded += (delegate(object state, CustomEventArgs <bool> e) { this.abilityEditorViewModel.SelectedAnimationElement = state as IAnimationElement; }); }
public void ManeuverWithCameraToggleOff_ReloadsCameraSkinOnCameraThenSpawnsCharacter() { CrowdMemberModel character = new CrowdMemberModel("Spyder"); character.Position = new Mock <Position>(false, (uint)0).Object; //Camera.position = new Mock<Position>(false, (uint)0).Object; character.ToggleManueveringWithCamera(); character.ToggleManueveringWithCamera(); Assert.AreEqual(string.Format("target_enemy_near$$benpc {0}", (new Camera()).Surface), KeyBindsGenerator.generatedKeybinds[3]); Assert.AreEqual(string.Format("target_enemy_near$$nop$$spawn_npc {0} {1}$$target_name {1}$$benpc {0}", character.ActiveIdentity.Surface, character.Label), KeyBindsGenerator.generatedKeybinds[4]); }
public void UnTargetCharacter_GeneratesCorrectKeybinds() { CrowdMemberModel character = new CrowdMemberModel(); character.UnTarget(); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains("target_enemy_near")); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void TargetAndFollowCharacter_GeneratesTargetAndFollowKeybind() { CrowdMemberModel character = new CrowdMemberModel("Spyder"); character.TargetAndFollow(); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains(string.Format("target_name {0}$$follow", character.Label))); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void ManeuverWithCameraToggleOn_WithModelBasedCharacter_TargetAndFollowsAndDeletesCharacterThenCameraBecomesNPC() { CrowdMemberModel character = new CrowdMemberModel("Character"); character.Position = new Mock <Position>(false, (uint)0).Object; //Camera.position = new Mock<Position>(false, (uint)0).Object; character.ToggleManueveringWithCamera(); Assert.AreEqual(string.Format("target_name {0}$$follow", character.Label), KeyBindsGenerator.generatedKeybinds[0]); Assert.AreEqual(string.Format("target_name {0}$$delete_npc", character.Label), KeyBindsGenerator.generatedKeybinds[1]); Assert.AreEqual(string.Format("benpc {0}", character.ActiveIdentity.Surface), KeyBindsGenerator.generatedKeybinds[2]); }
protected void InitializeDefaultList(bool nestCrowd = false) { CrowdModel crowdAllChars = new CrowdModel { Name = "All Characters", Order = -1 }; CrowdModel crowd1 = new CrowdModel { Name = "Gotham City" }; CrowdMemberModel crowdMember1 = new CrowdMemberModel { Name = "Batman" }; crowd1.SavedPositions = new Dictionary <string, IMemoryElementPosition>(); CrowdModel childCrowd = new CrowdModel { Name = "The Narrows" }; CrowdMemberModel crowdMember2 = new CrowdMemberModel { Name = "Scarecrow" }; crowd1.Add(crowdMember1); crowd1.Add(childCrowd); childCrowd.Add(crowdMember2); CrowdMemberModel crowdMember4 = new CrowdMemberModel() { Name = "Robin" }; crowd1.Add(crowdMember4); CrowdModel crowd2 = new CrowdModel { Name = "League of Shadows" }; CrowdMemberModel crowdMember3 = new CrowdMemberModel { Name = "Ra'as Al Ghul" }; crowd2.Add(crowdMember3); if (nestCrowd) { crowd2.Add(childCrowd); } crowdAllChars.Add(new List <ICrowdMemberModel>() { crowdMember1, crowdMember2, crowdMember3, crowdMember4 }); this.crowdModelList = new List <CrowdModel> { crowdAllChars, crowd1, crowd2, childCrowd }; }
public void ManeuverWithCameraToggleOn_WithCostumeBasedCharacter_TargetAndFollowsAndDeletesCharacterThenLoadsCharactersCostumeInCamera() { CrowdMemberModel character = new CrowdMemberModel("Spyder"); character.ActiveIdentity = new Identity("Spyder", HeroVirtualTabletop.Library.Enumerations.IdentityType.Costume); character.Position = new Mock <Position>(false, (uint)0).Object; //Camera.position = new Mock<Position>(false, (uint)0).Object; character.ToggleManueveringWithCamera(); Assert.AreEqual(string.Format("target_name {0}$$follow", character.Label), KeyBindsGenerator.generatedKeybinds[0]); Assert.AreEqual(string.Format("target_name {0}$$delete_npc", character.Label), KeyBindsGenerator.generatedKeybinds[1]); Assert.AreEqual(string.Format("load_costume {0}", character.ActiveIdentity.Surface), KeyBindsGenerator.generatedKeybinds[2]); }
public void TargetCharacter_TargetsCharacterUsingMemoryInstancesIfItExists() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[1]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[1].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); Mock <IMemoryElement> memoryElementMock = new Mock <IMemoryElement>(); memoryElementMock.Setup(x => x.IsReal).Returns(true); character.gamePlayer = memoryElementMock.Object; rosterExplorerViewModel.ToggleTargetedCommand.Execute(null); memoryElementMock.Verify(x => x.Target(), Times.Once()); }
public void MoveCharacterToCamera_GeneratesCorrectKeyBinds() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[1]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[1].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.MoveTargetToCameraCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains(string.Format("target_name {0}$$move_npc", character.Label))); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void SpawnCharacter_UntargetEveryOtherBeforeSpawning() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[0]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[0].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains("target_enemy_near")); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void SpawnCharacter_CreatesCharacterInGame() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[0]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[0].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains("spawn_npc model_Statesman Batman")); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void SpawnCharacter_AssignsLabelWithBothCharacterAndCrowdName() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[1]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[1].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); string result = sr.ReadLine(); Assert.IsTrue(result.Contains(string.Format("spawn_npc Model_Statesman {0} [{1}]", character.Name, character.RosterCrowd.Name))); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void SpawnCharacter_WithIdentityThatHasAModelGeneratesSpawnKeybindUsingModel() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[1]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[1].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; character.ActiveIdentity = new HeroVirtualTabletop.Identities.Identity("1stSigArcIssue4_Doctor_Female", HeroVirtualTabletop.Library.Enumerations.IdentityType.Model); rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains(string.Format("spawn_npc 1stSigArcIssue4_Doctor_Female {0} [{1}]", character.Name, character.RosterCrowd.Name))); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void RemoveCharacterFromDesktop_GeneratesTargetAndDeleteKeybind() { characterExplorerViewModel.SelectedCrowdModel = characterExplorerViewModel.CrowdCollection[0]; characterExplorerViewModel.SelectedCrowdMemberModel = characterExplorerViewModel.CrowdCollection[0].CrowdMemberCollection[0] as CrowdMemberModel; characterExplorerViewModel.AddToRosterCommand.Execute(null); CrowdMemberModel character = rosterExplorerViewModel.Participants[0] as CrowdMemberModel; rosterExplorerViewModel.SelectedParticipants = new ArrayList { character }; rosterExplorerViewModel.SpawnCommand.Execute(null); rosterExplorerViewModel.ClearFromDesktopCommand.Execute(null); StreamReader sr = File.OpenText(new KeyBindsGenerator().BindFile); Assert.IsTrue(sr.ReadLine().Contains("target_name Batman$$delete_npc")); sr.Close(); File.Delete(new KeyBindsGenerator().BindFile); }
public void TestInitialize() { characterEditorVM = new CharacterEditorViewModel(busyServiceMock.Object, unityContainerMock.Object, eventAggregatorMock.Object); character = new CrowdMemberModel("Spyder"); characterEditorVM.LoadCharacter(new Tuple <ICrowdMemberModel, IEnumerable <ICrowdMemberModel> >(character, null)); }