Esempio n. 1
0
        public void parseXml(XmlElement elem)
        {
            clear();

            m_name = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);

            XmlNodeList     stateMachineNodeList = elem.SelectNodes("Statemachine");
            XmlElement      stateMachineElem     = null;
            XmlStateMachine stateMachine;

            foreach (XmlNode stateMachineNode in stateMachineNodeList)
            {
                stateMachineElem   = (XmlElement)stateMachineNode;
                stateMachine       = new XmlStateMachine();
                stateMachine.layer = this;
                m_stateMachineList.Add(stateMachine);
                stateMachine.parseXml(stateMachineElem);
            }

            // 解析状态机转换
            XmlNodeList stateMachineTransitionNodeList = elem.SelectNodes("StateMachineTransition");
            XmlElement  stateMachineTransitionElem     = null;
            XmlStateMachineTransition stateMachineTransition;

            foreach (XmlNode stateMachineTransitionNode in stateMachineTransitionNodeList)
            {
                stateMachineTransitionElem      = (XmlElement)stateMachineTransitionNode;
                stateMachineTransition          = new XmlStateMachineTransition();
                stateMachineTransition.xmlLayer = this;
                m_xmlStateMachineTransitionList.Add(stateMachineTransition);
                stateMachineTransition.parseXml(stateMachineTransitionElem);
            }
        }
Esempio n. 2
0
        static public void BuildAnimationStateMachine(XmlStateMachine xmlStateMachine)
        {
            // 创建 Default State ,第一个创建的状态默认就是 Default State
            //AnimatorState animatorState = null;
            //AnimatorStateTransition trans = null;

            //animatorState = xmlStateMachine.animatorStateMachine.AddState("Start");
            //animatorState.writeDefaultValues = true;

            // 添加一个默认的状态,当没有所有的状态的时候,可以循环播放这个状态
            //animatorState = xmlStateMachine.animatorStateMachine.AddState("Idle");          // 待机状态
            //animatorState.writeDefaultValues = false;
            //trans = xmlStateMachine.animatorStateMachine.AddAnyStateTransition(animatorState);
            //trans.hasExitTime = true;
            //trans.exitTime = 0;
            //trans.duration = 0;
            //trans.canTransitionToSelf = true;           // 可以循环自己
            //trans.AddCondition(AnimatorConditionMode.Equals, 0, "StateId");

            // 创建没有动画资源的状态
            foreach (XmlState xmlState in xmlStateMachine.noResStateList)
            {
                BuildNoResState(xmlState);
            }

            // 创建有动画资源的状态
            foreach (XmlClip xmlClip in xmlStateMachine.clipList)
            {
                BuildAnimationClip(xmlClip);
            }
        }
Esempio n. 3
0
        // 添加状态机之间的转换
        static public void BuildStateMachineTransition(XmlLayer xmlLayer)
        {
            XmlStateMachine xmlSrcStateMachine  = null;
            XmlStateMachine xmlDestStateMachine = null;
            XmlState        xmlDestState        = null;

            foreach (var stateMachineTransition in xmlLayer.xmlStateMachineTransitionList)
            {
                xmlSrcStateMachine  = xmlLayer.getXmlStateMachineByName(stateMachineTransition.srcStateMachineName);
                xmlDestStateMachine = xmlLayer.getXmlStateMachineByName(stateMachineTransition.destStateMachineName);
                xmlDestState        = xmlDestStateMachine.getXmlStateByName(stateMachineTransition.destStateName);

                stateMachineTransition.animatorTransition = xmlSrcStateMachine.animatorStateMachine.AddStateMachineTransition(xmlDestStateMachine.animatorStateMachine, xmlDestState.animatorState);
                //stateMachineTransition.animatorTransition = xmlDestStateMachine.animatorStateMachine.AddStateMachineTransition(xmlSrcStateMachine.animatorStateMachine, xmlDestState.animatorState);
            }
        }
Esempio n. 4
0
        // 这个是添加状态机内部状态的转换
        static public void BuildStateTransition(XmlStateMachine xmlStateMachine)
        {
            XmlState srcXmlState  = null;
            XmlState destXmlState = null;

            foreach (var tran in xmlStateMachine.tranList)
            {
                srcXmlState  = xmlStateMachine.getXmlStateByName(tran.srcStateName);
                destXmlState = xmlStateMachine.getXmlStateByName(tran.destStateName);
                //tran.animatorTransition = xmlStateMachine.animatorStateMachine.AddStateMachineTransition(xmlStateMachine.animatorStateMachine, destXmlState.animatorState);
                tran.animatorStateTransition = srcXmlState.animatorState.AddTransition(destXmlState.animatorState);

                foreach (var xmlCond in tran.condList)
                {
                    tran.animatorStateTransition.AddCondition(xmlCond.opMode, xmlCond.getFloatValue(), xmlCond.name);
                }
            }
        }
Esempio n. 5
0
        public void parseXml(XmlElement elem)
        {
            clear();

            m_name = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);

            XmlNodeList stateMachineNodeList = elem.SelectNodes("Statemachine");
            XmlElement stateMachineElem = null;
            XmlStateMachine stateMachine;
            foreach (XmlNode stateMachineNode in stateMachineNodeList)
            {
                stateMachineElem = (XmlElement)stateMachineNode;
                stateMachine = new XmlStateMachine();
                stateMachine.layer = this;
                m_stateMachineList.Add(stateMachine);
                stateMachine.parseXml(stateMachineElem);
            }

            // 解析状态机转换
            XmlNodeList stateMachineTransitionNodeList = elem.SelectNodes("StateMachineTransition");
            XmlElement stateMachineTransitionElem = null;
            XmlStateMachineTransition stateMachineTransition;
            foreach (XmlNode stateMachineTransitionNode in stateMachineTransitionNodeList)
            {
                stateMachineTransitionElem = (XmlElement)stateMachineTransitionNode;
                stateMachineTransition = new XmlStateMachineTransition();
                stateMachineTransition.xmlLayer = this;
                m_xmlStateMachineTransitionList.Add(stateMachineTransition);
                stateMachineTransition.parseXml(stateMachineTransitionElem);
            }
        }