Esempio n. 1
0
        //加载角色
        private void LoadFigure(string sFigureName)
        {
            //先搜索角色列表,打开该角色
            CFigure tempFig = g_FigureList.Find(x => x.sName == sFigureName);

            if (tempFig == null)
            {
                CFigure newFigure = new CFigure(sFigureName);
                g_FigureList.Add(newFigure);
                g_CurrEditFigure = newFigure;
            }
            else
            {
                g_CurrEditFigure = tempFig;
            }

            //刷新控件显示
            listBox2.DataSource    = null;
            listBox2.DisplayMember = "m_sShowText";
            listBox2.DataSource    = g_CurrEditFigure.CardList;

            //显示人物名
            label_FigureName.Text = sFigureName;

            //加载任务的卡牌图片
            LoadCardImgList();
        }
Esempio n. 2
0
        //读xml
        private void ReadXml()
        {
            if (!File.Exists(g_sXmlDirPath + g_sXmlName))
            {
                return;
            }

            XDocument doc           = XDocument.Load(g_sXmlDirPath + g_sXmlName);
            XElement  root          = doc.Root;
            XElement  UserConfig    = root.Element("UserConfig");
            XElement  ControlSelect = UserConfig.Element("ControlSelect");

            XElement Param = ControlSelect.Element("nRace");

            g_nRace = long.Parse(Param.Value);
            g_nRace = g_nRace < 0 ? 0 : g_nRace;
            g_nRace = g_nRace > 2 ? 2 : g_nRace;

            Param     = ControlSelect.Element("nCareer");
            g_nCareer = long.Parse(Param.Value);
            g_nCareer = g_nCareer < 0 ? 0 : g_nCareer;
            g_nCareer = g_nCareer > 2 ? 2 : g_nCareer;

            //读取角色数据
            g_FigureList.Clear();
            XElement FigureData = root.Element("FigureData");

            if (FigureData != null)
            {
                int nFigureCount = int.Parse(FigureData.Element("nFigureCount").Value);
                for (int i = 0; i < nFigureCount; i++)
                {
                    string   sFigureName = FigureData.Element(string.Format("FigureName{0}", i)).Value;
                    CFigure  tempFigure  = new CFigure(sFigureName);
                    long     nCardCount  = int.Parse(FigureData.Element(string.Format("CardCount{0}", i)).Value);
                    XElement tempElement = FigureData.Element(sFigureName);
                    for (int j = 0; j < nCardCount; j++)
                    {
                        string sCardName = tempElement.Element(string.Format("CardName{0}", j)).Value;
                        long   nCount    = long.Parse(tempElement.Element(string.Format("Count{0}", j)).Value);
                        tempFigure.AddCard(sCardName, nCount);
                    }
                    g_FigureList.Add(tempFigure);
                }
            }
        }
Esempio n. 3
0
        //写xml
        private void WriteXml()
        {
            if (!Directory.Exists(g_sXmlDirPath))
            {
                return;
            }

            XDocument doc  = new XDocument();
            XElement  root = new XElement("SaveData");
            //保存用户配置
            XElement UserConfig    = new XElement("UserConfig");
            XElement ControlSelect = new XElement("ControlSelect");

            ControlSelect.SetElementValue("nRace", g_nRace);
            ControlSelect.SetElementValue("nCareer", g_nCareer);
            UserConfig.Add(ControlSelect);
            root.Add(UserConfig);

            //保存角色数据
            XElement FigureData   = new XElement("FigureData");
            int      nFigureCount = g_FigureList.Count;

            FigureData.SetElementValue("nFigureCount", nFigureCount);
            for (int i = 0; i < nFigureCount; i++)
            {
                CFigure tempiFigure = g_FigureList[i];
                FigureData.SetElementValue(string.Format("FigureName{0}", i), tempiFigure.sName);
                XElement tempElement = new XElement(tempiFigure.sName);
                long     nCardCount  = tempiFigure.CardList.Count;
                FigureData.SetElementValue(string.Format("CardCount{0}", i), nCardCount);
                for (int j = 0; j < nCardCount; j++)
                {
                    tempElement.SetElementValue(string.Format("CardName{0}", j), tempiFigure.CardList[j].m_sName);
                    tempElement.SetElementValue(string.Format("Count{0}", j), tempiFigure.CardList[j].m_nCount);
                }
                FigureData.Add(tempElement);
            }
            root.Add(FigureData);

            doc.Add(root);
            doc.Save(g_sXmlDirPath + g_sXmlName);
            //保存角色类
        }