HeroPropertyProxy.lua 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local HeroPropertyProxy = class("HeroPropertyProxy", RemoteProxy)
  3. HeroPropertyProxy.NAME = global.ProxyTable.HeroPropertyProxy
  4. local cjson = require("cjson")
  5. local AttFun = require("util/AttributeFunction")
  6. function HeroPropertyProxy:ctor()
  7. HeroPropertyProxy.super.ctor(self)
  8. local HeroPropertyVO = requireVO("remote/HeroPropertyVO")
  9. self.VOdata = HeroPropertyVO.new()
  10. self._herologin = false -- 英雄是否出生
  11. self._guardState = false
  12. self.isInited = false
  13. self.alive = true
  14. self.heroNameColor = 255
  15. self._feature =
  16. {
  17. clothID = 0,
  18. weaponID = 0,
  19. shieldID = 0,
  20. wingsID = 0,
  21. hairID = 0,
  22. leftWeaponID = 0,
  23. }
  24. self._internalData = {} -- 内功数据
  25. self._godMgicShowSetting = true --设置显示神魔
  26. self._superEquipShowSetting = false --设置时装显示
  27. --主角切页开关
  28. self._mainPlayerPageSwitch = {
  29. -- [SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SUPER_EQUIP] = false --nil/true为开启;false为关闭 神装默认为关闭
  30. }
  31. self._mainLookPlayerPageSwitch = {
  32. [SLDefine.PlayerPage.MAIN_PLAYER_LAYER_EQUIP] = true,
  33. [SLDefine.PlayerPage.MAIN_PLAYER_LAYER_TITLE] = true,
  34. [SLDefine.PlayerPage.MAIN_PLAYER_LAYER_SUPER_EQUIP] = true,
  35. }
  36. self._attribute = {}
  37. self._lockTargetID = nil
  38. ---怒气
  39. self._angerMax = 0 --最大怒气
  40. self._angerCur = 0--当前怒气
  41. self._shan = false --是否要闪
  42. self._speed = 10
  43. self._delayTime = 1
  44. -----
  45. self.m_heroid = nil
  46. self._LoginCD = 30
  47. self._LoginCDTime = 0
  48. self._attr_not_hint = {} --不弹出属性飘字提示
  49. self._lastJob = -1
  50. self:initLoadConfig()
  51. end
  52. function HeroPropertyProxy:initLoadConfig()
  53. local attrNotHintArray = string.split(SL:GetMetaValue("GAME_DATA","attr_not_hint") or "", "#")
  54. for i, v in ipairs(attrNotHintArray) do
  55. local attid = tonumber(v)
  56. if attid then
  57. self._attr_not_hint[attid] = attid
  58. end
  59. end
  60. end
  61. function HeroPropertyProxy:initConfig()
  62. self.m_states = self:getStatesSysSet()--手机版点击快捷切换状态 战斗 跟随 休息 守护 0-3
  63. local localdata = self:readLocalData()
  64. if localdata then
  65. self.m_states = localdata
  66. end
  67. end
  68. function HeroPropertyProxy:getStatesSysSet()--Heroqiehuan 三个或四个
  69. if self._Statesysset then
  70. return self._Statesysset
  71. end
  72. self._Statesysset = {}
  73. if global.ConstantConfig and SL:GetMetaValue("GAME_DATA","Heroqiehuan") then
  74. local strs = string.split(SL:GetMetaValue("GAME_DATA","Heroqiehuan"), "#")
  75. for i, v in ipairs(strs) do
  76. local num = tonumber(v)
  77. table.insert(self._Statesysset, num and num - 1 or nil)
  78. end
  79. else
  80. self._Statesysset = { 0, 1, 2, 3 }
  81. end
  82. return clone(self._Statesysset)
  83. end
  84. function HeroPropertyProxy:setCD(cd)
  85. self._LoginCD = cd
  86. end
  87. function HeroPropertyProxy:getCD(cd)
  88. return self._LoginCDTime
  89. end
  90. function HeroPropertyProxy:readLocalData()
  91. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login)
  92. local mainPlayerID = LoginProxy:GetSelectedRoleID()
  93. local path = "hero_state_" .. mainPlayerID
  94. local key = "setting"
  95. local userData = UserData:new(path)
  96. local jsonStr = userData:getStringForKey(key, "")
  97. if not jsonStr or string.len(jsonStr) == 0 then
  98. return false
  99. end
  100. local jsonData = cjson.decode(jsonStr)
  101. if not jsonData then
  102. return false
  103. end
  104. local set = self:getStatesSysSet()
  105. for i = #jsonData, 1, -1 do
  106. if not table.indexof(set, jsonData[i]) then
  107. table.remove(jsonData, i)
  108. end
  109. end
  110. return jsonData
  111. end
  112. function HeroPropertyProxy:saveLocalData(data)
  113. if not data then
  114. return false
  115. end
  116. local LoginProxy = global.Facade:retrieveProxy(global.ProxyTable.Login)
  117. local mainPlayerID = LoginProxy:GetSelectedRoleID()
  118. local path = "hero_state_" .. mainPlayerID
  119. local key = "setting"
  120. local userData = UserData:new(path)
  121. pcall(function()
  122. local jsonStr = cjson.encode(data)
  123. userData:setStringForKey(key, jsonStr)
  124. end)
  125. return true
  126. end
  127. function HeroPropertyProxy:GetHeroActor()
  128. local actor = global.actorManager:GetActor(self:GetRoleUID())
  129. return actor
  130. end
  131. function HeroPropertyProxy:getIsMergePanelMode()
  132. local res = false
  133. if global.ConstantConfig and tonumber(SL:GetMetaValue("GAME_DATA","playerInfoMode")) == 1 and not global.isWinPlayMode and tonumber(SL:GetMetaValue("GAME_DATA","syshero")) == 1 then--heromode 单面板模式
  134. res = true
  135. end
  136. return res
  137. end
  138. function HeroPropertyProxy:IsInited()
  139. return self.isInited
  140. end
  141. function HeroPropertyProxy:Inited()
  142. self.isInited = true
  143. end
  144. function HeroPropertyProxy:GetSample()
  145. return self.VOdata:GetSampleData()
  146. end
  147. -- 等级
  148. function HeroPropertyProxy:GetRoleLevel()
  149. return self.VOdata:GetLevel()
  150. end
  151. -- 主角名字
  152. function HeroPropertyProxy:GetName()
  153. return self.VOdata:GetName()
  154. end
  155. -- 行会名字
  156. function HeroPropertyProxy:GetGuildName()
  157. return self.VOdata:GetGuildName()
  158. end
  159. -- 职业
  160. function HeroPropertyProxy:GetRoleJob()
  161. local job = self.VOdata:GetRoleJob()
  162. return job
  163. end
  164. -- 职业
  165. function HeroPropertyProxy:GetRoleJobName()
  166. local job = self:GetRoleJob()
  167. local name = GET_STRING(1067 + job)
  168. return name
  169. end
  170. -- 性别
  171. function HeroPropertyProxy:SetRoleSex(sex)
  172. self.VOdata:SetRoleSex(sex)
  173. end
  174. function HeroPropertyProxy:GetRoleSex()
  175. return self.VOdata:GetRoleSex()
  176. end
  177. -- uid
  178. function HeroPropertyProxy:GetRoleUID()
  179. return self.m_heroid
  180. end
  181. -- 转生
  182. function HeroPropertyProxy:GetRoleReinLv()
  183. return self.VOdata:GetReinLv()
  184. end
  185. function HeroPropertyProxy:SetRoleReinLv(relevel)
  186. self.VOdata:SetReinLv(relevel)
  187. -- rein level
  188. end
  189. --获取玩家状态的脚本的变量
  190. function HeroPropertyProxy:GetVariableInfo()
  191. return self.VOdata:GetVariableInfo()
  192. end
  193. --设置玩家状态的脚本的变量
  194. function HeroPropertyProxy:SetVariableInfo(variable_info)
  195. self.VOdata:SetVariableInfo(variable_info)
  196. end
  197. function HeroPropertyProxy:GetRoleCurrHP()
  198. return self.VOdata:GetRoleCurrHP()
  199. end
  200. function HeroPropertyProxy:GetRoleCurrMP()
  201. return self.VOdata:GetRoleCurrMP()
  202. end
  203. function HeroPropertyProxy:GetRoleMaxHP()
  204. return self.VOdata:GetRoleMaxHP()
  205. end
  206. function HeroPropertyProxy:GetRoleMaxMP()
  207. return self.VOdata:GetRoleMaxMP()
  208. end
  209. -- 当前经验值
  210. function HeroPropertyProxy:GetCurrExp()
  211. return self.VOdata:GetCurrExp()
  212. end
  213. -- 升级所需经验值
  214. function HeroPropertyProxy:GetNeedExp()
  215. return self.VOdata:GetNeedExp()
  216. end
  217. function HeroPropertyProxy:GetRoleHPPercent()
  218. return self:GetRoleCurrHP() / self:GetRoleMaxHP() * 100
  219. end
  220. function HeroPropertyProxy:GetRoleMPPercent()
  221. return self:GetRoleCurrMP() / self:GetRoleMaxMP() * 100
  222. end
  223. function HeroPropertyProxy:GetRoleEXPPercent()
  224. return self:GetCurrExp() / self:GetNeedExp() * 100
  225. end
  226. function HeroPropertyProxy:GetLastLevel()
  227. return self.VOdata:GetLastLevel()
  228. end
  229. function HeroPropertyProxy:GetRoleAttByAttType(attId)
  230. return self.VOdata:GetAttByAttType(attId)
  231. end
  232. --获取外观
  233. function HeroPropertyProxy:GetFeature()
  234. return self._feature
  235. end
  236. function HeroPropertyProxy:setAlive( alive )
  237. self.alive = alive
  238. if alive then
  239. self:getFacade():sendNotification( global.NoticeTable.SelfHeroRevive )
  240. else
  241. self:getFacade():sendNotification( global.NoticeTable.SelfHeroDie )
  242. end
  243. end
  244. function HeroPropertyProxy:getAlive()
  245. return self.alive
  246. end
  247. function HeroPropertyProxy:SetRoleMana(curHP, maxHP, curMP, maxMP)
  248. local nData = {}
  249. if self.maxHP ~= maxHP then
  250. nData.maxHPChange = true
  251. self.maxHP = maxHP
  252. end
  253. if self.maxMP ~= maxMP then
  254. nData.maxMPChange = true
  255. self.maxMP = maxMP
  256. end
  257. nData.curHP = curHP
  258. nData.curMP = curMP
  259. nData.maxHP = maxHP
  260. nData.maxMP = maxMP
  261. self.VOdata:SetRoleManaData(curHP, maxHP, curMP, maxMP)
  262. global.Facade:sendNotification(global.NoticeTable.PlayerManaChange_Hero, nData)
  263. SLBridge:onLUAEvent(LUA_EVENT_HERO_HPMP_CHANGE, nData)
  264. end
  265. function HeroPropertyProxy:SetCurrExp(value, changed)
  266. self.VOdata:SetRoleCurrExp(value)
  267. -- exp change notice
  268. global.Facade:sendNotification(global.NoticeTable.PlayerExpChange_Hero, { changed = changed })
  269. SLBridge:onLUAEvent(LUA_EVENT_HERO_EXP_CHANGE)
  270. end
  271. function HeroPropertyProxy:SetLastLevel(level)
  272. self.VOdata:SetLastLevel(level)
  273. end
  274. function HeroPropertyProxy:SetNeedExp(exp)
  275. self.VOdata:SetNeedExp(exp)
  276. end
  277. function HeroPropertyProxy:SetFeature(feature)
  278. self._feature.clothID = feature.clothID
  279. self._feature.weaponID = feature.weaponID
  280. self._feature.shieldID = feature.shieldID
  281. self._feature.wingsID = feature.wingsID
  282. self._feature.hairID = feature.hairID
  283. self._feature.leftWeaponID = feature.leftWeaponID
  284. end
  285. function HeroPropertyProxy:SetName(name)
  286. self.VOdata:SetName(name)
  287. end
  288. function HeroPropertyProxy:SetGuildName(guildname)
  289. self.VOdata:SetGuildName(guildname)
  290. end
  291. function HeroPropertyProxy:GetPKMode()
  292. return self.VOdata:GetPKMode()
  293. end
  294. function HeroPropertyProxy:SetPKMode(curse)
  295. self.VOdata:SetPKMode(curse)
  296. end
  297. function HeroPropertyProxy:SetHeroNameColor(color)
  298. self.heroNameColor = color and color or 255
  299. SL:onLUAEvent(LUA_EVENT_HERO_FRAME_NAME_RRFRESH)
  300. end
  301. function HeroPropertyProxy:GetHeroNameColor()
  302. return self.heroNameColor
  303. end
  304. function HeroPropertyProxy:SetWeight(weight, wearWeight, handWeight)
  305. self.VOdata:SetWeight(weight, wearWeight, handWeight)
  306. end
  307. --0-2来回切换
  308. function HeroPropertyProxy:RequestChangeHeroMode(idx)
  309. local state = self:getHeroState()
  310. state = state + 1
  311. if state > 2 then--win32
  312. state = 0
  313. end
  314. if idx then--
  315. state = idx
  316. end
  317. self:setHeroState(state)
  318. LuaSendMsg(global.MsgType.MSG_CS_HERO_ATTACK_MODE, state)
  319. end
  320. function HeroPropertyProxy:setStates(states)
  321. self.m_states = states
  322. self:saveLocalData(self.m_states)
  323. end
  324. --当前开启的状态
  325. function HeroPropertyProxy:getStates()
  326. return self.m_states or {}
  327. end
  328. --锁定对象
  329. function HeroPropertyProxy:RequestLockTarget(id, x, y, isPlayer)
  330. local isp = isPlayer and 1 or 0
  331. self._tempID = id
  332. LuaSendMsg(global.MsgType.MSG_CS_LOCKTARGET_HERO, x, y, isp, 0, id, string.len(id))
  333. end
  334. --守护位置 -- mappos
  335. function HeroPropertyProxy:RequestTargetXY(x, y)
  336. LuaSendMsg(global.MsgType.MSG_CS_LOCKTARGET_HERO, x, y)
  337. end
  338. function HeroPropertyProxy:CancelLock()
  339. LuaSendMsg(global.MsgType.MSG_CS_LOCKTARGET_CANCEL_HERO)
  340. end
  341. --守护按钮点击
  342. function HeroPropertyProxy:setGuardBtnState(guard)
  343. if guard then
  344. global.Facade:sendNotification(global.NoticeTable.SystemTips, GET_STRING(600000266))
  345. end
  346. self._guardState = guard
  347. end
  348. function HeroPropertyProxy:getGuardBtnState()
  349. return self._guardState
  350. end
  351. function HeroPropertyProxy:CompareAttribute(property)
  352. if not SL:GetMetaValue("GAME_DATA","isShowAttributeTips") or tonumber(SL:GetMetaValue("GAME_DATA","isShowAttributeTips")) == 0 then
  353. return nil
  354. end
  355. -- 五秒内不播放
  356. if (not self._attribute_effect_enable) then
  357. PerformWithDelayGlobal(function()
  358. self._attribute_effect_enable = true
  359. end, 5)
  360. end
  361. local AttrConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.AttrConfigProxy)
  362. local AttrType = GUIFunction:PShowAttType()
  363. --
  364. local isInvalid = true
  365. local attrItems = {}
  366. for k, v in pairs(AttrType) do
  367. local config = AttrConfigProxy:GetAttConfigByAttId(v)
  368. if config and not self._attr_not_hint[v] then
  369. local attrValue = 0
  370. if v == 1 then
  371. attrValue = self:GetRoleMaxHP()
  372. elseif v == 2 then
  373. attrValue = self:GetRoleMaxMP()
  374. else
  375. attrValue = self:GetRoleAttByAttType(v)
  376. end
  377. attrItems[v] = attrValue
  378. if attrValue > 0 then
  379. isInvalid = false
  380. end
  381. end
  382. end
  383. -- invalid
  384. if isInvalid then
  385. return nil
  386. end
  387. -- init
  388. if not next(self._attribute) then
  389. self._attribute = attrItems
  390. return nil
  391. end
  392. local mfloor = math.floor
  393. local diffAttr = {}
  394. for i, v in pairs(AttrType) do
  395. if attrItems[v] then
  396. local diff = mfloor(attrItems[v] - (self._attribute[v] or 0))
  397. if diff >= 1 then
  398. local data = {}
  399. data.id = v
  400. data.value = diff
  401. table.insert(diffAttr, data)
  402. end
  403. end
  404. end
  405. if next(diffAttr) and self._attribute_effect_enable then
  406. local attribute_data = {}
  407. attribute_data.attributes = diffAttr
  408. attribute_data.attr_type = 0
  409. if SL:GetMetaValue("GAME_DATA","isShowAttributeTips") and tonumber(SL:GetMetaValue("GAME_DATA","isShowAttributeTips")) ~= 0 then
  410. global.Facade:sendNotification(global.NoticeTable.Layer_Notice_Attribute, attribute_data)
  411. end
  412. global.Facade:sendNotification(global.NoticeTable.PlayerAttribute_Change_Hero, diffAttr)
  413. end
  414. self._attribute = attrItems
  415. end
  416. function HeroPropertyProxy:SyncProperties()
  417. local Sample = self:GetSample()
  418. -- 属性对比
  419. -- 因为脚本属性刷新是一段一段的,需要做个处理,一定时间内没有属性变化时才对比刷新
  420. if self._attributeScheduleID then
  421. UnSchedule(self._attributeScheduleID)
  422. self._attributeScheduleID = nil
  423. end
  424. self._attributeScheduleID = PerformWithDelayGlobal(function()
  425. self:CompareAttribute(Sample)
  426. end, 1)
  427. -- level change
  428. local lastLevel = self:GetLastLevel()
  429. if lastLevel and lastLevel ~= Sample.level then
  430. -- notifi
  431. local nData = {}
  432. nData.last = lastLevel
  433. nData.level = Sample.level
  434. global.Facade:sendNotification(global.NoticeTable.PlayerLevelChange_Hero, nData)
  435. SLBridge:onLUAEvent(LUA_EVENT_HERO_LEVEL_CHANGE, {currlevel = Sample.level, lastlevel = lastLevel})
  436. end
  437. self:SetLastLevel(Sample.level)
  438. global.Facade:sendNotification(global.NoticeTable.PlayerPropertyChange_Hero)
  439. ---------------
  440. if Sample.job ~= self._lastJob then
  441. self._lastJob = Sample.job
  442. global.Facade:sendNotification(global.NoticeTable.PlayerJobChange_Hero, Sample.job)
  443. end
  444. if Sample.sex ~= self._lastSex then
  445. self._lastSex = Sample.sex
  446. global.Facade:sendNotification(global.NoticeTable.PlayerSexChange_Hero, Sample.sex)
  447. SLBridge:onLUAEvent(LUA_EVENT_HERO_SEX_CHANGE)
  448. end
  449. if Sample.relevel ~= self._lastRelevel then
  450. global.Facade:sendNotification(global.NoticeTable.PlayerReinLevelChange_Hero, Sample.relevel)
  451. SLBridge:onLUAEvent(LUA_EVENT_HERO_REINLEVEL_CHANGE, {currReinLevel = Sample.relevel, lastReinLevel = self._lastRelevel})
  452. self._lastRelevel = Sample.relevel
  453. end
  454. ----------------
  455. SLBridge:onLUAEvent(LUA_EVENT_HERO_PROPERTY_CHANGE)
  456. --
  457. local actor = self:GetHeroActor()
  458. if actor then
  459. actor:SetLevel(Sample.level)
  460. actor:SetJobID(Sample.job)
  461. local curHP = self:GetRoleAttByAttType(GUIFunction:PShowAttType().HP)
  462. local maxHP = self:GetRoleMaxHP()
  463. actor:SetHPHUD(curHP, maxHP)
  464. actor:SetNGHUD(self._internalData.force, self._internalData.maxForce)
  465. end
  466. if not self:IsInited() then
  467. self:Inited()
  468. end
  469. end
  470. function HeroPropertyProxy:handle_MSG_SC_PLAYER_PROPERTIES_HERO(msg)
  471. local Sample = self:GetSample()
  472. local data = ParseRawMsgToJson(msg)
  473. local PShowAttType = GUIFunction:PShowAttType()
  474. local maxHP = data.maxhp
  475. local maxMP = data.maxmp
  476. local curExp = data.exp
  477. local curHP = data.hp
  478. local curMP = data.mp
  479. local sex = data.sex
  480. local variableInfo = data.InfoEx
  481. -- Sample.yb = head.param2
  482. Sample.job = data.job
  483. Sample.sex = data.sex
  484. Sample.level = data.level
  485. Sample.needExp = data.maxexp
  486. Sample.relevel = data.relevel
  487. Sample.HeroLuck = data.HeroLuck
  488. Sample.attdata = {}
  489. Sample.attdata[PShowAttType.Min_DEF] = data.ac1 --物防
  490. Sample.attdata[PShowAttType.Max_DEF] = data.ac2 --
  491. Sample.attdata[PShowAttType.Min_MDF] = data.mac1 --魔防
  492. Sample.attdata[PShowAttType.Max_MDF] = data.mac2
  493. Sample.attdata[PShowAttType.Min_ATK] = data.dc1 --物理
  494. Sample.attdata[PShowAttType.Max_ATK] = data.dc2
  495. Sample.attdata[PShowAttType.Min_MAT] = data.mc1 --魔法
  496. Sample.attdata[PShowAttType.Max_MAT] = data.mc2
  497. Sample.attdata[PShowAttType.Min_Daoshu] = data.sc1 --道术
  498. Sample.attdata[PShowAttType.Max_Daoshu] = data.sc2
  499. Sample.attdata[PShowAttType.HP] = curHP --生命
  500. Sample.attdata[PShowAttType.MP] = curMP --魔法
  501. Sample.attdata[PShowAttType.Weight] = data.weight--当前重量
  502. Sample.attdata[PShowAttType.Max_Weight] = data.maxweight--玩家最大负重
  503. Sample.attdata[PShowAttType.Wear_Weight] = data.wearweight--穿戴负重
  504. Sample.attdata[PShowAttType.Max_Wear_Weight] = data.maxwearweight--最大穿戴负重
  505. Sample.attdata[PShowAttType.Hand_Weight] = data.handweight--腕力
  506. Sample.attdata[PShowAttType.Max_Hand_Weight] = data.maxhandweight--当前最大可穿戴腕力
  507. Sample.attdata[PShowAttType.Anti_Magic] = data.antimagic
  508. Sample.attdata[PShowAttType.Hit_Point] = data.hitPoint
  509. Sample.attdata[PShowAttType.Speed_Point] = data.SpeedPoint
  510. Sample.attdata[PShowAttType.Anti_Posion] = data.AntiPoison
  511. Sample.attdata[PShowAttType.Posion_Recover] = data.PoisonRecover
  512. Sample.attdata[PShowAttType.Health_Recover] = data.HealthRecover
  513. Sample.attdata[PShowAttType.Spell_Recover] = data.SpellRecover
  514. Sample.attdata[PShowAttType.Hit_Speed] = data.HitSpeed
  515. Sample.attdata[PShowAttType.Block_Rate] = data.GedangRate
  516. Sample.attdata[PShowAttType.Block_Value] = data.GedangPower
  517. Sample.attdata[PShowAttType.Double_Rate] = data.BjRate
  518. Sample.attdata[PShowAttType.Double_Damage] = data.BjPoint
  519. Sample.attdata[PShowAttType.Defence] = data.Abil23
  520. Sample.attdata[PShowAttType.Double_Defence] = data.Abil24
  521. Sample.attdata[PShowAttType.More_Damage] = data.Abil25
  522. Sample.attdata[PShowAttType.ATK_Defence] = data.Abil26
  523. Sample.attdata[PShowAttType.MAT_Defence] = data.Abil27
  524. Sample.attdata[PShowAttType.Ignore_Defence] = data.Abil28
  525. Sample.attdata[PShowAttType.Bounce_Damage] = data.Abil29
  526. Sample.attdata[PShowAttType.Health_Add] = data.Abil30
  527. Sample.attdata[PShowAttType.Magice_Add] = data.Abil31
  528. Sample.attdata[PShowAttType.More_Item] = data.Abil32
  529. Sample.attdata[PShowAttType.Less_Item] = data.Abil33
  530. Sample.attdata[PShowAttType.Vampire] = data.Abil34
  531. Sample.attdata[PShowAttType.A_M_D_Add] = data.Abil35
  532. Sample.attdata[PShowAttType.Defence_Add] = data.Abil36
  533. Sample.attdata[PShowAttType.MDefence_Add] = data.Abil37
  534. Sample.attdata[PShowAttType.God_Damage] = data.Abil38
  535. Sample.attdata[PShowAttType.Lucky] = data.Abil39
  536. Sample.attdata[PShowAttType.Monster_Damage_Value] = data.Abil40
  537. Sample.attdata[PShowAttType.Monster_Damage_Per] = data.Abil41
  538. Sample.attdata[PShowAttType.Anger_Recover] = data.Abil42
  539. Sample.attdata[PShowAttType.Combine_Skill_Damage] = data.Abil43
  540. Sample.attdata[PShowAttType.Monster_DropItem] = data.Abil44
  541. Sample.attdata[PShowAttType.No_Palsy] = data.Abil45
  542. Sample.attdata[PShowAttType.No_Protect] = data.Abil46
  543. Sample.attdata[PShowAttType.No_Rebirth] = data.Abil47
  544. Sample.attdata[PShowAttType.No_ALL] = data.Abil48
  545. Sample.attdata[PShowAttType.No_Charm] = data.Abil49
  546. Sample.attdata[PShowAttType.No_Fire] = data.Abil50
  547. Sample.attdata[PShowAttType.No_Ice] = data.Abil51
  548. Sample.attdata[PShowAttType.No_Web] = data.Abil52
  549. Sample.attdata[PShowAttType.Att_UnKonw] = data.Abil53
  550. Sample.attdata[PShowAttType.More_A_Damage] = data.Abil54
  551. Sample.attdata[PShowAttType.Less_A_Damage] = data.Abil55
  552. Sample.attdata[PShowAttType.More_M_Damage] = data.Abil56
  553. Sample.attdata[PShowAttType.Less_M_Damage] = data.Abil57
  554. Sample.attdata[PShowAttType.More_D_Damage] = data.Abil58
  555. Sample.attdata[PShowAttType.Less_D_Damage] = data.Abil59
  556. Sample.attdata[PShowAttType.More_Health_Per] = data.Abil60
  557. Sample.attdata[PShowAttType.HP_Recover] = data.Abil61
  558. Sample.attdata[PShowAttType.MP_Recover] = data.Abil62
  559. -- Sample.attdata[PShowAttType.Block_Rate] = data.Abil63
  560. -- Sample.attdata[PShowAttType.Block_Value] = data.Abil64
  561. Sample.attdata[PShowAttType.Drop_Rate] = data.Abil65
  562. Sample.attdata[PShowAttType.Exp_Add_Rate] = data.Abil66
  563. Sample.attdata[PShowAttType.Damage_Rate_Add] = data.Abil67
  564. Sample.attdata[PShowAttType.Damage_Human] = data.Abil68
  565. Sample.attdata[PShowAttType.Ice_Rate] = data.Abil69
  566. Sample.attdata[PShowAttType.Defen_Ice] = data.Abil70
  567. Sample.attdata[PShowAttType.Sec_Recovery_HP] = data.Abil71
  568. Sample.attdata[PShowAttType.Mon_Bj_Power_Rate] = data.Abil72
  569. Sample.attdata[PShowAttType.DC_Add_Rate] = data.Abil73
  570. local monPKV = data.FaMeMonPK or 0
  571. local abil74 = data.Abil74 or 0
  572. Sample.attdata[PShowAttType.Monster_Damage] = abil74 + monPKV
  573. Sample.attdata[PShowAttType.Monster_Damage_Percent] = data.Abil75
  574. Sample.attdata[PShowAttType.PK_Damage_Add_Percent] = data.Abil76
  575. local pk = data.FaMePK or 0
  576. local abil77 = data.Abil77 or 0
  577. Sample.attdata[PShowAttType.PK_Damage_Dec_Percent] = abil77 + pk
  578. Sample.attdata[PShowAttType.Penetrate] = data.Abil78
  579. Sample.attdata[PShowAttType.Death_Hit_Percent] = data.Abil79
  580. Sample.attdata[PShowAttType.Death_Hit_Value] = data.Abil80
  581. Sample.attdata[PShowAttType.Monster_Suck_HP_Rate] = data.Abil81
  582. Sample.attdata[PShowAttType.Monster_Vampire] = data.Abil82
  583. Sample.attdata[PShowAttType.Less_Monster_Damage] = data.Abil83
  584. Sample.attdata[PShowAttType.Drug_Recover] = data.Abil84
  585. Sample.attdata[PShowAttType.Ignore_Def_Dec] = data.Abil85
  586. Sample.attdata[PShowAttType.Fire_Hit_Dec_Rate] = data.Abil86
  587. Sample.attdata[PShowAttType.Ergum_Hit_Dec_Rate] = data.Abil87
  588. Sample.attdata[PShowAttType.Hit_Plus_Dec_Rate] = data.Abil88
  589. Sample.attdata[PShowAttType.Health_Add_WPer] = data.Abil89
  590. Sample.attdata[PShowAttType.Death_Hit_Dec_Percent] = data.Abil90
  591. Sample.attdata[PShowAttType.Sec_Recovery_MP] = data.Abil91
  592. Sample.attdata[PShowAttType.Internal_AddPower] = data.Abil101
  593. Sample.attdata[PShowAttType.Internal_DecPower] = data.Abil102
  594. Sample.attdata[PShowAttType.HJ_DecPower] = data.Abil103
  595. Sample.attdata[PShowAttType.Internal_ForceRate] = data.Abil104
  596. Sample.attdata[PShowAttType.Internal_DZValue] = data.Abil105
  597. Sample[PShowAttType.All_Du_ADD] = data.Abil130
  598. Sample[PShowAttType.All_Du_Less] = data.Abil131
  599. if PShowAttType.Magic_Hit then
  600. Sample.attdata[PShowAttType.Magic_Hit] = data.Abil132
  601. end
  602. if data.CustAbil then
  603. for i, v in ipairs(data.CustAbil) do
  604. Sample.attdata[v[1]] = v[2]
  605. end
  606. end
  607. self:SetRoleSex(sex)
  608. self:SetRoleMana(curHP, maxHP, curMP, maxMP)
  609. self:SetCurrExp(curExp)
  610. self:SetVariableInfo(variableInfo)
  611. self:SetHeroLuck(Sample.HeroLuck)
  612. -- 内功
  613. self:SetInternalData(data)
  614. -- print("-----------------------property change", curExp, data.maxexp, Sample.level)
  615. local bagnum = data.HeroBagCount
  616. local HeroBagProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroBagProxy)
  617. if HeroBagProxy:getBagMaxNum() ~= bagnum then
  618. HeroBagProxy:setBagMaxNum(bagnum)
  619. global.Facade:sendNotification(global.NoticeTable.HeroBagCountChnage, bagnum)
  620. SLBridge:onLUAEvent(LUA_EVENT_REF_HERO_ITEM_LIST)
  621. end
  622. local SndaItemBoxOpened = data.SndaItemBoxOpened or false
  623. local HeroEquipProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroEquipProxy)
  624. HeroEquipProxy:SetBestRingsOpenState(SndaItemBoxOpened == 1)
  625. self:SyncProperties()
  626. end
  627. function HeroPropertyProxy:handle_MSG_SC_PLAYER_EXP_HERO(msg)
  628. local jsonData = ParseRawMsgToJson(msg)
  629. if not jsonData then
  630. return nil
  631. end
  632. local isNG = tonumber(jsonData.isNG) or 0
  633. if isNG == 0 then
  634. local currentExp = tonumber(jsonData.curr) or 0
  635. local changed = tonumber(jsonData.changed) or 0
  636. self:SetCurrExp(currentExp, changed)
  637. if changed and changed > 0 then
  638. local value = GET_SETTING(35, true)
  639. local disable = value[1] == 1
  640. local limit = tonumber(value[2]) or 1
  641. if not disable or changed >= limit then
  642. if CHECK_SERVER_OPTION(global.MMO.SERVER_EXP_IN_CHAT) == 0 then
  643. local str = string.format(GET_STRING(600000222), changed)
  644. local ChatProxy = global.Facade:retrieveProxy(global.ProxyTable.Chat)
  645. local mdata = {
  646. Msg = str,
  647. FColor = 255,
  648. BColor = 249,
  649. ChannelId = ChatProxy.CHANNEL.System,
  650. }
  651. global.Facade:sendNotification(global.NoticeTable.AddChatItem, mdata)
  652. else
  653. local pointList = SL:GetMetaValue("GAME_DATA","pointList")
  654. if not pointList then
  655. return
  656. end
  657. if changed < pointList[4] then
  658. return
  659. end
  660. local str = string.format(GET_STRING(600000216), changed)
  661. local platformIndex = global.isWinPlayMode and 1 or 2
  662. local mdata = {
  663. Msg = str,
  664. X = pointList[platformIndex].X,
  665. Y = pointList[platformIndex].Y,
  666. FColor = pointList[3].X,
  667. BColor = pointList[3].Y,
  668. }
  669. global.Facade:sendNotification(global.NoticeTable.ShowPlayerEXPNotice, mdata)
  670. end
  671. end
  672. end
  673. elseif isNG == 1 then -- 内功经验
  674. local currentExp = tonumber(jsonData.curr) or 0
  675. local changed = tonumber(jsonData.changed) or 0
  676. self:SetInternalExp(currentExp, changed)
  677. end
  678. end
  679. function HeroPropertyProxy:GetHeroLuck()
  680. return self.VOdata:GetHeroLuck()
  681. end
  682. function HeroPropertyProxy:SetHeroLuck(_HeroLuck)
  683. local HeroLuck = self:GetHeroLuck()
  684. if _HeroLuck and HeroLuck ~= _HeroLuck then --请求刷新
  685. self.VOdata:SetHeroLuck(_HeroLuck)
  686. global.Facade:sendNotification(global.NoticeTable.PlayerPropertyChange_Hero)
  687. end
  688. end
  689. function HeroPropertyProxy:GetShowSetting()
  690. return self._superEquipShowSetting
  691. end
  692. function HeroPropertyProxy:SetShowSetting(show)
  693. self._superEquipShowSetting = show
  694. end
  695. function HeroPropertyProxy:SetShowGodMgicSetting(show)
  696. self._godMgicShowSetting = show
  697. end
  698. function HeroPropertyProxy:SetInternalForce(value)
  699. self._internalData.force = value
  700. end
  701. function HeroPropertyProxy:RefreshNGHUD()
  702. local actor = self:GetHeroActor()
  703. if actor then
  704. actor:SetNGHUD(self._internalData.force, self._internalData.maxForce)
  705. end
  706. end
  707. function HeroPropertyProxy:SetInternalExp(value, changed)
  708. self._internalData.exp = value
  709. SL:onLUAEvent(LUA_EVENT_HERO_INTERNAL_EXP_CHANGE, {changed = changed})
  710. end
  711. function HeroPropertyProxy:SetInternalDZValue(curValue, maxValue)
  712. self.VOdata:SetDZValue(curValue)
  713. self._internalData.maxDZValue = maxValue
  714. end
  715. function HeroPropertyProxy:SetInternalData(data)
  716. local lastLv = self._internalData.level or 0
  717. self._internalData.force = data.InternalForce or 0 -- 内力值
  718. self._internalData.maxForce = data.MaxInternalForce or 0 -- 内力值上限
  719. self._internalData.exp = data.InternalEXP or 0 -- 内功经验值
  720. self._internalData.maxExp = data.MaxInternalEXP or 0 -- 内功经验值上限
  721. self._internalData.level = data.InternalLevel or 0 -- 内功等级
  722. self._internalData.maxDZValue = data.MaxDZXYValue or 0 -- 最大斗转星移值
  723. if lastLv ~= self._internalData.level then
  724. global.Facade:sendNotification(global.NoticeTable.HeroInternalLevelChange)
  725. SLBridge:onLUAEvent(LUA_EVENT_HERO_INTERNAL_LEVEL_CHANGE, {lastLevel = lastLv, curLevel = self._internalData.level})
  726. end
  727. if lastLv == 0 and self._internalData.level > lastLv then
  728. SLBridge:onLUAEvent(LUA_EVENT_HERO_LEARNED_INTERNAL)
  729. end
  730. end
  731. function HeroPropertyProxy:GetInternalData()
  732. return self._internalData
  733. end
  734. function HeroPropertyProxy:SetIForceData(force, maxForce)
  735. if force then
  736. self._internalData.force = force
  737. end
  738. if maxForce then
  739. self._internalData.maxForce = maxForce
  740. end
  741. SL:onLUAEvent(LUA_EVENT_HERO_INTERNAL_FORCE_CHANGE)
  742. end
  743. function HeroPropertyProxy:SendSuperEquipSetting(stting_type)
  744. local state = 0
  745. local data = nil
  746. if stting_type == 1 then
  747. if self._superEquipShowSetting then
  748. state = 1
  749. end
  750. data = {
  751. ShowShiZhuang = state
  752. }
  753. elseif stting_type == 2 then
  754. if self._godMgicShowSetting then
  755. state = 1
  756. end
  757. data = {
  758. ShowShenMo = state
  759. }
  760. end
  761. if data then
  762. local cjson = require("cjson")
  763. local jsonStr = cjson.encode(data)
  764. LuaSendMsg(global.MsgType.MSG_CS_SUPER_EQUIP_SETTING_HERO, 0, 0, 0, 0, jsonStr, string.len(jsonStr))
  765. end
  766. end
  767. --获取主角切页开关 main_player_layer: 主角切页
  768. function HeroPropertyProxy:GetMainPlayerPageSwitch(main_player_layer, look_player)
  769. if look_player then
  770. return self._mainLookPlayerPageSwitch[main_player_layer]
  771. end
  772. if self._mainPlayerPageSwitch[main_player_layer] ~= false then
  773. return true
  774. end
  775. return false
  776. end
  777. --设置主角切页开关 main_player_layer: 主角切页 is_turn_on: 开关是否开启
  778. function HeroPropertyProxy:SetMainPlayerPageSwitch(main_player_layer, is_turn_on)
  779. self._mainPlayerPageSwitch[main_player_layer] = is_turn_on
  780. end
  781. --召唤英雄或收起
  782. function HeroPropertyProxy:RequestHeroInOrOut()
  783. LuaSendMsg(global.MsgType.MSG_CS_HERO, 0, 0, 0, 0, 0, 0)
  784. end
  785. -- 角色名字 名字颜色ID
  786. function HeroPropertyProxy:handle_MSG_SC_PLAYER_NAMEANDID_HERO(msg)
  787. local msgLen = msg:GetDataLength()
  788. local msgHdr = msg:GetHeader()
  789. if msgLen <= 0 then
  790. return
  791. end
  792. local dataString = msg:GetData():ReadString(msgLen)
  793. local strs = string.split(dataString, "&")
  794. self:SetName(strs[1])
  795. self:SetHeroNameColor(msgHdr.param1)
  796. end
  797. --请求合击
  798. function HeroPropertyProxy:ReqJointAttack()
  799. if not global.isWinPlayMode then
  800. local HeroSkillProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroSkillProxy)
  801. local skillID = HeroSkillProxy:haveHeroSkill()
  802. if skillID then
  803. global.Facade:sendNotification(global.NoticeTable.SkillEnterCD_Hero, skillID)
  804. end
  805. end
  806. LuaSendMsg(global.MsgType.MSG_CS_JOINTATTACK_HERO, 0, 0, 0, 0, 0, 0)
  807. end
  808. function HeroPropertyProxy:getShan()
  809. return self._shan
  810. end
  811. function HeroPropertyProxy:getMaxAnger()
  812. return self._angerMax
  813. end
  814. --获取当前怒气
  815. function HeroPropertyProxy:getCurAnger()
  816. return self._angerCur
  817. end
  818. function HeroPropertyProxy:getDelayTime()
  819. return self._delayTime
  820. end
  821. function HeroPropertyProxy:getSpeed()
  822. return self._speed
  823. end
  824. --英雄怒气值
  825. function HeroPropertyProxy:handle_MSG_SC_ANGER_HERO(msg)
  826. local msgLen = msg:GetDataLength()
  827. local msgHdr = msg:GetHeader()
  828. local max = msgHdr.recog or 0
  829. local cur = msgHdr.param1 or 0
  830. local s = msgHdr.param2 or 0
  831. self._angerMax = max
  832. self._angerCur = cur
  833. self._shan = s == 1
  834. self._delayTime = msgHdr.param3 or 1
  835. local msgLen = msg:GetDataLength()
  836. if msgLen > 0 then
  837. local dataString = msg:GetData():ReadString(msgLen)
  838. self._speed = tonumber(dataString) or 10
  839. end
  840. SLBridge:onLUAEvent(LUA_EVENT_HERO_ANGER_CAHNGE)
  841. end
  842. --获取英雄状态0 攻击 1 跟随 2 休息
  843. function HeroPropertyProxy:getHeroState()
  844. return self._state or 0
  845. end
  846. function HeroPropertyProxy:setHeroState(state)
  847. self._state = state
  848. end
  849. --获取英雄守护状态0 1
  850. function HeroPropertyProxy:getHeroGuardState()
  851. return self._guard or 0
  852. end
  853. --获取英雄锁定状态0 1
  854. function HeroPropertyProxy:getHeroLockState()
  855. return self._target or 0
  856. end
  857. function HeroPropertyProxy:setLockID(ID)
  858. self._lockTargetID = ID
  859. end
  860. function HeroPropertyProxy:getLockID()
  861. return self._lockTargetID
  862. end
  863. --英雄状态
  864. function HeroPropertyProxy:handle_MSG_SC_PLAYER_STATE_HERO(msg)
  865. local msgLen = msg:GetDataLength()
  866. local msgHdr = msg:GetHeader()
  867. local state = msgHdr.recog or 0
  868. local guard = msgHdr.param1 or 0
  869. local target = msgHdr.param2 or 0
  870. self._state = state -- 状态
  871. self._guard = guard -- 守护
  872. self._target = target -- 锁定
  873. if target == 1 and self._tempID then
  874. self:setLockID(self._tempID)
  875. self._tempID = nil
  876. global.Facade:sendNotification(global.NoticeTable.HeroLock_Icon)
  877. elseif target == 0 then
  878. self:setLockID(nil)
  879. global.Facade:sendNotification(global.NoticeTable.HeroLock_Icon)
  880. end
  881. global.Facade:sendNotification(global.NoticeTable.HeroState_change)
  882. end
  883. --英雄开关
  884. function HeroPropertyProxy:IsHeroOpen()
  885. local res = false
  886. if global.ConstantConfig and tonumber(SL:GetMetaValue("GAME_DATA","syshero")) == 1 then
  887. res = true
  888. end
  889. return res
  890. end
  891. --英雄面板模式 1 单面板 2多面板
  892. function HeroPropertyProxy:getHeroPanelMode()
  893. local res = "1"
  894. if global.ConstantConfig and tonumber(SL:GetMetaValue("GAME_DATA","playerInfoMode")) == 2 then
  895. res = "2"
  896. end
  897. return res
  898. end
  899. --英雄出生
  900. function HeroPropertyProxy:handle_MSG_SC_HEROLOGIN(msg)
  901. local msgLen = msg:GetDataLength()
  902. local msgHdr = msg:GetHeader()
  903. if msgLen <= 0 then
  904. return
  905. end
  906. local dataString = msg:GetData():ReadString(msgLen)
  907. local ids = string.split(dataString, "&")
  908. local playerID = ids[1]
  909. local heroID = ids[2]
  910. local func = function(sender, eventType)
  911. sender:removeFromParent()
  912. end
  913. local animID = 98
  914. local anim = global.FrameAnimManager:CreateSFXAnim(animID)
  915. local srcX = msgHdr.param1
  916. local srcY = msgHdr.param2
  917. local worldPos = global.sceneManager:MapPos2WorldPos(srcX, srcY)
  918. local root = global.sceneGraphCtl:GetSceneNode(global.MMO.NODE_ACTOR_SFX_FRONT)
  919. root:addChild(anim)
  920. anim:setPosition(worldPos)
  921. anim:setLocalZOrder(animID)
  922. anim:Play(0, 0, true)
  923. anim:SetAnimEventCallback(func)
  924. global.Facade:sendNotification(global.NoticeTable.Audio_Play, { type = global.MMO.SND_TYPE_FLY_IN_HERO })
  925. if playerID == global.playerManager:GetMainPlayerID() then
  926. self.m_heroid = heroID
  927. self._herologin = true
  928. global.Facade:sendNotification( global.NoticeTable.Layer_Hero_Login )
  929. global.Facade:sendNotification( global.NoticeTable.HeroLock_Icon)--刷新图标
  930. SLBridge:onLUAEvent(LUA_EVENT_HERO_LOGIN_OROUT, true)
  931. end
  932. end
  933. --英雄退出
  934. function HeroPropertyProxy:handle_MSG_SC_HEROLOGOUT(msg)
  935. local msgLen = msg:GetDataLength()
  936. local msgHdr = msg:GetHeader()
  937. if msgLen <= 0 then
  938. return
  939. end
  940. local dataString = msg:GetData():ReadString(msgLen)
  941. local ids = string.split(dataString, "&")
  942. local playerID = ids[1]
  943. local heroID = ids[2]
  944. local actor = global.actorManager:GetActor(heroID)
  945. local func = function(sender, eventType)
  946. sender:removeFromParent()
  947. end
  948. local animID = 99
  949. local anim = global.FrameAnimManager:CreateSFXAnim(animID)
  950. local srcX = msgHdr.param1
  951. local srcY = msgHdr.param2
  952. local worldPos = global.sceneManager:MapPos2WorldPos(srcX, srcY)
  953. local root = global.sceneGraphCtl:GetSceneNode(global.MMO.NODE_ACTOR_SFX_FRONT)
  954. root:addChild(anim)
  955. anim:setPosition(worldPos)
  956. anim:setLocalZOrder(animID)
  957. anim:Play(0, 0, true)
  958. anim:SetAnimEventCallback(func)
  959. if playerID == global.playerManager:GetMainPlayerID() then--如果是自己的英雄
  960. self:NoticeOut()
  961. end
  962. global.Facade:sendNotification(global.NoticeTable.Audio_Play, { type = global.MMO.SND_TYPE_FLY_OUT_HERO })
  963. end
  964. function HeroPropertyProxy:NoticeOut()--英雄退出 或尸体消失 -- 或主角死亡
  965. self._angerCur = 0
  966. self._shan = false
  967. self:setLockID(nil)
  968. self._herologin = false
  969. --隐藏英雄怒气
  970. SLBridge:onLUAEvent(LUA_EVENT_HERO_ANGER_CAHNGE)
  971. global.Facade:sendNotification(global.NoticeTable.HeroLock_Icon)--刷新图标
  972. self._LoginCDTime = self._LoginCD
  973. if self.ScheduleID1 then
  974. UnSchedule(self.ScheduleID1)
  975. end
  976. self.ScheduleID1 = Schedule(function()
  977. self._LoginCDTime = self._LoginCDTime - 1
  978. if self._LoginCDTime <= 0 then
  979. self._LoginCDTime = 0
  980. UnSchedule(self.ScheduleID1)
  981. self.ScheduleID1 = nil
  982. end
  983. end, 1)
  984. local HeroSkillProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroSkillProxy)
  985. HeroSkillProxy:DelAllSkill()
  986. local HeroEquipProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroEquipProxy)
  987. HeroEquipProxy:loginOut()
  988. local HeroPropertyVO = requireVO("remote/HeroPropertyVO")
  989. self.VOdata = HeroPropertyVO.new()
  990. self._guardState = false
  991. self.isInited = false
  992. self.alive = true
  993. self.heroNameColor = 255
  994. self._feature =
  995. {
  996. clothID = 0,
  997. weaponID = 0,
  998. shieldID = 0,
  999. wingsID = 0,
  1000. fireID = 0,
  1001. hairID = 0,
  1002. leftWeaponID = 0,
  1003. }
  1004. self._godMgicShowSetting = true --设置显示神魔
  1005. self._superEquipShowSetting = false --设置时装显示
  1006. self._attribute = {}
  1007. self._lockTargetID = nil
  1008. ---怒气
  1009. self._angerMax = 0 --最大怒气
  1010. self._angerCur = 0--当前怒气
  1011. self._shan = false --是否要闪
  1012. self._speed = 10
  1013. self._delayTime = 1
  1014. ----
  1015. self.m_heroid = nil
  1016. global.Facade:sendNotification(global.NoticeTable.Layer_Hero_Logout)
  1017. SLBridge:onLUAEvent(LUA_EVENT_HERO_LOGIN_OROUT, false)
  1018. end
  1019. function HeroPropertyProxy:handle_MSG_SC_PLAYER_RELIVE_STATE(msg)
  1020. local header = msg:GetHeader()
  1021. self._canRevive = header.param1 == 1
  1022. end
  1023. function HeroPropertyProxy:handle_MSG_SC_HERO_DIE(msg)
  1024. self:setAlive(false)
  1025. end
  1026. function HeroPropertyProxy:handle_MSG_SC_HERO_ITEM_REMOVE(msg)
  1027. local len = msg:GetDataLength()
  1028. if len <= 0 then
  1029. return
  1030. end
  1031. local msgData = msg:GetData()
  1032. local sliceStr = msgData:ReadString(len)
  1033. local MakeIndexList = {}
  1034. local itemList = string.split(sliceStr, "/")
  1035. for k,v in pairs(itemList) do
  1036. if tonumber(v) then
  1037. table.insert(MakeIndexList, tonumber(v))
  1038. end
  1039. end
  1040. local ItemManagerProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemManagerProxy)
  1041. ItemManagerProxy:RemoveItems(MakeIndexList)
  1042. end
  1043. function HeroPropertyProxy:HeroIsLogin()
  1044. return self._herologin
  1045. end
  1046. function HeroPropertyProxy:IsCanRevive()
  1047. return self._canRevive
  1048. end
  1049. function HeroPropertyProxy:onRegister()
  1050. HeroPropertyProxy.super.onRegister(self)
  1051. end
  1052. function HeroPropertyProxy:RegisterMsgHandler()
  1053. HeroPropertyProxy.super.RegisterMsgHandler(self)
  1054. local msgType = global.MsgType
  1055. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_PROPERTIES_HERO, handler(self, self.handle_MSG_SC_PLAYER_PROPERTIES_HERO)) -- 角色基础属性
  1056. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_NAMEANDID_HERO, handler(self, self.handle_MSG_SC_PLAYER_NAMEANDID_HERO)) -- 角色名字 名字颜色ID
  1057. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EXP_HERO, handler(self, self.handle_MSG_SC_PLAYER_EXP_HERO)) -- 角色经验值
  1058. LuaRegisterMsgHandler(msgType.MSG_SC_ANGER_HERO, handler(self, self.handle_MSG_SC_ANGER_HERO)) -- 英雄怒气
  1059. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_STATE_HERO, handler(self, self.handle_MSG_SC_PLAYER_STATE_HERO))
  1060. LuaRegisterMsgHandler(msgType.MSG_SC_HEROLOGIN, handler(self, self.handle_MSG_SC_HEROLOGIN))--英雄出生
  1061. LuaRegisterMsgHandler(msgType.MSG_SC_HEROLOGOUT, handler(self, self.handle_MSG_SC_HEROLOGOUT))--英雄退出
  1062. LuaRegisterMsgHandler(msgType.MSG_SC_HERO_ITEM_REMOVE, handler( self, self.handle_MSG_SC_HERO_ITEM_REMOVE) )--死亡掉落
  1063. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_RELIVE_STATE, handler(self, self.handle_MSG_SC_PLAYER_RELIVE_STATE)) -- 是否可复活状态(角色的地方也有监听,不是bug)
  1064. LuaRegisterMsgHandler(msgType.MSG_SC_HERO_DIE, handler(self, self.handle_MSG_SC_HERO_DIE))--英雄死亡
  1065. end
  1066. return HeroPropertyProxy