Beispiel #1
0
        public void apply(GMoveComponent gmc)
        {
            switch (char.ToUpper(gmc.command))
            {
            case 'F':
                velocity = gmc.scalar;
                break;

            case 'X':
                position.x    = gmc.scalar;
                validPosition = true;
                break;

            case 'Y':
                position.y    = gmc.scalar;
                validPosition = true;
                break;

            case 'Z':
                position.z    = gmc.scalar;
                validPosition = true;
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        private static int next(string[] compos, int startIndex, out GMoveComponent gComponent)
        {
            string subject;
            string scalarS = "";
            char   command = GMoveComponent.InvalidChar;

            while (startIndex < compos.Length)
            {
                subject = compos[startIndex++].Trim();
                if (string.IsNullOrEmpty(subject))
                {
                    continue;
                }
                if (!GMoveComponent.isValidCommand(subject[0]))
                {
                    continue;
                }

                command = subject[0];
                if (subject.Length == 1)
                {
                    if (++startIndex < compos.Length)
                    {
                        scalarS = compos[startIndex];
                    }
                    break;
                }

                scalarS = subject.Substring(1);
                break;
            }

            try {
                gComponent = new GMoveComponent()
                {
                    command = command, scalar = float.Parse(scalarS)
                };
            } catch (Exception e) {
                gComponent = GMoveComponent.Invalid();
            }
            return(startIndex);
        }