Exemplo n.º 1
0
        public static GameConfigVo createGameConfigVoByXml()
        {
            GameConfigVo vo             = new GameConfigVo();
            string       configRootPath = Application.dataPath + "/Editor/Doc/";
            XmlDocument  xmlDoc         = new XmlDocument();

            xmlDoc.Load(configRootPath + "Configs/GameConfig.xml");
            XmlNodeList itemList = xmlDoc.SelectNodes("GameConfigs/GameInfo");

            XmlNode node = itemList[0];
            Type    t    = typeof(GameConfigVo);

            FieldInfo[] fs = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

            for (int i = 0; i < fs.Length; i++)
            {
                FieldInfo field           = fs[i] as FieldInfo;
                string    resultFieldName = field.Name.Substring(1, field.Name.Length - 1); // private int _id -- > id ;
                if (node.Attributes[resultFieldName] != null)
                {
                    field.SetValue(vo, node.Attributes[resultFieldName].Value);
                }
            }

            return(vo);
        }
Exemplo n.º 2
0
 public static void openGameConfig()
 {
     GameConfigVo vo = GameTools.createGameConfigVoByXml();
     System.Diagnostics.Process p = new System.Diagnostics.Process();
     p.StartInfo.FileName = vo.comment_textEditorEXE;
     p.StartInfo.Arguments = vo.comment_gameConfigXmlFilePath;
     p.Start();
 }
Exemplo n.º 3
0
        private static void addTags(GameConfigVo vo)
        {
            SerializedObject   tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
            SerializedProperty it         = tagManager.GetIterator();
            SerializedProperty tagit      = null;

            string[] tagsLst = vo.tags.Split(new char[] { ',' });

            //  删除所有Tag
            while (it.NextVisible(true))
            {
                if (it.name == "tags")
                {
                    tagit = it;
                    break;
                }
            }

            tagit.ClearArray();
            tagit.arraySize = tagsLst.Length + 1;

            for (int i = 0; i < tagit.arraySize - 1; i++)
            {
                SerializedProperty dataPoint = tagit.GetArrayElementAtIndex(i);
                if (string.IsNullOrEmpty(dataPoint.stringValue))
                {
                    string tagVal = tagsLst[i];
                    tagVal = tagVal.Replace("\t", "").Trim();
                    dataPoint.stringValue = tagVal;
                }
            }
            tagManager.ApplyModifiedProperties();


            //  更新cs文件
            String        enter = "\n";
            StringBuilder sb    = new StringBuilder();

            sb.Append("\t/// <summary>").Append(enter);
            sb.Append("\t/// 自动生成不要修改").Append(enter);
            sb.Append("\t/// </summary>").Append(enter);
            sb.Append("public class GameTagsConstent{").Append(enter);

            foreach (string tags in tagsLst)
            {
                string tagsVal = tags.Replace("\t", "").Trim();
                sb.Append(" public const string  " + tags + " = \"" + tagsVal + "\";").Append(enter);
            }
            sb.Append("}").Append(enter);

            File.WriteAllText(vo.comment_gametags_filePath.Replace("{assetsPath}", Application.dataPath), sb.ToString());
        }
Exemplo n.º 4
0
        private static void convertionXmlToBytes()
        {
            GameConfigVo vo = GameTools.createGameConfigVoByXml();

            string[]       resultInfoArr = vo.packageArrRef.Split(new char[] { ':' });
            CompreResultVo cr            = new CompreResultVo();

            cr.filePath     = resultInfoArr[0];
            cr.childFileArr = resultInfoArr[1].Split(new char[] { ',' });
            processCompreXmlVo(cr);
            processCompreResultVo(cr);

            removeXmlNodeLst.RemoveAll(delegate(XmlNode node) { return(true); });
        }
Exemplo n.º 5
0
        public static void openFile( string path )
        {
            GameConfigVo vo = GameTools.createGameConfigVoByXml();
            string editFile = vo.comment_textEditorEXE;

            if ( File.Exists( editFile ) )
            {
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = vo.comment_textEditorEXE;
                p.StartInfo.Arguments = path;
                p.Start();
            }
            else
            {
                throw new Exception( editFile + " not exists ! input comment_textEditorEXE val --> gameConfig.xml" );
            }
        }
Exemplo n.º 6
0
        public static void buildGameConfigCSharpFiles()
        {
            //  1. 将Gameconfig.xml 转换成 GameConfigVo.cs
            doBuildGameConfigCSharpFiles();

            //  2. 将GameConfig.xml 压缩成Bytes
            convertionXmlToBytes();

            //  3. 自动生成Prefabs的地址映射c#文件

            GameConfigVo vo = GameTools.createGameConfigVoByXml();

            //  4. 添加Tags
            addTags(vo);

            //  5. 添加Layers
            addLayers(vo);
        }
Exemplo n.º 7
0
        private static void addLayers(GameConfigVo vo)
        {
            //SerializedObject tagManager = new SerializedObject( AssetDatabase.LoadAllAssetsAtPath( "ProjectSettings/TagManager.asset" )[0] );
            //SerializedProperty it = tagManager.GetIterator();
            //SerializedProperty tagit = null;

            //List<string> layersLst = new List<string>();
            //layersLst.Add( GameService.getInstance().gameConfig.layer_unit_movement );
            //layersLst.Add( GameService.getInstance().gameConfig.layer_unit_attack );



            //int startLayerIndex = 8 ;
            //int i = 0;
            //while ( it.NextVisible( true ) )
            //{
            //    if ( i >= layersLst.Count || startLayerIndex >= 31 )
            //        break;

            //    if ( it.name == "User Layer " + startLayerIndex )
            //    {
            //        if ( it.type == "string" )
            //            it.stringValue = layersLst[i];

            //        startLayerIndex += 1;
            //        i += 1;
            //    }
            //}
            ////Builtin Layer 1
            ////return;

            //////  unity3d 5.0 version
            ////while ( it.NextVisible( true ) )
            ////{
            ////    if ( it.name == "layers" )
            ////    {
            ////        tagit = it;
            ////        break;
            ////    }
            ////}

            ////int i = 0;
            ////int startIndex = 0;
            ////while ( tagit.NextVisible( true ) )
            ////{
            ////    if ( startIndex >= 9 ) // layers + size = 8 + 1
            ////    {
            ////        if ( i < layersLst.Count )
            ////        {
            ////            if ( tagit.type == "string" )
            ////                tagit.stringValue = layersLst[i];
            ////        }
            ////        else
            ////        {
            ////            if ( tagit.type == "string" )
            ////                tagit.stringValue = "";
            ////        }

            ////        i += 1;
            ////    }

            ////    startIndex += 1;

            ////}

            //tagManager.ApplyModifiedProperties();
        }