// 接口实现(ICloneable的接口) public override object Clone() { sdBehaviourEventNode kBehaviourEventNode = new sdBehaviourEventNode(); foreach (sdBehaviourTrigger kBehaviourTrigger in mBehaviourTriggerList) { kBehaviourEventNode.AddBehaviourTrigger(kBehaviourTrigger.Clone() as sdBehaviourTrigger); } foreach (sdBehaviourAction kBehaviourAction in mBehaviourActionList) { kBehaviourEventNode.AddBehaviourAction(kBehaviourAction.Clone() as sdBehaviourAction); } foreach (sdBehaviourState kBehaviourState in mBehaviourStateList) { kBehaviourEventNode.AddBehaviourState(kBehaviourState.Clone() as sdBehaviourState); } foreach (sdBehaviourEvent kBehaviourEvent in mBehaviourEventList) { kBehaviourEventNode.AddBehaviourEvent(kBehaviourEvent.Clone() as sdBehaviourEvent); } foreach (sdBehaviourEventNode kChildBehaviourEventNode in mChildBehaviourEventNodeList) { kChildBehaviourEventNode.AddChildBehaviourEventNode(kChildBehaviourEventNode.Clone() as sdBehaviourEventNode); } kBehaviourEventNode.ID = this.ID; kBehaviourEventNode.MaxUseCount = this.MaxUseCount; kBehaviourEventNode.mBehaviourAdvancedState = this.mBehaviourAdvancedState; return(kBehaviourEventNode); }
// 加载事件节点aa protected sdBehaviourEventNode LoadBehaviourEventNode(XmlNode kXmlNode) { XmlElement kXmlElement = (XmlElement)kXmlNode; if (kXmlElement.Name != "AIEventNode") { return(null); } sdBehaviourEventNode kBehaviourEventNode = new sdBehaviourEventNode(); kBehaviourEventNode.ID = int.Parse(kXmlElement.GetAttribute("id")); kBehaviourEventNode.MaxUseCount = int.Parse(kXmlElement.GetAttribute("maxtickcount")); XmlNodeList kXmlChildNodeList = kXmlNode.ChildNodes; foreach (XmlNode kXmlChildNode in kXmlChildNodeList) { XmlElement kXmlChildElement = (XmlElement)kXmlChildNode; if (kXmlChildElement.Name == "AITrigger") { sdBehaviourTrigger kBehaviourTrigger = LoadBehaviourTrigger(kXmlChildNode); if (kBehaviourTrigger != null) { kBehaviourEventNode.AddBehaviourTrigger(kBehaviourTrigger); } } else if (kXmlChildElement.Name == "AIAction") { sdBehaviourAction kBehaviourAction = LoadBehaviourAction(kXmlChildNode); if (kBehaviourAction != null) { kBehaviourEventNode.AddBehaviourAction(kBehaviourAction); } } else if (kXmlChildElement.Name == "AIState") { sdBehaviourState kBehaviourState = LoadBehaviourState(kXmlChildNode); if (kBehaviourState != null) { kBehaviourEventNode.AddBehaviourState(kBehaviourState); } } else if (kXmlChildElement.Name == "AIEvent") { sdBehaviourEvent kBehaviourEvent = LoadBehaviourEvent(kXmlChildNode); if (kBehaviourEvent != null) { kBehaviourEventNode.AddBehaviourEvent(kBehaviourEvent); } } else if (kXmlChildElement.Name == "AIEventNode") { sdBehaviourEventNode kBehaviourEventChildNode = LoadBehaviourEventNode(kXmlChildNode); if (kBehaviourEventChildNode != null) { kBehaviourEventNode.AddChildBehaviourEventNode(kBehaviourEventChildNode); } } } return(kBehaviourEventNode); }