RedNameInfo.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ---@class RedNameInfo
  2. RedNameInfo = class()
  3. local this = RedNameInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. SL:UnRegisterTrigger(LUA_TRIGGER_SET_ACTORNAMECOLOR)
  8. end
  9. function this:Init()
  10. self.redNameInfo={}
  11. self:RegistMessages()
  12. end
  13. function this:RegistMessages()
  14. SL:RegisterLuaNetMsg(LuaMessageIdToClient.PK_VALUE_CHANGE,self.PK_VALUE_CHANGE,self)
  15. SL:RegisterTrigger(LUA_TRIGGER_SET_ACTORNAMECOLOR,self.LUA_TRIGGER_SET_ACTORNAMECOLOR,self)
  16. end
  17. function this:PK_VALUE_CHANGE(_,message)
  18. local role = SL:GetRoleById(message.rid.id)
  19. ---攻城战中不走红名机制
  20. if message.rid.id ~= SL:MeData_GetId() and role and SL:MeData_Check() and InfoManager.loranSiegeInfo:IsMap() then
  21. if not InfoManager.loranSiegeInfo:LUA_TRIGGER_CLICK_ROLE(message.rid.id) then
  22. SL:SetRedNameColorChange(role,SL:ConvertColorFromHexString("#ff0000"))
  23. else
  24. SL:SetRedNameColorChange(role,SL:ConvertColorFromHexString("#FFFFFF"))
  25. end
  26. return
  27. end
  28. self.redNameInfo[message.rid.id] = message.pkValue
  29. if role then
  30. local color = cfg_pk_count_post.GetPkValueRedNameColor(message.pkValue)
  31. if color then
  32. local nameChangeColor = cfg_pk_count_post.GetPkValueNameColor(message.pkValue)
  33. local _,_,_,label = cfg_pk_count_post.GetPkInfoByPkValue(message.pkValue)
  34. SL:SetRedNameColorChange(role,nameChangeColor)
  35. local txt = string.gsub(label, "恶人","e")
  36. txt = string.gsub(txt, "阶","#")
  37. SL:SetPkIcon(role,txt,color,"redName_font")
  38. else
  39. SL:SetActorNameColor(role)
  40. SL:SetPkIcon(role,nil)
  41. end
  42. end
  43. end
  44. function this:IsRedName(id)
  45. local pkValue = self.redNameInfo[tonumber(id)]
  46. if cfg_pk_count_post.GetInfoByRedNamePkValue(pkValue) then
  47. return true
  48. end
  49. return false
  50. end
  51. function this:GetPkValueById(id)
  52. return self.redNameInfo[tonumber(id)]
  53. end
  54. function this:IsLimitItemById(pkValue,itemId)
  55. local _,_,_,_,shopPurchase = cfg_pk_count_post.GetPkInfoByPkValue(pkValue)
  56. if not shopPurchase then
  57. return false
  58. end
  59. return table.contains(shopPurchase,itemId)
  60. end
  61. function this:IsLimitTransferById(id)
  62. local pkValue = self.redNameInfo[tonumber(id)]
  63. local _,_,_,_,_,mapTransmission = cfg_pk_count_post.GetPkInfoByPkValue(pkValue)
  64. if not mapTransmission then
  65. return false
  66. end
  67. return mapTransmission == 1
  68. end
  69. function this:LUA_TRIGGER_SET_ACTORNAMECOLOR(redNameChangeFunc,playerHead,rid)
  70. local role = SL:GetRoleById(rid)
  71. ---攻城战中不走红名机制
  72. if rid ~= SL:MeData_GetId() and role and SL:MeData_Check() and InfoManager.loranSiegeInfo:IsMap() then
  73. if not InfoManager.loranSiegeInfo:LUA_TRIGGER_CLICK_ROLE(rid) then
  74. SL:SetRedNameColorChange(role,SL:ConvertColorFromHexString("#ff0000"))
  75. else
  76. SL:SetRedNameColorChange(role,SL:ConvertColorFromHexString("#FFFFFF"))
  77. end
  78. return true
  79. end
  80. local pkValue = self.redNameInfo[tonumber(rid)]
  81. if role and pkValue then
  82. local color = cfg_pk_count_post.GetPkValueRedNameColor(pkValue)
  83. if color then
  84. local nameChangeColor = cfg_pk_count_post.GetPkValueNameColor(pkValue)
  85. local _,_,_,label = cfg_pk_count_post.GetPkInfoByPkValue(pkValue)
  86. redNameChangeFunc(playerHead,nameChangeColor)
  87. local txt = string.gsub(label, "恶人","e")
  88. txt = string.gsub(txt, "阶","#")
  89. SL:SetPkIcon(role,txt,color,"redName_font")
  90. return true
  91. else
  92. SL:SetPkIcon(role,nil)
  93. return false
  94. end
  95. end
  96. return false
  97. end