ToXml() public method

public ToXml ( ) : SecurityElement
return System.Security.SecurityElement
Exemplo n.º 1
0
    public void Initalize()
    {
        string xmlPath = Common.StringUtils.CombineString(Common.PathUtils.PERSISTENT_DATA_PATH, LocalVersionXML);

        if (!Common.FileUtils.Exist(xmlPath))
        {
            xmlPath = Common.StringUtils.CombineString(Common.PathUtils.STREAMING_ASSET_PATH, LocalVersionXML);
        }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS
        if (DevelopSetting.IsUsePersistent)
        {
            xmlPath = xmlPath.Replace("file:///", "");
        }
        else
        {
            xmlPath = xmlPath.Replace("file://", "");
        }
#elif UNITY_ANDROID
        if (DevelopSetting.IsUsePersistent)
        {
            xmlPath = xmlPath.Replace("file:///", "");
        }
#endif
        Mono.Xml.SecurityParser xml = Mono.Xml.MonoXmlUtils.LoadXml(xmlPath);
        if (xml != null && xml.ToXml() != null)
        {
            var dom = xml.ToXml();
            m_ip           = Mono.Xml.MonoXmlUtils.Parse(dom, "local_info/server_adress");
            m_iport        = Mono.Xml.MonoXmlUtils.Parse(dom, "local_info/server_iport");
            m_version      = Mono.Xml.MonoXmlUtils.Parse(dom, "local_info/local_app_version");
            m_PhotoAdress  = Mono.Xml.MonoXmlUtils.Parse(dom, "local_info/photo_adress");
            _chargeAddress = Mono.Xml.MonoXmlUtils.Parse(dom, "local_info/charge_adress");
        }
    }
Exemplo n.º 2
0
    public void Initalize()
    {
        string xmlPath = Common.StringUtils.CombineString(Common.PathUtils.PERSISTENT_DATA_PATH, ServerNoticeXmlPath);

        if (!Common.FileUtils.Exist(xmlPath))
        {
            xmlPath = Common.StringUtils.CombineString(Common.PathUtils.STREAMING_ASSET_PATH, ServerNoticeXmlPath);
        }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS
        if (DevelopSetting.IsUsePersistent)
        {
            xmlPath = xmlPath.Replace("file:///", "");
        }
        else
        {
            xmlPath = xmlPath.Replace("file://", "");
        }
#elif UNITY_ANDROID
        if (DevelopSetting.IsUsePersistent)
        {
            xmlPath = xmlPath.Replace("file:///", "");
        }
#endif
        Mono.Xml.SecurityParser xml = Mono.Xml.MonoXmlUtils.LoadXml(xmlPath);
        if (xml != null && xml.ToXml() != null)
        {
            parse(xml.ToXml());
        }
    }
Exemplo n.º 3
0
        public void parseXml(string xmlStr)
        {
            SecurityParser xmlDoc = new SecurityParser();
            xmlDoc.LoadXml(xmlStr);

            SecurityElement rootNode = xmlDoc.ToXml();
            ArrayList behaviorTemplateNode = rootNode.Children;
            ArrayList behaviorTreeXmlList = null;
            SecurityElement xmlElemTpl;
            SecurityElement xmlElemBT;
            BehaviorTree behaviorTree = null;
            string strId = "";
            BTID id = BTID.eNone;

            foreach (SecurityElement node in behaviorTemplateNode)  // 树列表,包括树和其它信息
            {
                xmlElemTpl = node;
                behaviorTreeXmlList = xmlElemTpl.Children;
                behaviorTree = new BehaviorTree(new BTRoot());

                UtilXml.getXmlAttrStr(node, "name", ref strId);
                id = m_btAttrSys.getBTIDByName(strId);
                m_id2BTDic[id] = behaviorTree;

                foreach (SecurityElement nodetree in behaviorTreeXmlList)
                {
                    xmlElemBT = nodetree;
                    m_BTFactory.parseXml(behaviorTree, xmlElemBT);
                }
            }
        }
Exemplo n.º 4
0
        override protected void initImpl(ResItem res)
        {
            base.initImpl(res);

            SecurityParser xmlDoc = new SecurityParser();
            xmlDoc.LoadXml(m_text);

            SecurityElement rootNode = xmlDoc.ToXml();
            ArrayList itemMeshList = rootNode.Children;
            SecurityElement itemMesh;

            ArrayList itemSubMeshList;
            SecurityElement itemSubMesh;
            string meshName = "";
            string subMeshName = "";
            string bonesList = "";

            foreach (SecurityElement itemNode1f in itemMeshList)
            {
                itemMesh = itemNode1f;
                UtilXml.getXmlAttrStr(itemMesh, "name", ref meshName);

                itemSubMeshList = itemMesh.Children;
                foreach (SecurityElement itemNode2f in itemSubMeshList)
                {
                    itemSubMesh = itemNode2f;
                    UtilXml.getXmlAttrStr(itemSubMesh, "name", ref subMeshName);
                    UtilXml.getXmlAttrStr(itemSubMesh, "bonelist", ref bonesList);
                    m_boneArr = bonesList.Split(',');
                }
            }

            m_text = "";
        }
Exemplo n.º 5
0
 public bool load_xml(byte[] pBuffer)
 {
     try
     {
         string xml = Encoding.UTF8.GetString(pBuffer);
         Mono.Xml.SecurityParser parser = new Mono.Xml.SecurityParser();
         parser.LoadXml(xml);
         SecurityElement node = parser.ToXml();
         if ((node.Tag != "behavior") && ((node.Children == null) || (node.Children.Count != 1)))
         {
             return(false);
         }
         this.m_name = node.Attribute("name");
         string agentType = node.Attribute("agenttype");
         int    version   = int.Parse(node.Attribute("version"));
         base.SetClassNameString("BehaviorTree");
         base.SetId(-1);
         base.load_properties_pars_attachments_children(true, version, agentType, node);
         return(true);
     }
     catch (Exception)
     {
     }
     return(false);
 }
    public void Initalize()
    {
        string xmlPath = Common.StringUtils.CombineString(Common.PathUtils.PERSISTENT_DATA_PATH, UpdateConfigForSubsectionXML);

        if (!Common.FileUtils.Exist(xmlPath))
        {
            xmlPath = Common.StringUtils.CombineString(Common.PathUtils.STREAMING_ASSET_PATH, UpdateConfigForSubsectionXML);
        }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS
        if (DevelopSetting.IsUsePersistent)
        {
            xmlPath = xmlPath.Replace("file:///", "");
        }
        else
        {
            xmlPath = xmlPath.Replace("file://", "");
        }
#elif UNITY_ANDROID
        if (DevelopSetting.IsUsePersistent)
        {
            xmlPath = xmlPath.Replace("file:///", "");
        }
#endif
        Mono.Xml.SecurityParser xml = Mono.Xml.MonoXmlUtils.LoadXml(xmlPath);
        if (xml != null && xml.ToXml() != null)
        {
            var dom = xml.ToXml();
            foreach (SecurityElement child in  dom.Children)
            {
                int ID = int.Parse(child.Text);
                if (m_sectionDic.ContainsKey(ID))
                {
                    m_sectionDic [ID].Add(child.Tag);
                }
                else
                {
                    m_sectionDic.Add(ID, new List <string> ()
                    {
                        child.Tag
                    });
                }
            }
        }
    }
