Example #1
0
 /// <summary>
 /// Prints the graphical text to the console
 /// </summary>
 /// <param name="myChar">A MyChar representation of the text</param>
 public static void ShowOutput(MyChar[] myChar)
 {
     for(int index=0; index<myChar.Length; index++){
         MyChar c = myChar[index];
         System.Console.ForegroundColor = c.FrontColor;
         System.Console.BackgroundColor = c.BackgroundColor;
         System.Console.Write(c.Char);
     }
 }
Example #2
0
 public void Remove(MyChar myChar )
 {
     var result = MyCharList.Remove(myChar);
     if (!result)
         Debug.Log ("remove is failed");
     Debug.Log ("Remove is success. count is " + MyCharList.Count);
     foreach (MyChar m in MyCharList) {
         Debug.Log (m);
     }
 }
Example #3
0
        public void Does_unescaped_unicode_char()
        {
            var dto = new MyChar();

            var json = dto.ToJson();

            Assert.That(json, Is.EqualTo("{\"Char\":\"\\u0000\"}"));

            var fromDto = json.FromJson <MyChar>();

            Assert.That(fromDto.Char, Is.EqualTo(dto.Char));
        }
Example #4
0
    //создание своего персонажа на клиенте
    [RPC] public void CreatMyChar(int _chid, Vector3 _spawnPos, float spawnR)
    {
        GameObject _mch;

        _mch = Instantiate(playerFPC, _spawnPos, Quaternion.identity) as GameObject;
        _mch.transform.eulerAngles = new Vector3(0, spawnR, 0);
        //---
        myChar            = _mch.GetComponent <MyChar>();
        myChar.rpcc       = this;
        myChar.idOnServer = myIdOnServer;
        camera_main.SetActive(false);
        MenuOnCharCreated();
    }
Example #5
0
 public override bool Equals(object obj)
 {
     if (!(obj is MyChar))
     {
         return(base.Equals(obj));
     }
     else
     {
         if (IsWildCard())
         {
             return(true);
         }
         else
         {
             MyChar theChar = (MyChar)obj;
             return(theChar.IsWildCard() || base.Equals((char)theChar));
         }
     }
 }
