コード例 #1
0
    ///\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    //XmlNode RowID = Doc.CreateElement("RowID");
    //XmlNode pic = Doc.CreateElement("pic");
    //XmlNode score = Doc.CreateElement("score");
    //XmlNode sence = Doc.CreateElement("sence");
    //XmlNode starCount = Doc.CreateElement("starCount");
    //XmlNode isLocked = Doc.CreateElement("isLocked");
    public static void insert(IGLevelMode leveldata)
    {
        string path =IGState.GetLevelDataPath() ; // GetXmlFullPath() ;

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load( path );

        XmlNode root = xmlDoc.SelectSingleNode("gamelevel");
        XmlElement _xmlElement = xmlDoc.CreateElement("level");
        _xmlElement.SetAttribute("id", leveldata.ID +"" );

        XmlElement xesub_pic = xmlDoc.CreateElement("pic");
        xesub_pic.InnerText = leveldata.pic ;
        _xmlElement.AppendChild(xesub_pic);

        XmlElement xesub_score = xmlDoc.CreateElement("score");
        xesub_score.InnerText = leveldata.score +"" ;
        _xmlElement.AppendChild(xesub_score);

        XmlElement xesub_sence = xmlDoc.CreateElement("sence");
        xesub_sence.InnerText = leveldata.sence +"" ;
        _xmlElement.AppendChild(xesub_sence);

        XmlElement xesub_starCount = xmlDoc.CreateElement("starCount");
        xesub_starCount.InnerText = leveldata.starCount +"";
        _xmlElement.AppendChild(xesub_starCount);

        XmlElement xesub_isLocked = xmlDoc.CreateElement("isLocked");
        xesub_isLocked.InnerText = leveldata.isLocked +"" ;
        _xmlElement.AppendChild(xesub_isLocked);

        root.AppendChild(_xmlElement);//添加到节点中
        xmlDoc.Save( path );
    }
コード例 #2
0
    static void InitLevelData()
    {
        string path =IGState.GetLevelDataPath() ;

        // GetXmlFullPath() ;
        // using System.Xml ;

           		XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load( path );
        XmlNodeList rootnodeList = xmlDoc.SelectSingleNode("gamelevel").ChildNodes;

        //Debug.Log(string.Format("id={0},score={1},starcount={2}",id,score,starcount) );
        foreach (XmlNode xn in rootnodeList)
        {
            IGLevelMode lm=new IGLevelMode ()   ;
            XmlElement xe = (XmlElement)xn  ;
            XmlNodeList nls = xe.ChildNodes ;

            lm.ID = System.Convert.ToInt32(  xe.Attributes[0].Value ) ;
            foreach (XmlNode xnchlid in nls)
            {
                XmlElement xeclild = (XmlElement)xnchlid;
                if (xeclild.Name == "score")
                {
                    lm.score  = System.Convert.ToInt32( xeclild.InnerText ) ;  ;
                }

                if (xeclild.Name == "starCount")
                {
                   lm.starCount = System.Convert.ToInt32( xeclild.InnerText ) ;  ;
                }

                if (xeclild.Name == "isLocked")
                {
                    lm.isLocked  = System.Convert.ToBoolean( xeclild.InnerText ) ;  ;
                }
            }

            IGState.LevelDataList.Add(lm.ID,lm);
            // break ;
        }

        /*
        string selectlevelsql = " select id, score,starCount,isLocked from [GameLevels] " ;
        // SQLHelper sh = new SQLHelper () ;
        // sh.executeNonQuery(sql);

        using (SqliteDataReader reader =sh.executeReader (  selectlevelsql ) )
        {
            GameState.LevelDataList.Clear();
            while ( reader.Read() )
            {
                LevelMode lm=new LevelMode ();
                lm.ID = reader.GetInt32 (0);
                lm.score = reader.GetInt32 (1);
                lm.starCount = reader.GetInt32 (2);
                lm.isLocked = reader.GetBoolean (3);
                GameState.LevelDataList.Add(lm.ID,lm);
         		//Debug.Log( string.Format("id={0},ispass={1}, pic={2},score={3},sence={4},getstar={5}",id,ispass,pic,score,sence,getstar ) );
            }
        }

        */
    }
コード例 #3
0
    public void XMLInsert( IGLevelMode leveldata, string bz, int childNodesIndex )
    {
        IList _list = new ArrayList();
        string Load =  "\\" + bz + ".xml";

        XmlDocument Doc = new XmlDocument();

        XmlNode RowID = Doc.CreateElement("RowID");
        XmlNode pic = Doc.CreateElement("pic");
        XmlNode score = Doc.CreateElement("score");
        XmlNode sence = Doc.CreateElement("sence");
        XmlNode starCount = Doc.CreateElement("starCount");
        XmlNode isLocked = Doc.CreateElement("isLocked");

        //XmlAttribute RowID = Doc.CreateAttribute("RowID");
        //---------------------------------------------------------------

        XmlAttribute RowType = Doc.CreateAttribute("RowType");
        RowType.Value = leveldata.ID.ToString();

        XmlText strpic = Doc.CreateTextNode(leveldata.pic );
        XmlText strscore = Doc.CreateTextNode(leveldata.score.ToString() );
        XmlText strsence = Doc.CreateTextNode(leveldata.sence.ToString());
        XmlText strstarCount = Doc.CreateTextNode(leveldata.starCount.ToString() );
        XmlText strisLocked = Doc.CreateTextNode(leveldata.isLocked.ToString() );

        //----------------------------------------------------------------

        RowID.Attributes.Append(RowType);

        //RowNodes.Attributes.Append(RowID);
        RowID.AppendChild(pic);
        RowID.AppendChild(score);
        RowID.AppendChild(sence);
        RowID.AppendChild(starCount);
        RowID.AppendChild(isLocked);

        score.AppendChild(strscore);
        sence.AppendChild(strsence);
        pic.AppendChild(strpic);
        starCount.AppendChild(strstarCount);
        isLocked.AppendChild(strisLocked);

        // if (leveldata.Flag == 1)
        {
            try
            {
                Doc.Load(Load);
                XmlNode root = Doc.DocumentElement;

                for (int i = 0; i < root.ChildNodes.Count; i++)
                {
                    _list.Add(root.ChildNodes.Item(i));
                }
                // root.ChildNodes.Count
                for (int i = 0; i < _list.Count; i++)
                {
                    if (childNodesIndex == i)
                    {
                        root.AppendChild(RowID);
                        root.AppendChild((XmlNode)_list[i]);
                    }
                    else
                        root.AppendChild((XmlNode)_list[i]);
                }

                Doc.Save(Load);
            }
            catch (Exception e)
            {

            }
        }
    }