// Process a Icon command protected bool ExecuteIconCommand(COMMAND_TYPE commandType_p, int iconToShow_p) { int spacingIconCount = 3; // The amount of spacing characters needed to fill the size of an icon // Check if the icon's position will be out of the UI Panel's bounds if (lineCharactersCount + spacingIconCount > nbrCharactersByLine) { // We need to add a new line before creating the icon CompleteLineWithSpacing(); hiddenText_text.text = " "; text_text.text = text_text.text + "\n"; // Insert '\n' AddNewLine(); return(false); // The icon will be created next time } // Instanciate and position a new icon if (CreateNewIcon(commandType_p, iconToShow_p)) { // Add spacing characters to fit icon size for (int i = 0; i < spacingIconCount; i++) { text_text.text = text_text.text + " "; hiddenText_text.text = hiddenText_text.text + " "; } lineCharactersCount += spacingIconCount; } // Show Controllers if (this.gameObject.activeInHierarchy) { ShowControllers(commandType_p, iconToShow_p); } return(true); }
public IMAGE_scription(IMAGE_scription main, Sprite spr, string str, COMMAND_TYPE t) : base(str, t) { this._animation = main.animation; this._timmer = main.timmer; this._imagename = main.imagename; this._image = spr; }
protected COMMAND_TYPE parseCommandType(string commandCharacter_p) { COMMAND_TYPE parsedCommand = COMMAND_TYPE.NONE; // If text is #G, #K or #M we need to display a controller icon if (commandCharacter_p == "G") { parsedCommand = COMMAND_TYPE.GAMEPAD_ICON; } else if (commandCharacter_p == "M") { parsedCommand = COMMAND_TYPE.MOUSE_ICON; } else if (commandCharacter_p == "K") { parsedCommand = COMMAND_TYPE.KEYBOARD_ICON; } else if (commandCharacter_p == "W") { parsedCommand = COMMAND_TYPE.WAIT; } else if (commandCharacter_p == "P") { parsedCommand = COMMAND_TYPE.PAUSE; } else { parsedCommand = COMMAND_TYPE.ICON; } return(parsedCommand); }
public static string ToString(this COMMAND_TYPE value) { string _type = null; switch (value) { case COMMAND_TYPE.CACHE: _type = "CACHE"; break; case COMMAND_TYPE.CACHE_CTRL: _type = "CACHE OBJECT CONTROL"; break; case COMMAND_TYPE.NON_CACHE: _type = "NON CACHE"; break; case COMMAND_TYPE.NON_CACHE_CTRL: _type = "NON CACHE OBJECT CONTROL"; break; default: _type = "NOT SUPPORTED { value : " + value + " }"; break; } return(_type); }
// 监听就否存在 public static bool FindCommandHook(COMMAND_TYPE command) { if (command <= 0 || command >= COMMAND_TYPE.COMMAND_MAX) { return(false); } return(allCB.ContainsKey(command)); }
public COMMAND(int duration, COMMAND_TYPE type, bool complite = false, bool decoded = false, bool deferred = false) { DURATIONCOMMAND = duration; TYPE = type; COMPLITE = complite; DECODED = decoded; DEFERRED = deferred; }
protected COMMAND_TYPE ReturnCommandTypeFromString(string[] newString) { COMMAND_TYPE newCommandType = COMMAND_TYPE.NONE; for (int i = 0; i < allCommands.Length; i++) { if (newString[0].Equals(allCommands[i].info.commandString, StringComparison.OrdinalIgnoreCase) || newString[0].Equals(allCommands[i].info.alternativeCommandString, StringComparison.OrdinalIgnoreCase)) { return(allCommands[i].info.commandType); } } return(newCommandType); }
// 删除监听 public static bool RemoveCommandHook(COMMAND_TYPE command) { if (command <= 0 || command >= COMMAND_TYPE.COMMAND_MAX) { return(false); } if (!allCB.ContainsKey(command)) { return(false); } else { allCB.Remove(command); return(true); } }
public void SetCommand(Command command) { if (command != null && command.type != COMMAND_TYPE.NONE && IsCancelAble(command) && (lastActCommandType == COMMAND_TYPE.NONE || command.type != lastActCommandType || !(Time.get_time() - lastActCommandTime < parameter.inputCommandIntervalTime[(int)command.type]))) { lastActCommandType = COMMAND_TYPE.NONE; lastActCommandTime = -1f; CancelInput(); if (CheckCommand(command)) { ActCommand(command); } else { nextCommand = command; } } }
protected CommandBuilder(string db_name, string table_name, bool isCount) { if (string.IsNullOrEmpty(db_name)) { throw new Exception("Invalid Db Name"); } if (string.IsNullOrEmpty(table_name)) { throw new Exception("Invalid Table Name"); } this.db_name = db_name; this.table_name = table_name; command_type = (isCount) ? COMMAND_TYPE.QUERY_COUNT : COMMAND_TYPE.NONQUERY; }
/// <summary>Send command to FileWall port.</summary> public virtual void SendCommand(COMMAND_TYPE CommandType, String path, int ruleID) { if (!IsRunning) { throw new InvalidOperationException("FileWall is stopped."); } if (CommandType == COMMAND_TYPE.ADD && string.IsNullOrEmpty(path)) { throw new ArgumentException("Path cannot be empty or null when adding.", "path"); } if (CommandType == COMMAND_TYPE.DEL && path != null) { throw new ArgumentException("Path must equal null when deleting.", "path"); } try { uint lpBytesReturned; var Command = new COMMAND { CommandType = CommandType, Path = path, ID = (uint)ruleID }; var hr = fltLib.FilterSendMessage(portHandle, ref Command, (UInt32)Marshal.SizeOf(Command), IntPtr.Zero, 0, out lpBytesReturned); Marshal.ThrowExceptionForHR(hr); } catch (COMException ex) { switch ((uint)ex.ErrorCode) { case 0xc000022b: // NT_STATUS_DUPLICATE_OBJECTID or HRESULT=0xC000022B case 0x80071392: // The same for Vista. throw new PathAlreadyAddedException(path, ex); case 0x80070490: //Element not found. (Exception from HRESULT: 0x80070490) throw new IdNotFoundException(ruleID, ex); } throw; } }
// 添加监听 public static bool AddCommandHook(COMMAND_TYPE command, CommandCallBack cb) { if (command <= 0 || command >= COMMAND_TYPE.COMMAND_MAX) { return(false); } if (!allCB.ContainsKey(command)) { List <CommandCallBack> list = new List <CommandCallBack>(); list.Add(cb); allCB.Add(command, list); } else { allCB[command].Add(cb); } return(true); }
// 发送监听信息 public static void Command(COMMAND_TYPE command, params object[] args) { if (command <= 0 || command >= COMMAND_TYPE.COMMAND_MAX) { return; } if (!allCB.ContainsKey(command)) { return; } List <CommandCallBack> list = allCB[command]; foreach (var item in list) { if (item != null) { item(args); } } }
public override void OnChangeEnableControll(bool enable) { if (!(self == null)) { CancelInput(); if (touchInfo != null && initTouch) { touchInfo = null; enableTouch = false; isInputtedTouch = false; self.SetEnableTap(false); } if (self.isGuardWalk || self.actionID == (Character.ACTION_ID) 18) { self.ActIdle(true, -1f); } moveStickInfo = null; lastActCommandType = COMMAND_TYPE.NONE; lastActCommandTime = -1f; base.OnChangeEnableControll(enable); } }
protected void Enter() { string[] commandString = SplitStringIntoParts(currentString); COMMAND_TYPE commandType = ReturnCommandTypeFromString(commandString); if (IsCustomCommandAvailable(commandString, customCommands)) { Command customCommand = ReturnCustomCommand(commandString, customCommands); customCommand.ExecuteCommand(); } else { CommandParser(commandString, commandType); } currentString = string.Empty; UI.SetNewInputText(currentString); audio.StartSFX(); }
protected CommandBuilder(string db_name, string table_name, Type object_type) { if (string.IsNullOrEmpty(db_name)) { throw new Exception("Invalid Db Name"); } if (string.IsNullOrEmpty(table_name)) { throw new Exception("Invalid Table Name"); } if (object_type == null) { throw new Exception("Invalid Object Type"); } this.db_name = db_name; this.table_name = table_name; this.object_type = object_type; command_type = COMMAND_TYPE.QUERY_RECORDS; }
public static void ManagerCommandOperation(DataResultBlock resultBlock, COMMAND_TYPE type, List <string> pars) { CSCommand.Builder command = new CSCommand.Builder(); command.Cmd = (int)type; if (pars != null && pars.Count > 0) { foreach (string param in pars) { command.AddParams(param); } } MessageContent.Builder content = new MessageContent.Builder(); content.MessageType = 1; content.CsCommand = command.Build(); SendModel send = new SendModel() { cmd = Cmd.CMD_COMMAND, content = content.Build(), }; NetMessageManage.SendMsg(send, resultBlock); }
private static void WritePushPop(StreamWriter writer, COMMAND_TYPE type, string line, string filename) { var args = line.Split(" "); if (type == COMMAND_TYPE.C_PUSH) { //push local 4 if (args[1] == "constant") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); } else if (args[1] == "static") { //Get value at foo.i writer.WriteLine("@" + filename + "." + args[2]); writer.WriteLine("D=M"); } else if (args[1] == "local") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@LCL"); writer.WriteLine("A=M+D"); writer.WriteLine("D=M"); } else if (args[1] == "argument") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@ARG"); writer.WriteLine("A=M+D"); writer.WriteLine("D=M"); } else if (args[1] == "this") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@THIS"); writer.WriteLine("A=M+D"); writer.WriteLine("D=M"); } else if (args[1] == "that") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@THAT"); writer.WriteLine("A=M+D"); writer.WriteLine("D=M"); } else if (args[1] == "pointer") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@3"); writer.WriteLine("A=A+D"); writer.WriteLine("D=M"); } else if (args[1] == "temp") { //Get i writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@5"); writer.WriteLine("A=A+D"); writer.WriteLine("D=M"); } //ADD TO Stack writer.WriteLine("@SP"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); //Increment *SP writer.WriteLine("@SP"); writer.WriteLine("M=M+1"); } else if (type == COMMAND_TYPE.C_POP) { if (args[1] == "constant") { return; } //Pop Local 3 if (args[1] == "static") { writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@" + filename + "." + args[2]); writer.WriteLine("M=D"); } else if (args[1] == "local") { writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@LCL"); writer.WriteLine("D=M+D"); writer.WriteLine("@R13"); writer.WriteLine("M=D"); writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@R13"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); } else if (args[1] == "argument") { writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@ARG"); writer.WriteLine("D=M+D"); writer.WriteLine("@R13"); writer.WriteLine("M=D"); writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@R13"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); } else if (args[1] == "this") { writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@THIS"); writer.WriteLine("D=M+D"); writer.WriteLine("@R13"); writer.WriteLine("M=D"); writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@R13"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); } else if (args[1] == "that") { writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@THAT"); writer.WriteLine("D=M+D"); writer.WriteLine("@R13"); writer.WriteLine("M=D"); writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@R13"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); } else if (args[1] == "pointer") { writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@3"); writer.WriteLine("D=A+D"); writer.WriteLine("@R13"); writer.WriteLine("M=D"); writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@R13"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); } else if (args[1] == "temp") { writer.WriteLine("@" + args[2]); writer.WriteLine("D=A"); writer.WriteLine("@5"); writer.WriteLine("D=A+D"); writer.WriteLine("@R13"); writer.WriteLine("M=D"); writer.WriteLine("@SP"); writer.WriteLine("AM=M-1"); writer.WriteLine("D=M"); writer.WriteLine("@R13"); writer.WriteLine("A=M"); writer.WriteLine("M=D"); } } }
public ITargetBlock <Tuple <int[], int[], SIGNAL_TYPE, int, COMMAND_TYPE> > CreateGuiPipeline(TaskScheduler uiTask, CancellationToken cancelToken, Dictionary <SIGNAL_TYPE, ChartArray> _charts, AggregateChart _aggregateChart) { Dictionary <SIGNAL_TYPE, ChartArray> charts = _charts; AggregateChart aggregateChart = _aggregateChart; SIGNAL_TYPE visibleSignal = SIGNAL_TYPE.RAW; float[] axisRange = new float[4]; var GuiUpdates = new ActionBlock <Tuple <int[], int[], SIGNAL_TYPE, int, COMMAND_TYPE> >(inputData => { // INPUTS: // item 1 - x data array // item 2 - y data array // item 3 - the data's signal type, i.e. RAW, STATIC_RATIO, CONTROL_SUBTRACTION, or DYNAMIC_RATIO // item 4 - the index of the indicator to which this data belongs // item 5 - command type that is put on the queue. Depending on what this is, the previous parameters are // interpreted differently. For example, if it is RESIZE, the new bitmap dimensions should be // in x and y (items 1 and 2 above). The new chartArray should be x[0], y[0], // and the new aggregate chart should be x[1], y[1]. if (inputData == null) { return; } int[] x = inputData.Item1; int[] y = inputData.Item2; SIGNAL_TYPE signalType = inputData.Item3; int indicatorNdx = inputData.Item4; COMMAND_TYPE commandType = inputData.Item5; try { switch (commandType) { case COMMAND_TYPE.RESIZE: // resize chartArray and aggregate bitmaps // find the optimal size to best fit the Actual window size int pixelWidthPerChart = (x[0] - (2 * m_margin) - ((m_cols - 1) * m_padding)) / m_cols; int pixelHeightPerChart = (y[0] - (2 * m_margin) - ((m_rows - 1) * m_padding)) / m_rows; int w = (pixelWidthPerChart * m_cols) + ((m_cols - 1) * m_padding) + (2 * m_margin); int h = (pixelHeightPerChart * m_rows) + ((m_rows - 1) * m_padding) + (2 * m_margin); if (w != m_chartArrayWidth || h != m_chartArrayHeight) { m_chartArrayWidth = w; m_chartArrayHeight = h; if (aggregateChart != null) { aggregateChart.SetBitmap(BitmapFactory.New(x[1], y[1])); } m_bitmap = BitmapFactory.New(w, h); m_overlay = BitmapFactory.New(w, h); imageBitmap.Source = m_bitmap; overlayBitmap.Source = m_overlay; foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE))) { SIGNAL_TYPE signal = (SIGNAL_TYPE)value; charts[signal].Resize(w, h, x[1], y[1]); } } // refresh chart array charts[visibleSignal].Redraw(); WriteableBitmap bitmapRef4 = m_bitmap; charts[visibleSignal].Refresh(ref bitmapRef4); // refresh aggregate chart if (aggregateChart != null) { charts[visibleSignal].RedrawAggregate(); WriteableBitmap aggregateBitmapRef4 = aggregateChart.m_bitmap; charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef4); } break; case COMMAND_TYPE.REFRESH: visibleSignal = signalType; // refresh chart array image charts[visibleSignal].Redraw(); WriteableBitmap bitmapRef1 = m_bitmap; charts[visibleSignal].Refresh(ref bitmapRef1); // refresh aggregate image if (aggregateChart != null) { charts[visibleSignal].RedrawAggregate(); WriteableBitmap aggregateBitmapRef4 = aggregateChart.m_bitmap; charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef4); // update the range labels charts[visibleSignal].GetRanges(ref axisRange, indicatorNdx); aggregateChart.SetRanges(axisRange[1], axisRange[2], axisRange[3]); } break; case COMMAND_TYPE.RESET: // clears data from all charts foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE))) { SIGNAL_TYPE signal = (SIGNAL_TYPE)value; charts[signal].Reset(); charts[signal].Redraw(); charts[signal].RedrawAggregate(); } WriteableBitmap bitmapRef2 = m_bitmap; charts[visibleSignal].Refresh(ref bitmapRef2); if (aggregateChart != null) { WriteableBitmap aggregateBitmapRef2 = aggregateChart.m_bitmap; charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef2); // update the range labels charts[visibleSignal].GetRanges(ref axisRange, indicatorNdx); aggregateChart.SetRanges(axisRange[1], axisRange[2], axisRange[3]); } m_totalPoints = 0; break; case COMMAND_TYPE.SET_SELECTED: // have to convert to a 1D bool array, because that's what is needed by the C++ function bool[] temp = new bool[m_rows * m_cols]; for (int r = 0; r < m_rows; r++) { for (int c = 0; c < m_cols; c++) { temp[r * m_cols + c] = m_chartSelected[r, c]; } } foreach (int value in Enum.GetValues(typeof(SIGNAL_TYPE))) { SIGNAL_TYPE signal = (SIGNAL_TYPE)value; // refresh chart array charts[signal].Redraw(); if (signal == visibleSignal) { WriteableBitmap bitmapRef3 = m_bitmap; charts[signal].SetSelectedCharts(temp, ref bitmapRef3); } else { charts[signal].SetSelectedCharts(temp); } if (aggregateChart != null) { // refresh aggregate chart charts[signal].RedrawAggregate(); if (signal == visibleSignal) { WriteableBitmap aggregateBitmapRef3 = aggregateChart.m_bitmap; charts[visibleSignal].RefreshAggregate(ref aggregateBitmapRef3); } } } break; } } catch (OperationCanceledException) { return; } }, new ExecutionDataflowBlockOptions { TaskScheduler = uiTask, CancellationToken = cancelToken, MaxDegreeOfParallelism = 4 }); return(GuiUpdates); }
// Display the message override protected void DisplaySingleMessage(string message_p) { message = message_p; // Calculate the width of the UI panel's message testing each line's length string[] lines = message.Split('\n'); for (int i = 0; i < lines.Length; i++) { // Calculate the number characters used for commands inside message. These characters are not displayed and must not be taken into account in the total width of the panel string[] commands = lines[i].Split('#'); int commandCharactersCount = 0; for (int j = 0; j < commands.Length; j++) { if (commands[j].Length > 1) { COMMAND_TYPE commandType = parseCommandType(commands[j][0].ToString()); if (commandType == COMMAND_TYPE.PAUSE) { commandCharactersCount++; } else if (commandType == COMMAND_TYPE.WAIT) { commandCharactersCount += 3; } // If command is Keyboard, Mouse or Gamepad icon, increment current index by one else if (commandType == COMMAND_TYPE.GAMEPAD_ICON || commandType == COMMAND_TYPE.KEYBOARD_ICON || commandType == COMMAND_TYPE.MOUSE_ICON) { int commandNumber = 0; if (int.TryParse(commands [j].ToString().Substring(1, 2), out commandNumber)) { commandCharactersCount += 3; } else { commandCharactersCount++; } } else if (commandType == COMMAND_TYPE.ICON) { commandCharactersCount += 2; } commandCharactersCount++; } } if (lines[i].Length - commandCharactersCount < nbrCharactersByLine) { if (lines[i].Length - commandCharactersCount > hiddenText_text.text.Length) { hiddenText_text.text = lines[i].Substring(0, lines[i].Length - commandCharactersCount); } } else { hiddenText_text.text = lines[i].Substring(0, nbrCharactersByLine); } } // Start displaying text StartCoroutine("OpeningMessage"); }
// Show the controller linked with the icon void ShowControllers(COMMAND_TYPE controllerType_p, int iconToShow_p) { if (linkWithController) { // Assign the controller linked to the icon ControllersManager controller = null; int controllerOffset = 0; switch (controllerType_p) { case COMMAND_TYPE.GAMEPAD_ICON: if (GamePadController != null) { controller = GamePadController; controllerOffset = OFFSET_GAMEPAD_Y_POSITION; } break; case COMMAND_TYPE.KEYBOARD_ICON: if (KeyboardController != null) { controller = KeyboardController; controllerOffset = OFFSET_KEYBOARD_Y_POSITION; } break; case COMMAND_TYPE.MOUSE_ICON: if (MouseController != null) { controller = MouseController; controllerOffset = OFFSET_MOUSE_Y_POSITION; } break; } if (controller != null) { controller.setActive(true); controller.startFadeIn(); controller.HighlightButton(iconToShow_p); if (automaticControllerPosition) { // Set Y position of the controller relative to Panel's rect and depending on the vertical alignment if (panelVAlignment == VERTICAL_ALIGNMENT.UPPER_ALIGNMENT) { controller.SetYPosition(UIPanelRect.rect.height + ControllerPadding + controllerOffset); } else if (panelVAlignment == VERTICAL_ALIGNMENT.MIDDLE) { controller.SetYPosition(UIPanelRect.rect.height / 2.0f + ControllerPadding + controllerOffset); } else if (panelVAlignment == VERTICAL_ALIGNMENT.LOWER_ALIGNMENT) { controller.SetYPosition(defaultHeight + ControllerPadding + controllerOffset); } // Set X position of the controller to be centered with Panel's rect if (panelHAlignment == ALIGNMENT.LEFT_ALIGNMENT) { controller.SetXPosition(UIPanel.transform.position.x + UIPanelRect.rect.width / 2.0f); } else if (panelHAlignment == ALIGNMENT.CENTERED) { controller.SetXPosition(0); } else if (panelHAlignment == ALIGNMENT.RIGHT_ALIGNMENT) { controller.SetXPosition(UIPanel.transform.position.x - UIPanelRect.rect.width / 2.0f); } } } } }
// Instanciate and position a new icon in the text bool CreateNewIcon(COMMAND_TYPE controllerType_p, int index_p) { Sprite newIcon; // Check if icon exists switch (controllerType_p) { case COMMAND_TYPE.GAMEPAD_ICON: if (index_p >= iconsGamePad.Length) { return(false); } newIcon = iconsGamePad[index_p]; break; case COMMAND_TYPE.KEYBOARD_ICON: if (index_p >= iconsKeyboard.Length) { return(false); } newIcon = iconsKeyboard[index_p]; break; case COMMAND_TYPE.MOUSE_ICON: if (index_p >= iconsMouse.Length) { return(false); } newIcon = iconsMouse[index_p]; break; case COMMAND_TYPE.NONE: default: if (index_p >= iconsList.Length) { return(false); } newIcon = iconsList[index_p]; break; } if (newIcon != null) { // Create, position and resize new icon GameObject img = new GameObject("Icon" + index_p); instanciatedIcons.Add(img); img.AddComponent <Image> (); img.GetComponent <Image> ().sprite = Instantiate(newIcon) as Sprite; img.GetComponent <Image> ().rectTransform.sizeDelta = iconSize; img.transform.SetParent(textList[textList.Count - 1].transform); img.transform.localScale = new Vector3(1, 1, 1); img.transform.localRotation = Quaternion.identity; if (hiddenTextRect.rect.width > 0 && hiddenText_text.text == "") { // This manage the case where an icon is the frist element to display on the message img.transform.localPosition = new Vector3(iconSize.x / 2, -(linesCount) * (hiddenTextRect.rect.height / 2.0f) * (text_text.lineSpacing), 0); } else { if (textAlignment == ALIGNMENT.RIGHT_ALIGNMENT) { // When text alignment is right, icon's position must be adjust evry time the text is updated, because position is relative to the right img.transform.localPosition = new Vector3(-iconSize.x / 2, 0, 0); relativeRightPosition.Add(hiddenTextRect.rect.width); inCurrentLine.Add(true); } else { img.transform.localPosition = new Vector3(hiddenTextRect.rect.width + iconSize.x / 2, 0, 0); } } img.GetComponent <RectTransform> ().anchorMin = new Vector2(0, 0.5f); img.GetComponent <RectTransform> ().anchorMax = new Vector2(0, 0.5f); return(true); } else { return(false); } }
// Main function where text animation is managed. At each call on this function a new character is displayed. virtual protected void ProceedNextCharacter() { // Process the waiting or pausing command if requested if (waitingDuration > 0) { waitingDuration--; return; } else if (waitingDuration == -1) { return; } // Process the next character if (message != "") { bool isACommand = false; // Check if a command must be executed if (message[currentIndexDisplayed].ToString() == "#" && currentIndexDisplayed + 2 < message.Length) { // Get the first character after #. It defines which command to execute string commandCharacter = message [currentIndexDisplayed + 1].ToString(); // Parse the character to get the corresponding command COMMAND_TYPE commandType = parseCommandType(commandCharacter); isACommand = true; // If command is Keyboard, Mouse or Gamepad icon, increment current index by one if (commandType != COMMAND_TYPE.ICON && commandType != COMMAND_TYPE.NONE) { currentIndexDisplayed++; } // Execute command if (commandType == COMMAND_TYPE.PAUSE) { ExecutePauseCommand(); } else { // Try to parse the number of the command int commandNumber = 0; if (!int.TryParse(message.Substring(currentIndexDisplayed + 1, 2), out commandNumber)) { currentIndexDisplayed++; // If next character is not a number, we cancel the process isACommand = false; return; } if (commandType == COMMAND_TYPE.GAMEPAD_ICON || commandType == COMMAND_TYPE.KEYBOARD_ICON || commandType == COMMAND_TYPE.MOUSE_ICON || commandType == COMMAND_TYPE.ICON) { if (!ExecuteIconCommand(commandType, commandNumber)) { return; // Icon will be created next time } } else if (commandType == COMMAND_TYPE.WAIT) { ExecuteWaitCommand(commandNumber); } } currentIndexDisplayed += 2; // Position index after the controller command text } else { // Display the next character text_text.text = text_text.text + message[currentIndexDisplayed]; hiddenText_text.text = hiddenText_text.text + message[currentIndexDisplayed]; lineCharactersCount++; CheckNextWordFit(); } // Check on message width to see if it wiil exceed panel's width CheckMessageWidth(); // Management for multiple line message if (lineCharactersCount >= nbrCharactersByLine && currentIndexDisplayed + 1 < message.Length) { text_text.text = text_text.text + "\n"; // Insert '\n' AddNewLine(); } else if (message[currentIndexDisplayed].Equals('\n')) { AddNewLine(); } // If text is in right alignment, we need to adjust icons position if (textAlignment == ALIGNMENT.RIGHT_ALIGNMENT) { if (!isACommand) { RightAlignmentAdjustIconPosition(); } } } // Whrn message is finished, wait for the next if (currentIndexDisplayed >= message.Length - 1) { CancelInvoke("ProceedNextCharacter"); if (automaticPageSwitch) { Invoke("OnClick", messageDuration); } } else { // Display next character currentIndexDisplayed++; } }
public STAND_IMAGE_scription(int place, IMAGE_scription main, Sprite spr, string str, COMMAND_TYPE t) : base(main, spr, str, t) { _place = place; }
public UI_IMAGE_scription(float x, float y, string imagename, COMMAND_TYPE t) : base(imagename, t) { _x = x; _y = y; }
public STAND_IMAGE_scription(int place, Sprite spr, ANIMATION_TYPE animation, string str, int time, string image_name, COMMAND_TYPE t) : base(spr, animation, str, time, image_name, t) { _place = place; }
//-------------------------------------------------------------------------- // Construction //-------------------------------------------------------------------------- public NxtMessage(COMMAND_TYPE commandType, byte command, int cbPayload) { int cbMessage = 4 + cbPayload; // two bytes for length, command type, command, payload int cbTotal = cbMessage - 2; // don't count the two length bytes this.RgbMessage = new byte[cbMessage]; this.RgbMessage[0] = (byte)(cbTotal & 0xFF); this.RgbMessage[1] = (byte)((cbTotal>>8) & 0xFF); this.RgbMessage[2] = (byte)commandType; this.RgbMessage[3] = command; this.Payload = new PayloadAccessor(this); }
public IMAGE_scription(Sprite spr, ANIMATION_TYPE animation, string str, int time, string image_name, COMMAND_TYPE t) : base(str, t) { this._image = spr; this._animation = animation; this._timmer = time; this._imagename = image_name; }
public NxtMessage(COMMAND_TYPE commandType, DIRECT_COMMAND command, int cbPayload) : this(commandType, (byte)command, cbPayload) { }
public AUDIO_scription(AudioClip audio, string str, string audioname, COMMAND_TYPE t) : base(str, t) { _audio_name = audioname; this._audio = audio; }
public AUDIO_scription(AUDIO_scription main, AudioClip audio, string str, COMMAND_TYPE t) : base(str, t) { this._audio_name = main.audio_name; _audio = audio; }
public Scription(string text, COMMAND_TYPE type) { this.text = text; this.type = type; }