Exemplo n.º 7
0
    void Start()
    {
        var parser = new Mono.Xml.SecurityParser();

        parser.LoadXml(Resources.Load("Tutorial").ToString());
        var element = parser.ToXml();

        foreach (SecurityElement node in element.Children)
        {
            Debug.Log("node: tag=" + node.Tag + " ID=" + node.Attribute("ID") + " text=" + node.Attribute("text") + " people=" + node.Attribute("people"));
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// 从指定的字符串加载 XML 文档。
 /// </summary>
 /// <param name="xml">包含要加载的 XML 文档的字符串。</param>
 /// <returns>编码安全对象的 XML 对象模型。</returns>
 public static SecurityElement LoadXML(String xml)
 {
     try
     {
         SecurityParser securityParser = new SecurityParser();
         securityParser.LoadXml(xml);
         return securityParser.ToXml();
     }
     catch (Exception ex)
     {
         ALog.except(ex);
         return null;
     }
 }
Exemplo n.º 9
0
 public static TdirConfigData GetFileTdirAndTverData()
 {
     if ((tdirConfigData == null) && File.Exists(Application.persistentDataPath + tdirConfigDataPath))
     {
         try
         {
             byte[] bytes = CFileManager.ReadFile(Application.persistentDataPath + tdirConfigDataPath);
             if ((bytes != null) && (bytes.Length > 0))
             {
                 tdirConfigData = new TdirConfigData();
                 string xml = Encoding.UTF8.GetString(bytes);
                 Mono.Xml.SecurityParser parser = new Mono.Xml.SecurityParser();
                 parser.LoadXml(xml);
                 IEnumerator enumerator = parser.ToXml().Children.GetEnumerator();
                 try
                 {
                     while (enumerator.MoveNext())
                     {
                         SecurityElement current = (SecurityElement)enumerator.Current;
                         if (current.Tag == "serverType")
                         {
                             tdirConfigData.serverType = int.Parse(current.Text);
                         }
                         else if (current.Tag == "versionType")
                         {
                             tdirConfigData.versionType = int.Parse(current.Text);
                         }
                     }
                 }
                 finally
                 {
                     IDisposable disposable = enumerator as IDisposable;
                     if (disposable == null)
                     {
                     }
                     disposable.Dispose();
                 }
             }
         }
         catch (Exception)
         {
             tdirConfigData = null;
         }
     }
     return(tdirConfigData);
 }
Exemplo n.º 10
0
        public void parseXml(string str)
        {
            m_itemList = new MList<AttackActionItem>();
            AttackActionItem attackItem;

            SecurityParser _xmlDoc = new SecurityParser();
            _xmlDoc.LoadXml(str);

            SecurityElement rootNode = _xmlDoc.ToXml();         // Config 节点
            ArrayList attackItemXmlList = rootNode.Children;    // AttackItem 列表

            foreach (SecurityElement attackItemElem_ in attackItemXmlList)
            {
                attackItem = new AttackActionItem();
                m_itemList.Add(attackItem);
                attackItem.parseXmlElem(attackItemElem_);
            }
        }
Exemplo n.º 11
0
 public void Read()
 {
     SecurityParser SP = new SecurityParser();
     // 假设xml文件路径为 Resources/test.xml
     string xmlPath = "test.xml";
     SP.LoadXml(Resources.Load( xmlPath ).ToString());
     SecurityElement SE = SP.ToXml();
     foreach (SecurityElement child in SE.Children)
     {           //比对下是否使自己所需要得节点
         if(child.Tag == "table")
         {               //获得节点得属性
             string wave = child.Attribute("wave");
             string level = child.Attribute("level");
             string name = child.Attribute("name");
             Debug.Log("wave:" + wave + " level:" + level + " name:" + name);
         }
     }
 }
Exemplo n.º 12
0
        public void parse(string xmlstr)
        {
            SecurityParser xmlDoc = new SecurityParser();
            xmlDoc.LoadXml(xmlstr);
            SecurityElement SE = xmlDoc.ToXml();
            ArrayList xnl = SE.Children;
            SceneNodeCfg node;
            foreach (SecurityElement xn in xnl)
            {
                SecurityElement xe = (SecurityElement)xn;

                if (xe.Tag == "Terrain")
                {
                    m_sceneCfg.terrainCfg.parse(xe);
                }
                else
                {
                    node = new SceneNodeCfg();
                    node.parse(xe);
                    m_sceneCfg.addSceneNode(node);
                }
            }
        }
Exemplo n.º 13
0
		/// <summary>
		/// Reconstructs a <see cref="DiffieHellman"/> object from an XML string.
		/// </summary>
		/// <param name="xmlString">The XML string to use to reconstruct the DiffieHellman object.</param>
		/// <exception cref="CryptographicException">One of the values in the XML string is invalid.</exception>
		public override void FromXmlString (string xmlString) {
			if (xmlString == null)
				throw new ArgumentNullException ();

			DHParameters dhParams = new DHParameters();
			try {
				SecurityParser sp = new SecurityParser();
				sp.LoadXml(xmlString);
				SecurityElement se = sp.ToXml();
				if (se.Tag != "DHKeyValue")
					throw new CryptographicException();
				dhParams.P = GetNamedParam(se, "P");
				dhParams.G = GetNamedParam(se, "G");
				dhParams.X = GetNamedParam(se, "X");
				ImportParameters(dhParams);
			} finally {
				if (dhParams.P != null)
					Array.Clear(dhParams.P, 0, dhParams.P.Length);
				if (dhParams.G != null)
					Array.Clear(dhParams.G, 0, dhParams.G.Length);
				if (dhParams.X != null)
					Array.Clear(dhParams.X, 0, dhParams.X.Length);
			}
		}
		// note: more than one configuration file can be loaded at the 
		// same time (e.g. user specific and machine specific config).
		static public void LoadConfig (string filename) 
		{
			if (File.Exists (filename)) {
				SecurityParser sp = new SecurityParser ();
				using (StreamReader sr = new StreamReader (filename)) {
					string xml = sr.ReadToEnd ();
					sp.LoadXml (xml);
				}
				SecurityElement root = sp.ToXml ();
				if ((root != null) && (root.Tag == "configuration")) {
					SecurityElement strongnames  = root.SearchForChildByTag ("strongNames");
					if ((strongnames != null) && (strongnames.Children.Count > 0)) {
						SecurityElement mapping  = strongnames.SearchForChildByTag ("pubTokenMapping");
						if ((mapping != null) && (mapping.Children.Count > 0)) {
							LoadMapping (mapping);
						}

						SecurityElement settings = strongnames.SearchForChildByTag ("verificationSettings");
						if ((settings != null) && (settings.Children.Count > 0)) {
							LoadVerificationSettings (settings);
						}
					}
				}
			}
		}
Exemplo n.º 15
0
        private bool LoadWorkspaceSetting(string file, string ext, ref string workspaceFile)
        {
            try
            {
                byte[] pBuffer = ReadFileToBuffer(file, ext);

                if (pBuffer != null)
                {
                    string xml = System.Text.Encoding.UTF8.GetString(pBuffer);
#if BEHAVIAC_USE_SYSTEM_XML
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(xml);

                    XmlNode rootNode = xmlDoc.DocumentElement;

                    if (rootNode.Name == "workspace")
                    {
                        workspaceFile = rootNode.Attributes["path"].Value;
                        return true;
                    }

#else
                    SecurityParser xmlDoc = new SecurityParser();
                    xmlDoc.LoadXml(xml);

                    SecurityElement rootNode = xmlDoc.ToXml();

                    if (rootNode.Tag == "workspace")
                    {
                        workspaceFile = rootNode.Attribute("path");
                        return true;
                    }

#endif
                }
            }
            catch (Exception e)
            {
                string errorInfo = string.Format("Load Workspace {0} Error : {1}", file, e.Message);
                behaviac.Debug.LogError(errorInfo);
            }

            return false;
        }
Exemplo n.º 16
0
    static IEnumerator CheckSkillGfxCoroutine()
    {
        var logPath = EntryPoint.Instance.AssetsPath + "/checkskillgfx.txt";
        File.WriteAllText(logPath, "");

        SecurityParser doc = new SecurityParser();
        string gfxpath = "Configs/SkillGfxData.xml";
        doc.LoadXml(AFileWrapper.af_ReadAllText(gfxpath));

        int count = 0;
        SecurityElement root = doc.ToXml();
        foreach (SecurityElement child in root.Children)
        {
            if (child.Tag == "SkillGfx")
            {
                string path = child.Attributes["FilePath"].ToString();
                if (path != "")
                {
                    count++;
                    Debug.LogWarning("gfx load: " + path);
                    File.AppendAllText(logPath, path + "\n");
                    bool flag = false;
                    AssetUtility.ResourceManager.AsyncLoadResourceAndCleanUp(path, false, false, (asset) =>
                    {
                        flag = true;
                        if (asset == null)
                        {
                            Debug.LogWarning("load failed");
                        }
                    });

                    while (!flag)
                        yield return null;
                }
            }
        }

        Debug.LogWarning("Check skill gfx finished, count = " + count);
        File.AppendAllText(logPath, "Check skill gfx finished, count = " + count);
    }
Exemplo n.º 17
0
		private SecurityElement FromString (string xml) 
		{
			SecurityParser parser = new SecurityParser ();
			parser.LoadXml (xml);
			// configuration / mscorlib / security / policy / PolicyLevel
			SecurityElement configuration = parser.ToXml ();
			if (configuration.Tag != "configuration")
				throw new ArgumentException (Locale.GetText ("missing <configuration> root element"));
			SecurityElement mscorlib = (SecurityElement) configuration.Children [0];
			if (mscorlib.Tag != "mscorlib")
				throw new ArgumentException (Locale.GetText ("missing <mscorlib> tag"));
			SecurityElement security = (SecurityElement) mscorlib.Children [0];
			if (security.Tag != "security")
				throw new ArgumentException (Locale.GetText ("missing <security> tag"));
			SecurityElement policy = (SecurityElement) security.Children [0];
			if (policy.Tag != "policy")
				throw new ArgumentException (Locale.GetText ("missing <policy> tag"));
			SecurityElement policyLevel = (SecurityElement) policy.Children [0];
			return policyLevel;
		}
Exemplo n.º 18
0
Arquivo: Key.cs Projeto: nobled/mono
		void ReadFile ()
		{
			var sp = new SecurityParser ();
			sp.LoadXml (File.ReadAllText (file));

			SecurityElement root = sp.ToXml ();
			if (root.Tag == "KeyPair") {
				SecurityElement keyvalue = root.SearchForChildByTag ("KeyValue");
				if (keyvalue.Children.Count == 0)
					return;
				
				KeyValue = keyvalue.Children [0].ToString ();

				SecurityElement properties = root.SearchForChildByTag ("Properties");
				if (properties.Children.Count == 0)
					return;

				SecurityElement property;
				string containerName = null, attribute;
				int providerType = -1;
				
				foreach (object o in properties.Children) {
					property = o as SecurityElement;
					if (property == null)
						continue;

					switch (property.Tag) {
						case "Provider":
							attribute = property.Attribute ("Type");
							if (String.IsNullOrEmpty (attribute))
								return;

							if (!Int32.TryParse (attribute, out providerType))
								return;
							break;

						case "Container":
							attribute = property.Attribute ("Name");
							if (String.IsNullOrEmpty (attribute))
								return;

							containerName = attribute;
							break;
					}
				}

				if (String.IsNullOrEmpty (containerName) || providerType == -1)
					return;

				ContainerName = containerName;
				ProviderType = providerType;
				IsValid = true;
			}
		}
Exemplo n.º 19
0
    private bool LoadSkillData()
    {
        SkillMap.Clear();
        PerformMap.Clear();

        string strKey = null;

        string[] strFilePathes = new string[] { "Configs/SkillData_1.xml", "Configs/SkillData_2.xml" };
        foreach (string strFilePath in strFilePathes)
        {
#if USING_SYSTEM_XML
            XmlDocument doc = new XmlDocument();
			doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));

            XmlElement root = doc.DocumentElement;
            foreach (XmlNode skillNode in root.ChildNodes)
            {
                XmlElement skillEle = skillNode as XmlElement;
                if (skillEle == null)
                    continue;

                int iSkillID = Convert.ToInt32(skillEle.GetAttribute("ID"));
                if (SkillMap.ContainsKey(iSkillID))
                {
                    Debug.LogWarning("Failed to add skill, ID: " + iSkillID);
                    return false;
                }

                ECSkill skill = new ECSkill();
                skill.Type = (e_Skill_Type)Convert.ToInt32(skillEle.GetAttribute("Type"));
                skill.ID = iSkillID;
                skill.Name = skillEle.GetAttribute("Name");
                skill.Rank = Convert.ToInt32(skillEle.GetAttribute("Rank"));
                skill.CtrlRank = Convert.ToInt32(skillEle.GetAttribute("CtrlRank"));

                strKey = "Move";
                if (skillEle.HasAttribute(strKey))
                    skill.CanPushMove = (Convert.ToInt32(skillEle.GetAttribute(strKey)) != 0);

                strKey = "CastInCtrl";
                if (skillEle.HasAttribute(strKey))
                    skill.CastInCtrl = (Convert.ToInt32(skillEle.GetAttribute(strKey)) != 0);

                skill.MinDisplace = Convert.ToSingle(skillEle.GetAttribute("MinDistance"));
                skill.MaxDisplace = Convert.ToSingle(skillEle.GetAttribute("MaxDistance"));

                strKey = "CooldownID";
                if (skillEle.HasAttribute(strKey))
                    skill.CooldownID = Convert.ToInt32(skillEle.GetAttribute(strKey));

                strKey = "Cooldown";
                if (skillEle.HasAttribute(strKey))
                    skill.CooldownTime = Convert.ToSingle(skillEle.GetAttribute(strKey));
                
                SkillMap[skill.ID] = skill;

                foreach (XmlNode node in skillEle.ChildNodes)
                {
                    XmlElement ele = node as XmlElement;
                    if (ele == null)
                        continue;

                    if (ele.Name == "Perform")
                    {
                        int iPerformID = Convert.ToInt32(ele.GetAttribute("ID"));
                        ECPerform perform;
                        if (!PerformMap.TryGetValue(iPerformID, out perform))
                        {
                            perform = new ECPerform();
                            perform.Type = (e_Perform_Type)Convert.ToInt32(ele.GetAttribute("Type"));
                            perform.Type2 = (e_Perform_Type2)Convert.ToInt32(ele.GetAttribute("PerformType"));
                            perform.ID = iPerformID;
                            perform.TTL = Convert.ToSingle(ele.GetAttribute("Time"));
                            perform.AnmName = ele.GetAttribute("AnmName");
                            perform.CtrlType = (e_Ctrl_Type)Convert.ToInt32(ele.GetAttribute("CtrlType1"));
                            perform.CtrlArg = (e_Ctrl_Arg)Convert.ToInt32(ele.GetAttribute("CtrlType2"));
                            perform.Grab = (Convert.ToInt32(ele.GetAttribute("IsGrab")) != 0);
                            perform.Weak = (Convert.ToInt32(ele.GetAttribute("IsWeak")) != 0);
                            perform.AttackType = (EXP_ATTACK_TYPE)Convert.ToInt32(ele.GetAttribute("AttackType"));
                            perform.Att = Convert.ToInt32(ele.GetAttribute("Att"));
                            perform.HitGfxID = Convert.ToInt32(ele.GetAttribute("HitGfx"));
                            perform.HitSfxID = Convert.ToInt32(ele.GetAttribute("HitSfx"));
                            perform.ShoutOdds = Convert.ToSingle(ele.GetAttribute("ShoutOdds"));
                            
                            for (int i = 0; i < ECPerform.FxIDNum; ++i)
                            {
                                string strName = string.Format("SkillGfxID{0}", i + 1);
                                perform.SkillGfxIDs[i] = Convert.ToInt32(ele.GetAttribute(strName));
                            }

                            for (int i = 0; i < ECPerform.FxIDNum; ++i)
                            {
                                string strName = string.Format("SkillSfxID{0}", i + 1);
                                perform.SkillSfxIDs[i] = Convert.ToInt32(ele.GetAttribute(strName));
                            }

                            PerformMap[iPerformID] = perform;
                        }

                        skill.PerformList.Add(perform);
                        skill.PerformCount = skill.PerformList.Count;

                        string strForce = ele.GetAttribute("Force");
                        if (strForce.Length > 1)
                            skill.ForceParams.Add(strForce);

                        skill.TTL += perform.TTL;
                    }
                    else if (ele.Name == "ChangeSelfPosInfo")
                    {
                        skill.ChangeSelfPos = true;
                        skill.ChangeSelfPosPerformIdx = Convert.ToInt32(ele.GetAttribute("PerformIdx"));
                        skill.ChangeSelfPosType = (e_ChangeSelfPos_Type)Convert.ToInt32(ele.GetAttribute("Type"));
                        skill.DistToDestRatio = Convert.ToSingle(ele.GetAttribute("DistToDestRatio"));
                        skill.MinDisplace = Convert.ToSingle(ele.GetAttribute("MinDisplace"));
                        skill.MaxDisplace = Convert.ToSingle(ele.GetAttribute("MaxDisplace"));
                        skill.Passable = (Convert.ToInt32(ele.GetAttribute("Pass")) == 1);
                        skill.ServerMove = (Convert.ToInt32(ele.GetAttribute("ServerMove")) == 1);
                        skill.MultiMove = (Convert.ToInt32(ele.GetAttribute("MultiMove")) == 1);
                    }
                    else if (ele.Name == "MoveJumpInfo")
                    {
                        ECSkillMoveJumpInfo skillMoveJumpInfo = new ECSkillMoveJumpInfo();
                        skillMoveJumpInfo.Type = (e_SkillMoveJumpInfo_Type)Convert.ToInt32(ele.GetAttribute("Type"));
                        skillMoveJumpInfo.PerformIdx = Convert.ToInt32(ele.GetAttribute("PerformIdx"));
                        skillMoveJumpInfo.BeginTime = Convert.ToSingle(ele.GetAttribute("BeginTime"));
                        skillMoveJumpInfo.EndTime = Convert.ToSingle(ele.GetAttribute("EndTime"));
                        skillMoveJumpInfo.UpTimeRatio = Convert.ToSingle(ele.GetAttribute("UpTimeRatio"));
                        skillMoveJumpInfo.UpDisplace = Convert.ToSingle(ele.GetAttribute("UpAcceleration"));

                        skill.SkillMoveJumpInfoList.Add(skillMoveJumpInfo);
                    }
                }
            }
#else
            SecurityParser doc = new SecurityParser();
			doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));
            SecurityElement root = doc.ToXml();

            foreach (SecurityElement skillEle in root.Children)
            {
                if (skillEle == null)
                    continue;

                int iSkillID = Convert.ToInt32(skillEle.Attribute("ID"));
                if (SkillMap.ContainsKey(iSkillID))
                {
                    Debug.LogWarning("Failed to add skill, ID: " + iSkillID);
                    return false;
                }

                ECSkill skill = new ECSkill();
                skill.Type = (e_Skill_Type)Convert.ToInt32(skillEle.Attribute("Type"));
                skill.ID = iSkillID;
                skill.Name = skillEle.Attribute("Name");
                skill.Rank = Convert.ToInt32(skillEle.Attribute("Rank"));
                skill.CtrlRank = Convert.ToInt32(skillEle.Attribute("CtrlRank"));

                strKey = "Move";
                if (skillEle.Attribute(strKey) != "")
                    skill.CanPushMove = (Convert.ToInt32(skillEle.Attribute(strKey)) != 0);

                strKey = "CastInCtrl";
                if (skillEle.Attribute(strKey) != "")
                    skill.CastInCtrl = (Convert.ToInt32(skillEle.Attribute(strKey)) != 0);

                skill.MinDisplace = Convert.ToSingle(skillEle.Attribute("MinDistance"));
                skill.MaxDisplace = Convert.ToSingle(skillEle.Attribute("MaxDistance"));

                //strKey = "CooldownID";
                //if (skillEle.Attribute(strKey) != "")
                //    skill.CooldownID = Convert.ToInt32(skillEle.Attribute(strKey));

                //strKey = "Cooldown";
                //if (skillEle.Attribute(strKey) != "")
                 //   skill.CooldownTime = Convert.ToSingle(skillEle.Attribute(strKey));

                SkillMap[skill.ID] = skill;

                foreach (SecurityElement ele in skillEle.Children)
                {
                    if (ele == null)
                        continue;

                    if (ele.Tag == "Perform")
                    {
                        int iPerformID = Convert.ToInt32(ele.Attribute("ID"));
                        ECPerform perform;
                        if (!PerformMap.TryGetValue(iPerformID, out perform))
                        {
                            perform = new ECPerform();
                            perform.Type = (e_Perform_Type)Convert.ToInt32(ele.Attribute("Type"));
                            perform.Type2 = (e_Perform_Type2)Convert.ToInt32(ele.Attribute("PerformType"));
                            perform.ID = iPerformID;
                            perform.TTL = Convert.ToSingle(ele.Attribute("Time"));
                            perform.AnmName = ele.Attribute("AnmName");
                            perform.CtrlType = (e_Ctrl_Type)Convert.ToInt32(ele.Attribute("CtrlType1"));
                            perform.CtrlArg = (e_Ctrl_Arg)Convert.ToInt32(ele.Attribute("CtrlType2"));
                            perform.Grab = (Convert.ToInt32(ele.Attribute("IsGrab")) != 0);
                            perform.Weak = (Convert.ToInt32(ele.Attribute("IsWeak")) != 0);
                            perform.AttackType = (EXP_ATTACK_TYPE)Convert.ToInt32(ele.Attribute("AttackType"));
                            perform.Att = Convert.ToInt32(ele.Attribute("Att"));
                            perform.HitGfxID = Convert.ToInt32(ele.Attribute("HitGfx"));
                            perform.HitSfxID = Convert.ToInt32(ele.Attribute("HitSfx"));
                            perform.ShoutOdds = Convert.ToSingle(ele.Attribute("ShoutOdds"));

                            for (int i = 0; i < ECPerform.FxIDNum; ++i)
                            {
                                string strName = string.Format("SkillGfxID{0}", i + 1);
                                perform.SkillGfxIDs[i] = Convert.ToInt32(ele.Attribute(strName));
                            }

                            for (int i = 0; i < ECPerform.FxIDNum; ++i)
                            {
                                string strName = string.Format("SkillSfxID{0}", i + 1);
                                perform.SkillSfxIDs[i] = Convert.ToInt32(ele.Attribute(strName));
                            }

                            PerformMap[iPerformID] = perform;
                        }

                        skill.PerformList.Add(perform);
                        skill.PerformCount = skill.PerformList.Count;

                        string strForce = ele.Attribute("Force");
                        if (strForce.Length > 1)
                            skill.ForceParams.Add(strForce);

                        skill.TTL += perform.TTL;
                    }
                    else if (ele.Tag == "ChangeSelfPosInfo")
                    {
                        skill.ChangeSelfPos = true;
                        skill.ChangeSelfPosPerformIdx = Convert.ToInt32(ele.Attribute("PerformIdx"));
                        skill.ChangeSelfPosType = (e_ChangeSelfPos_Type)Convert.ToInt32(ele.Attribute("Type"));
                        skill.DistToDestRatio = Convert.ToSingle(ele.Attribute("DistToDestRatio"));
                        skill.MinDisplace = Convert.ToSingle(ele.Attribute("MinDisplace"));
                        skill.MaxDisplace = Convert.ToSingle(ele.Attribute("MaxDisplace"));
                        skill.Passable = (Convert.ToInt32(ele.Attribute("Pass")) == 1);
                        skill.ServerMove = (Convert.ToInt32(ele.Attribute("ServerMove")) == 1);
                        skill.MultiMove = (Convert.ToInt32(ele.Attribute("MultiMove")) == 1);
                    }
                    else if (ele.Tag == "MoveJumpInfo")
                    {
                        ECSkillMoveJumpInfo skillMoveJumpInfo = new ECSkillMoveJumpInfo();
                        skillMoveJumpInfo.Type = (e_SkillMoveJumpInfo_Type)Convert.ToInt32(ele.Attribute("Type"));
                        skillMoveJumpInfo.PerformIdx = Convert.ToInt32(ele.Attribute("PerformIdx"));
                        skillMoveJumpInfo.BeginTime = Convert.ToSingle(ele.Attribute("BeginTime"));
                        skillMoveJumpInfo.EndTime = Convert.ToSingle(ele.Attribute("EndTime"));
                        skillMoveJumpInfo.UpTimeRatio = Convert.ToSingle(ele.Attribute("UpTimeRatio"));
                        skillMoveJumpInfo.UpDisplace = Convert.ToSingle(ele.Attribute("UpAcceleration"));

                        skill.SkillMoveJumpInfoList.Add(skillMoveJumpInfo);
                    }
                }
            }
