601 lines
22 KiB
Plaintext
601 lines
22 KiB
Plaintext
import { _decorator, AudioSource, EditBox, isValid, Label, Node, Sprite, tween, utils, Vec3 } from 'cc';
|
||
import { GButton } from '../../Main/Common/GButton';
|
||
import Utils from '../../Main/Common/Utils';
|
||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||
import SubManager from '../SubManager';
|
||
import GameManager, { E_TalkStage, E_TalkStatusType } from '../../Main/Manager/GameManager';
|
||
import { I_LevelConfig, I_NpcTalkBack } from '../../Main/Config/CommonConfig';
|
||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||
import ResManager from '../../Main/Manager/ResManager';
|
||
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
|
||
import GameRootUI from '../../Main/Common/GameRootUI';
|
||
import { E_AD_TARGET } from './TalkAdDialog';
|
||
const { ccclass, property } = _decorator;
|
||
|
||
//聊天界面
|
||
@ccclass('Talk_UI')
|
||
export class Talk_UI extends li_BaseView {
|
||
|
||
private _nodeTab: any = {};
|
||
private _data;
|
||
|
||
private dazijiInfo = {stage: 0, idx: 0, str: "", tm:0, ts:0.05, lab:null}; //打字机信息 stage:0-未开始,1-正在打字,2-打字结束
|
||
private npcTalkInfo = {stage: 0, str:"", dotStr:"...", dotIdx:0, tm:0, ts:0.3}; //等待npc回复 stage:0-未开始,1-获取中,2-获取完成
|
||
private ebTalk: EditBox;
|
||
private labNpcTalk: Label;
|
||
private xindongSpt: Sprite;
|
||
private lvCfg: I_LevelConfig = null; //当前关卡配置
|
||
private lastRandTalkIdx: number = -1; //上一次随机对话的索引
|
||
|
||
//----重写父类接口---------------------------------------
|
||
onLoadCT() {
|
||
Utils.parseNode(this.node, this._nodeTab)
|
||
this.registerListenner();
|
||
this.ebTalk = this._nodeTab.ebTalk.getComponent(EditBox);
|
||
this.labNpcTalk = this._nodeTab.npcTalk.getComponent(Label);
|
||
this.xindongSpt = this._nodeTab.xindongSpt.getComponent(Sprite);
|
||
this.ebTalk.node.on('editing-did-began', this.onEditingBegan, this);
|
||
this.ebTalk.node.on('editing-did-ended', this.onEditingEnded, this);
|
||
this.ebTalk.node.on('editing-return', this.onEditingReturn, this);
|
||
|
||
this._nodeTab.arrowNode.active = false;
|
||
let npcNextArrow:Node = this._nodeTab.npcNextArrow
|
||
tween(npcNextArrow)
|
||
.to(0.5, {position: new Vec3(15, 0, 0)})
|
||
.to(0.5, {position: new Vec3(-15, 0, 0)})
|
||
.union()
|
||
.repeatForever()
|
||
.start()
|
||
}
|
||
openUIDataCT(data: any): void {
|
||
this._data = data
|
||
}
|
||
|
||
|
||
registerListenner() {
|
||
Utils.addInnerEL(InnerMsgCode.Data_NpcTalkBack, this, this.resiveNpcTalkBack)
|
||
Utils.addInnerEL(InnerMsgCode.UI_Socket_Timeout, this, this.resiveSocketTimeout)
|
||
Utils.addInnerEL(InnerMsgCode.UI_TalkStageUp, this, this.resiveTalkStageUp)
|
||
}
|
||
|
||
|
||
start() {
|
||
GButton.BandClick(this._nodeTab.btnBack, this.onBackClick, this);
|
||
GButton.BandClick(this._nodeTab.btnSend, this.onSendClick, this);
|
||
GButton.BandClick(this._nodeTab.btnSuiji, this.onSuijiClick, this);
|
||
|
||
GButton.BandClick(this._nodeTab.npcTalkFrame, ()=>{
|
||
this.onNpcFramClick();
|
||
}, this, 0, null, null, false);
|
||
|
||
GButton.BandClick(this._nodeTab.btnRecord, ()=>{
|
||
ViewManager.I.openBundlesView("UI/StartUI/Record_UI")
|
||
}, this);
|
||
GButton.BandClick(this._nodeTab.btnTishi, ()=>{
|
||
ViewManager.I.openBundlesView("UI/StartUI/Tips_UI")
|
||
}, this);
|
||
GButton.BandClick(this._nodeTab.btnAD, ()=>{
|
||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||
type: E_AD_TARGET.liaotian, //加聊天次数
|
||
content: "看广告或分享可额外获取对话次数",
|
||
adCallback: ()=>{
|
||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||
},
|
||
shareCallback: ()=>{
|
||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||
}
|
||
})
|
||
}, this);
|
||
|
||
GButton.BandClick(this._nodeTab.btnRole, ()=>{
|
||
this._nodeTab.ruleNode.active = true
|
||
}, this);
|
||
GButton.BandClick(this._nodeTab.btnRoleOk, ()=>{
|
||
this.onRoleCloseClick()
|
||
}, this);
|
||
GButton.BandClick(this._nodeTab.btnRoleClose, ()=>{
|
||
this.onRoleCloseClick()
|
||
}, this);
|
||
|
||
//ai语音开关
|
||
GButton.BandClick(this._nodeTab.btnYuyin, ()=>{
|
||
GameManager.AIVoiceSwt = !GameManager.AIVoiceSwt;
|
||
this.refreshAIVoiceState()
|
||
}, this);
|
||
this.refreshAIVoiceState()
|
||
if (!SDKManager.checkSupportBase64Audio()) {
|
||
this._nodeTab.btnYuyin.active = false
|
||
}
|
||
|
||
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
|
||
console.log("视频广告回调", tag)
|
||
if (tag == 1) {
|
||
// 加次数
|
||
HttpUnit.ins.setUserAd({type:2}, (data) => {
|
||
let addCnt = HttpUnit.GetTalkAdAddNum()
|
||
SubManager.ShowPrompt("观看视频成功,获得聊天次数")
|
||
this.doAddLevelCnt(addCnt)
|
||
})
|
||
}
|
||
})
|
||
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
||
console.log("分享回调", tag)
|
||
if (tag == 1) {
|
||
// 加次数
|
||
HttpUnit.ins.setUserShare({type:2}, (data) => {
|
||
let addCnt = HttpUnit.GetTalkShareAddNum()
|
||
SubManager.ShowPrompt("分享成功,获得聊天次数")
|
||
this.doAddLevelCnt(addCnt)
|
||
})
|
||
}
|
||
})
|
||
|
||
|
||
this.lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
|
||
|
||
//刷新历史星级
|
||
for (let i=1; i<=3; i++) {
|
||
let lsStar = this._nodeTab["lsStar"+i].getComponent(Sprite)
|
||
let starPath = this.lvCfg.star >= i ? "lv_3" : "lv_2"
|
||
ResManager.I.changeBundleSpriteFrame(lsStar, starPath, "Zhujiemian")
|
||
}
|
||
|
||
this._nodeTab.ruleNode.active = false
|
||
|
||
let scaleRatio = Utils.getScaleRatio(2)
|
||
if (scaleRatio > 1) {
|
||
scaleRatio = 1;
|
||
}
|
||
this._nodeTab.gs1frame.scale = new Vec3(scaleRatio, scaleRatio, 1)
|
||
|
||
this.refreshTalkStage()
|
||
|
||
//刷新状态显示
|
||
this.refreshTalkStepData()
|
||
this.refreshXindongCishu()
|
||
this.refreshDuihuaDefen()
|
||
|
||
//检测引导
|
||
this.checkGuide()
|
||
}
|
||
|
||
onDestroy () {
|
||
super.onDestroy()
|
||
if (isValid(this.ebTalk)) {
|
||
this.ebTalk.node.off('editing-did-began', this.onEditingBegan, this);
|
||
this.ebTalk.node.off('editing-did-ended', this.onEditingEnded, this);
|
||
this.ebTalk.node.off('editing-return', this.onEditingReturn, this);
|
||
}
|
||
}
|
||
|
||
update(deltaTime: number) {
|
||
|
||
//region 打字机效果逻辑
|
||
if (this.dazijiInfo.stage == 1) {
|
||
this.dazijiInfo.tm += deltaTime
|
||
if (this.dazijiInfo.tm >= this.dazijiInfo.ts) {
|
||
this.dazijiInfo.tm = 0
|
||
this.dazijiInfo.lab.string = this.dazijiInfo.str.substring(0, this.dazijiInfo.idx)
|
||
|
||
this.dazijiInfo.idx += 1
|
||
if (this.dazijiInfo.idx > this.dazijiInfo.str.length) {
|
||
this.dazijiInfo.stage = 2
|
||
}
|
||
}
|
||
} else if (this.dazijiInfo.stage == 2) {
|
||
console.log("文本打字机效果结束")
|
||
this.dazijiInfo.stage = 0
|
||
this.dazijiInfo.lab.string = this.dazijiInfo.str
|
||
this._nodeTab.arrowNode.active = true;
|
||
}
|
||
|
||
//接收npc回复逻辑
|
||
if (this.npcTalkInfo.stage == 1) {
|
||
this.npcTalkInfo.tm += deltaTime
|
||
if (this.npcTalkInfo.tm >= this.npcTalkInfo.ts) {
|
||
this.npcTalkInfo.tm = 0
|
||
GameManager.I.getNpcTalkBack({})
|
||
|
||
this.labNpcTalk.string = this.npcTalkInfo.dotStr.substring(0, this.npcTalkInfo.dotIdx)
|
||
this.npcTalkInfo.dotIdx += 1
|
||
if (this.npcTalkInfo.dotIdx > this.npcTalkInfo.dotStr.length) {
|
||
this.npcTalkInfo.dotIdx = 0
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//region AI回复消息
|
||
/**接收到npc回复数据流 */
|
||
resiveNpcTalkBack(data:I_NpcTalkBack) {
|
||
this.npcTalkInfo.stage = 0
|
||
GameManager.TurnToStage(E_TalkStage.npcTalk)
|
||
}
|
||
|
||
/**socket连接超时 */
|
||
resiveSocketTimeout(data:any) {
|
||
SubManager.ShowConfirm({
|
||
content: "连接已断开,请重新开始游戏",
|
||
hideNo: true, //隐藏取消按钮
|
||
yesCallback: () => {
|
||
this.doClose();
|
||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||
}
|
||
})
|
||
this.npcTalkInfo.stage = 0
|
||
}
|
||
|
||
/**接收到聊天状态变化消息 */
|
||
resiveTalkStageUp(data:any) {
|
||
this.refreshTalkStage()
|
||
}
|
||
|
||
|
||
//输入框开始编辑事件
|
||
onEditingBegan(param1:any, param2:any) {
|
||
console.log("聊天界面1: onEditingBegan", param1, param2)
|
||
}
|
||
//输入框回车事件
|
||
onEditingReturn(param1:any, param2:any) {
|
||
console.log("聊天界面2: onEditingReturn", param1, param2)
|
||
}
|
||
//输入框结束编辑事件
|
||
onEditingEnded(param1:any, param2:any) {
|
||
console.log("聊天界面3: onEditingEnded", param1, param2)
|
||
}
|
||
|
||
|
||
//刷新AI语音状态
|
||
private refreshAIVoiceState() {
|
||
let voicePath = GameManager.AIVoiceSwt ? "lv_4" : "lv_5"
|
||
let sptYuyin = this._nodeTab.sptYuyin.getComponent(Sprite)
|
||
ResManager.I.changeBundleSpriteFrame(sptYuyin, voicePath, "Zhujiemian")
|
||
}
|
||
|
||
//播放AI语音
|
||
private playAIVoice(str:string) {
|
||
if (!GameManager.AIVoiceSwt) {
|
||
return //开关没开
|
||
}
|
||
if (!SDKManager.checkSupportBase64Audio()) {
|
||
return //不支持base64音频
|
||
}
|
||
HttpUnit.ins.getAIVoice({record_id: GameManager.RecordId, text:str}, (data) => {
|
||
if (data) {
|
||
console.log("播放AI语音11", data)
|
||
SDKManager.playBase64Audio(data.url, false)
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
|
||
//region 刷新聊天状态
|
||
private refreshTalkStage() {
|
||
let gStage = GameManager.curStage
|
||
if (gStage == E_TalkStage.prologue) {
|
||
this.showNpcPrologue()
|
||
} else if (gStage == E_TalkStage.myTalk) {
|
||
this.turnToMyTalk()
|
||
} else if (gStage == E_TalkStage.waitNpcTalk) {
|
||
this.turnToWaitNpcTalk()
|
||
} else if (gStage == E_TalkStage.npcTalk) {
|
||
this.turnToNpcTalk(GameManager.CurNpcTalkData)
|
||
} else if (gStage == E_TalkStage.npcFixedTalk) {
|
||
this.turnToNpcFixedTalk(GameManager.CurNpcFixedTalkText)
|
||
} else if (gStage == E_TalkStage.upTalkStatus) {
|
||
this.turnToUpdateStage()
|
||
}
|
||
}
|
||
|
||
|
||
//显示NPC开场白
|
||
private showNpcPrologue() {
|
||
this._nodeTab.NpcTalkNode.active = true
|
||
this._nodeTab.MyTalkNode.active = false
|
||
this._nodeTab.arrowNode.active = false;
|
||
//名称
|
||
Utils.setString(this._nodeTab.npcName, this.lvCfg.name)
|
||
//开场白
|
||
this.dazijiInfo.stage = 1
|
||
this.dazijiInfo.idx = 0
|
||
this.dazijiInfo.lab = this.labNpcTalk
|
||
this.dazijiInfo.str = this.lvCfg.prologueMessage
|
||
this.dazijiInfo.tm = this.dazijiInfo.ts
|
||
GameManager.AddTalkRecord({talk:this.lvCfg.prologueMessage, isMe:false})
|
||
// this.playAIVoice(this.lvCfg.prologueMessage)
|
||
}
|
||
|
||
/**切换到玩家说话状态 */
|
||
private turnToMyTalk() {
|
||
this._nodeTab.NpcTalkNode.active = false
|
||
this._nodeTab.MyTalkNode.active = true
|
||
this.ebTalk.string = ""
|
||
//刷新npc表情
|
||
let rolePath = GameManager.GetNpcEmoPic("")
|
||
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {rolePath:rolePath})
|
||
}
|
||
/**切换到等待NPC说话状态 */
|
||
private turnToWaitNpcTalk() {
|
||
this._nodeTab.NpcTalkNode.active = true
|
||
this._nodeTab.MyTalkNode.active = false
|
||
this._nodeTab.arrowNode.active = false;
|
||
this.labNpcTalk.string = ""
|
||
}
|
||
/**切换到NPC说话状态 */
|
||
private turnToNpcTalk(data:I_NpcTalkBack) {
|
||
this._nodeTab.NpcTalkNode.active = true
|
||
this._nodeTab.MyTalkNode.active = false
|
||
this._nodeTab.arrowNode.active = false;
|
||
GameManager.AddStepScore(data.aiScore) //记录本次分数
|
||
this.refreshDuihuaDefen()
|
||
//npc回复
|
||
// this.labNpcTalk.string = data.aiResponse
|
||
this.dazijiInfo.stage = 1
|
||
this.dazijiInfo.idx = 0
|
||
this.dazijiInfo.lab = this.labNpcTalk
|
||
this.dazijiInfo.str = data.aiResponse
|
||
this.dazijiInfo.tm = this.dazijiInfo.ts
|
||
GameManager.AddTalkRecord({talk:data.aiResponse, isMe:false})
|
||
this.playAIVoice(data.aiResponse)
|
||
//刷新npc表情
|
||
let rolePath = GameManager.GetNpcEmoPic(data.aiEmoji)
|
||
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {rolePath:rolePath})
|
||
//分数
|
||
|
||
//对话轮次
|
||
GameManager.srouceCnt = data.sourceCnt
|
||
this.refreshTalkStepData()
|
||
}
|
||
/**切换到npc固定话术展示状态 */
|
||
private turnToNpcFixedTalk(str:string) {
|
||
this._nodeTab.NpcTalkNode.active = true
|
||
this._nodeTab.MyTalkNode.active = false
|
||
this._nodeTab.arrowNode.active = false;
|
||
//npc固定话术
|
||
this.dazijiInfo.stage = 1
|
||
this.dazijiInfo.idx = 0
|
||
this.dazijiInfo.lab = this.labNpcTalk
|
||
this.dazijiInfo.str = str
|
||
this.dazijiInfo.tm = this.dazijiInfo.ts
|
||
}
|
||
/**切换到更新聊天状态状态 */
|
||
private turnToUpdateStage() {
|
||
HttpUnit.ins.getTalkStage({record_id: GameManager.RecordId}, (data) => {
|
||
if (data) {
|
||
GameManager.CurLevelData = data.level
|
||
this.checkIsFinish()
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
/**刷新心动次数 */
|
||
private refreshXindongCishu() {
|
||
let maxCount = HttpUnit.GetXindongMaxCount()
|
||
let curCount = GameManager.xindongCishu
|
||
Utils.setString(this._nodeTab.xindongNum, `${curCount}/${maxCount}`)
|
||
this.xindongSpt.fillRange = curCount / maxCount
|
||
}
|
||
/**刷新对话得分 */
|
||
private refreshDuihuaDefen() {
|
||
let curScore = GameManager.getCurStepScore()
|
||
let [totalScore, pjScore] = GameManager.getGameScore()
|
||
Utils.setString(this._nodeTab.scoreNew, curScore+"")
|
||
Utils.setString(this._nodeTab.scoreTotal, totalScore+"")
|
||
}
|
||
/**刷新当前状态显示 */
|
||
private refreshTalkStepData() {
|
||
let curCnt = GameManager.srouceCnt
|
||
let stepData = GameManager.CurLevelData
|
||
Utils.setString(this._nodeTab.lunciNum, `${curCnt}/${stepData.total_cnt}`)
|
||
}
|
||
|
||
//region 检测是否结束
|
||
/**检查对话轮次是否用完
|
||
* @returns [是否结束对话,是否显示广告加次数]
|
||
*/
|
||
private checkIsFinish() {
|
||
|
||
let isFinish = false //是否结束对话
|
||
let isShowAD = false //是否显示广告
|
||
let isSendEnd = false //是否发送结束请求
|
||
let stepData = GameManager.CurLevelData
|
||
if (stepData.status == E_TalkStatusType.succ) {
|
||
//已成功
|
||
isFinish = true
|
||
} else if (stepData.status == E_TalkStatusType.fail) {
|
||
//已失败
|
||
isFinish = true
|
||
} else if (stepData.status == E_TalkStatusType.noCount) {
|
||
//次数已用完
|
||
isFinish = true
|
||
isShowAD = true
|
||
isSendEnd = true
|
||
}
|
||
|
||
if (isFinish) {
|
||
if (isShowAD) {
|
||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||
type: E_AD_TARGET.liaotian, //加聊天次数
|
||
content: "看广告或分享可额外获取对话次数",
|
||
adCallback: ()=>{
|
||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||
},
|
||
shareCallback: ()=>{
|
||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||
},
|
||
closeCallback: ()=>{
|
||
if (isSendEnd) {
|
||
this.doJiesuan()
|
||
} else {
|
||
ViewManager.I.openBundlesView("UI/StartUI/Finish_UI", stepData)
|
||
}
|
||
}
|
||
})
|
||
} else {
|
||
if (isSendEnd) {
|
||
this.doJiesuan()
|
||
} else {
|
||
ViewManager.I.openBundlesView("UI/StartUI/Finish_UI", stepData)
|
||
}
|
||
}
|
||
} else {
|
||
GameManager.TurnToStage(E_TalkStage.myTalk)
|
||
}
|
||
|
||
}
|
||
|
||
//增加聊天次数
|
||
private doAddLevelCnt(add:number = 1) {
|
||
HttpUnit.ins.addTalkCnt({record_id: GameManager.RecordId, add_cnt:add}, (data) => {
|
||
if (data) {
|
||
GameManager.CurLevelData = data.level
|
||
this.refreshTalkStepData()
|
||
//判断是否继续对话
|
||
if (GameManager.srouceCnt < data.level.total_cnt) {
|
||
GameManager.TurnToStage(E_TalkStage.myTalk)
|
||
} else {
|
||
this.doJiesuan()
|
||
}
|
||
}
|
||
})
|
||
}
|
||
|
||
//结算
|
||
private doJiesuan() {
|
||
let [score_all, score] = GameManager.getGameScore()
|
||
HttpUnit.ins.sendLevelFinish({record_id: GameManager.RecordId, score:score, score_all:score_all}, (data) => {
|
||
if (data && data.level) {
|
||
//成功
|
||
ViewManager.I.openBundlesView("UI/StartUI/Finish_UI", data.level)
|
||
} else {
|
||
//失败
|
||
console.warn("结算失败,服务器返回异常!")
|
||
this.doClose();
|
||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
//退出聊天
|
||
onBackClick() {
|
||
SubManager.ShowConfirm({
|
||
content: "确定退出吗?",
|
||
yesCallback: () => {
|
||
//退出并结算
|
||
// this.doJiesuan();
|
||
|
||
//只退出聊天,不结算
|
||
this.doClose();
|
||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||
}
|
||
})
|
||
}
|
||
|
||
//发送消息
|
||
onSendClick() {
|
||
let str = this.ebTalk.string;
|
||
if (str.length == 0) {
|
||
SubManager.ShowPrompt("请先输入内容")
|
||
return
|
||
}
|
||
GameManager.TurnToStage(E_TalkStage.waitNpcTalk)
|
||
this.ebTalk.string = ""
|
||
HttpUnit.ins.sendUserTalk({record_id: GameManager.RecordId, user_input: str}, (data) => {
|
||
if (data) {
|
||
GameManager.AddTalkRecord({talk:str, isMe:true})
|
||
//开始接收npc回复
|
||
this.npcTalkInfo.stage = 1
|
||
this.npcTalkInfo.str = ""
|
||
this.npcTalkInfo.tm = this.npcTalkInfo.ts
|
||
this.npcTalkInfo.dotIdx = 0
|
||
}
|
||
})
|
||
}
|
||
|
||
//随机回复对话
|
||
onSuijiClick() {
|
||
let sjLen = this.lvCfg.randomInputPool.length
|
||
let randIdx = Utils.getRandomInt(0, sjLen-1)
|
||
console.log("随机回复对话:", randIdx, sjLen)
|
||
if (randIdx == this.lastRandTalkIdx) {
|
||
randIdx++
|
||
if (randIdx >= sjLen) randIdx = 0
|
||
}
|
||
this.lastRandTalkIdx = randIdx
|
||
this.ebTalk.string = this.lvCfg.randomInputPool[randIdx]
|
||
}
|
||
|
||
//点击npc对话背景
|
||
onNpcFramClick() {
|
||
if (this.dazijiInfo.stage == 1) {
|
||
this.dazijiInfo.stage = 2
|
||
} else {
|
||
if (GameManager.curStage == E_TalkStage.prologue) {
|
||
GameManager.TurnToStage(E_TalkStage.upTalkStatus)
|
||
} else if (GameManager.curStage == E_TalkStage.npcTalk) {
|
||
// let stepData = GameManager.CurLevelData
|
||
let npcTalk = GameManager.CurNpcTalkData
|
||
if (npcTalk.judgement == 0) {
|
||
console.log("固定鼓励话术展示!", GameManager.npcFixTalkCountXihuan)
|
||
if (GameManager.npcFixTalkCountXihuan > 0) {
|
||
GameManager.TurnToStage(E_TalkStage.upTalkStatus)
|
||
} else {
|
||
GameManager.CurNpcFixedTalkText = this.lvCfg.encourageMessage
|
||
GameManager.TurnToStage(E_TalkStage.npcFixedTalk)
|
||
}
|
||
GameManager.npcFixTalkCountXihuan = GameManager.npcFixTalkCountXihuan + 1
|
||
GameManager.xindongCishu = GameManager.xindongCishu + 1
|
||
this.refreshXindongCishu()
|
||
} else if (npcTalk.judgement == 2) {
|
||
console.log("固定厌恶话术展示!", GameManager.npcFixTalkCountTaoyan)
|
||
if (GameManager.npcFixTalkCountTaoyan > 0) {
|
||
GameManager.TurnToStage(E_TalkStage.upTalkStatus)
|
||
} else {
|
||
GameManager.CurNpcFixedTalkText = this.lvCfg.hateMessage
|
||
GameManager.TurnToStage(E_TalkStage.npcFixedTalk)
|
||
}
|
||
GameManager.npcFixTalkCountTaoyan = GameManager.npcFixTalkCountTaoyan + 1
|
||
} else {
|
||
GameManager.TurnToStage(E_TalkStage.upTalkStatus)
|
||
}
|
||
} else if (GameManager.curStage == E_TalkStage.npcFixedTalk) {
|
||
GameManager.TurnToStage(E_TalkStage.upTalkStatus)
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//region 引导相关
|
||
//检查引导
|
||
private checkGuide() {
|
||
if (PlayerDataManager.I.GuideTalkFinished) {
|
||
return
|
||
}
|
||
|
||
let delayInterval = 0.5
|
||
GameRootUI.DisableOper(delayInterval)
|
||
this.scheduleOnce(() => {
|
||
this._nodeTab.ruleNode.active = true
|
||
},delayInterval)
|
||
}
|
||
//引导完成
|
||
private finishGuide() {
|
||
if (PlayerDataManager.I.GuideTalkFinished) {
|
||
return
|
||
}
|
||
PlayerDataManager.I.SetGuideTalkFinish(true)
|
||
}
|
||
//关闭规则弹窗
|
||
private onRoleCloseClick() {
|
||
this._nodeTab.ruleNode.active = false
|
||
this.finishGuide()
|
||
}
|
||
}
|