コード例 #1
0
ファイル: BMLScheduler.cs プロジェクト: KevinKlever/BMLTest
        private float getDuration(Behaviours.Behaviour newBehaviour)
        {
            float duration = 0;

            if (newBehaviour.hasLexeme())
            {
                string lexeme = "";
                switch (newBehaviour.Type)
                {
                    case Behaviours.Behaviour.eType.Face:
                        if (((Behaviours.Face)newBehaviour).Lexeme != null)
                        {
                            lexeme = ((Behaviours.Face)newBehaviour).Lexeme.Lexeme;
                        }
                        break;
                    case Behaviours.Behaviour.eType.FaceLexeme:
                        lexeme = ((Behaviours.FaceLexeme)newBehaviour).Lexeme;
                        break;
                    case Behaviours.Behaviour.eType.FaceShift:
                        if (((Behaviours.FaceShift)newBehaviour).Lexeme != null)
                        {
                            lexeme = ((Behaviours.FaceShift)newBehaviour).Lexeme.Lexeme;
                        }
                        break;
                    case Behaviours.Behaviour.eType.Gesture:
                        lexeme = ((Behaviours.Gesture)newBehaviour).Lexeme;
                        break;
                    case Behaviours.Behaviour.eType.Head:
                        lexeme = ((Behaviours.Head)newBehaviour).Lexeme;
                        break;
                }

                // TODO IO Caching!
                // get Duration
                if (lexeme != "")
                {
                    string path = "Assets\\Animations.xml";

                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(path);

                    // parse XML
                    foreach (XmlNode node in xmlDoc.ChildNodes[1])
                    {
                        if ((node.Attributes["name"] != null) && (node.Attributes["name"].Value == lexeme))
                        {
                            if (node.Attributes["duration"] != null)
                            {
                                duration = float.Parse(node.Attributes["duration"].Value);
                            }
                        }
                    }
                }
            }


            return duration;
        }