Example #6
0
 public virtual void Effect(MyChar myChar)
 {
 }
        //Realiza Analisis Lexico y Agrupa Lexemas validos en Tokens
        public void ScanText(RichTextBox Entrada)
        {
            //Guarda valor ASCII
            char MyChar;
            //Cantidad de Caracteres
            int NCaracteres = Entrada.Text.Length;

            for (int i = 0; i < NCaracteres; i++)
            {
                MyChar = Entrada.Text[i];

                Token   TempToken  = new Token();
                String  TempLexema = "";
                Boolean Control    = true;

                //PARA SIMBOLOS INDIVIDUALES

                switch (MyChar)
                {
                case '{':
                    TempToken.setTipo(Token.TipoToken.ABRE_LLAVE);
                    TempToken.setLexema("{");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '}':
                    TempToken.setTipo(Token.TipoToken.CIERRA_LLAVE);
                    TempToken.setLexema("}");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '%':
                    TempToken.setTipo(Token.TipoToken.PORCENTAJE);
                    TempToken.setLexema("%");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '~':
                    TempToken.setTipo(Token.TipoToken.GUION_CURVO);
                    TempToken.setLexema("~");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '-':
                    TempToken.setTipo(Token.TipoToken.GUION);
                    TempToken.setLexema("-");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '>':
                    TempToken.setTipo(Token.TipoToken.SIGNO_MAYOR);
                    TempToken.setLexema(">");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '.':
                    TempToken.setTipo(Token.TipoToken.PUNTO);
                    TempToken.setLexema(".");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '*':
                    TempToken.setTipo(Token.TipoToken.SIGNO_ASTERISCO);
                    TempToken.setLexema("*");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '+':
                    TempToken.setTipo(Token.TipoToken.SIGNO_MAS);
                    TempToken.setLexema("+");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case ';':
                    TempToken.setTipo(Token.TipoToken.PUNTO_COMA);
                    TempToken.setLexema(";");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case ':':
                    TempToken.setTipo(Token.TipoToken.DOS_PUNTOS);
                    TempToken.setLexema(":");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '|':
                    TempToken.setTipo(Token.TipoToken.SIGNO_ALTERNANCIA);
                    TempToken.setLexema("|");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case '?':
                    TempToken.setTipo(Token.TipoToken.SIGNO_INTERROGACION);
                    TempToken.setLexema("?");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;

                case ',':
                    TempToken.setTipo(Token.TipoToken.COMA);
                    TempToken.setLexema(",");
                    TempToken.setID(TokenID++);
                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                    ListaTokens.AddLast(TempToken);
                    Control = false;
                    break;
                }


                if (Control)
                {
                    //PARA IDENTIFICADORES
                    //if (testAlfabeto(MyChar) && MyChar>90)
                    if (testAlfabeto(MyChar))
                    {
                        for (int j = i; j < NCaracteres; j++)
                        {
                            MyChar = Entrada.Text[j];
                            if (testAlfabeto(MyChar))
                            {
                                TempLexema = TempLexema + Entrada.Text[j];
                            }
                            else
                            {
                                i = j - 1;
                                break;
                            }
                        }
                        //HACER IDENTIFICACION DE PALABRAS RESERVADAS SI FUERA NECESARIO
                        TempToken.setTipo(Token.TipoToken.ID);
                        TempToken.setLexema(TempLexema);
                        TempToken.setID(TokenID++);
                        TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                        TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                        ListaTokens.AddLast(TempToken);
                    }

                    //PARA CADENAS

                    else if ((int)MyChar == 34)
                    {
                        i++;
                        MyChar = Entrada.Text[i];
                        for (int j = i; j < NCaracteres; j++)
                        {
                            MyChar = Entrada.Text[j];
                            if ((int)MyChar == 34)
                            {
                                i = j;
                                TempToken.setTipo(Token.TipoToken.CADENA);
                                TempToken.setLexema(TempLexema);
                                TempToken.setID(TokenID++);
                                TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                                TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                                ListaTokens.AddLast(TempToken);
                                break;
                            }
                            else if ((int)MyChar == 92)
                            {
                                MyChar = Entrada.Text[j + 1];
                                switch ((int)MyChar)
                                {
                                case 39:
                                    TempLexema = TempLexema + Entrada.Text[j] + Entrada.Text[++j];
                                    break;

                                case 34:
                                    TempLexema = TempLexema + Entrada.Text[j] + Entrada.Text[++j];
                                    break;

                                default:
                                    TempLexema = TempLexema + Entrada.Text[j];
                                    break;
                                }
                            }
                            else
                            {
                                TempLexema = TempLexema + Entrada.Text[j];
                            }
                        }
                    }

                    else if ((int)MyChar == 91)
                    {
                        i++;
                        i++;
                        MyChar = Entrada.Text[i];
                        for (int j = i; j < NCaracteres; j++)
                        {
                            MyChar = Entrada.Text[j];
                            if ((int)MyChar == 58 && Entrada.Text[j + 1] == 93)
                            {
                                i = j + 1;
                                TempToken.setTipo(Token.TipoToken.CADENA);
                                TempToken.setLexema(TempLexema);
                                TempToken.setID(TokenID++);
                                TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                                TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                                ListaTokens.AddLast(TempToken);
                                break;
                            }
                            else if ((int)MyChar == 92)
                            {
                                MyChar = Entrada.Text[j + 1];
                                switch ((int)MyChar)
                                {
                                case 110:
                                    TempLexema = TempLexema + Environment.NewLine; j++;
                                    break;

                                case 39:
                                    TempLexema = TempLexema + Entrada.Text[j] + Entrada.Text[++j];
                                    break;

                                case 34:
                                    TempLexema = TempLexema + Entrada.Text[j] + Entrada.Text[++j];
                                    break;

                                case 116:
                                    TempLexema = TempLexema + "\t"; j++;
                                    break;

                                default:
                                    TempLexema = TempLexema + Entrada.Text[j];
                                    break;
                                }
                            }
                            else
                            {
                                TempLexema = TempLexema + Entrada.Text[j];
                            }
                        }
                    }

                    //PARA COMENTARIOS MULTILINEA

                    else if (MyChar == '<')
                    {
                        i++;
                        MyChar = Entrada.Text[i];
                        if (MyChar == '!')
                        {
                            i++;
                            MyChar = Entrada.Text[i];
                            for (int j = i; j < NCaracteres; j++)
                            {
                                MyChar = Entrada.Text[j];
                                if (MyChar == '!')
                                {
                                    j++;
                                    MyChar = Entrada.Text[j];
                                    if (MyChar == '>')
                                    {
                                        i = j;
                                        TempToken.setTipo(Token.TipoToken.COMENTARIO);
                                        TempToken.setLexema(TempLexema);
                                        TempToken.setID(TokenID++);
                                        TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                                        TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                                        ListaTokens.AddLast(TempToken);
                                        break;
                                    }
                                    else
                                    {
                                        //CONTROLAR EXCEPCION DE MAL FINAL DE COMENTARIO
                                    }
                                }
                                else
                                {
                                    TempLexema = TempLexema + Entrada.Text[j];
                                }
                            }
                        }
                        else
                        {
                            //CONTROLAR EXCEPCION DE MAL INICIO DE COMENTARIO
                            i--;
                            TempLexema = TempLexema + Entrada.Text[i];
                            TempToken.setTipo(Token.TipoToken.ID);
                            TempToken.setLexema(TempLexema);
                            TempToken.setID(TokenID++);
                            TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                            TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                            ListaTokens.AddLast(TempToken);
                        }
                    }

                    //PARA COMENTARIOS DE UNA LINEA
                    else if (MyChar == '/')
                    {
                        i++;
                        MyChar = Entrada.Text[i];
                        if (MyChar == '/')
                        {
                            i++;
                            MyChar = Entrada.Text[i];
                            for (int j = i; j < NCaracteres; j++)
                            {
                                MyChar = Entrada.Text[j];

                                if ((int)MyChar == 10)
                                {
                                    i = j;
                                    TempToken.setTipo(Token.TipoToken.COMENTARIO);
                                    TempToken.setLexema(TempLexema);
                                    TempToken.setID(TokenID++);
                                    TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                                    TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                                    ListaTokens.AddLast(TempToken);
                                    break;
                                }
                                else
                                {
                                    TempLexema = TempLexema + Entrada.Text[j];
                                }
                            }
                        }
                        else
                        {
                            //CONTROLAR EXCEPCION DE MAL INICIO DE COMENTARIO
                            i--;
                            TempLexema = TempLexema + Entrada.Text[i];
                            TempToken.setTipo(Token.TipoToken.ID);
                            TempToken.setLexema(TempLexema);
                            TempToken.setID(TokenID++);
                            TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                            TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                            ListaTokens.AddLast(TempToken);
                        }
                    }

                    else if (MyChar >= 33 && MyChar <= 125)
                    {
                        TempLexema = TempLexema + Entrada.Text[i];
                        TempToken.setTipo(Token.TipoToken.ID);
                        TempToken.setLexema(TempLexema);
                        TempToken.setID(TokenID++);
                        TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                        TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                        ListaTokens.AddLast(TempToken);
                    }

                    else if (MyChar > 125)
                    {
                        Errores = true;

                        TempToken.setID(ErrorID++);
                        TempToken.setLexema(MyChar.ToString());
                        TempToken.Fila    = Entrada.GetLineFromCharIndex(i) + 1;
                        TempToken.Columna = i - Entrada.GetFirstCharIndexFromLine(TempToken.Fila - 1);
                        ListaErrores.AddLast(TempToken);
                    }
                }
            }
        }
 public Task <char> SubCharTask(MyChar data)
 {
     return(Task.FromResult(data.Data));
 }
