/// <summary> /// Remove an alias from the dict of aliases /// </summary> /// <param name="alias">The alias.</param> public void UnAlias(string alias) { //Is the alias saved if (CommandListScript.AliasDictionary.ContainsKey(alias)) { //Iterate through the lists to find it foreach (var list in CommandListScript.ValidCommandsList) { //Perform a reverse for loop on each list so that they can be changed for (int i = list.Count - 1; i > -1; i--) { //If the current string in the list is equal to the alias if (string.Equals(list[i], alias, StringComparison.CurrentCultureIgnoreCase)) { //Remove the alias from the list list.Remove(alias); //also remove it from the aliasdictionary CommandListScript.AliasDictionary.Remove(alias); //Inform the player that they've removed the alias DialogueScript.MovementText("You forgot how to use that alias."); } } } } }
/// <summary> /// Create an alias of a command and place it in a dictionary /// </summary> /// <param name="alias">The alias.</param> /// <param name="function">The function.</param> public void Alias(string alias, string function) { //First check that the alias is not already in use if (CommandListScript.AliasDictionary.ContainsKey(alias)) { DialogueScript.ErrorText("You've already used that alias for something."); return; } //Also check that there's not already an alias in place for that function. if (CommandListScript.AliasDictionary.ContainsValue(function)) { DialogueScript.ErrorText("Alias already exist."); return; } //Iterate through all the lists foreach (var list in CommandListScript.ValidCommandsList) { //Perform a reverse for loop on each list so that they can be changed for (int i = list.Count - 1; i > -1; i--) { //If the current string in the list is equal to the function the player want to make an alias from if (string.Equals(list[i], function, StringComparison.CurrentCultureIgnoreCase)) { //Add their alias to the list list.Add(alias); //Then add the alias to the aliaslist CommandListScript.AliasDictionary.Add(alias, function); //CommandListScript.AliasesList.Add(alias); //Inform the player that they've saved the command DialogueScript.MovementText( "You create an alias out of that command."); return; } } } DialogueScript.ErrorText("I'm not sure that's a thing you know how to do."); }
/// <summary> /// Print out a list of argument /// </summary> /// <param name="arg">The argument.</param> new public void List(string arg) { CheckString("List", arg); if (NoInput) { return; } if (arg.ToUpper() == "ALIAS") { //Make sure that the Player has actually saved an alias if (CommandListScript.AliasDictionary.Count != 0) { //Inform the Player that these are the aliases created DialogueScript.GameInformationText( "Here's a list of aliases. "); //Iterate through the dictionary and print out each alias alongside the function foreach (string s in CommandListScript.AliasDictionary.Keys) { string value = CommandListScript.AliasDictionary[s]; DialogueScript.MovementText(s + " : " + value); } } else { DialogueScript.ErrorText("No aliases saved."); } } if (arg.ToUpper() == "COMMANDS") { StringBuilder builtString = new StringBuilder(); foreach (var list in CommandListScript.ValidCommandsList) { foreach (string s in list) { builtString.Append(s).Append(" | "); } } foreach (string s in CommandListScript.CommandsList) { builtString.Append(s).Append(" | "); } foreach (string s in CommandListScript.CombatCommands) { builtString.Append(s).Append(" | "); } InterfaceScript.PlaceText(builtString.ToString(), new Color(0, 255, 200), 15); } if (string.Equals(arg, "emotes", StringComparison.CurrentCultureIgnoreCase)) { var builtString = new StringBuilder(); foreach (string s in CommandListScript.EmoteList) { builtString.Append(s).Append(" - "); } InterfaceScript.PlaceText(builtString.ToString(), new Color(0, 255, 200), 15); } if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat) { InterfaceScript.ActivateInput(); } }
/// <summary> /// IEnumerator that will go through the command chain until it is done, then reset everything that needs resetting to be ready for next turn. /// This is called from the function Start in the in-game commands list /// </summary> /// <returns></returns> public IEnumerator ActivatingCommands() { GameTurnController.CurrentState = GameTurnController.PlayerState.CommandChain; int textToRemove = 0; InterfaceScript.DeActivateInput(); if (DialogueScript.CommandHistoryList.Count > 0) { foreach (string s in DialogueScript.CommandHistoryList) { DialogueScript.MovementText("You perform " + s); DissectingScript.DissectPlayerInput(s, 2); InterfaceScript.CommandPoolTexts[textToRemove].color = Color.green; if (MovementCommands.MovementHappening) { while (MovementCommands.MovementHappening) { yield return(new WaitForEndOfFrame()); } } if (MetObstacle) { DialogueScript.MovementText("You appear too disoriented to continue."); MetObstacle = false; break; } if ( CommandListScript.EmoteList.Any( x => string.Equals(InterfaceScript.CommandPoolTexts[textToRemove].text, x, StringComparison.CurrentCultureIgnoreCase))) { InterfaceScript.CommandPoolTexts[textToRemove].text = ""; textToRemove++; yield return(new WaitForSeconds(1.7f)); } else { InterfaceScript.CommandPoolTexts[textToRemove].text = ""; textToRemove++; yield return(new WaitForSeconds(0.7f)); } } } ClearCommandPool(); if (LevelScript.Darkness) { LevelScript.DarknessHealthLoss(); } if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat || GameTurnController.CurrentState == GameTurnController.PlayerState.EnemyCombatTurn) { yield break; } if (SceneManager.GetActiveScene().name == "Tutorial") { GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn; InterfaceScript.ActivateInput(); yield break; } if (LevelFinished) { GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn; yield break; } if (CheckForEnemies() == 0 || SceneManager.GetActiveScene().name == "Level20") { DialogueScript.GameInformationText("It's your turn."); GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn; InterfaceScript.ActivateInput(); yield break; } DialogueScript.GameInformationText("Enemies are moving."); GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyTurn; }