示例#1
0
    // 接口实现(ICloneable的接口)
    public override object Clone()
    {
        sdBehaviourEventRootNode kBehaviourEventRootNode = new sdBehaviourEventRootNode();

        foreach (sdBehaviourTrigger kBehaviourTrigger in mBehaviourTriggerList)
        {
            kBehaviourEventRootNode.AddBehaviourTrigger(kBehaviourTrigger.Clone() as sdBehaviourTrigger);
        }

        foreach (sdBehaviourAction kBehaviourAction in mBehaviourActionList)
        {
            kBehaviourEventRootNode.AddBehaviourAction(kBehaviourAction.Clone() as sdBehaviourAction);
        }

        foreach (sdBehaviourState kBehaviourState in mBehaviourStateList)
        {
            kBehaviourEventRootNode.AddBehaviourState(kBehaviourState.Clone() as sdBehaviourState);
        }

        foreach (sdBehaviourEvent kBehaviourEvent in mBehaviourEventList)
        {
            kBehaviourEventRootNode.AddBehaviourEvent(kBehaviourEvent.Clone() as sdBehaviourEvent);
        }

        foreach (sdBehaviourEventNode kChildBehaviourEventNode in mChildBehaviourEventNodeList)
        {
            kBehaviourEventRootNode.AddChildBehaviourEventNode(kChildBehaviourEventNode.Clone() as sdBehaviourEventNode);
        }

        kBehaviourEventRootNode.ID = this.ID;
        kBehaviourEventRootNode.mBehaviourAdvancedState = this.mBehaviourAdvancedState;
        kBehaviourEventRootNode.Name = this.Name;

        return(kBehaviourEventRootNode);
    }
示例#2
0
    // 加载触发行为树aa
    protected sdBehaviourEventRootNode LoadBehaviourEventRootNode(XmlNode kXmlNode)
    {
        XmlElement kXmlElement = (XmlElement)kXmlNode;

        if (kXmlElement.Name != "AIEventRootNode")
        {
            return(null);
        }

        sdBehaviourEventRootNode kBehaviourEventRootNode = new sdBehaviourEventRootNode();

        kBehaviourEventRootNode.MaxUseCount = -1;
        kBehaviourEventRootNode.ID          = int.Parse(kXmlElement.GetAttribute("id"));
        kBehaviourEventRootNode.Name        = kXmlElement.GetAttribute("name");

        XmlNodeList kXmlChildNodeList = kXmlNode.ChildNodes;

        foreach (XmlNode kXmlChildNode in kXmlChildNodeList)
        {
            XmlElement kXmlChildElement = (XmlElement)kXmlChildNode;

            if (kXmlChildElement.Name == "AITrigger")
            {
                sdBehaviourTrigger kBehaviourTrigger = LoadBehaviourTrigger(kXmlChildNode);
                if (kBehaviourTrigger != null)
                {
                    kBehaviourEventRootNode.AddBehaviourTrigger(kBehaviourTrigger);
                }
            }
            else if (kXmlChildElement.Name == "AIAction")
            {
                sdBehaviourAction kBehaviourAction = LoadBehaviourAction(kXmlChildNode);
                if (kBehaviourAction != null)
                {
                    kBehaviourEventRootNode.AddBehaviourAction(kBehaviourAction);
                }
            }
            else if (kXmlChildElement.Name == "AIState")
            {
                sdBehaviourState kBehaviourState = LoadBehaviourState(kXmlChildNode);
                if (kBehaviourState != null)
                {
                    kBehaviourEventRootNode.AddBehaviourState(kBehaviourState);
                }
            }
            else if (kXmlChildElement.Name == "AIEvent")
            {
                sdBehaviourEvent kBehaviourEvent = LoadBehaviourEvent(kXmlChildNode);
                if (kBehaviourEvent != null)
                {
                    kBehaviourEventRootNode.AddBehaviourEvent(kBehaviourEvent);
                }
            }
            else if (kXmlChildElement.Name == "AIEventNode")
            {
                sdBehaviourEventNode kBehaviourEventChildNode = LoadBehaviourEventNode(kXmlChildNode);
                if (kBehaviourEventChildNode != null)
                {
                    kBehaviourEventRootNode.AddChildBehaviourEventNode(kBehaviourEventChildNode);
                }
            }
        }

        return(kBehaviourEventRootNode);
    }