#endif
        }
        return true;
    }
Exemplo n.º 20
0
        private static bool load_xml(byte[] pBuffer)
        {
            try
            {
                Debug.Check(pBuffer != null);
                string xml = System.Text.Encoding.UTF8.GetString(pBuffer);

                SecurityParser xmlDoc = new SecurityParser();
                xmlDoc.LoadXml(xml);

                SecurityElement rootNode = xmlDoc.ToXml();

                if (rootNode.Children == null || rootNode.Tag != "agents" && rootNode.Children.Count != 1)
                {
                    return false;
                }

                string versionStr = rootNode.Attribute("version");
                Debug.Check(!string.IsNullOrEmpty(versionStr));

                foreach(SecurityElement bbNode in rootNode.Children)
                {
                    if (bbNode.Tag == "agent" && bbNode.Children != null)
                    {
                        string agentType = bbNode.Attribute("type").Replace("::", ".");

                        AgentProperties bb = new AgentProperties(agentType);
                        agent_type_blackboards[agentType] = bb;

                        foreach(SecurityElement propertiesNode in bbNode.Children)
                        {
                            if (propertiesNode.Tag == "properties" && propertiesNode.Children != null)
                            {
                                foreach(SecurityElement propertyNode in propertiesNode.Children)
                                {
                                    if (propertyNode.Tag == "property")
                                    {
                                        string name = propertyNode.Attribute("name");
                                        string type = propertyNode.Attribute("type").Replace("::", ".");
                                        string memberStr = propertyNode.Attribute("member");
                                        bool bIsMember = false;

                                        if (!string.IsNullOrEmpty(memberStr) && memberStr == "true")
                                        {
                                            bIsMember = true;
                                        }

                                        string isStatic = propertyNode.Attribute("static");
                                        bool bIsStatic = false;

                                        if (!string.IsNullOrEmpty(isStatic) && isStatic == "true")
                                        {
                                            bIsStatic = true;
                                        }

                                        //string agentTypeMember = agentType;
                                        string agentTypeMember = null;
                                        string valueStr = null;

                                        if (!bIsMember)
                                        {
                                            valueStr = propertyNode.Attribute("defaultvalue");
                                        }
                                        else
                                        {
                                            agentTypeMember = propertyNode.Attribute("agent").Replace("::", ".");
                                        }

                                        bb.AddProperty(type, bIsStatic, name, valueStr, agentTypeMember);
                                    }
                                }
                            }
                            else if (propertiesNode.Tag == "methods" && propertiesNode.Children != null)
                            {
                                Agent.CTagObjectDescriptor objectDesc = Agent.GetDescriptorByName(agentType);
                                foreach(SecurityElement methodNode in propertiesNode.Children)
                                {
                                    if (methodNode.Tag == "method")
                                    {
                                        //string eventStr = methodNode.Attribute("isevent");
                                        //bool bEvent = (eventStr == "true");
                                        //string taskStr = methodNode.Attribute("istask");
                                        //bool bTask = (taskStr == "true");
                                        //skip those other custom method
                                        string methodName = methodNode.Attribute("name");
                                        //string type = methodNode.Attribute("returntype").Replace("::", ".");
                                        //string isStatic = methodNode.Attribute("static");
                                        //string agentTypeStr = methodNode.Attribute("agent").Replace("::", ".");
                                        CCustomMethod customeMethod = new CTaskMethod(agentType, methodName);

                                        if (methodNode.Children != null)
                                        {
                                            foreach(SecurityElement paramNode in methodNode.Children)
                                            {
                                                if (paramNode.Tag == "parameter")
                                                {
                                                    string paramName = paramNode.Attribute("name");
                                                    Debug.Check(!string.IsNullOrEmpty(paramName));

                                                    string paramType = paramNode.Attribute("type");

                                                    //string paramFullName = string.Format("{0}::{1}", paramType, paramName);

                                                    customeMethod.AddParamType(paramType);
                                                }
                                            }
                                        }

                                        objectDesc.ms_methods.Add(customeMethod);
                                    }
                                }//end of for methodNode
                            }//end of methods
                        }//end of for propertiesNode
                    }
                }//end of for bbNode

                return true;
            }
            catch (Exception e)
            {
                Debug.Check(false, e.Message);
            }

            Debug.Check(false);
            return false;
        }
