UIMomo:聊天支持获取奖励

This commit is contained in:
fatiao 2025-11-18 14:36:12 +08:00
parent d2c518bb2a
commit 7e0a6a328e
13 changed files with 2788 additions and 452 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,197 @@
local StoryNpcCfgV2 = {
[1]={
['Id']=1,
['StoryNpcId']=1001,
['Type']=0,
['NameKey']='player',
['Name']='玩家',
['Head']='PlayerHeads/player_head_1',
['Img']='HeroDraw/Npc_01',
['Location']='NPCLoc1',
['Age']=0,
['Nation']='NPCNation1',
['Marry']='NPCMarry1',
['Sign']='NPCSign1',
['Post']='NPCPost1',
['Upvote']=0,
['Comment']=0,
['MapLevel']=0,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=0,
},
[2]={
['Id']=2,
['StoryNpcId']=1002,
['Type']=0,
['NameKey']='system',
['Name']='系统',
['Head']='PlayerHeads/player_head_1',
['Img']='HeroDraw/Npc_01',
['Location']='NPCLoc2',
['Age']=0,
['Nation']='NPCNation2',
['Marry']='NPCMarry2',
['Sign']='NPCSign2',
['Post']='NPCPost2',
['Upvote']=0,
['Comment']=0,
['MapLevel']=0,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=0,
},
[3]={
['Id']=3,
['StoryNpcId']=2001,
['Type']=0,
['NameKey']='actor_nvshen',
['Name']='女神',
['Head']='PlayerHeads/player_head_nvshen',
['Img']='HeroDraw/Npc_01',
['Location']='NPCLoc3',
['Age']=0,
['Nation']='NPCNation3',
['Marry']='NPCMarry3',
['Sign']='NPCSign3',
['Post']='NPCPost3',
['Upvote']=0,
['Comment']=0,
['MapLevel']=0,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=0,
},
[4]={
['Id']=4,
['StoryNpcId']=2002,
['Type']=0,
['NameKey']='actor_weier',
['Name']='薇儿',
['Head']='PlayerHeads/player_head_weier',
['Img']='HeroDraw/Npc_02',
['Location']='NPCLoc4',
['Age']=23,
['Nation']='NPCNation4',
['Marry']='NPCMarry4',
['Sign']='NPCSign4',
['Post']='NPCPost4',
['Upvote']=0,
['Comment']=0,
['MapLevel']=0,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=0,
},
[5]={
['Id']=5,
['StoryNpcId']=2003,
['Type']=1,
['NameKey']='actor_xifu',
['Name']='希芙',
['Head']='PlayerHeads/player_head_xifu',
['Img']='HeroDraw/Npc_03',
['Location']='NPCLoc5',
['Age']=23,
['Nation']='NPCNation5',
['Marry']='NPCMarry5',
['Sign']='NPCSign5',
['Post']='NPCPost5',
['Photos']={'Momo/photo_100001','Momo/photo_100002','Momo/photo_100001','Momo/photo_100002'},
['Upvote']=456,
['Comment']=34,
['MapLevel']=10005,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=100900,
},
[6]={
['Id']=6,
['StoryNpcId']=2004,
['Type']=1,
['NameKey']='actor_furuiya',
['Name']='芙蕾雅',
['Head']='PlayerHeads/player_head_furuiya',
['Img']='HeroDraw/Npc_04',
['Location']='NPCLoc6',
['Age']=22,
['Nation']='NPCNation6',
['Marry']='NPCMarry6',
['Sign']='NPCSign6',
['Post']='NPCPost6',
['Photos']={'Momo/photo_100001','Momo/photo_100002'},
['Upvote']=396,
['Comment']=45,
['MapLevel']=10010,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=100901,
},
[7]={
['Id']=7,
['StoryNpcId']=2005,
['Type']=1,
['NameKey']='actor_yideng',
['Name']='伊登',
['Head']='PlayerHeads/player_head_yideng',
['Img']='HeroDraw/Npc_05',
['Location']='NPCLoc7',
['Age']=18,
['Nation']='NPCNation7',
['Marry']='NPCMarry7',
['Sign']='NPCSign7',
['Post']='NPCPost7',
['Photos']={'Momo/photo_100001','Momo/photo_100002','Momo/photo_100001','Momo/photo_100002'},
['Upvote']=562,
['Comment']=44,
['MapLevel']=10015,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=100902,
},
[8]={
['Id']=8,
['StoryNpcId']=2006,
['Type']=1,
['NameKey']='actor_haila',
['Name']='海拉',
['Head']='PlayerHeads/player_head_haila',
['Img']='HeroDraw/Npc_06',
['Location']='NPCLoc8',
['Age']=35,
['Nation']='NPCNation8',
['Marry']='NPCMarry8',
['Sign']='NPCSign8',
['Post']='NPCPost8',
['Photos']={'Momo/photo_100001','Momo/photo_100002'},
['Upvote']=235,
['Comment']=24,
['MapLevel']=10020,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=100903,
},
[9]={
['Id']=9,
['StoryNpcId']=2007,
['Type']=1,
['NameKey']='actor_waerjili',
['Name']='瓦尔基里',
['Head']='PlayerHeads/player_head_waerjili',
['Img']='HeroDraw/Npc_07',
['Location']='NPCLoc9',
['Age']=28,
['Nation']='NPCNation9',
['Marry']='NPCMarry9',
['Sign']='NPCSign9',
['Post']='NPCPost9',
['Photos']={'Momo/photo_100001','Momo/photo_100002','Momo/photo_100001','Momo/photo_100002'},
['Upvote']=224,
['Comment']=57,
['MapLevel']=10025,
['PlayerLevel']=0,
['TowerLevel']=0,
['StoryId']=100904,
},
}
return StoryNpcCfgV2

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fa1f1e960e39a8f43ba4f154e4d0bfec
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
local StoryRewardCfg = {
[301]={
['Id']=301,
['StoryId']=3,
['MapLevel']=10010,
['RewardType']=1,
['HeartReward']='2003:2',
},
[302]={
['Id']=302,
['StoryId']=3,
['MapLevel']=10010,
['RewardType']=2,
['GiftReward']={{841,1},{11,100000},{19,20000}},
},
[303]={
['Id']=303,
['StoryId']=3,
['MapLevel']=10010,
['RewardType']=2,
['GiftReward']={{841,1},{11,100000},{19,20000}},
},
[304]={
['Id']=304,
['StoryId']=3,
['MapLevel']=10010,
['RewardType']=3,
['DateRewardS']={{841,1},{11,100000},{19,20000}},
['DateRewardA']={{841,1},{11,100000},{19,20000}},
['DateRewardB']={{841,1},{11,100000},{19,20000}},
},
}
return StoryRewardCfg

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1808da61e1e26124699aeba7e5b533f6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4f41ba348b3653c4e8f201cb9257af2d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -135,7 +135,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST23',
['SpeakTime']=0,
@ -429,6 +429,24 @@ local StroyPerformCfgV2 = {
['WordTime']=10,
['OverTime']=0,
},
[3023]={
['Id']=3023,
['StoryId']=302,
['Type']=0,
['LeftAct']='RoleMovein',
['LeftActBgTime']=0,
['RightAct']='RoleMoveout',
['RightActBgTime']=0,
['LeftName']='actor_xifu',
['LeftNameColour']='title02',
['LeftImg']='PlayerHeads/player_head_xifu',
['RightNameColour']='title01',
['SpeakSite']=1,
['SpeakId']='ST3023',
['SpeakTime']=0,
['WordTime']=10,
['OverTime']=0,
},
[3031]={
['Id']=3031,
['StoryId']=303,
@ -483,6 +501,24 @@ local StroyPerformCfgV2 = {
['WordTime']=10,
['OverTime']=0,
},
[3034]={
['Id']=3034,
['StoryId']=303,
['Type']=0,
['LeftAct']='RoleMovein',
['LeftActBgTime']=0,
['RightAct']='RoleMoveout',
['RightActBgTime']=0,
['LeftName']='actor_xifu',
['LeftNameColour']='title02',
['LeftImg']='PlayerHeads/player_head_xifu',
['RightNameColour']='title01',
['SpeakSite']=1,
['SpeakId']='ST3034',
['SpeakTime']=0,
['WordTime']=10,
['OverTime']=0,
},
[41]={
['Id']=41,
['StoryId']=4,
@ -3517,7 +3553,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST143',
['SpeakTime']=0,
@ -3659,7 +3695,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST14013',
['SpeakTime']=0,
@ -4601,7 +4637,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST16035',
['SpeakTime']=0,
@ -4619,7 +4655,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST16036',
['SpeakTime']=0,
@ -4637,7 +4673,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST16037',
['SpeakTime']=0,
@ -4673,7 +4709,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST16039',
['SpeakTime']=0,
@ -4691,7 +4727,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=0,
['SpeakTime']=0,
['WordTime']=10,
@ -11799,7 +11835,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST313',
['SpeakTime']=0,
@ -11941,7 +11977,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST31014',
['SpeakTime']=0,
@ -12083,7 +12119,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST31024',
['SpeakTime']=0,
@ -12225,7 +12261,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST31034',
['SpeakTime']=0,
@ -15787,7 +15823,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST412',
['SpeakTime']=0,
@ -15911,7 +15947,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST41013',
['SpeakTime']=0,
@ -16053,7 +16089,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST41023',
['SpeakTime']=0,
@ -19345,7 +19381,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST503',
['SpeakTime']=0,
@ -19487,7 +19523,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST50014',
['SpeakTime']=0,
@ -19593,7 +19629,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST50023',
['SpeakTime']=0,
@ -19717,7 +19753,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST50033',
['SpeakTime']=0,
@ -19771,7 +19807,7 @@ local StroyPerformCfgV2 = {
['LeftNameColour']='title02',
['RightName']='player',
['RightNameColour']='title01',
['RightImg']='player',
['RightImg']='HeroDraw/Npc_01',
['SpeakSite']=2,
['SpeakId']='ST50036',
['SpeakTime']=0,

View File

@ -1031,6 +1031,7 @@ local Enum = {
Image = 5, --图片消息
Hongbao = 6, --红包消息
Notify = 7, --通知消息
Heart = 8, --好感度消息
},
ExpeditionHelpSource = {

View File

@ -188,14 +188,17 @@ end
function StoryData:RecordStoryPlay(storyId)
if self:IsStoryPlay(storyId) then return end
local storyVal = self.data.storyDatas[storyId] or 0
local storyPlayVal = Bit.lshift(1, 0)
storyVal = Bit.bor(storyVal, storyPlayVal)
self:_Record(storyId, storyVal)
-- local storyVal = self.data.storyDatas[storyId] or 0
-- local storyPlayVal = Bit.lshift(1, 0)
-- storyVal = Bit.bor(storyVal, storyPlayVal)
self:_Record(storyId, 0)
end
-- giftId: 1, 2, 3, 4, dateId: 5, 6, 7, 8
-- rewardId format: storyId + '0' + idx
function StoryData:IsGetReward(storyId, rewardId)
--LogError("[IsGetReward] "..Inspect(self.data.storyDatas))
--LogError("[IsGetReward] storyId="..storyId.." rewardId="..rewardId)
rewardId = rewardId % 10
if self.data.storyDatas[storyId] then
local storyGetRewardVal = Bit.lshift(1, rewardId)
local andVal = Bit.band(self.data.storyDatas[storyId], storyGetRewardVal)
@ -204,23 +207,23 @@ function StoryData:IsGetReward(storyId, rewardId)
return false
end
-- giftId: 1, 2, 3, 4, dateId: 5, 6, 7, 8
-- rewardId format: storyId + '0' + idx
function StoryData:RecordGetReward(storyId, rewardId)
if self:IsGetReward() then return end
local storyVal = self.data.storyDatas[storyId] or 0
local storyGetRewardVal = Bit.lshift(1, rewardId)
storyVal = Bit.bor(storyVal, storyGetRewardVal)
self:_Record(storyId, storyVal)
if self:IsGetReward(storyId, rewardId) then return end
-- local storyVal = self.data.storyDatas[storyId] or 0
-- local storyGetRewardVal = Bit.lshift(1, rewardId)
-- storyVal = Bit.bor(storyVal, storyGetRewardVal)
self:_Record(storyId, rewardId)
end
-- val是移位数
function StoryData:_Record(storyId, val)
LogError("[_Record] storyId="..storyId.." val="..val)
self.data.storyDatas[storyId] = val
ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_ROLE_STORY_REQ, {story_id = {key = storyId, value = val or 0}})
end
function StoryData:AddHeart(storyId)
ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_ROLE_STORY_NPC_REQ, {story_npc_id = {key = storyId, value = 0}})
function StoryData:AddHeart(storyId, rewardId)
ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_ROLE_STORY_NPC_REQ, {story_npc_id = {key = storyId, value = rewardId}})
end
return StoryData

View File

@ -144,6 +144,21 @@ function ChatContentItemCtr:SetData(wnd, itemLua, itemData, enterType, onClickOw
itemLua.rectTransform.sizeDelta = Vector2(itemLua.rectTransform.sizeDelta.x, 0 + height)
currContentNode.rectTransform.sizeDelta = Vector2(width, height)
return
elseif itemData.message.subType == Enum.ChatSubType.Heart then
itemLua.leftNode:SetActive(false)
itemLua.rightNode:SetActive(false)
itemLua.centerNode:SetActive(true)
local contentStr = itemData.message.message
contentStr = "好感度+2"
local currContentNode = itemLua.centerNode.contentText
currContentNode.chatText.symbolText.text = contentStr
local length = 40 + StringUtil.GetTextLeng(currContentNode.chatText.symbolText, contentStr)
local width = math.min(length, 700)
local height = math.max(40 + 40*(1 + length/700), 120)
itemLua.layoutElement.preferredHeight = 0 + height
itemLua.rectTransform.sizeDelta = Vector2(itemLua.rectTransform.sizeDelta.x, 0 + height)
currContentNode.rectTransform.sizeDelta = Vector2(width, height)
return
end
end

View File

@ -236,7 +236,7 @@ end
function UIChatCtr:OnStoryChatFinish(lastStoryId)
ManagerContainer.DataMgr.StoryData:RecordStoryPlay(self.currStartStoryId)
ManagerContainer.DataMgr.StoryData:AddHeart(lastStoryId)
-- ManagerContainer.DataMgr.StoryData:AddHeart(lastStoryId)
self.storyPlayFinishNtfFunc()
-- if self.currStartStoryId then
-- ManagerContainer.DataMgr.StoryData:Record(self.currStartStoryId, 1)
@ -434,7 +434,8 @@ function UIChatCtr:CheckChatSubType(contentStr, nickname)
[Enum.ChatSubType.Gift] = "%[gift%-%d+%]",
[Enum.ChatSubType.Date] = "%[date%-%d+%]",
[Enum.ChatSubType.Image] = "%[photo%-%d+%]",
[Enum.ChatSubType.Hongbao] = "%[rp%-%d+%]"
[Enum.ChatSubType.Hongbao] = "%[rp%-%d+%]",
[Enum.ChatSubType.Heart] = "%[heart%-%d+%]",
}
local subType = Enum.ChatSubType.Text
for k, v in pairs(patterns) do

View File

@ -1011,7 +1011,20 @@ function UIChatView:EnterChatLayer2(channelId, storyData)
if channelId == CONST_CHANNEL_STORY then
self.controller:ResetStoryChatDatas()
local newMessageNtfFunc = function(currStoryId, currStoryPerformCfgId)
-- TODO: Check chatContent type If Reward Message: [Gift-11111]
local tmpStoryCfg = ManagerContainer.CfgMgr:GetStoryDataById(currStoryId)
local storyPerformCfg = ManagerContainer.CfgMgr:GetStoryPerformCfgV2(currStoryPerformCfgId)
if storyPerformCfg then
local chatContent = I18N.T(storyPerformCfg.SpeakId)
local subType = self.controller:CheckChatSubType(chatContent)
if subType == Enum.ChatSubType.Heart then
local rewardId = chatContent:match("%[heart%-(%d+)%]")
local rewardIdNum = tonumber(rewardId)
if rewardIdNum ~= nil then
ManagerContainer.DataMgr.StoryData:AddHeart(currStoryId, rewardIdNum)
end
end
end
self:RefreshChatLayer2(channelId, tmpStoryCfg)
end
local chatInputNtfFunc = function(options)
@ -1093,12 +1106,11 @@ function UIChatView:OnChatContentItemClicked(button, params)
local storyPerformCfgId = p1.targetId
local contentStr = p1.message.message
if p1.message.subType == Enum.ChatSubType.Gift then
-- giftId: 1, 2, 3, 4
local giftId = tonumber(contentStr:match("%[gift%-(%d+)%]"))
local rewardId = tonumber(contentStr:match("%[gift%-(%d+)%]"))
local storyPerformCfgV2 = ManagerContainer.CfgMgr:GetStoryPerformCfgV2(storyPerformCfgId)
local storyId = storyPerformCfgV2.StoryId
LogError("OnChatContentItemClicked: giftId="..giftId)
ManagerContainer.DataMgr.StoryData:RecordGetReward(storyId, giftId)
LogError("OnChatContentItemClicked: rewardId="..rewardId)
ManagerContainer.DataMgr.StoryData:RecordGetReward(storyId, rewardId)
end
end