GameWorldInfoInitCommand.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. local GameWorldInfoInitCommand = class('GameWorldInfoInitCommand', framework.SimpleCommand)
  2. local cjson = require("cjson")
  3. function GameWorldInfoInitCommand:ctor()
  4. end
  5. function GameWorldInfoInitCommand:execute(note)
  6. print( "====================================" )
  7. print( "GameWorldInfoInit" )
  8. print( "====================================" )
  9. local data = note:getBody()
  10. local jsonData = data and data.jsonData
  11. local header = data and data.header
  12. dump(jsonData)
  13. -- 重连
  14. local disconnectProxy = global.Facade:retrieveProxy( global.ProxyTable.Disconnect )
  15. local isDisconnect = disconnectProxy:IsDisconnect()
  16. --是否试玩模式
  17. local shiwan = global.L_GameEnvManager:GetEnvDataByKey("shiwan")
  18. if shiwan and tonumber(shiwan) == 1 or global.IsReceiveRole then
  19. global.IsVisitor = true
  20. local TradingBankLookPlayerProxy = global.Facade:retrieveProxy( global.ProxyTable.TradingBankLookPlayerProxy )
  21. TradingBankLookPlayerProxy:RequestPlayerData(global.playerManager:GetMainPlayerID())
  22. global.Facade:sendNotification( global.NoticeTable.ReconnectForbidden )
  23. global.Facade:sendNotification( global.NoticeTable.Layer_NPC_Talk_Close )
  24. end
  25. self:handle_game_state(jsonData, isDisconnect)
  26. self:handle_game_info(jsonData, isDisconnect, header)
  27. end
  28. function GameWorldInfoInitCommand:handle_game_state(jsonData, isDisconnect)
  29. if isDisconnect then
  30. global.Facade:sendNotification( global.NoticeTable.Reconnect )
  31. end
  32. end
  33. function GameWorldInfoInitCommand:handle_game_info(jsonData, isDisconnect, header)
  34. -- 重连
  35. if isDisconnect then
  36. return nil
  37. end
  38. -- set dispatch msg enable:true
  39. global.LuaBridgeCtl:SetModulesSwitch( global.MMO.Modules_Index_Enable_Disconnect_Msg, 1 )
  40. if jsonData then
  41. --kfday 开服天数
  42. --unixtime 当前时间戳
  43. --kfunixtime 开服时间戳
  44. local ServerTimeProxy = global.Facade:retrieveProxy(global.ProxyTable.ServerTimeProxy)
  45. ServerTimeProxy:SaveTimeData(jsonData)
  46. -- save 云端存储
  47. local CloudStorageProxy = global.Facade:retrieveProxy(global.ProxyTable.CloudStorageProxy)
  48. CloudStorageProxy:RespCloudStorage(jsonData.save)
  49. -- 拍卖行数据
  50. local AuctionProxy = global.Facade:retrieveProxy(global.ProxyTable.AuctionProxy)
  51. AuctionProxy:setQualities(jsonData.auctionby or {})
  52. AuctionProxy:setJobAble(jsonData.paimaijob or {})
  53. AuctionProxy:setLimitShelf(jsonData.paimaicount or 0)
  54. AuctionProxy:setLowBidPrice(jsonData.AuctionPrice)
  55. AuctionProxy:setLowBuyPrice(jsonData.OneBitePrice)
  56. AuctionProxy:setHighBidPrice(jsonData.MaxAuctionPrice)
  57. AuctionProxy:setHighBuyPrice(jsonData.MaxOneBitePrice)
  58. -- 转生颜色变色
  59. if jsonData.RelvColor and jsonData.RelvChange then
  60. local actorUtils = requireProxy( "actorUtils" )
  61. actorUtils.actorReLvData( {RelvColor=jsonData.RelvColor, RelvChange=jsonData.RelvChange} )
  62. end
  63. -- 拍卖行物品列表请求最小间隔
  64. if jsonData.PaiMaiQueryTime then
  65. AuctionProxy:SetRequestMinTime(jsonData.PaiMaiQueryTime)
  66. end
  67. -- 是否上报主界面txt按钮/图片点击事件
  68. if jsonData.LogCusBury then
  69. local SUIComponentProxy = global.Facade:retrieveProxy(global.ProxyTable.SUIComponentProxy)
  70. SUIComponentProxy:SetMainUIClickEvent(true)
  71. end
  72. -- 服务器开关
  73. local ServerOptionsProxy = global.Facade:retrieveProxy(global.ProxyTable.ServerOptionsProxy)
  74. ServerOptionsProxy:setOptions(jsonData.gameoptions)
  75. local EquipProxy = global.Facade:retrieveProxy(global.ProxyTable.Equip)
  76. EquipProxy:SetBestRingsOpenState(jsonData.SndaItemBoxOpened)
  77. EquipProxy:SetCustUserItem(jsonData.gameoptions.CustUserItem)
  78. -- 多开数量
  79. if global.isWindows and jsonData.maxClientCount then
  80. local luaBridgeCtl = LuaBridgeCtl:Inst()
  81. local maxCount = jsonData.maxClientCount
  82. if luaBridgeCtl.CheckClientCount and false == luaBridgeCtl:CheckClientCount(maxCount) then
  83. local function callback(bType, custom)
  84. global.Director:endToLua()
  85. end
  86. local data = {}
  87. data.str = GET_STRING(1089)
  88. data.btnDesc = {GET_STRING(1001)}
  89. data.callback = callback
  90. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Open, data)
  91. --客户端上限不允许联网
  92. global.gameEnvironment:GetNetClient():Disconnect()
  93. global.Facade:sendNotification( global.NoticeTable.ReconnectForbidden )
  94. end
  95. end
  96. -- 掉落光柱时间
  97. if jsonData.JPshuxingEquipEffect then
  98. SL:SetMetaValue("GAME_DATA","JPshuxingEquipEffect",jsonData.JPshuxingEquipEffect)
  99. end
  100. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login) --本地储存devicecode
  101. LoginProxy:SaveDeviceCode(jsonData.devicecode)
  102. --是否是 新版交易行
  103. if jsonData.gameoptions.IsNewBoxSellVersion then
  104. global.IsNewBoxSellVersion = true
  105. end
  106. if global.IsVisitor then
  107. global.Facade:sendNotification(global.NoticeTable.Layer_TradingBankReceiveLayer_Open)
  108. end
  109. -- 禁止聊天开关
  110. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login)
  111. LoginProxy:SetForbidChat(jsonData.LimitChat == 1)
  112. --英雄召唤cd时间
  113. if jsonData.recallherotime then
  114. dump(jsonData.recallherotime,"jsonData.recallherotime___")
  115. local HeroPropertyProxy = global.Facade:retrieveProxy("HeroPropertyProxy")
  116. HeroPropertyProxy:setCD(jsonData.recallherotime)
  117. end
  118. -- 连击格子加额外暴击几率
  119. local PlayerProperty = global.Facade:retrieveProxy("PlayerProperty")
  120. for i = 1, 4 do
  121. if jsonData["BJCommonRate" .. i] then
  122. PlayerProperty:SetComboExtraBJRate(jsonData["BJCommonRate" .. i], i)
  123. end
  124. end
  125. -- 是否启用新版属性加点
  126. local reinAttrProxy = global.Facade:retrieveProxy(global.ProxyTable.ReinAttrProxy)
  127. reinAttrProxy:SetIsNewBouns(jsonData.gameoptions.NewBonus)
  128. -- 人物最大等级 [暂供行会申请等级使用]
  129. if jsonData.gameoptions.MaxLevel then
  130. PlayerProperty:SetMaxLevel(jsonData.gameoptions.MaxLevel)
  131. end
  132. -- 求购货币默认
  133. if jsonData.gameoptions.sQiugouDefaultGoldType then
  134. local PurchaseProxy = global.Facade:retrieveProxy(global.ProxyTable.PurchaseProxy)
  135. PurchaseProxy:SetCurrencies(jsonData.gameoptions.sQiugouDefaultGoldType)
  136. end
  137. -- 掉落格式
  138. if jsonData.DropItemHint then
  139. local data = {
  140. Msg = global.isWinPlayMode and jsonData.PCDropItemHint or jsonData.DropItemHint,
  141. BColor = jsonData.DropItemBC,
  142. FColor = jsonData.DropItemFC,
  143. }
  144. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  145. ChatProxy:SetFakeDropParam(data)
  146. end
  147. -- 血魄一击技能配置消耗值不足耗血相关
  148. local SkillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  149. SkillProxy:SetXPSpellParam(jsonData.XPSpellType, jsonData.XPSpellTypeValue, jsonData.XPMPType)
  150. SkillProxy:SetMooteboWithCD(jsonData.MooteboWithCD or 0)
  151. end
  152. -- config
  153. self:initConfig()
  154. -- ui
  155. self:initUI()
  156. -- 后台添加
  157. self:InitExAddUI(header, jsonData)
  158. end
  159. function GameWorldInfoInitCommand:initConfig()
  160. global.skillManager:LoadConfig()
  161. local SceneOptionsProxy = global.Facade:retrieveProxy(global.ProxyTable.SceneOptionsProxy)
  162. SceneOptionsProxy:LoadConfig()
  163. local GameSettingProxy = global.Facade:retrieveProxy(global.ProxyTable.GameSettingProxy)
  164. GameSettingProxy:LoadConfig()
  165. local BuffProxy = global.Facade:retrieveProxy(global.ProxyTable.Buff)
  166. BuffProxy:LoadConfig()
  167. local SkillProxy = global.Facade:retrieveProxy(global.ProxyTable.Skill)
  168. SkillProxy:LoadConfig()
  169. local HeroSkillProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroSkillProxy)
  170. HeroSkillProxy:LoadConfig()
  171. local AttrConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.AttrConfigProxy)
  172. AttrConfigProxy:LoadConfig()
  173. local NPCStorageProxy = global.Facade:retrieveProxy(global.ProxyTable.NPCStorageProxy)
  174. NPCStorageProxy:LoadConfig()
  175. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  176. ItemConfigProxy:LoadConfig()
  177. local ThrowDamageNumProxy = global.Facade:retrieveProxy(global.ProxyTable.ThrowDamageNumProxy)
  178. ThrowDamageNumProxy:LoadConfig()
  179. local JumpLayerProxy = global.Facade:retrieveProxy(global.ProxyTable.JumpLayerProxy)
  180. JumpLayerProxy:LoadConfig()
  181. local ItemTipsProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemTipsProxy)
  182. ItemTipsProxy:LoadConfig()
  183. ItemTipsProxy:LoadCustAbilConfig()
  184. local MiniMapProxy = global.Facade:retrieveProxy(global.ProxyTable.MiniMapProxy)
  185. MiniMapProxy:LoadConfig()
  186. local SUIComponentProxy = global.Facade:retrieveProxy(global.ProxyTable.SUIComponentProxy)
  187. SUIComponentProxy:LoadConfig()
  188. local PageStoreProxy = global.Facade:retrieveProxy(global.ProxyTable.PageStoreProxy)
  189. PageStoreProxy:InitPageStoreData()
  190. local HeroPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  191. HeroPropertyProxy:initConfig()
  192. local AuctionProxy = global.Facade:retrieveProxy(global.ProxyTable.AuctionProxy)
  193. AuctionProxy:InitItemConfig()
  194. local ColorStyleProxy = global.Facade:retrieveProxy(global.ProxyTable.ColorStyleProxy)
  195. ColorStyleProxy:LoadConfig()
  196. local SummonsProxy = global.Facade:retrieveProxy(global.ProxyTable.SummonsProxy)
  197. SummonsProxy:LoadConfig()
  198. local ReinAttrProxy = global.Facade:retrieveProxy(global.ProxyTable.ReinAttrProxy)
  199. ReinAttrProxy:LoadConfig()
  200. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  201. ChatProxy:LoadConfig()
  202. end
  203. function GameWorldInfoInitCommand:initUI()
  204. --
  205. SLBridge:onEnterWorld()
  206. global.Facade:sendNotification( global.NoticeTable.Layer_RTouch_Open)
  207. global.Facade:sendNotification( global.NoticeTable.Layer_Moved_Open)
  208. global.Facade:sendNotification( global.NoticeTable.Layer_Notice_Open)
  209. -- init main nodes
  210. global.Facade:sendNotification( global.NoticeTable.Layer_Main_Open )
  211. -- init main ui
  212. global.Facade:sendNotification(global.NoticeTable.Layer_Main_Init)
  213. global.Facade:sendNotification(global.NoticeTable.Layer_TopTouch_Open)
  214. --
  215. global.Facade:sendNotification(global.NoticeTable.GameWorldInitComplete)
  216. -- ssr
  217. ssr.ssrBridge:onWorldInfoInit()
  218. -- SL
  219. SLBridge:onLUAEvent(LUA_EVENT_ENTER_WORLD)
  220. end
  221. function GameWorldInfoInitCommand:InitExAddUI(header, jsonData)
  222. if header then
  223. local data = {}
  224. data.x = header.recog
  225. data.y = header.param1
  226. data.subid = header.param2
  227. data.scale = jsonData.ratio
  228. local openState = tonumber(header.param3) == 1
  229. if openState then
  230. global.Facade:sendNotification(global.NoticeTable.AddBoxDayBtnToScreen, data)
  231. end
  232. end
  233. local isOpen = jsonData.jyh_state and jsonData.jyh_state == 1
  234. if isOpen then
  235. local btnData = {}
  236. btnData.x = jsonData.jyh_x_axis
  237. btnData.y = jsonData.jyh_y_axis
  238. btnData.subid = jsonData.jyh_hitch_point
  239. btnData.width = jsonData.jyh_width
  240. btnData.height= jsonData.jyh_height
  241. if next(btnData) then
  242. global.Facade:sendNotification(global.NoticeTable.AddTradingBankBtnToScreen, btnData)
  243. end
  244. end
  245. end
  246. return GameWorldInfoInitCommand