Exemplo n.º 21
0
        static bool LoadWorkspaceSetting(string file, string ext, ref string workspaceFile)
        {
			try
			{
            	byte[] pBuffer = ReadFileToBuffer(file, ext);
                if (pBuffer != null)
                {
                    string xml = System.Text.Encoding.UTF8.GetString(pBuffer);
					SecurityParser xmlDoc = new SecurityParser();
                    xmlDoc.LoadXml(xml);

                    SecurityElement rootNode = xmlDoc.ToXml();
                    if (rootNode.Tag == "workspace")
                    {
                        workspaceFile = rootNode.Attribute("path");
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
				string errorInfo = string.Format("Load Workspace {0} Error : {1}", file, e.Message);
				behaviac.Debug.LogError(errorInfo);
			}

            return false;
        }
Exemplo n.º 22
0
        /**
        <?xml version="1.0" encoding="utf-8"?>
        <behavior agenttype="AgentTest">
        <!--EXPORTED BY TOOL, DON'T MODIFY IT!-.
        <!--Source File: ... -.
        <node class="DecoratorLoopTask">
        <property Count="10" />
        <node class="SelectorTask">
            ...
        </node>
        </node>
        </behavior>
        */

        public bool load_xml(byte[] pBuffer)
        {
            try
            {
                Debug.Check(pBuffer != null);
                string xml = System.Text.Encoding.UTF8.GetString(pBuffer);

#if BEHAVIAC_USE_SYSTEM_XML
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);

                XmlNode behaviorNode = xmlDoc.DocumentElement;

                if (behaviorNode.Name != "behavior" && behaviorNode.ChildNodes.Count != 1)
                {
                    return false;
                }

                this.m_name = behaviorNode.Attributes["name"].Value;
                string agentType = behaviorNode.Attributes["agenttype"].Value;
                string fsm = (behaviorNode.Attributes["fsm"] != null) ? behaviorNode.Attributes["fsm"].Value : null;
                string versionStr = behaviorNode.Attributes["version"].Value;
#else
                SecurityParser xmlDoc = new SecurityParser();
                xmlDoc.LoadXml(xml);

                SecurityElement behaviorNode = xmlDoc.ToXml();

                if (behaviorNode.Tag != "behavior" && (behaviorNode.Children == null || behaviorNode.Children.Count != 1))
                {
                    return false;
                }

                this.m_name = behaviorNode.Attribute("name");
                string agentType = behaviorNode.Attribute("agenttype").Replace("::", ".");
                string fsm = behaviorNode.Attribute("fsm");
                string versionStr = behaviorNode.Attribute("version");
#endif
                int version = int.Parse(versionStr);

                if (version != SupportedVersion)
                {
                    Debug.LogError(string.Format("'{0}' Version({1}), while Version({2}) is supported, please update runtime or rexport data using the latest designer", this.m_name, version, SupportedVersion));
                }

                this.SetClassNameString("BehaviorTree");
                this.SetId(-1);

                if (!string.IsNullOrEmpty(fsm) && fsm == "true")
                {
                    this.m_bIsFSM = true;
                }

                this.load_properties_pars_attachments_children(true, version, agentType, behaviorNode);

                return true;
            }
            catch (Exception e)
            {
                Debug.Check(false, e.Message);
            }

            Debug.Check(false);
            return false;
        }
Exemplo n.º 23
0
        /**
        <?xml version="1.0" encoding="utf-8"?>
        <behavior agenttype="AgentTest">
        <!--EXPORTED BY TOOL, DON'T MODIFY IT!-.
        <!--Source File: ... -.
        <node class="DecoratorLoopTask">
        <property Count="10" />
        <node class="SelectorTask">
            ...
        </node>
        </node>
        </behavior>
        */
        public bool load_xml(byte[] pBuffer)
        {
			try
			{
	            Debug.Check(pBuffer != null);
	            string xml = System.Text.Encoding.UTF8.GetString(pBuffer);

				SecurityParser xmlDoc = new SecurityParser();
				xmlDoc.LoadXml(xml);

				SecurityElement behaviorNode = xmlDoc.ToXml();
				if (behaviorNode.Tag != "behavior" && (behaviorNode.Children == null || behaviorNode.Children.Count != 1))
	            {
	                return false;
	            }

	            this.m_name = behaviorNode.Attribute("name");
	            string agentType = behaviorNode.Attribute("agenttype");
	            string versionStr = behaviorNode.Attribute("version");
	            int version = int.Parse(versionStr);

	            this.SetClassNameString("BehaviorTree");
	            this.SetId(-1);

	            this.load_properties_pars_attachments_children(true, version, agentType, behaviorNode);

				return true;
			}
			catch (Exception e)
			{
				Debug.Check(false, e.Message);
			}

			Debug.Check(false);
            return false;
        }
Exemplo n.º 24
0
		private PermissionSet CreateFromXml (string xml) 
		{
#if !NET_2_1
			SecurityParser sp = new SecurityParser ();
			try {
				sp.LoadXml (xml);
			}
			catch (Mono.Xml.SmallXmlParserException xe) {
				throw new XmlSyntaxException (xe.Line, xe.ToString ());
			}
			SecurityElement se = sp.ToXml ();

			string className = se.Attribute ("class");
			if (className == null)
				return null;

			PermissionState state = PermissionState.None;
			if (CodeAccessPermission.IsUnrestricted (se))
				state = PermissionState.Unrestricted;

			if (className.EndsWith ("NamedPermissionSet")) {
				NamedPermissionSet nps = new NamedPermissionSet (se.Attribute ("Name"), state);
				nps.FromXml (se);
				return (PermissionSet) nps;
			}
			else if (className.EndsWith ("PermissionSet")) {
				PermissionSet ps = new PermissionSet (state);
				ps.FromXml (se);
				return ps;
			}
#endif
			return null;
		}
Exemplo n.º 25
0
		public static SecurityElement FromString (string xml)
		{
			if (xml == null)
				throw new ArgumentNullException ("xml");
			if (xml.Length == 0)
				throw new XmlSyntaxException (Locale.GetText ("Empty string."));

			try {
				SecurityParser sp = new SecurityParser ();
				sp.LoadXml (xml);
				return sp.ToXml ();
			} catch (Exception e) {
				string msg = Locale.GetText ("Invalid XML.");
				throw new XmlSyntaxException (msg, e);
			}
		}
Exemplo n.º 26
0
        // 加载一个表完成
        public void onLoadEventHandle(IDispatchObject dispObj)
        {
            ResItem res = dispObj as ResItem;
            //Ctx.m_instance.m_logSys.debugLog_1(LangItemID.eItem0, res.GetPath());    // 这行执行的时候 m_isLoaded 设置加载标志,但是 m_nodeList 还没有初始化
            Ctx.m_instance.m_logSys.log("local xml loaded");

            string text = res.getText(m_ID2FileName[m_langID].m_filePath);
            if (text != null)
            {
                SecurityParser SP = new SecurityParser();
                SP.LoadXml(text);
                SecurityElement SE = SP.ToXml();
                m_nodeList = SE.Children;
            }

            // 卸载资源
            Ctx.m_instance.m_resLoadMgr.unload(res.GetPath(), onLoadEventHandle);
        }
Exemplo n.º 27
0
    private bool LoadSkillGfxData()
    {
        SkillGfxMap.Clear();

        string strFilePath = "Configs/SkillGfxData.xml";
#if USING_SYSTEM_XML
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));

        XmlElement root = doc.DocumentElement;
        foreach (XmlNode skillGfxNode in root.ChildNodes)
        {
            XmlElement skillGfxEle = skillGfxNode as XmlElement;
            if (skillGfxEle == null)
                continue;

            int iSkillGfxID = Convert.ToInt32(skillGfxEle.GetAttribute("ID"));
            if (SkillGfxMap.ContainsKey(iSkillGfxID))
            {
                Debug.LogWarning(string.Format("Failed to add existed skill gfx"));
                return false;
            }

            ECSkillGfx skillGfx = new ECSkillGfx();
            skillGfx.ID = Convert.ToInt32(skillGfxEle.GetAttribute("ID"));
            skillGfx.FilePath = skillGfxEle.GetAttribute("FilePath");
            skillGfx.BornTime = Convert.ToSingle(skillGfxEle.GetAttribute("Time"));
            skillGfx.RefBone = skillGfxEle.GetAttribute("RefBone");
            skillGfx.Pos.x = Convert.ToSingle(skillGfxEle.GetAttribute("Pos_x"));
            skillGfx.Pos.y = Convert.ToSingle(skillGfxEle.GetAttribute("Pos_y"));
            skillGfx.Pos.z = Convert.ToSingle(skillGfxEle.GetAttribute("Pos_z"));
            skillGfx.Rot.x = Convert.ToSingle(skillGfxEle.GetAttribute("Rot_x"));
            skillGfx.Rot.y = Convert.ToSingle(skillGfxEle.GetAttribute("Rot_y"));
            skillGfx.Rot.z = Convert.ToSingle(skillGfxEle.GetAttribute("Rot_z"));
            skillGfx.AsChild = Convert.ToBoolean(skillGfxEle.GetAttribute("AsChild"));
            skillGfx.SkillTargetPos = Convert.ToBoolean(skillGfxEle.GetAttribute("SkillTargetPos"));
            skillGfx.AnmScope = Convert.ToBoolean(skillGfxEle.GetAttribute("AnmScope"));
            skillGfx.AutoPosRot = (e_SkillGfxAutoPosRot)Convert.ToInt32(skillGfxEle.GetAttribute("AutoPosRot"));

            SkillGfxMap[iSkillGfxID] = skillGfx;
        }
