Exemplo n.º 1
0
    private bool LoadRoleRankXml(bool IsError = false)
    {
        if (IsError)
        {
            m_IsLoadXmlInfo = true;
            RankXmlMap.Clear();               //清空数据
            tagRankXmlChangeEvent pEvent = new tagRankXmlChangeEvent();
            MsgEventHandle.HandleMsg(pEvent); //添加排行榜XML文件读取成功的函数
            return(true);
        }
        //读取配置文件 并且加载到数据集合里面去
        DateTime time     = SystemTime.Instance.GetSystemDateTime;
        UInt32   WriteSec = FishConfig.Instance.GetWriteSec();

        time = time.AddSeconds(WriteSec * -1);
        string FileName = string.Format("Rank_{0}_{1}_{2}.xml", time.Year, time.Month, time.Day);

        Byte[]      FileText = RuntimeInfo.GetLocalFile(FileName);
        XmlDocument doc      = new XmlDocument();

        doc.LoadXml(System.Text.Encoding.UTF8.GetString(FileText));
        XmlElement pRankConfig = doc.DocumentElement;

        for (int i = 0; i < doc.ChildNodes.Count; ++i)
        {
            if (doc.ChildNodes[i].Name == "FishRanks")
            {
                for (int k = 0; k < doc.ChildNodes[i].ChildNodes.Count; ++k)
                {
                    if (doc.ChildNodes[i].ChildNodes[k].Name == "FishRook")
                    {
                        RankInfo pRankInfo = new RankInfo();
                        pRankInfo.RankID = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].Attributes["TypeID"].Value);

                        for (int j = 0; j < doc.ChildNodes[i].ChildNodes[k].ChildNodes.Count; ++j)
                        {
                            if (doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Name == "Info")
                            {
                                tagRankInfo pInfo = new tagRankInfo();
                                pInfo.bIndex   = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Index"].Value);
                                pInfo.dwFaceID = Convert.ToUInt32(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["FaceID"].Value);
                                pInfo.dwUserID = Convert.ToUInt32(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["UserID"].Value);
                                pInfo.Gender   = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Gender"].Value) == 1 ? true : false;
                                pInfo.NickName = Convert.ToString(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Name"].Value);
                                pInfo.TitleID  = Convert.ToByte(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["TitleID"].Value);
                                pInfo.Param    = Convert.ToInt64(doc.ChildNodes[i].ChildNodes[k].ChildNodes[j].Attributes["Param"].Value);

                                pRankInfo.RankMap.Add(pInfo.bIndex, pInfo);
                            }
                        }
                        RankXmlMap.Add(pRankInfo.RankID, pRankInfo);
                    }
                }
                m_IsLoadXmlInfo = true;
                return(true);
            }
        }
        return(false);
    }
 public RankItemUI(RankType type, tagRankInfo rankInfo)
 {
     m_RankType = type;
     m_RankInfo = rankInfo;
     m_bFriends = false;
 }