public override void OnEnter() { mControlBuffConfig = mBuffConfig as ControlBuffConfig; base.OnEnter(); if (mControlBuffConfig.mClearBuff) { mReceRole.mBuffSystem.ClearAllBuff(); } }
public IEnumerator load(string filePath) { string url = filePath + "/config/buff.xml"; WWW www = new WWW(url); yield return(www); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(www.text); XmlNode root = xmldoc.SelectSingleNode("root"); XmlNode behaviorNode = root.SelectSingleNode("behavior"); XmlNodeList behaviorChilds = behaviorNode.SelectNodes("buff"); foreach (XmlNode buffNode in behaviorChilds) { BehaviorBuffConfig info = new BehaviorBuffConfig(); XmlElement buffxml = (XmlElement)buffNode; info.mType = IBuff.BuffType.Behavior; info.mTypeId = int.Parse(buffxml.GetAttribute("id")); info.mName = buffxml.GetAttribute("Name"); info.mDuration = float.Parse(buffxml.GetAttribute("Duration")); info.mCanAtk = int.Parse(buffxml.GetAttribute("CanAtk")) == 1 ? true : false; info.mCanMove = int.Parse(buffxml.GetAttribute("CanMove")) == 1 ? true : false; mBehaviorBuffConfigDict.Add(info.mTypeId, info); } XmlNode moveNode = root.SelectSingleNode("move"); XmlNodeList moveChilds = moveNode.SelectNodes("buff"); foreach (XmlNode buffNode in moveChilds) { MoveBuffConfig info = new MoveBuffConfig(); XmlElement buffxml = (XmlElement)buffNode; info.mType = IBuff.BuffType.Move; info.mTypeId = int.Parse(buffxml.GetAttribute("id")); info.mName = buffxml.GetAttribute("Name"); info.mDir = (MoveBuff.MoveDir) int.Parse(buffxml.GetAttribute("Dir")); info.mDuration = float.Parse(buffxml.GetAttribute("Duration")); info.mDistance = float.Parse(buffxml.GetAttribute("Distance")); mMoveBuffConfigDict.Add(info.mTypeId, info); } XmlNode hurtNode = root.SelectSingleNode("hurt"); XmlNodeList hurtChilds = hurtNode.SelectNodes("buff"); foreach (XmlNode buffNode in hurtChilds) { HurtBuffConfig info = new HurtBuffConfig(); XmlElement buffxml = (XmlElement)buffNode; info.mType = IBuff.BuffType.Hurt; info.mTypeId = int.Parse(buffxml.GetAttribute("id")); info.mName = buffxml.GetAttribute("Name"); info.mDuration = float.Parse(buffxml.GetAttribute("Duration")); info.mStateName = buffxml.GetAttribute("StateName"); mHurtBuffConfigDict.Add(info.mTypeId, info); } XmlNode controlNode = root.SelectSingleNode("control"); XmlNodeList controlChilds = controlNode.SelectNodes("buff"); foreach (XmlNode buffNode in controlChilds) { ControlBuffConfig info = new ControlBuffConfig(); XmlElement buffxml = (XmlElement)buffNode; info.mType = IBuff.BuffType.Control; info.mTypeId = int.Parse(buffxml.GetAttribute("id")); info.mName = buffxml.GetAttribute("Name"); info.mDuration = float.Parse(buffxml.GetAttribute("Duration")); info.mClearBuff = int.Parse(buffxml.GetAttribute("ClearBuff")) == 1 ? true : false; info.mEnableBehavior = int.Parse(buffxml.GetAttribute("EnableBehavior")) == 1 ? true : false; info.mEnableMove = int.Parse(buffxml.GetAttribute("EnableMove")) == 1 ? true : false; info.mEnableHurt = int.Parse(buffxml.GetAttribute("EnableHurt")) == 1 ? true : false; info.mEnableSelect = int.Parse(buffxml.GetAttribute("EnableSelect")) == 1 ? true : false; mControlBuffConfigDict.Add(info.mTypeId, info); } }