Пример #1
0
        private static UInt64 StringToFlags(string str)
        {
            UInt64 flags = 0;
            char   mode  = '-';

            foreach (char c in str)
            {
                if (c == 'q' || c == 'x' || c == 'y' || c == 'z')
                {
                    mode = c;
                }
                else if ('0' <= c && c <= '5')
                {
                    if (mode == 'x' || mode == 'y' || mode == 'z')
                    {
                        var seq = new string(new char[] { mode, c });
                        switch (seq)
                        {
                        case "x0": flags |= Flags.PosX0; break;

                        case "x1": flags |= Flags.PosX1; break;

                        case "x2": flags |= Flags.PosX2; break;

                        case "y0": flags |= Flags.PosY0; break;

                        case "y1": flags |= Flags.PosY1; break;

                        case "y2": flags |= Flags.PosY2; break;

                        case "z0": flags |= Flags.PosZ0; break;

                        case "z1": flags |= Flags.PosZ1; break;

                        case "z2": flags |= Flags.PosZ2; break;
                        }
                    }
                    else if (mode == 'q')
                    {
                        switch (c)
                        {
                        case '0': flags |= Flags.DirLeft; break;

                        case '1': flags |= Flags.DirRight; break;

                        case '2': flags |= Flags.DirDown; break;

                        case '3': flags |= Flags.DirUp; break;

                        case '4': flags |= Flags.DirBack; break;

                        case '5': flags |= Flags.DirFwd; break;
                        }
                    }
                }
                else
                {
                    flags |= Flags.BitValueForLetter(c);
                }
            }
            return(flags);
        }