Example #1
0
        public static string[] SplitedString; // The Splited String
        public static void ReadAsync(string Command)
        {
            SplitedString = Command.Split(' '); // The Splited String

            // Format the current Taiyou Line
            for (int i = 0; i < SplitedString.Length; i++)
            {
                // FORMATATION
                SplitedString[i] = SplitedString[i].Replace("%N", Environment.NewLine); // New Line

                for (int i2 = 0; i2 < GlobalVars_String_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$STRING_" + GlobalVars_String_Names[i2] + "$", GlobalVars_String_Content[i2].Replace(" ", ""));
                }
                for (int i2 = 0; i2 < GlobalVars_Bool_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$BOOL_" + GlobalVars_Bool_Names[i2] + "$", Convert.ToString(GlobalVars_Bool_Content[i2]));
                }
                for (int i2 = 0; i2 < GlobalVars_Int_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$INT_" + GlobalVars_Int_Names[i2] + "$", Convert.ToString(GlobalVars_Int_Content[i2]));
                }
                for (int i2 = 0; i2 < GlobalVars_Float_Names.Count; i2++)
                {
                    SplitedString[i] = SplitedString[i].Replace("$FLOAT_" + GlobalVars_Float_Names[i2] + "$", Convert.ToString(GlobalVars_Float_Content[i2]));
                }



                if (SplitedString[i].Contains("%RANDOM%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    Random   RND = new Random();

                    SplitedString[i] = SplitedString[i].Replace("%RANDOM%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(RND.Next(Convert.ToInt32(Arg1), Convert.ToInt32(Arg2))));
                }

                if (SplitedString[i].Contains("%ADD%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');

                    string Arg1       = SubSplitedString[2]; // Number 1
                    string Arg2       = SubSplitedString[3]; // Number 2
                    int    MathResult = Convert.ToInt32(Arg1) + Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%ADD%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%DECREASE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = Convert.ToInt32(Arg1) - Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%DECREASE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%MULTIPLY%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // MultiplyTimes
                    int      MathResult       = Convert.ToInt32(Arg1) * Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%MULTIPLY%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%DIVIDE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = Convert.ToInt32(Arg1) / Convert.ToInt32(Arg2);

                    SplitedString[i] = SplitedString[i].Replace("%DIVIDE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%DIFERENCE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = Math.Abs(Convert.ToInt32(Arg1) - Convert.ToInt32(Arg2));


                    SplitedString[i] = SplitedString[i].Replace("%DIFERENCE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%PERCENTAGE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // Number 1
                    string   Arg2             = SubSplitedString[3]; // Number 2
                    int      MathResult       = (int)Math.Round((double)(100 * Convert.ToInt32(Arg1)) / Convert.ToInt32(Arg2));


                    SplitedString[i] = SplitedString[i].Replace("%PERCENTAGE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(MathResult));
                }

                if (SplitedString[i].Contains("%LOCATION_OF%"))
                {
                    string[]  SubSplitedString = SplitedString[i].Split('%');
                    string    Arg1             = SubSplitedString[2]; // Render Type
                    string    Arg2             = SubSplitedString[3]; // Render Name
                    string    Arg3             = SubSplitedString[4]; // Value Type
                    Rectangle RectObject       = GlobalVars_Rectangle_Content[RenderQuee.Main.RenderCommand_RectangleVar.IndexOf(Arg2)];

                    int RenderNameIndex = -1;
                    if (Arg1 == "SPRITE")
                    {
                        RenderNameIndex = RenderQuee.Main.RenderCommand_Name.IndexOf(Arg2);
                    }
                    ;
                    if (Arg1 == "TEXT")
                    {
                        RenderNameIndex = RenderQuee.Main.TextRenderCommand_Name.IndexOf(Arg2);
                    }
                    ;
                    int ValToReturn = 0;
                    if (Arg3 == "X" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.X;
                    }
                    ;
                    if (Arg3 == "X" && Arg1 == "TEXT")
                    {
                        ValToReturn = RenderQuee.Main.TextRenderCommand_X[RenderNameIndex];
                    }

                    if (Arg3 == "Y" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.Y;
                    }
                    ;
                    if (Arg3 == "Y" && Arg1 == "TEXT")
                    {
                        ValToReturn = RenderQuee.Main.TextRenderCommand_Y[RenderNameIndex];
                    }
                    ;

                    if (Arg3 == "W" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.Width;
                    }
                    ;
                    if (Arg3 == "H" && Arg1 == "SPRITE")
                    {
                        ValToReturn = RectObject.Height;
                    }
                    ;


                    SplitedString[i] = SplitedString[i].Replace("%LOCATION_OF%" + Arg1 + "%" + Arg2 + "%" + Arg3 + "%", Convert.ToString(ValToReturn));
                }

                if (SplitedString[i].Contains("%COLOR_VALUE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   Arg1             = SubSplitedString[2]; // ColorVarName
                    string   Arg2             = SubSplitedString[3]; // CodeName
                    int      ColorVarIndex    = GlobalVars_Color_Names.IndexOf(Arg1);
                    string   ValToReturn      = "0";
                    if (ColorVarIndex == -1)
                    {
                        throw new Exception("Color Variable [" + Arg1 + "] does not exist.");
                    }

                    if (Arg2.Equals("R"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].R);
                    }
                    ;
                    if (Arg2.Equals("G"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].G);
                    }
                    ;
                    if (Arg2.Equals("B"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].B);
                    }
                    ;
                    if (Arg2.Equals("A"))
                    {
                        ValToReturn = Convert.ToString(GlobalVars_Color_Content[ColorVarIndex].A);
                    }
                    ;
                    if (Arg2.Equals("ALL"))
                    {
                        ValToReturn = GlobalVars_Color_Content[ColorVarIndex].R + "," + GlobalVars_Color_Content[ColorVarIndex].G + "," + GlobalVars_Color_Content[ColorVarIndex].B + "," + GlobalVars_Color_Content[ColorVarIndex].A;
                    }
                    ;


                    SplitedString[i] = SplitedString[i].Replace("%COLOR_VALUE%" + Arg1 + "%" + Arg2 + "%", Convert.ToString(ValToReturn));
                }


                if (SplitedString[i].Contains("%LIST_VALUE%"))
                {
                    string[] SubSplitedString = SplitedString[i].Split('%');
                    string   ValToReturn      = "null_or_incorrect";
                    string   Arg1             = SubSplitedString[2]; // ListType
                    string   Arg2             = SubSplitedString[3]; // ListName
                    string   Arg3             = SubSplitedString[4]; // Index

                    if (Arg1.Equals("STRING"))
                    {
                        int ListNameIndex = GlobalVars_StringList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        ValToReturn = GlobalVars_StringList_Content[ListNameIndex][Index];
                    }

                    if (Arg1.Equals("INT"))
                    {
                        int ListNameIndex = GlobalVars_IntList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        ValToReturn = Convert.ToString(GlobalVars_IntList_Content[ListNameIndex][Index]);
                    }

                    if (Arg1.Equals("COLOR"))
                    {
                        int ListNameIndex = GlobalVars_ColorList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        Color  ColorGetted       = GlobalVars_ColorList_Content[ListNameIndex][Index];
                        string ColorCodeToReturn = ColorGetted.R + "," + ColorGetted.G + "," + ColorGetted.B + "," + ColorGetted.A;

                        ValToReturn = ColorCodeToReturn;
                    }

                    if (Arg1.Equals("FLOAT"))
                    {
                        int ListNameIndex = GlobalVars_FloatList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        ValToReturn = Convert.ToString(GlobalVars_FloatList_Content[ListNameIndex][Index]);
                    }

                    if (Arg1.Equals("RECTANGLE"))
                    {
                        int ListNameIndex = GlobalVars_RectangleList_Names.IndexOf(Arg2);
                        int Index         = Convert.ToInt32(Arg3);

                        Rectangle RectGetted    = GlobalVars_RectangleList_Content[ListNameIndex][Index];
                        string    RectangleCode = RectGetted.X + "," + RectGetted.Y + "," + RectGetted.Width + "," + RectGetted.Height;

                        ValToReturn = Convert.ToString(RectangleCode);
                    }


                    SplitedString[i] = SplitedString[i].Replace("%LIST_VALUE%" + Arg1 + "%" + Arg2 + "%" + Arg3 + "%", Convert.ToString(ValToReturn));
                }
            }


            // Begin Command Interpretation
            if (SplitedString[0].Equals("0x0"))
            {
                Clear.Initialize();
            }
            if (SplitedString[0].Equals("0x1"))
            {
                Call.Initialize(SplitedString[1]);
            }
            if (SplitedString[0].Equals("0x2"))
            {
                Write.Initialize(SplitedString[1]);
            }
            if (SplitedString[0].Equals("0x3"))
            {
                WriteLine.Initialize(SplitedString[1]);
            }
            if (SplitedString[0].Equals("0x4"))
            {
                WriteFile.Initialize(SplitedString[1], SplitedString[2]);
            }
            if (SplitedString[0].Equals("0x5"))
            {
                TaiyouIF.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("0x6"))
            {
                Abort.Initialize();
            }
            if (SplitedString[0].Equals("0x7"))
            {
                Declare.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("0x8"))
            {
                WriteVar.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("0x9"))
            {
                MathOP.Intialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x0"))
            {
                Goto.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x1"))
            {
                FileExists.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x2"))
            {
                ReadFile.Intialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x3"))
            {
                DirectoryExists.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x4"))
            {
                DownloadServerString.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x5"))
            {
                CopyFile.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x6"))
            {
                MoveFile.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x7"))
            {
                DeleteFile.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x8"))
            {
                AddRenderQuee.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("1x9"))
            {
                AddEvent.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x0"))
            {
                CheckEvent.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x1"))
            {
                ChangeWindowPropertie.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x2"))
            {
                Colision.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x3"))
            {
                Reload.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x4"))
            {
                GetKeyPressed.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x5"))
            {
                AddRenderTextQuee.Initialize(SplitedString);
            }
            if (SplitedString[0].Equals("2x6"))
            {
                ChangeRenderProp.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("2x7"))
            {
                ChangeBackgroundColor.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("2x8"))
            {
                Undeclare.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("2x9"))
            {
                SendBGMCommand.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("3x0"))
            {
                MasterVolume.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("3x1"))
            {
                LanguageSystemManager.Initialize(SplitedString);
            }

            if (SplitedString[0].Equals("3x2"))
            {
                // FIXME Not Working
                //VarMath.Initialize(SplitedString);
            }



            if (Global.IsLowLevelDebugEnabled)
            {
                for (int i = 0; i < SplitedString.Length; i++)
                {
                    Console.Write(SplitedString[i] + " ");
                }
                Console.Write("\n");
            }
        }