Пример #1
0
 //写小解析
 public static void sWriteFileSmallType_Lua(StringBuilder sb, Dictionary <string, CmdBigTypeData> cmdbigTypeList)
 {
     foreach (KeyValuePair <string, CmdBigTypeData> iterType in cmdbigTypeList)
     {
         CmdBigTypeData bigType = iterType.Value;
         sb.AppendLine();
         string targetFun = "function " + LuaHandler + ".Parse{0}(gsCmd,gsParam,msgBytes)";
         sb.AppendLine(string.Format(targetFun, bigType.mCmdClassName));
         sb.AppendLine("\t\t\tif gsCmd == nil then");
         for (int j = 0; j < bigType.mAllSubData.Count; ++j)
         {
             CmdSmallTypeData subType = bigType.mAllSubData[j];
             if (!subType.isNeedLua)
             {
                 continue;
             }
             string targetDefine = "\t\t\telseif gsParam == {0}_S.{1} then ";
             sb.AppendLine(string.Format(targetDefine, subType.mGsClassName, subType.mGsParamName));
             string targetHandler = "\t\t\t\t{0}_Handler.{1}(msgBytes);";
             sb.AppendLine(string.Format(targetHandler, subType.mGsClassName, CmdXmlParser.cmdHandlerFuncName));
         }
         sb.AppendLine("\t\t\tend");
         sb.AppendLine("end");
     }
 }
Пример #2
0
 //写大解析
 static void sWriteFileBigType(StringBuilder sb, Dictionary <string, CmdBigTypeData> cmdbigTypeList)
 {
     sb.AppendLine("\tstatic public void " + functionName + "(byte[] msg)");
     sb.AppendLine("\t{");
     sb.AppendLine("\t\tif (msg.Length < 6)");
     sb.AppendLine("\t\t\tDebug.LogError(\"消息包数据长度过小\");");
     sb.AppendLine();
     sb.AppendLine("\t\tbyte gsCmd = msg[0];");
     sb.AppendLine("\t\tbyte gsParamType = msg[5];");
     sb.AppendLine();
     sb.AppendLine("\t\tswitch (gsCmd)");
     sb.AppendLine("\t\t{");
     foreach (KeyValuePair <string, CmdBigTypeData> iterType in cmdbigTypeList)
     {
         CmdBigTypeData bigType = iterType.Value;
         //判断是否生成C#的handle文件中
         if (!bigType.mIsCS)
         {
             continue;
         }
         string targetDefine = "\t\t\tcase {0}.{1}:";
         sb.AppendLine(string.Format(targetDefine, bigType.mCmdClassName, bigType.mCmdTypeName));
         string targetFun = "\t\t\t\tParse{0}(gsCmd, gsParamType, msg);";
         sb.AppendLine(string.Format(targetFun, bigType.mCmdClassName));
         sb.AppendLine("\t\t\t\tbreak;");
     }
     sb.AppendLine("\t\t\tdefault : ");
     sb.AppendLine("\t\t\t\t//C#没有此消息的处理方法,尝试让Lua处理");
     sb.AppendLine("\t\t\t\tLuaTool.Instance.CallFunction(\"NetCmdLuaHandler.HandleCommond\", gsCmd, gsParamType, msg);");
     sb.AppendLine("\t\t\t\tbreak;");
     sb.AppendLine("\t\t}");
     sb.AppendLine("\t}");
 }
Пример #3
0
 public static void AddBigType(string cmdName, CmdBigTypeData bigType)
 {
     if (mCmdBigDic != null && !mCmdBigDic.ContainsKey(cmdName))
     {
         mCmdBigDic[cmdName] = bigType;
     }
     else
     {
         Debug.LogError("错误");
     }
 }
Пример #4
0
 //写大解析
 public static void sWriteFileBigType_Lua(StringBuilder sb, Dictionary <string, CmdBigTypeData> cmdbigTypeList)
 {
     sb.AppendLine("function " + LuaHandler + "." + functionName + "(gsCmd,gsParam,msgBytes)");
     sb.AppendLine("\t\t\tif gsCmd == nil then");
     foreach (KeyValuePair <string, CmdBigTypeData> iterType in cmdbigTypeList)
     {
         CmdBigTypeData bigType      = iterType.Value;
         string         targetDefine = "\t\t\telseif gsCmd == {0}.{1} then ";
         sb.AppendLine(string.Format(targetDefine, bigType.mCmdClassName, bigType.mCmdTypeName));
         string targetFun = "\t\t\t\t this.Parse{0}(gsCmd,gsParam,msgBytes);";
         sb.AppendLine(string.Format(targetFun, bigType.mCmdClassName));
     }
     sb.AppendLine("\t\t\tend");
     sb.AppendLine("end");
 }
Пример #5
0
 //写小解析
 public static void sWriteFileSmallType(StringBuilder sb, Dictionary <string, CmdBigTypeData> cmdbigTypeList)
 {
     foreach (KeyValuePair <string, CmdBigTypeData> iterType in cmdbigTypeList)
     {
         CmdBigTypeData bigType = iterType.Value;
         //判断是否生成C#的handle文件中
         if (!bigType.mIsCS)
         {
             continue;
         }
         sb.AppendLine();
         string targetFun = "\tstatic void Parse{0}(byte gsCmd, byte gsParamType, byte[] msg)";
         sb.AppendLine(string.Format(targetFun, bigType.mCmdClassName));
         sb.AppendLine("\t{");
         sb.AppendLine("\t\tswitch (gsParamType)");
         sb.AppendLine("\t\t{");
         for (int j = 0; j < bigType.mAllSubData.Count; ++j)
         {
             CmdSmallTypeData subType = bigType.mAllSubData[j];
             //判断是否生成C#的handle文件中
             if (!subType.mIsCS)
             {
                 continue;
             }
             string targetDefine = "\t\t\tcase {0}_S.{1}:";
             sb.AppendLine(string.Format(targetDefine, subType.mGsClassName, subType.mGsParamName));
             string targetHandler = "\t\t\t\t{0}_Handler.{1}(msg);";
             sb.AppendLine(string.Format(targetHandler, subType.mGsClassName, CmdXmlParser.cmdHandlerFuncName));
             sb.AppendLine("\t\t\t\tbreak;");
         }
         sb.AppendLine("\t\t\tdefault : ");
         sb.AppendLine("\t\t\t\t//C#没有此消息的处理方法,尝试让Lua处理");
         sb.AppendLine("\t\t\t\tLuaTool.Instance.CallFunction(\"NetCmdLuaHandler.HandleCommond\", gsCmd, gsParamType, msg);");
         sb.AppendLine("\t\t\t\tbreak;");
         sb.AppendLine("\t\t}");
         sb.AppendLine("\t}");
     }
 }