//Since our command is {command:value}, we want to extract the name of the command and its value. private SpecialCommand GetSpecialCommand(string text) { SpecialCommand newCommand = new SpecialCommand(); //Regex to get the command name and the command value string commandRegex = "[:]"; //Split the command and its values. string[] matches = Regex.Split(text, commandRegex); //Get the command and its values. if (matches.Length > 0) { for (int i = 0; i < matches.Length; i++) { //0 = command name. 1 >= value. if (i == 0) { newCommand.Name = matches[i]; } else { newCommand.Values.Add(matches[i]); } } } else { //Oh no.... return(null); } return(newCommand); }
public ProfileBarVM(ProfileBarUC profileBarUC) { CurrentModel = new ProfileBarModel(profileBarUC.Shop); this.profileBarUC = profileBarUC; MyCommand = new SpecialCommand(); MyCommand.callComplete += UpdateShop; }
private List <SpecialCommand> BuildSpecialCommandList(string text) { List <SpecialCommand> listCommand = new List <SpecialCommand>(); string command = ""; char[] tags = { '<', '>' }; // Go through the dialogue line, get all our special commands for (int i = 0; i < text.Length; i++) { string currentChar = text[i].ToString(); //If true, we are getting a command. if (currentChar == "<") { // Go ahead and get the command. while (currentChar != ">" && i < text.Length) { currentChar = text[i].ToString(); command += currentChar; text = text.Remove(i, 1); // Remove current character. We want to get the next character in the command } // Done getting the command if (currentChar == ">") { command = command.Trim(tags); if (command.Contains("/")) { if (listCommand.Count > 0) { listCommand[listCommand.Count - 1].EndIndex = i; } } else { SpecialCommand newCommand = new SpecialCommand(command, i); listCommand.Add(newCommand); } command = ""; // Take a step back otherwise a character will be skipped i--; } else { Debug.Log("Command in dialogue line not closed."); } } } return(listCommand); }
public Task <StoreCollectionResult> CreateCollectionAsync(string name, bool overwrite, IHttpContext httpContext) { // Return error if (!IsWritable) { return(Task.FromResult(new StoreCollectionResult(DavStatusCode.PreconditionFailed))); } // Determine the destination path //var destinationPath = Path.Combine(FullPath, name).Replace("\\", "/"); var destinationPath = WebDAVPath.Combine(FullPath, name); var cmd = new SpecialCommand(destinationPath); if (cmd.IsCommand) { bool k = Cloud.Instance.CloneItem(cmd.Path, cmd.Value).Result; return(Task.FromResult(new StoreCollectionResult(k ? DavStatusCode.Created : DavStatusCode.PreconditionFailed))); } DavStatusCode result; if (name != string.Empty && FindSubItem(name) != null) { if (!overwrite) { return(Task.FromResult(new StoreCollectionResult(DavStatusCode.PreconditionFailed))); } result = DavStatusCode.NoContent; } else { result = DavStatusCode.Created; } try { // Attempt to create the directory //Directory.CreateDirectory(destinationPath); Cloud.Instance.CreateFolder(name, FullPath).Wait(); } catch (Exception exc) { // Log exception Logger.Log(LogLevel.Error, () => $"Unable to create '{destinationPath}' directory.", exc); return(null); } return(Task.FromResult(new StoreCollectionResult(result, new MailruStoreCollection(LockingManager, new Folder { FullPath = destinationPath }, IsWritable)))); }
private void ExecuteCommand(SpecialCommand command) { if (command == null) { return; } if (command.Name == ShakyCommandName) { StartCoroutine(ShakeTextAt(command.StartIndex, command.EndIndex)); } }
private void Start() { rightCom = new RightCommand(); leftCom = new LeftCommand(); attackCom = new AttackCommand(); jumpCom = new JumpCommand(); crouchCom = new CrouchCommand(); idleCom = new IdleCommand(); specialCom = new SpecialCommand(); altSpecialCom = new AltSpecialCommand(); mindControlCom = new MindControlCommand(); }
private List <SpecialCommand> BuildSpecialCommandList(string text) { List <SpecialCommand> listCommand = new List <SpecialCommand>(); string command = ""; //Current command name char[] squiggles = { '{', '}' }; //Trim these characters when the command is found. //Go through the dialogue line, get all our special commands. for (int i = 0; i < text.Length; i++) { string currentChar = text[i].ToString(); //If true, we are getting a command. if (currentChar == "{") { //Go ahead and get the command. while (currentChar != "}" && i < text.Length) { currentChar = text[i].ToString(); command += currentChar; text = text.Remove(i, 1); //Remove current character. We want to get the next character in the command. } //Done getting the command. if (currentChar == "}") { //Trim "{" and "}" command = command.Trim(squiggles); //Get Command Name and Value. SpecialCommand newCommand = GetSpecialCommand(command); //Command index position in the string. newCommand.Index = i; //Add to list. listCommand.Add(newCommand); //Reset command = ""; //Take a step back otherwise a character will be skipped. //i = 0 also works, but it means going through characters we already checked. i--; } else { Debug.Log("Command in dialogue line not closed."); } } } return(listCommand); }
private void ExecuteCommand(SpecialCommand command) { if (command == null) { return; } Debug.Log("Command " + command.Name + " found"); if (command.Name == "sound") { Debug.Log("BOOOOM! Command played a sound"); } else { Debug.Log("Command " + command.Name + " doesn't exist"); } }
/* COMMANDS */ //Used to build a list containing ALL our commands private List <SpecialCommand> BuildSpecialCommandList(string text) { List <SpecialCommand> listCommand = new List <SpecialCommand>(); string command = ""; //Current command name char[] squiggles = { '{', '}' }; //Trim these characters when the command is found. //Go through the dialogue line, get all our special commands. for (int i = 0; i < text.Length; i++) { string currentChar = text[i].ToString(); //If true, it's at the start of a command if (currentChar == "{") { //Get the full command while (currentChar != "}" && i < text.Length) { currentChar = text[i].ToString(); //Needed as we remove characters from the text. command += currentChar; //Adds each character in the command in the text to the "command" variable text = text.Remove(i, 1); //removes the current character to get to the next. This is so we'll remove the command from the text that'll be displayed } if (currentChar == "}") { command = command.Trim(squiggles); //Trims away the { and } from the actual command SpecialCommand newCommand = GetSpecialCommand(command); //Gets command name and value newCommand.Index = i; //Command index position in the string listCommand.Add(newCommand); //Adds to the list command = ""; //Reset so we can use the command again //Take a step back otherwise a character will be skipped. //i = 0 also works, but it means going through characters we already checked. i--; } else { Debug.Log("Command in dialogue line not closed."); } } } return(listCommand); }
private async Task <string?> GetResponse(CommandParameter <T> param, Command?cmd) { if (cmd == null) { return("Not sure what you were trying to do? That is not an available command. Try '!help' or '!help <command>'"); } else if (cmd.RequiresMod && !await param.SenderIsMod()) { return("You're not allowed to use that command"); } else //Get the appropriate response depending on command-type { _logger.LogInformation("Executing command: {0}", cmd.Name); return(cmd switch { SpecialCommand <CommandParameter> sp => await sp.Handle(param), SpecialCommand s => await s.Handle(), _ => cmd.Response, });
//Where you will execute your command! private void ExecuteCommand(SpecialCommand command, TMP_Text teshMeshPro) { if (command == null) { return; } Debug.Log(LogUtility.MakeLogStringFormat("GUIDialogue", "Command " + command.Name + " found!")); if (command.Name == "sound") { Debug.Log("BOOOOM! Command played a sound."); } else if (command.Name == "color") { if (command.Values[0] != "end") { c1 = new Color32(255, 0, 0, 255); isColorizing = true; } else { isColorizing = false; } } else if (command.Name == "action") { if (command.Values[0] == "continue") { CurrentTimelineManager.PlayNextTimeline(); } else if (command.Values[0] == "end") { CurrentTimelineManager.isTheLastDialogue = true; } } }
public void executeSpecialCommand(object providerDeviceId, SpecialCommand command, object value) { // na }
public SpecialViewModel(int userId, ParkingManager pk) { _userId = userId; _pk = pk; CalculateMaxQuantity = new SpecialCommand(new Action(Calculate)); }
private void ExecuteCommand(SpecialCommand command) { if (command == null) { return; } Debug.Log("Command: " + command.Name + " Was started"); //Dialouge if (command.Name == "Speed") { commandTextSpeedMultiplier = float.Parse(command.Values[0]); } if (command.Name == "FullWords") { if (command.Values.Count > 0) { if (int.Parse(command.Values[0]) == 0) { displayFullWordAtTheTime = false; } else { displayFullWordAtTheTime = true; } } else { displayFullWordAtTheTime = true; } } if (command.Name == "LockInput") { lockPlayerInputForRestOfSentence = true; } if (command.Name == "UnlockInput") { lockPlayerInputForRestOfSentence = false; } if (command.Name == "NextSentenceAuto") { goToNextSentenceAutomatically = true; } if (command.Name == "Pause") { if (command.Values.Count > 0) { pauseTime = float.Parse(command.Values[0]); } } //Audio if (command.Name == "Sound") { ServiceLocator.GetAudio().PlaySound(command.Values[0], SoundType.normal); } //FXs if (command.Name == "ScreenShake") { if (command.Values.Count <= 0) { ServiceLocator.GetScreenShake().StartScreenShake(2f, 1f); } else if (command.Values.Count <= 1) { Debug.Log(command.Values[0]); ServiceLocator.GetScreenShake().StartScreenShake(float.Parse(command.Values[0]), 1f); } else { Debug.Log(command.Values[0]); Debug.Log(command.Values[1]); ServiceLocator.GetScreenShake().StartScreenShake(float.Parse(command.Values[0]), float.Parse(command.Values[1])); } } if (command.Name == "ScreenFlash") { if (command.Values.Count <= 0) { ServiceLocator.GetScreenShake().StartScreenFlash(0.05f, 0.3f); } else if (command.Values.Count <= 1) { ServiceLocator.GetScreenShake().StartScreenFlash(int.Parse(command.Values[0]), 1f); } else { ServiceLocator.GetScreenShake().StartScreenFlash(float.Parse(command.Values[0]), float.Parse(command.Values[1])); } } }