Artemis.Engine.Graphics.Animation.AnimationStateReader.ParseElementChildNodes C# (CSharp) Метод

ParseElementChildNodes() приватный Метод

private ParseElementChildNodes ( XmlElement parentElement ) : void
parentElement System.Xml.XmlElement
Результат void
        private void ParseElementChildNodes(XmlElement parentElement)
        {
            foreach (var node in parentElement.ChildNodes)
            {
                var element = node as XmlElement;

                if (element == null)
                {
                    continue;
                }

                switch (element.Name)
                {
                    case FRAMES:
                        hasFrameTags = !hasFrameTags;
                        if (!hasFrameTags)
                        {
                            throw new AAMLConfigurationException();
                        }

                        foreach (var frame in Regex.Split(element.InnerText, FRAME_SEPARATOR_REGEX))
                        {
                            StepActions.Add(new FrameAnimationStepAction(StateName + frame));
                        }
                        break;

                    case STEP_ACTIONS:
                        hasFrameTags = !hasFrameTags;
                        if (!hasFrameTags)
                        {
                            throw new AAMLConfigurationException();
                        }
                        ParseElementChildNodes(element);
                        break;

                    // Step Action Inner Tags
                    case FRAME:
                        StepActions.Add(
                            new FrameAnimationStepAction(element.InnerText));
                        break;

                    case WAIT:
                        int waitFrame = Convert.ToInt32(
                            Regex.Match(element.InnerText, INT_REGEX).Groups[1].Value);
                        StepActions.Add(new WaitAnimationStepAction(waitFrame));
                        break;

                    case SOUND:
                        throw new NotImplementedException();
                        // Not done
                        /*
                        if (element.InnerText.Contains(UriUtilities.URI_SEPARATOR))
                        {
                            AssetLoader.Load<SoundEffect>(element.InnerText);
                        }
                        else
                        {
                            AssetLoader.LoadUsingExtension(element.InnerText);
                        }
                        */

                    case CALL_FUNCTION:
                        throw new NotImplementedException();

                    case REVERSE:
                        StepActions.Add(new ReverseAnimationStepAction());
                        break;

                    case REPEAT:
                        ParseElementAttributes(element);

                        for (int i = repeatStart; i < repeatEnd + 1; i += repeatStep)
                        {
                            foreach (var repeatNode in element.ChildNodes)
                            {
                                var repeatElement = repeatNode as XmlElement;

                                if (repeatElement == null)
                                {
                                    continue;
                                }

                                switch (repeatElement.Name)
                                {
                                    case FRAME:
                                        StepActions.Add(new FrameAnimationStepAction(StateName + i));
                                        break;

                                    case WAIT:
                                        int repWaitFrame = Convert.ToInt32(Regex.Match(repeatElement.InnerText, INT_REGEX).Groups[1].Value);
                                        StepActions.Add(new WaitAnimationStepAction(repWaitFrame));
                                        break;

                                    default:
                                        break;
                                }
                            }
                        }
                        break;

                    // Optional Inner Tags
                    case FRAME_DURATION:
                        StepActions.Add(new WaitAnimationStepAction(Convert.ToInt32(Regex.Match(element.InnerText, POS_INT_REGEX))));
                        break;

                    case LOOP_TYPE:
                        string type = element.InnerText.Trim().ToLower();

                        if (type.Equals("cycle"))
                        {
                            StepActions.Add(new FrameAnimationStepAction(StateName + "0"));
                        }
                        else if (type.Equals("reverse"))
                        {
                            StepActions.Add(new ReverseAnimationStepAction());
                        }

                        break;

                    case LOOP_COUNT:
                        break;

                    // Timing elements
                    case WHEN_FINISHED:
                        ParseElementChildNodes(element);
                        break;

                    case WHEN_AFTER:
                        // Check for time attribute then childNodes
                        break;

                    // Inner timing elements
                    case ENTER:
                        StepActions.Add(new EnterAnimationStepAction(element.InnerText.Trim()));
                        break;

                    case JUMP_TO:
                        if (Regex.IsMatch(element.InnerText, POS_INT_REGEX))
                        {
                            StepActions.Add(new JumpToAnimationStepAction(Convert.ToInt32(Regex.Match(element.InnerText, POS_INT_REGEX).Groups[1])));
                        }
                        break;

                    default:
                        break;
                }
            }
        }