#else
        SecurityParser doc = new SecurityParser();
        doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));

        SecurityElement root = doc.ToXml();
        foreach (SecurityElement skillGfxEle in root.Children)
        {
            if (skillGfxEle == null)
                continue;

            int iSkillGfxID = Convert.ToInt32(skillGfxEle.Attribute("ID"));
            if (SkillGfxMap.ContainsKey(iSkillGfxID))
            {
                Debug.LogWarning(string.Format("Failed to add existed skill gfx"));
                return false;
            }

            ECSkillGfx skillGfx = new ECSkillGfx();
            skillGfx.ID = Convert.ToInt32(skillGfxEle.Attribute("ID"));
            skillGfx.FilePath = skillGfxEle.Attribute("FilePath");
            skillGfx.BornTime = Convert.ToSingle(skillGfxEle.Attribute("Time"));
            skillGfx.RefBone = skillGfxEle.Attribute("RefBone");
            skillGfx.Pos.x = Convert.ToSingle(skillGfxEle.Attribute("Pos_x"));
            skillGfx.Pos.y = Convert.ToSingle(skillGfxEle.Attribute("Pos_y"));
            skillGfx.Pos.z = Convert.ToSingle(skillGfxEle.Attribute("Pos_z"));
            skillGfx.Rot.x = Convert.ToSingle(skillGfxEle.Attribute("Rot_x"));
            skillGfx.Rot.y = Convert.ToSingle(skillGfxEle.Attribute("Rot_y"));
            skillGfx.Rot.z = Convert.ToSingle(skillGfxEle.Attribute("Rot_z"));
            skillGfx.AsChild = Convert.ToBoolean(skillGfxEle.Attribute("AsChild"));
            skillGfx.SkillTargetPos = Convert.ToBoolean(skillGfxEle.Attribute("SkillTargetPos"));
            skillGfx.AnmScope = Convert.ToBoolean(skillGfxEle.Attribute("AnmScope"));
            skillGfx.AutoPosRot = (e_SkillGfxAutoPosRot)Convert.ToInt32(skillGfxEle.Attribute("AutoPosRot"));

            SkillGfxMap[iSkillGfxID] = skillGfx;
        }
