UIMoMO:NPC AI

This commit is contained in:
fatiao 2025-11-18 18:17:18 +08:00
parent c2d3a4f949
commit 1f2932044f
2 changed files with 84 additions and 39 deletions

View File

@ -234,7 +234,7 @@ function CfgMgr:GetStoryNpcCfgIn(recordStoryIdList)
break
end
end
if isIn == true then
if isIn == true and v['Type'] >= 1 then
table.insert(cfgs, v)
end
end

View File

@ -23,6 +23,7 @@ local BottonTabNames = {
local CONST_CHANNEL_WORLD = "10000"
local CONST_CHANNEL_GUILD = "10001"
local CONST_CHANNEL_STORY = "20000"
local CONST_CHANNEL_STORY_AI = "30000"
local CONST_TOGGLE_EMOJI = 1
local CONST_TOGGLE_GIFT = 2
@ -34,6 +35,8 @@ local CONST_TITLE_HEIGHT = 150
local CONST_INPUT_BAR_HEIGHT = 270
local CONST_INPUT_WINDOW_HEIGHT = 730
local currInputToolBarToggleType = 0
local uIChatRootWorld
function UIChatView:OnAwake(data)
self.controller = require("UIChat/UIChatCtr")
@ -922,42 +925,48 @@ function UIChatView:OnGreetBtn(itemData)
end
function UIChatView:RefreshMeTab()
local contactDatas = {
{
type = 2,
name = "妻子",
num = 2,
},
{
type = 1,
name = "海拉1",
head = "NpcHeads/npc_head_1",
heart = 12
},
{
type = 1,
name = "海拉2",
head = "NpcHeads/npc_head_2",
heart = 90
},
{
type = 2,
name = "情人",
num = 2,
},
{
type = 1,
name = "海拉3",
head = "NpcHeads/npc_head_3",
heart = 12
},
{
type = 1,
name = "海拉4",
head = "NpcHeads/npc_head_4",
heart = 56
},
}
local contactDatas = {}
local wiftNum = 0
local npcDatas = ManagerContainer.DataMgr.StoryData:GetStoryNpcDatas()
for k, v in pairs(npcDatas) do
local npcId = k
local heart = v
local storyNpcCfg = ManagerContainer.CfgMgr:GetStoryNpcCfgByChatNpcId(tonumber(npcId))
if storyNpcCfg and storyNpcCfg.Type == 1 then
wiftNum = wiftNum + 1
table.insert(contactDatas, {type = 1, name = I18N.T(storyNpcCfg.NameKey), heart = heart, storyNpcId=npcId})
end
end
table.insert(contactDatas, 1, {type = 2, name = I18N.T("妻子"), num = wiftNum})
local loverNum = 0
local loverGroup = {type = 2, name = I18N.T("情人"), num = loverNum}
table.insert(contactDatas, loverGroup)
for k, v in pairs(npcDatas) do
local npcId = k
local heart = v
local storyNpcCfg = ManagerContainer.CfgMgr:GetStoryNpcCfgByChatNpcId(tonumber(npcId))
if storyNpcCfg and storyNpcCfg.Type == 2 then
loverNum = loverNum + 1
table.insert(contactDatas, {type = 1, name = I18N.T(storyNpcCfg.NameKey), heart = heart, storyNpcId=npcId})
end
end
loverGroup.num = loverNum
local paNum = 0
local paGroup = {type = 2, name = I18N.T("啪友"), num = paNum}
table.insert(contactDatas, paGroup)
for k, v in pairs(npcDatas) do
local npcId = k
local heart = v
local storyNpcCfg = ManagerContainer.CfgMgr:GetStoryNpcCfgByChatNpcId(tonumber(npcId))
if storyNpcCfg and storyNpcCfg.Type == 3 then
paNum = paNum + 1
table.insert(contactDatas, {type = 1, name = I18N.T(storyNpcCfg.NameKey), heart = heart, storyNpcId=npcId})
end
end
paGroup.num = paNum
CommonUtil.LoopGridViewEleCreateNew(
self, self.meTab.meTabLoopScrollView.loopVerticalScrollRect,
self.meTab.meTabContent.verticalLayoutGroup,
@ -990,6 +999,12 @@ function UIChatView:OnClickContactItem(btn, params)
local itemLua = params[0]
local itemData = params[1]
PrintJson("OnClickContactItem: ", itemData)
local storyNpcId = itemData.storyNpcId
local storyNpcCfg = ManagerContainer.CfgMgr:GetStoryNpcCfgByChatNpcId(tonumber(storyNpcId))
-- local storyId = itemData['StoryId']
-- local channelId = CONST_CHANNEL_STORY
-- local storyCfgData = ManagerContainer.CfgMgr:GetStoryDataById(storyId)
self:EnterChatLayer2(CONST_CHANNEL_STORY_AI, storyNpcCfg)
end
function UIChatView:Layer2_OnClickReturnBtn()
@ -1049,6 +1064,11 @@ function UIChatView:EnterChatLayer2(channelId, storyData)
self:SetUIStoryMode(false)
end
self:RefreshChatLayer2(channelId, storyData)
-- Chat With Story Npc AI
elseif channelId == CONST_CHANNEL_STORY_AI then
self:SetStoryAIMode()
--self:RefreshChatLayer2(channelId, storyData)
else
self:SetUIStoryMode(false)
self:RefreshChatLayer2(channelId, storyData)
@ -1069,6 +1089,26 @@ function UIChatView:SetUIStoryMode(isStoryMode)
self.chatLayer2.AnyBtn.button.interactable = canInteractable
end
function UIChatView:SetStoryAIMode()
for k, v in pairs(self.InputBarToggles) do
v:SetActive(false)
end
for k, v in pairs(self.InputBarToggles) do
v.toggle.interactable = true
end
self.chatLayer2.titleBarHeart:SetActive(true)
self.chatLayer2.storyInputTip:SetActive(true)
self.chatLayer2.titleBarReturnBtn.button.interactable = true
self.chatLayer2.AnyBtn.button.interactable = true
self.InputBarToggles[CONST_TOGGLE_GIFT]:SetActive(true)
-- self.InputBarToggles[CONST_TOGGLE_GIFT].on:SetActive(false)
-- self.InputBarToggles[CONST_TOGGLE_GIFT].off:SetActive(true)
currInputToolBarToggleType = CONST_TOGGLE_GIFT
ManagerContainer.LuaTimerMgr:AddLuaTimer(100, 1, function()
self:CloseAllInputToolBarToggles()
end)
end
function UIChatView:UpdateChatLayer2Item(gridView, itemIndex)
local datas = self.currChatData.chats
if not datas then return nil end
@ -1174,6 +1214,11 @@ function UIChatView:RefreshChatLayer2(channelId, storyData)
local storyPerformCfgId = self.controller:GetCurrStoryPerformCfgId(storyData.StoryId)
self.currChatData.chats = self.controller:GetStoryChatDatas(storyData.StoryId, storyPerformCfgId)
elseif channelId == CONST_CHANNEL_STORY_AI then
local currStoryNpcCfg = storyData
self:RefreshTitleForStoryNpc(currStoryNpcCfg.StoryNpcId)
self.currChatData.chats = {}
-- private chat
else
self.currChatData.chats = {}
@ -1290,7 +1335,7 @@ function UIChatView:AddUIEventListener()
self.uiBase:AddButtonEventListener(self.btnBack.button, self, self.OnBtnBack)
end
local currInputToolBarToggleType = 0
function UIChatView:OnValueChanged_InputToolBarToggleGroup(toggle, toggleType, isOn)
--LogError("toggle: "..tostring(toggleType).."-"..tostring(isOn))
if isOn == false then
@ -1301,7 +1346,7 @@ function UIChatView:OnValueChanged_InputToolBarToggleGroup(toggle, toggleType, i
--LogError("UIChatView: close "..tostring(toggleType))
self:CloseAllInputToolBarToggles()
else
--LogError("UIChatView: open "..tostring(toggleType))
LogError("UIChatView: open "..tostring(toggleType))
self:ShowInputToolBarWindow(toggleType)
end
end