Example #9
0
        /// <summary>
        /// Adds graphical touch to the text 
        /// </summary>
        /// <param name="structs">All the structs containing the search results</param>
        /// <returns>The graphical representation of the text</returns>
        private static MyChar[] TurnIntoChars(params ReturnStruct[][] structs)
        {
            MyChar[] mychar = new MyChar[text.Length];
            char[] charArray = text.ToCharArray();
            for (int index = 0; index < mychar.Length; index++)
            {
                mychar[index] = new MyChar();
                mychar[index].Char = charArray[index];
                mychar[index].BackgroundColor = ConsoleColor.Black;
                mychar[index].FrontColor = ConsoleColor.White;
            }
            foreach (ReturnStruct[] rArr in structs)
            {
                foreach (ReturnStruct r in rArr)
                {
                    for (int i = r.Start; i <= r.End; i++)
                    {
                        if (r.Type == MatchType.URL) mychar[i].FrontColor = ConsoleColor.Blue;
                        if (r.Type == MatchType.Date) mychar[i].FrontColor = ConsoleColor.Red;
                        if (r.Type == MatchType.Search)
                        {
                            mychar[i].BackgroundColor = ConsoleColor.Yellow;
                            mychar[i].FrontColor = ConsoleColor.Black;
                        }
                    }
                }
            }

            return mychar;
        }
Example #10
0
        void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            List <string> temp;

            if (!string.IsNullOrEmpty(Num))
            {
                string[]      regStrs = Num.Split(' ');
                StringBuilder sb      = new StringBuilder();
                foreach (string str in regStrs)
                {
                    sb.Append(@"\w*?").Append(str.Trim()).Append("|");
                }
                sb.Remove(sb.Length - 1, 1);

                temp = new List <string>(BlueList);
                int count = 0;
                foreach (string data in temp)
                {
                    if (Regex.IsMatch(data, sb.ToString(), RegexOptions.IgnoreCase))
                    {
                        if (!RedList.Contains(data))
                        {
                            RedList.Add(data);
                        }
                        BlueList.Remove(data);
                        ++count;
                    }
                }

                Window.Dispatcher.Invoke(new Action(() =>
                {
                    Window.Log(LogType.筛选, "线程" + Seq + ": 自定义数字", count, RedList.Count, BlueList.Count);
                }));
            }

            if (!string.IsNullOrEmpty(MyChar))
            {
                string[]      regStrs = MyChar.Split(' ');
                StringBuilder sb      = new StringBuilder();
                foreach (string str in regStrs)
                {
                    sb.Append(@"\w*?").Append(str.Trim()).Append("|");
                }
                sb.Remove(sb.Length - 1, 1);

                temp = new List <string>(BlueList);
                int count = 0;
                foreach (string data in temp)
                {
                    if (Regex.IsMatch(data, sb.ToString(), RegexOptions.IgnoreCase))
                    {
                        if (!RedList.Contains(data))
                        {
                            RedList.Add(data);
                        }
                        BlueList.Remove(data);
                        ++count;
                    }
                }
                Window.Dispatcher.Invoke(new Action(() =>
                {
                    Window.Log(LogType.筛选, "线程" + Seq + ": 自定义数字", count, RedList.Count, BlueList.Count);
                }));
            }
        }
Example #11
0
 public override void Effect(MyChar myChar)
 {
     myChar.IncHp(3);
 }