#endif
        return true;
    }
		private void FromXml (string xml) 
		{
			SecurityParser sp = new SecurityParser ();
			sp.LoadXml (xml);

			SecurityElement root = sp.ToXml ();
			if (root.Tag == "KeyPair") {
				//SecurityElement prop = root.SearchForChildByTag ("Properties");
				SecurityElement keyv = root.SearchForChildByTag ("KeyValue");
				if (keyv.Children.Count > 0)
					_keyvalue = keyv.Children [0].ToString ();
				// Note: we do not read other stuff because 
				// it can't be changed after key creation
			}
		}
Exemplo n.º 29
0
    private bool LoadSubObjectSkillData()
    {
        SubObjectSkillMap.Clear();
        SubObjectPerformMap.Clear();

        string strFilePath = "Configs/SubObjectSkillData_1.xml";
#if USING_SYSTEM_XML
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));

        XmlElement root = doc.DocumentElement;

        foreach (XmlNode skillNode in root.ChildNodes)
        {
            XmlElement skillEle = skillNode as XmlElement;
            if (skillEle == null)
                continue;

            int iSkillID = Convert.ToInt32(skillEle.GetAttribute("ID"));
            if (SubObjectSkillMap.ContainsKey(iSkillID))
            {
                Debug.LogWarning("Failed to add subobject skill, ID: " + iSkillID);
                return false;
            }

            ECSubObjSkill ss = new ECSubObjSkill();
            ss.ID = iSkillID;

            foreach (XmlNode node in skillEle.ChildNodes)
            {
                XmlElement ele = node as XmlElement;
                if (ele == null)
                    continue;

                if (ele.Name == "Perform")
                {
                    ECPerform perform = new ECPerform();
                    perform.Type = (e_Perform_Type)Convert.ToInt32(ele.GetAttribute("Type"));
                    perform.ID = Convert.ToInt32(ele.GetAttribute("ID"));
                    perform.SkillGfxIDs[0] = Convert.ToInt32(ele.GetAttribute("GfxID"));
                    perform.HitGfxID = Convert.ToInt32(ele.GetAttribute("HitGfx"));
                    perform.HitSfxID = Convert.ToInt32(ele.GetAttribute("HitSfx"));

                    ss.PerformList.Add(perform);

                    SubObjectPerformMap[perform.ID] = perform;
                }
            }

            SubObjectSkillMap[iSkillID] = ss;
        }
