init
This commit is contained in:
@@ -0,0 +1,447 @@
|
||||
import { randomRange, view } from "cc";
|
||||
import GlobalValue from "../Common/GlobalValue";
|
||||
import SubManager from "../../Sub/SubManager";
|
||||
import { I_SDK_UserInfo_Callback } from "./SDKManager";
|
||||
|
||||
//广告ID
|
||||
const wx_banner_ad_unit_id = 'test'
|
||||
const wx_splash_ad_unit_id = 'test'
|
||||
const wx_video_ad_unit_id = 'test'
|
||||
|
||||
export class KSSDK{
|
||||
|
||||
static g_InGameScene = null; //游戏场景值
|
||||
|
||||
private wx_video:any = null;
|
||||
private wx_splash:any = null;
|
||||
private wx_banner:any = null;
|
||||
private wx_video_callback:Function = null;
|
||||
private wx_video_tag:number = null;
|
||||
private wx_gameClub:any = null; //游戏圈按钮
|
||||
|
||||
private ShareSTime: any;
|
||||
private ShareCb: any; //分享回调
|
||||
private shareTxt = ["分享失败", "请分享到一个群", "请分享给一位好友", "分享过于频繁"]
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
// 保持屏幕常亮
|
||||
// window['ks'].setKeepScreenOn({ keepScreenOn: true });
|
||||
|
||||
//获取小游戏冷启动时的参数 热启动参数通过 ks.onShow 接口获取。
|
||||
let launchOption = window['ks'].getLaunchOptionsSync();
|
||||
KSSDK.g_InGameScene = launchOption.from;
|
||||
console.log('init 快手 - 进入游戏的场景值', launchOption);
|
||||
|
||||
// //显示分享按钮
|
||||
// window['ks'].showShareMenu({
|
||||
// withShareTicket: true,
|
||||
// menus: ["shareAppMessage", "shareTimeline"],
|
||||
// });
|
||||
// window['ks'].onShareAppMessage(() => {
|
||||
// return this.shareInfo();
|
||||
// });
|
||||
// window['ks'].onShareTimeline(() => {
|
||||
// return this.shareInfo();
|
||||
// })
|
||||
|
||||
//小游戏回到前台
|
||||
window['ks'].onShow(this.onWxShow.bind(this));
|
||||
//小游戏被隐藏 记个时间
|
||||
window['ks'].onHide(() => {
|
||||
console.log("快手 onHide回调:")
|
||||
if (this.ShareCb) {
|
||||
this.ShareSTime = new Date().getTime();
|
||||
console.log("分享时间差 记录:", this.ShareSTime);
|
||||
}
|
||||
});
|
||||
|
||||
this.init_video(); //初始化视频广告
|
||||
this.init_splash(); //初始化插屏广告
|
||||
this.init_banner(); //初始化Banner广告 弹窗广告
|
||||
this.qiangzhiUpdata(); //强制更新
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
|
||||
//小游戏回到前台
|
||||
onWxShow(data: any) {
|
||||
console.log("快手 onShow回调:", data)
|
||||
if (data) {
|
||||
//启动小游戏时传入的参数 object
|
||||
if (data.query) {
|
||||
GlobalValue.ShareTocusid = data.query.ShareCode
|
||||
}
|
||||
//游戏启动场景 string
|
||||
if (data.from) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ShareCb) {
|
||||
if (this.ShareSTime) {
|
||||
let nT = new Date().getTime();
|
||||
console.log("分享时间差 计算:",nT, this.ShareSTime, nT - this.ShareSTime);
|
||||
if (nT - this.ShareSTime > 1) { //快手的onHide有问题,离onShow很近
|
||||
let cb = this.ShareCb.succ
|
||||
cb && cb()
|
||||
} else {
|
||||
this.tostErr()
|
||||
}
|
||||
}
|
||||
this.ShareCb = null;
|
||||
}
|
||||
}
|
||||
//分享失败
|
||||
tostErr() {
|
||||
let rint = Math.floor( randomRange(0, this.shareTxt.length - 1) )
|
||||
SubManager.ShowPrompt(this.shareTxt[rint])
|
||||
if (this.ShareCb) {
|
||||
let cb = this.ShareCb.fail
|
||||
cb && cb()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**获取用户授权状态
|
||||
* @param autoKey string 授权类型 userInfo=用户信息,对应接口wx.getUserInfo
|
||||
*/
|
||||
checkAutoSetting(autoKey:string, cb:Function = null) {
|
||||
window['ks'].getSetting({
|
||||
success(res:any) {
|
||||
console.log("快手 - 检测权限状态 succ:", res)
|
||||
if (autoKey == "userInfo" && res.authSetting['scope.userInfo']) {
|
||||
cb && cb(true)
|
||||
} else {
|
||||
cb && cb(false)
|
||||
}
|
||||
},
|
||||
fail(res:any) {
|
||||
console.log("快手 - 检测权限状态 fail:", res)
|
||||
cb && cb(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人信息
|
||||
*/
|
||||
getUserInfo(cb:I_SDK_UserInfo_Callback = null) {
|
||||
var self = this;
|
||||
window['ks'].getSetting({
|
||||
success(res:any) {
|
||||
console.log("快手 - 获取授权信息成功:", res);
|
||||
let isScope = res.authSetting['scope.userInfo']
|
||||
if (isScope) {
|
||||
window['ks'].getUserInfo({
|
||||
success: (res2) => {
|
||||
console.log("快手 - 获取用户信息成功:", res2);
|
||||
cb && cb({avatarUrl:res2.userInfo.avatarUrl, nickName:res2.userInfo.nickName})
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("快手 - 获取用户信息失败:", error);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//向用户发起授权请求
|
||||
window['ks'].authorize({
|
||||
scope: 'scope.userInfo',
|
||||
success: (res) => {
|
||||
console.log("快手 - 发起授权请求成功:", res);
|
||||
self.getUserInfo(cb)
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("快手 - 发起授权请求失败: ", error);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log("快手 - 获取授权信息失败: ", error);
|
||||
// cb && cb({avatarUrl:"", nickName:""})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//快手登录
|
||||
login(cb: Function = null) {
|
||||
window['ks'].login({
|
||||
success: (res) => {
|
||||
console.log('快手 - 登录成功', res.code);
|
||||
cb && cb({ platform:3, code: res.code });
|
||||
},
|
||||
fail(res: any) {
|
||||
console.log(`快手 login 调用失败`, res);
|
||||
cb && cb({ platform:3, code: null });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
//初始化视频广告
|
||||
private init_video() {
|
||||
this.wx_video = window['ks'].createRewardedVideoAd({
|
||||
adUnitId: wx_video_ad_unit_id
|
||||
});
|
||||
this.wx_video.onError((err) => {
|
||||
console.log('onError event emit', err);
|
||||
});
|
||||
this.wx_video.onClose(res => {
|
||||
console.log('onClose event emit',res);
|
||||
// 用户点击了【关闭广告】按钮
|
||||
// 小于 2.1.0 的基础库版本,res 是一个 undefined
|
||||
if ((res && res.isEnded) || res === undefined) {
|
||||
// 正常播放结束,可以下发游戏奖励
|
||||
if (this.wx_video_callback) {
|
||||
this.wx_video_callback(this.wx_video_tag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 播放中途退出,不下发游戏奖励
|
||||
//wx_video_callback(-1);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//初始化插屏广告
|
||||
private init_splash() {
|
||||
// 创建插屏广告实例,提前初始化
|
||||
if (window['ks'].createInterstitialAd){
|
||||
this.wx_splash = window['ks'].createInterstitialAd({
|
||||
adUnitId: wx_splash_ad_unit_id
|
||||
});
|
||||
this.wx_splash.onError((err) => {
|
||||
console.log('splash onError event emit', err);
|
||||
});
|
||||
this.wx_splash.onClose(res => {
|
||||
console.log('splash onClose event emit', res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//初始化Banner
|
||||
private init_banner() {
|
||||
|
||||
}
|
||||
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
if (wx_video_ad_unit_id == 'test') {
|
||||
console.log('未接入广告ID,视频广告请求直接返回');
|
||||
callback && callback();
|
||||
return;
|
||||
}
|
||||
if (this.wx_video) {
|
||||
this.wx_video_callback = callback;
|
||||
this.wx_video_tag = tag;
|
||||
let p = this.wx_video.show()
|
||||
p.then(function(result){
|
||||
// 激励视频展示成功
|
||||
console.log(`快手 show rewarded video ad success, result is ${result}`)
|
||||
}).catch(function(error){
|
||||
// 激励视频展示失败
|
||||
console.log(`快手 show rewarded video ad failed, error is ${error}`)
|
||||
})
|
||||
|
||||
// this.wx_video.load()
|
||||
// .then(() => {
|
||||
// this.wx_video.show()
|
||||
// .catch(err => {
|
||||
// this.wx_video.load()
|
||||
// .then(() => this.wx_video.show())
|
||||
// })
|
||||
// })
|
||||
}
|
||||
}
|
||||
|
||||
//显示插屏
|
||||
show_splash() {
|
||||
|
||||
if (this.wx_splash) {
|
||||
let p = this.wx_splash.show()
|
||||
p.then(function(result){
|
||||
// 插屏广告展示成功
|
||||
console.log(`快手 show interstitial ad success, result is ${result}`)
|
||||
}).catch(function(error){
|
||||
// 插屏广告展示失败
|
||||
console.log(`快手 show interstitial ad failed, error is ${error}`)
|
||||
if (error.code === -10005) {
|
||||
// 表明当前app版本不支持插屏广告,可以提醒用户升级app版本
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//显示Banner
|
||||
show_banner() {
|
||||
if (this.wx_banner) {
|
||||
this.wx_banner.show(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏Banner
|
||||
hide_banner() {
|
||||
if (this.wx_banner) {
|
||||
this.wx_banner.hide(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//分享信息
|
||||
shareInfo() {
|
||||
return {
|
||||
templateId: undefined, //分享模版id,不传走默认分享文案
|
||||
//查询字符串,从这条转发消息进入后,可通过 ks.getLaunchOptionsSync() 或 ks.onShow() 获取启动参数中的 query。必须是 key1=val1&key2=val2 的格式。
|
||||
query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(),
|
||||
}
|
||||
}
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
console.log("主动拉起分享");
|
||||
let info:any = this.shareInfo();
|
||||
info.succ = rewardCB;
|
||||
info.success = null;
|
||||
info.fail = null;
|
||||
this.ShareCb = info;
|
||||
window['ks'].shareAppMessage(info);
|
||||
}
|
||||
|
||||
//获取设备分辨率
|
||||
getWindowSize() {
|
||||
let windowinfo = window['ks'].getSystemInfoSync();
|
||||
return {width:windowinfo.screenWidth, height: windowinfo.screenHeight};
|
||||
}
|
||||
|
||||
//显示游戏圈
|
||||
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
|
||||
if (true) {
|
||||
console.log("显示游戏圈,快手暂不支持");
|
||||
return
|
||||
}
|
||||
}
|
||||
//隐藏游戏圈
|
||||
hide_gameClub() {
|
||||
console.log("隐藏游戏圈");
|
||||
if (this.wx_gameClub) {
|
||||
this.wx_gameClub.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//检查是否支持base64音频播放
|
||||
checkSupportBase64Audio() {
|
||||
return true;
|
||||
}
|
||||
//播放base64音频
|
||||
private _innerAudioContext: any = null;
|
||||
private _iacIdx = 0 //音频播放索引
|
||||
playBase64Audio(base64, loop) {
|
||||
if (!this.checkSupportBase64Audio()) {
|
||||
console.log("当前平台不支持base64音频播放");
|
||||
return;
|
||||
}
|
||||
|
||||
let substring = base64;
|
||||
let qianzhui = "data:audio/x-wav;base64,"
|
||||
if(base64.startsWith(qianzhui)) {
|
||||
substring = base64.substring(qianzhui.length, base64.length)
|
||||
}
|
||||
|
||||
let self = this;
|
||||
const fs = window['ks'].getFileSystemManager();
|
||||
//1.删除上一个音频
|
||||
const lastPath = window['ks'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
|
||||
console.log("快手 正在删除上一个音频 ->", lastPath);
|
||||
fs.removeSavedFile({
|
||||
filePath: lastPath,
|
||||
success(res) {
|
||||
console.log("快手 删除上一个音频成功", res);
|
||||
},
|
||||
fail(err) {
|
||||
console.log("快手 删除上一个音频失败", err);
|
||||
},
|
||||
complete(res) {
|
||||
console.log("快手 删除上一个音频完成", res);
|
||||
|
||||
//2.保存当前音频
|
||||
//这里需要每次保存时换一下名字的原因是:innerAudioContext设置路径时如果路径相同,会认为还是同一个音频,不会重新加载,所以需要每次保存时换一下名字
|
||||
self._iacIdx++;
|
||||
const audioPath = window['ks'].env.USER_DATA_PATH + `/ordernew${self._iacIdx}.mp3`
|
||||
console.log("快手 正在保存本次音频 ->", audioPath);
|
||||
fs.writeFile({
|
||||
filePath: audioPath,
|
||||
data: substring,
|
||||
encoding: 'base64',
|
||||
success(res) {
|
||||
if (self._innerAudioContext == null){
|
||||
self._innerAudioContext = window['ks'].createInnerAudioContext();
|
||||
// 添加播放结束的回调
|
||||
self._innerAudioContext.onEnded(() => {
|
||||
console.log("快手 AI语音播放结束")
|
||||
self._innerAudioContext.stop(); // 使用 stop 方法停止音频并重置播放状态
|
||||
self._innerAudioContext.destroy(); // 销毁音频实例
|
||||
self._innerAudioContext = null;
|
||||
});
|
||||
}
|
||||
console.log("快手 播放base64音频", audioPath)
|
||||
self._innerAudioContext.src = audioPath;
|
||||
self._innerAudioContext.play(); // 开始播放音频
|
||||
},
|
||||
fail(err) {
|
||||
console.log("快手 保存本次音频失败", err);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
//版本更新检测
|
||||
//微信开发者工具上可以通过「编译模式」下的「下次编译模拟更新」开关来调试
|
||||
qiangzhiUpdata() {
|
||||
if (window['ks'].getUpdateManager == null) {
|
||||
console.log("快手 没有更新管理器", window['ks'].getUpdateManager)
|
||||
return;
|
||||
}
|
||||
|
||||
const updateManager = window['ks'].getUpdateManager();
|
||||
|
||||
//监听向微信后台请求检查更新结果事件。微信在小程序每次启动(包括热启动)时自动检查更新,不需由开发者主动触发。
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
// 请求完新版本信息的回调
|
||||
console.log("快手 检查是否有新版本:", res.hasUpdate)
|
||||
});
|
||||
|
||||
//监听小程序有版本更新事件。客户端主动触发下载(无需开发者触发),下载成功后回调
|
||||
updateManager.onUpdateReady(async () => {
|
||||
const { confirm } = await window['ks'].showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
});
|
||||
if (confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
updateManager.applyUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
//监听小程序更新失败事件。小程序有新版本,客户端主动触发下载(无需开发者触发),下载失败(可能是网络原因等)时回调
|
||||
updateManager.onUpdateFailed(function () {
|
||||
console.log("快手 新版本下载失败")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//region 友盟+
|
||||
umaInit() {
|
||||
}
|
||||
//友盟统计是否开启
|
||||
umaSwt() {
|
||||
return false;
|
||||
}
|
||||
//友盟事件统计
|
||||
umaEvent(eventName: string, value: any = {}) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,909 @@
|
||||
{
|
||||
"gizmos-infos": {
|
||||
"is2D": true,
|
||||
"is3DIcon": false,
|
||||
"iconSize": 2,
|
||||
"gridVisible": true,
|
||||
"gridColor": [
|
||||
166,
|
||||
166,
|
||||
166,
|
||||
255
|
||||
],
|
||||
"transformToolName": "position",
|
||||
"pivot": "pivot",
|
||||
"coordinate": "local",
|
||||
"toolsVisibility3d": true
|
||||
},
|
||||
"__version__": "1.0.1",
|
||||
"builder": {
|
||||
"taskOptionsMap": {},
|
||||
"__version__": "1.3.8"
|
||||
},
|
||||
"snap-configs": {
|
||||
"position": {
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"rotation": 1,
|
||||
"scale": 1,
|
||||
"isPositionSnapEnabled": false,
|
||||
"isRotationSnapEnabled": false,
|
||||
"isScaleSnapEnabled": false
|
||||
},
|
||||
"rect-snap-configs": {
|
||||
"enableSnapping": true,
|
||||
"snapThreshold": 4
|
||||
},
|
||||
"float-window": {
|
||||
"position": {
|
||||
"cc": {
|
||||
"Camera": {
|
||||
"dock": false,
|
||||
"top": null,
|
||||
"bottom": 10,
|
||||
"left": null,
|
||||
"right": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"camera-infos": {
|
||||
"1fcc05e5-18d9-4302-b271-815963b8fb27": {
|
||||
"position": {
|
||||
"x": 640,
|
||||
"y": 360,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 1.0373478206705766e-13,
|
||||
"y": -74.33133732534921,
|
||||
"width": 701.4000000000001,
|
||||
"height": 394.5375
|
||||
},
|
||||
"scale": 0.5479687500000001
|
||||
},
|
||||
"1a23cd3e-e487-4fd1-a415-346c2087464d": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"1af15364-46a2-4eda-bfa1-afbc13cef7ed": {
|
||||
"position": {
|
||||
"x": 289.5058092012657,
|
||||
"y": 678.8326237675253,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -135.65154891336527,
|
||||
"y": -77.00267954737429,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.3148834130348147
|
||||
},
|
||||
"489b9fd0-6648-471e-9b73-f35de51e18ec": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"5eb8006b-fdb2-438f-824b-0e81c4ae7075": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"72516604-5e3c-4512-8eef-b189f45fda7c": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"e111b312-e977-4ce9-ad81-fd2ddbc9e9f2": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"3f3cae27-d5a5-46ac-a56d-76a3d342ad7c": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"9e3f36d6-1357-4d20-9915-71f4d2bac4d6": {
|
||||
"position": {
|
||||
"x": 550.6749823218985,
|
||||
"y": 278.4282055817483,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 88.64165919925301,
|
||||
"y": 214.8344523575063,
|
||||
"width": 701.4000000000001,
|
||||
"height": 96.5399166666667
|
||||
},
|
||||
"scale": 0.7590361613526038
|
||||
},
|
||||
"022d7be0-2614-43b7-b842-16a35156d49f": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"705cdc09-3fba-4d9d-aa9a-f9d3ae8314e5": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"8bc7d597-38f6-4755-8e62-94553fade1a1": {
|
||||
"position": {
|
||||
"x": 293.81696993091094,
|
||||
"y": 643.7949664167054,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 108.75648113281885,
|
||||
"y": 314.7985418867639,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.7234121171378869
|
||||
},
|
||||
"32268268-3574-4aed-bf34-19e36d1dd8e9": {
|
||||
"position": {
|
||||
"x": 448.6688078248885,
|
||||
"y": 966.7969265328356,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"16b0d021-6436-4bbc-ba5e-05ebe3e84ba4": {
|
||||
"position": {
|
||||
"x": 106.2581657551234,
|
||||
"y": 520.0515397307022,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -140.8191394251504,
|
||||
"y": 396.5128871405652,
|
||||
"width": 210,
|
||||
"height": 105
|
||||
},
|
||||
"scale": 0.4249682095382631
|
||||
},
|
||||
"c478a57c-0719-403b-88e4-9e567022dd22": {
|
||||
"position": {
|
||||
"x": 368.4259045292083,
|
||||
"y": 591.6464239527231,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -93.6074185934374,
|
||||
"y": -229.74615048753563,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.2897518280612484
|
||||
},
|
||||
"5871d76f-ef9e-42f6-a8c5-9ca3ae2b651f": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"b329560c-6337-48ce-ba86-988871cd00e8": {
|
||||
"position": {
|
||||
"x": 318.4838842900483,
|
||||
"y": 636.734687528431,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -41.51611570995182,
|
||||
"y": -3.2653124715691497,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.37187499999999996
|
||||
},
|
||||
"54bfe600-9105-42b7-8725-fbd33f2cbfaa": {
|
||||
"position": {
|
||||
"x": 411.3704703070499,
|
||||
"y": 617.8428703544104,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 261.88554544355594,
|
||||
"y": 457.1761281890805,
|
||||
"width": 442.8721419010482,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 1.481327104741393
|
||||
},
|
||||
"fd20222a-b807-4b44-89fa-ae93e9574469": {
|
||||
"position": {
|
||||
"x": 354.7265413901863,
|
||||
"y": 758.450040280192,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 74.22729271240608,
|
||||
"y": 135.11837655179178,
|
||||
"width": 214.2,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.3818192045249638
|
||||
},
|
||||
"5de6e399-8fdd-4be1-91fa-38439f59cc9b": {
|
||||
"position": {
|
||||
"x": 414.72457954320726,
|
||||
"y": 562.5440598439186,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 23.50002903381481,
|
||||
"y": -132.9662521727791,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.3421947825761153
|
||||
},
|
||||
"bbeb7b56-8ef0-46fe-98c6-47050bc1016d": {
|
||||
"position": {
|
||||
"x": 374.46474793346175,
|
||||
"y": 837.0936496891132,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 173.3530630804618,
|
||||
"y": 479.56176550600213,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.6656748965026782
|
||||
},
|
||||
"d5244228-33d7-4283-92f7-404f0ac0c4ff": {
|
||||
"position": {
|
||||
"x": 371.4988032185869,
|
||||
"y": 668.2894606307094,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 11.498803218586731,
|
||||
"y": 28.289460630709204,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.3718749999999999
|
||||
},
|
||||
"c3777bc8-76d6-4e30-90c7-d2b4b23cde93": {
|
||||
"position": {
|
||||
"x": 342.21177871319185,
|
||||
"y": 635.5038513987596,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 104.70035477407073,
|
||||
"y": 213.2613199514332,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.5636570981710539
|
||||
},
|
||||
"5a84048d-d377-4f41-9e8d-8acf18c0dfa7": {
|
||||
"position": {
|
||||
"x": 99.13899076873895,
|
||||
"y": 694.3980422980328,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -181.3602579090416,
|
||||
"y": 195.73271131531186,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.47727400565620404
|
||||
},
|
||||
"21f192c8-c0d9-4f88-8559-8867160aaac9": {
|
||||
"position": {
|
||||
"x": 89.97825047423066,
|
||||
"y": 696.4718239924364,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -241.2893037507273,
|
||||
"y": 107.55172759251091,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.4041295270018741
|
||||
},
|
||||
"f7d2d607-ac84-4c26-93fd-7cc6d2857123": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -583.0588235294117,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"db827e15-1acd-4bd6-ba11-7c97f1b1ef0b": {
|
||||
"position": {
|
||||
"x": 156.02863308204883,
|
||||
"y": 724.5633142001748,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -235.19591742733584,
|
||||
"y": 29.053002183490925,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.3421947825761221
|
||||
},
|
||||
"04f18f73-2683-4458-bcdb-0f050f757f42": {
|
||||
"position": {
|
||||
"x": 139.7254702323305,
|
||||
"y": 617.242698003844,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -140.7737784454499,
|
||||
"y": 578.6350930816661,
|
||||
"width": 701.4000000000001,
|
||||
"height": 96.5399166666667
|
||||
},
|
||||
"scale": 1.2502707285425274
|
||||
},
|
||||
"a4de2299-b1c9-4c38-8477-3c223941ee90": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"2e8ca9f8-230a-47e7-b6aa-f4381deb0261": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.371875
|
||||
},
|
||||
"9136198a-875d-4496-a164-f740afbc513e": {
|
||||
"position": {
|
||||
"x": 360,
|
||||
"y": 640,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": -920,
|
||||
"y": 0,
|
||||
"width": 59.0625,
|
||||
"height": 105
|
||||
},
|
||||
"scale": 0.08203125
|
||||
},
|
||||
"d849ab34-cd64-4950-b151-bf4d9b9fb04d": {
|
||||
"position": {
|
||||
"x": 341.7507778359528,
|
||||
"y": 612.4138912560493,
|
||||
"z": 5000
|
||||
},
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"viewCenter": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"contentRect": {
|
||||
"x": 10.483223610989976,
|
||||
"y": 23.493794856115475,
|
||||
"width": 267.75,
|
||||
"height": 476
|
||||
},
|
||||
"scale": 0.40412952700186844
|
||||
}
|
||||
},
|
||||
"camera-uuids": [
|
||||
"1fcc05e5-18d9-4302-b271-815963b8fb27",
|
||||
"1a23cd3e-e487-4fd1-a415-346c2087464d",
|
||||
"1af15364-46a2-4eda-bfa1-afbc13cef7ed",
|
||||
"489b9fd0-6648-471e-9b73-f35de51e18ec",
|
||||
"5eb8006b-fdb2-438f-824b-0e81c4ae7075",
|
||||
"72516604-5e3c-4512-8eef-b189f45fda7c",
|
||||
"e111b312-e977-4ce9-ad81-fd2ddbc9e9f2",
|
||||
"3f3cae27-d5a5-46ac-a56d-76a3d342ad7c",
|
||||
"9e3f36d6-1357-4d20-9915-71f4d2bac4d6",
|
||||
"022d7be0-2614-43b7-b842-16a35156d49f",
|
||||
"705cdc09-3fba-4d9d-aa9a-f9d3ae8314e5",
|
||||
"8bc7d597-38f6-4755-8e62-94553fade1a1",
|
||||
"32268268-3574-4aed-bf34-19e36d1dd8e9",
|
||||
"16b0d021-6436-4bbc-ba5e-05ebe3e84ba4",
|
||||
"c478a57c-0719-403b-88e4-9e567022dd22",
|
||||
"5871d76f-ef9e-42f6-a8c5-9ca3ae2b651f",
|
||||
"b329560c-6337-48ce-ba86-988871cd00e8",
|
||||
"54bfe600-9105-42b7-8725-fbd33f2cbfaa",
|
||||
"fd20222a-b807-4b44-89fa-ae93e9574469",
|
||||
"5de6e399-8fdd-4be1-91fa-38439f59cc9b",
|
||||
"bbeb7b56-8ef0-46fe-98c6-47050bc1016d",
|
||||
"d5244228-33d7-4283-92f7-404f0ac0c4ff",
|
||||
"c3777bc8-76d6-4e30-90c7-d2b4b23cde93",
|
||||
"5a84048d-d377-4f41-9e8d-8acf18c0dfa7",
|
||||
"21f192c8-c0d9-4f88-8559-8867160aaac9",
|
||||
"f7d2d607-ac84-4c26-93fd-7cc6d2857123",
|
||||
"db827e15-1acd-4bd6-ba11-7c97f1b1ef0b",
|
||||
"04f18f73-2683-4458-bcdb-0f050f757f42",
|
||||
"a4de2299-b1c9-4c38-8477-3c223941ee90",
|
||||
"2e8ca9f8-230a-47e7-b6aa-f4381deb0261",
|
||||
"9136198a-875d-4496-a164-f740afbc513e",
|
||||
"d849ab34-cd64-4950-b151-bf4d9b9fb04d"
|
||||
],
|
||||
"camera": {
|
||||
"color": [
|
||||
48,
|
||||
48,
|
||||
48,
|
||||
255
|
||||
],
|
||||
"fov": 45,
|
||||
"far": 10000,
|
||||
"near": 0.01,
|
||||
"wheelSpeed": 0.01,
|
||||
"wanderSpeed": 10,
|
||||
"enableAcceleration": true,
|
||||
"size": "__default_design__",
|
||||
"far2D": 10000,
|
||||
"near2D": 1,
|
||||
"wheelSpeed2D": 6,
|
||||
"iso": 0,
|
||||
"aperture": 19,
|
||||
"shutter": 7
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,644 @@
|
||||
import { _decorator, AudioSource, EditBox, EventTouch, isValid, Label, Node, Sprite, Tween, 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';
|
||||
import GlobalValue from '../../Main/Common/GlobalValue';
|
||||
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.npcTalkSV.on(Node.EventType.TOUCH_START, (event: EventTouch)=>{
|
||||
// event.preventSwallow = true; //允许点击事件穿透
|
||||
// }, this);
|
||||
this._nodeTab.npcTalkSV.getChildByName("view").on(Node.EventType.TOUCH_END, (event:EventTouch) => {
|
||||
// event.preventSwallow = true; //允许点击事件穿透
|
||||
this.onNpcFramClick();
|
||||
}, 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)
|
||||
Utils.addInnerEL(InnerMsgCode.Data_LevelStarUp, this, this.resiveLevelStarUp)
|
||||
Utils.addInnerEL(InnerMsgCode.UI_ResartGame, this, this.resiveResartGame)
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
//弹窗适配
|
||||
let scaleRatio = Utils.getScaleRatio(2)
|
||||
if (scaleRatio > 1) {
|
||||
scaleRatio = 1;
|
||||
}
|
||||
this._nodeTab.gs1frame.scale = new Vec3(scaleRatio, scaleRatio, 1)
|
||||
//规则内容
|
||||
Utils.setString(this._nodeTab.labGs1Tips, GlobalValue.RuleStr)
|
||||
|
||||
// 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.initedGame()
|
||||
}
|
||||
|
||||
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: () => {
|
||||
ViewManager.I.closeAllView();
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||||
},
|
||||
closeCallback: () => {
|
||||
ViewManager.I.closeAllView();
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||||
}
|
||||
})
|
||||
this.npcTalkInfo.stage = 0
|
||||
}
|
||||
|
||||
/**接收到聊天状态变化消息 */
|
||||
resiveTalkStageUp(data:any) {
|
||||
this.refreshTalkStage()
|
||||
}
|
||||
/**接收到星级变化消息 */
|
||||
resiveLevelStarUp(data:any) {
|
||||
if (data && data.level == GameManager.CurLevelId) {
|
||||
for (let i=1; i<=3; i++) {
|
||||
let lsStar = this._nodeTab["lsStar"+i].getComponent(Sprite)
|
||||
let starPath = data.star >= i ? "lv_3" : "lv_2"
|
||||
ResManager.I.changeBundleSpriteFrame(lsStar, starPath, "Zhujiemian")
|
||||
}
|
||||
}
|
||||
}
|
||||
/**重新开始游戏 */
|
||||
resiveResartGame(data:any) {
|
||||
console.log("重新开始游戏")
|
||||
this.initedGame()
|
||||
}
|
||||
|
||||
|
||||
/**初始化 */
|
||||
initedGame() {
|
||||
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
|
||||
|
||||
this.refreshTalkStage()
|
||||
|
||||
//刷新状态显示
|
||||
this.refreshTalkStepData()
|
||||
this.refreshXindongCishu(false)
|
||||
this.refreshDuihuaDefen()
|
||||
|
||||
//检测引导
|
||||
this.checkGuide()
|
||||
}
|
||||
|
||||
|
||||
//输入框开始编辑事件
|
||||
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.refreshTalkStepData()
|
||||
this.checkIsFinish()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**刷新心动次数 */
|
||||
private refreshXindongCishu(doAct:boolean = true) {
|
||||
let maxCount = HttpUnit.GetXindongMaxCount()
|
||||
let curCount = GameManager.xindongCishu
|
||||
Utils.setString(this._nodeTab.xindongNum, `${curCount}/${maxCount}`)
|
||||
|
||||
Tween.stopAllByTarget(this.xindongSpt)
|
||||
if (doAct) {
|
||||
tween(this.xindongSpt).to(0.3, { fillRange: curCount / maxCount }).start()
|
||||
} else {
|
||||
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("结算失败,服务器返回异常!")
|
||||
ViewManager.I.closeAllView();
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//退出聊天
|
||||
onBackClick() {
|
||||
SubManager.ShowConfirm({
|
||||
content: "确定退出吗?\n(退出会保留当前聊天进度)",
|
||||
yesCallback: () => {
|
||||
//退出并结算
|
||||
// this.doJiesuan();
|
||||
|
||||
//只退出聊天,不结算
|
||||
this.onClose();
|
||||
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 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(true)
|
||||
} 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()
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 183 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "91c22405-e7db-402c-9d68-462d7466a5c0",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "91c22405-e7db-402c-9d68-462d7466a5c0@6c48a",
|
||||
"displayName": "lingxia_default",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "91c22405-e7db-402c-9d68-462d7466a5c0",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "91c22405-e7db-402c-9d68-462d7466a5c0@f9941",
|
||||
"displayName": "lingxia_default",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 18,
|
||||
"offsetY": -9.5,
|
||||
"trimX": 182,
|
||||
"trimY": 19,
|
||||
"width": 597,
|
||||
"height": 1170,
|
||||
"rawWidth": 925,
|
||||
"rawHeight": 1189,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-298.5,
|
||||
-585,
|
||||
0,
|
||||
298.5,
|
||||
-585,
|
||||
0,
|
||||
-298.5,
|
||||
585,
|
||||
0,
|
||||
298.5,
|
||||
585,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
182,
|
||||
1170,
|
||||
779,
|
||||
1170,
|
||||
182,
|
||||
0,
|
||||
779,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.19675675675675675,
|
||||
0,
|
||||
0.8421621621621621,
|
||||
0,
|
||||
0.19675675675675675,
|
||||
0.9840201850294366,
|
||||
0.8421621621621621,
|
||||
0.9840201850294366
|
||||
],
|
||||
"minPos": [
|
||||
-298.5,
|
||||
-585,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
298.5,
|
||||
585,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "91c22405-e7db-402c-9d68-462d7466a5c0@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "91c22405-e7db-402c-9d68-462d7466a5c0@6c48a"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 282 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 346 KiB |
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "b8cd291d-68fa-4198-b8a9-724e5d784943",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 952 KiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "76aeec53-37c7-43ba-9eca-844abdf4d478",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "76aeec53-37c7-43ba-9eca-844abdf4d478@6c48a",
|
||||
"displayName": "tarenaya_portrait",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "76aeec53-37c7-43ba-9eca-844abdf4d478",
|
||||
"isUuid": true,
|
||||
"visible": false,
|
||||
"minfilter": "linear",
|
||||
"magfilter": "linear",
|
||||
"mipfilter": "none",
|
||||
"anisotropy": 0
|
||||
},
|
||||
"ver": "1.0.22",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
},
|
||||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "76aeec53-37c7-43ba-9eca-844abdf4d478@f9941",
|
||||
"displayName": "tarenaya_portrait",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 276,
|
||||
"height": 364,
|
||||
"rawWidth": 276,
|
||||
"rawHeight": 364,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-138,
|
||||
-182,
|
||||
0,
|
||||
138,
|
||||
-182,
|
||||
0,
|
||||
-138,
|
||||
182,
|
||||
0,
|
||||
138,
|
||||
182,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
364,
|
||||
276,
|
||||
364,
|
||||
0,
|
||||
0,
|
||||
276,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-138,
|
||||
-182,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
138,
|
||||
182,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "76aeec53-37c7-43ba-9eca-844abdf4d478@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "76aeec53-37c7-43ba-9eca-844abdf4d478@6c48a"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user