#else
        SecurityParser doc = new SecurityParser();
        doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));

        SecurityElement root = doc.ToXml();
        foreach (SecurityElement skillEle in root.Children)
        {
            if (skillEle == null)
                continue;

            int iSkillID = Convert.ToInt32(skillEle.Attribute("ID"));
            if (SubObjectSkillMap.ContainsKey(iSkillID))
            {
                Debug.LogWarning("Failed to add subobject skill, ID: " + iSkillID);
                return false;
            }

            ECSubObjSkill ss = new ECSubObjSkill();
            ss.ID = iSkillID;

            foreach (SecurityElement ele in skillEle.Children)
            {
                if (ele == null)
                    continue;

                if (ele.Tag == "Perform")
                {
                    ECPerform perform = new ECPerform();
                    perform.Type = (e_Perform_Type)Convert.ToInt32(ele.Attribute("Type"));
                    perform.ID = Convert.ToInt32(ele.Attribute("ID"));
                    perform.SkillGfxIDs[0] = Convert.ToInt32(ele.Attribute("GfxID"));
                    perform.HitGfxID = Convert.ToInt32(ele.Attribute("HitGfx"));
                    perform.HitSfxID = Convert.ToInt32(ele.Attribute("HitSfx"));

                    ss.PerformList.Add(perform);

                    SubObjectPerformMap[perform.ID] = perform;
                }
            }

            SubObjectSkillMap[iSkillID] = ss;
        }
#endif
        return true;
    }
Exemplo n.º 30
0
		// In Fx 1.0/1.1 there is not direct way to load a XML file 
		// into a SecurityElement so we use SecurityParser from 
		// Mono.Security.dll.
		static SecurityElement LoadXml (string filename)
		{
			if (!File.Exists (filename)) {
				Console.WriteLine ("Couldn't not find '{0}'.", filename);
				return null;
			}

			string xml = null;
			using (StreamReader sr = new StreamReader (filename)) {
				xml = sr.ReadToEnd ();
				sr.Close ();
			}
#if NET_2_0
			// actually this use the SecurityParser (on the Mono 
			// runtime) in corlib do to the job - but it remove 
			// the dependency on Mono.Security.dll
			SecurityElement se = SecurityElement.FromString (xml);
#else
			SecurityParser sp = new SecurityParser ();
			sp.LoadXml (xml);
			SecurityElement se = sp.ToXml ();
#endif
			return se;
		}
Exemplo n.º 31
0
Arquivo: ECMall.cs Projeto: fengqk/Art
    public bool LoadMallData()
    {
        ItemMap.Clear();

        string strFilePath = "Configs/malldata.xml";

#if USING_SYSTEM_XML     
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));

        XmlElement root = doc.DocumentElement;
        foreach (XmlNode rootChildNode in root.ChildNodes)
        {
            XmlElement rootChildEle = rootChildNode as XmlElement;
            if (rootChildEle == null)
                continue;

            if (rootChildEle.Name == "item_list")
            {
                foreach (XmlNode itemNode in rootChildNode.ChildNodes)
                {
                    XmlElement itemEle = itemNode as XmlElement;
                    if (itemEle == null)
                        continue;

                    ECMallItem item = new ECMallItem();
                    item.ID = Convert.ToInt32(itemEle.GetAttribute("id"));

                    foreach (XmlNode itemAttrNode in itemNode.ChildNodes)
                    {
                        XmlElement itemAttrEle = itemAttrNode as XmlElement;
                        if (itemAttrEle == null)
                            continue;

                        if (itemAttrEle.Name == "name")
                        {
                            item.Name = itemAttrEle.GetAttribute("value");
                        }
                        else if (itemAttrEle.Name == "templ_id")
                        {
                            item.TemplID = Convert.ToInt32(itemAttrEle.GetAttribute("value"));                            
                        }
                        else if (itemAttrEle.Name == "count")
                        {
                            string strVal = itemAttrEle.GetAttribute("value");
                            item.Count = (strVal.Length == 0) ? 0 : Convert.ToInt32(strVal);
                        }
                        else if (itemAttrEle.Name == "is_new")
                        {
                            item.IsNew = Convert.ToBoolean(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "is_hot")
                        {
                            item.IsHot = Convert.ToBoolean(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "is_promote")
                        {
                            item.IsPromote = Convert.ToBoolean(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "is_time_limit")
                        {
                            item.IsTimeLimit = Convert.ToBoolean(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "original_price")
                        {
                            item.OriginalPrice = Convert.ToInt32(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "restrict_level_min")
                        {
                            item.RestrictLevelMin = Convert.ToInt32(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "restrict_level_max")
                        {
                            item.RestrictLevelMax = Convert.ToInt32(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "restrict_vip_level_min")
                        {
                            item.RestrictVIPLevel = Convert.ToInt32(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "restrict_prof")
                        {
                            string prof_string = itemAttrEle.GetAttribute("value");
                            item.RestrictProf = UInt32.Parse(prof_string.Substring(2), System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (itemAttrEle.Name == "restrict_gender")
                        {
                            string gender_string = itemAttrEle.GetAttribute("value");
                            item.RestrictGender = UInt32.Parse(gender_string.Substring(2), System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (itemAttrEle.Name == "sell_begin_time")
                        {
                            item.SellBeginTime = Convert.ToInt32(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "sell_end_time")
                        {
                            item.SellEndTime = Convert.ToInt32(itemAttrEle.GetAttribute("value"));
                        }
                        else if (itemAttrEle.Name == "need_input_num")
                        {
                            item.BuyType = 0;
                            bool can_buy_multi = Convert.ToBoolean(itemAttrEle.GetAttribute("value"));
                            if( can_buy_multi )
                                item.BuyType = 1;
                        }
                        else if (itemAttrEle.Name == "payments")
						{
                            XmlElement paymentEle = itemAttrEle.ChildNodes[0] as XmlElement;
                            item.PaymentType = Convert.ToInt32(paymentEle.GetAttribute("type"));
                            item.CurrentPrice = Convert.ToInt32(paymentEle.GetAttribute("price"));
						}
                    }

                    if (ItemMap.ContainsKey(item.ID))
                        Debug.Log(string.Format("Failed to add duplicate mall item, ID: {0}", item.ID));
                    else
                        ItemMap[item.ID] = item;
                }
            }
            else if (rootChildEle.Name == "mall_tree")
            {
                foreach (XmlNode catalogNode in rootChildNode.ChildNodes)
                {
                    XmlElement catalogEle = catalogNode as XmlElement;
                    if (catalogEle == null)
                        continue;

                    ECMallCatalog catalog = new ECMallCatalog();
                    catalog.Name = catalogEle.GetAttribute("name");

                    foreach (XmlNode catalogItemNode in catalogNode.ChildNodes)
                    {
                        XmlElement catalogItemEle = catalogItemNode as XmlElement;
                        if (catalogItemEle == null)
                            continue;

                        ECMallCatalogItem catalogItem = new ECMallCatalogItem();
                        catalogItem.ID = Convert.ToInt32(catalogItemEle.GetAttribute("id"));
                        catalogItem.ShowModel = Convert.ToBoolean(catalogItemEle.GetAttribute("showmodel"));
                        catalog.ItemList.Add(catalogItem);
                    }

                    CatalogList[catalog.Name] = catalog;
                }
            }
        }
#else
        SecurityParser doc = new SecurityParser();
        doc.LoadXml(AFileWrapper.af_ReadAllText(strFilePath));
        SecurityElement root = doc.ToXml();

        foreach (SecurityElement rootChildEle in root.Children)
        {
            if (rootChildEle == null)
                continue;

            if (rootChildEle.Tag == "item_list")
            {
                foreach (SecurityElement itemEle in rootChildEle.Children)
                {
                    if (itemEle == null)
                        continue;

                    ECMallItem item = new ECMallItem();
                    item.ID = Convert.ToInt32(itemEle.Attribute("id"));

                    foreach (SecurityElement itemAttrEle in itemEle.Children)
                    {
                        if (itemAttrEle == null)
                            continue;

                        if (itemAttrEle.Tag == "name")
                        {
                            item.Name = itemAttrEle.Attribute("value");
                        }
                        else if (itemAttrEle.Tag == "templ_id")
                        {
                            item.TemplID = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "count")
                        {
                            string strVal = itemAttrEle.Attribute("value");
                            item.Count = (strVal.Length == 0) ? 0 : Convert.ToInt32(strVal);
                        }
                        else if (itemAttrEle.Tag == "is_new")
                        {
                            item.IsNew = Convert.ToBoolean(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "is_hot")
                        {
                            item.IsHot = Convert.ToBoolean(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "is_promote")
                        {
                            item.IsPromote = Convert.ToBoolean(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "is_time_limit")
                        {
                            item.IsTimeLimit = Convert.ToBoolean(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "original_price")
                        {
                            item.OriginalPrice = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "restrict_level_min")
                        {
                            item.RestrictLevelMin = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "restrict_level_max")
                        {
                            item.RestrictLevelMax = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "restrict_vip_level_min")
                        {
                            item.RestrictVIPLevel = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "restrict_prof")
                        {
                            string prof_string = itemAttrEle.Attribute("value");
                            item.RestrictProf = UInt32.Parse(prof_string.Substring(2), System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (itemAttrEle.Tag == "restrict_gender")
                        {
                            string gender_string = itemAttrEle.Attribute("value");
                            item.RestrictGender = UInt32.Parse(gender_string.Substring(2), System.Globalization.NumberStyles.HexNumber);
                        }
                        else if (itemAttrEle.Tag == "sell_begin_time")
                        {
                            item.SellBeginTime = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "sell_end_time")
                        {
                            item.SellEndTime = Convert.ToInt32(itemAttrEle.Attribute("value"));
                        }
                        else if (itemAttrEle.Tag == "need_input_num")
                        {
                            item.BuyType = 0;
                            bool can_buy_multi = Convert.ToBoolean(itemAttrEle.Attribute("value"));
                            if (can_buy_multi)
                                item.BuyType = 1;
                        }
                        else if (itemAttrEle.Tag == "cmn_uselimit_to_buy")
                        {
                            item.cmn_uselimit_to_buy = Convert.ToInt32(itemAttrEle.Attribute("value"));
                         }
                        else if (itemAttrEle.Tag == "payments")
                        {
                            SecurityElement paymentEle = itemAttrEle.Children[0] as SecurityElement;
                            item.PaymentType = Convert.ToInt32(paymentEle.Attribute("type"));
                            item.CurrentPrice = Convert.ToInt32(paymentEle.Attribute("price"));
                        }
                    }

                    if (ItemMap.ContainsKey(item.ID))
                        Debug.Log(string.Format("Failed to add duplicate mall item, ID: {0}", item.ID));
                    else
                        ItemMap[item.ID] = item;
                }
            }
            else if (rootChildEle.Tag == "mall_tree")
            {
                foreach (SecurityElement catalogEle in rootChildEle.Children)
                {
                    if (catalogEle == null)
                        continue;

                    ECMallCatalog catalog = new ECMallCatalog();
                    catalog.Name = catalogEle.Attribute("name");

                    if (catalogEle.Children != null)
                    {
                        foreach (SecurityElement catalogItemEle in catalogEle.Children)
                        {
                            if (catalogItemEle == null)
                                continue;

                            ECMallCatalogItem catalogItem = new ECMallCatalogItem();
                            catalogItem.ID = Convert.ToInt32(catalogItemEle.Attribute("id"));
                            catalogItem.ShowModel = Convert.ToBoolean(catalogItemEle.Attribute("showmodel"));
                            catalog.ItemList.Add(catalogItem);
                        }
                    }

                    CatalogList.Add(catalog);
                }
            }
        }
#endif
		//fill ItemTID in catalogList
		foreach (var catalog in CatalogList)
		{
			foreach (var catalogItem in catalog.ItemList)
			{
				var item = GetItem(catalogItem.ID);
				catalogItem.ItemTID = item != null ? item.TemplID : 0;
			}
		}
        return true;
    }