init
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "3bc495f4-f6d8-4b3b-98f5-398912f68ad9",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "3bc495f4-f6d8-4b3b-98f5-398912f68ad9@6c48a",
|
||||
"displayName": "blackmoon_nightgod_disgust",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "3bc495f4-f6d8-4b3b-98f5-398912f68ad9",
|
||||
"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": "3bc495f4-f6d8-4b3b-98f5-398912f68ad9@f9941",
|
||||
"displayName": "blackmoon_nightgod_disgust",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": -44.5,
|
||||
"trimX": 0,
|
||||
"trimY": 89,
|
||||
"width": 925,
|
||||
"height": 1100,
|
||||
"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": [
|
||||
-462.5,
|
||||
-550,
|
||||
0,
|
||||
462.5,
|
||||
-550,
|
||||
0,
|
||||
-462.5,
|
||||
550,
|
||||
0,
|
||||
462.5,
|
||||
550,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
1100,
|
||||
925,
|
||||
1100,
|
||||
0,
|
||||
0,
|
||||
925,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0.9251471825063078,
|
||||
1,
|
||||
0.9251471825063078
|
||||
],
|
||||
"minPos": [
|
||||
-462.5,
|
||||
-550,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
462.5,
|
||||
550,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "3bc495f4-f6d8-4b3b-98f5-398912f68ad9@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "3bc495f4-f6d8-4b3b-98f5-398912f68ad9@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import HttpUnit from "../Common/HttpUnit";
|
||||
|
||||
export class WebSDK{
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
console.log("init webSDK");
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
//检查权限
|
||||
checkAutoSetting(autoKey:string, cb:Function = null) {
|
||||
cb && cb(true);
|
||||
}
|
||||
|
||||
//获取用户信息
|
||||
getUserInfo(cb:Function = null) {
|
||||
let name = HttpUnit.GetNickName();
|
||||
cb && cb({ nickName:name, avatarUrl:"https://hxzgame.vip.hnhxzkj.com/lzx/XiangQin/webHead.png" });
|
||||
}
|
||||
|
||||
//登录
|
||||
login(cb: Function = null) {
|
||||
cb && cb({ platform:2, code: null });
|
||||
}
|
||||
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
callback && callback({ code: 0, tag: tag });
|
||||
}
|
||||
|
||||
//显示插屏
|
||||
show_splash() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
//显示Banner
|
||||
show_banner(...args) {
|
||||
|
||||
}
|
||||
|
||||
//隐藏Banner
|
||||
hide_banner(...args) {
|
||||
|
||||
}
|
||||
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
rewardCB && rewardCB();
|
||||
}
|
||||
|
||||
//获取设备分辨率
|
||||
getWindowSize() {
|
||||
return {width:screen.width, height: screen.height};
|
||||
}
|
||||
|
||||
//显示游戏圈
|
||||
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
|
||||
|
||||
}
|
||||
//隐藏游戏圈
|
||||
hide_gameClub() {
|
||||
|
||||
}
|
||||
|
||||
//检查是否支持base64音频播放
|
||||
checkSupportBase64Audio() {
|
||||
return true;
|
||||
}
|
||||
//播放base64音频
|
||||
private _audioInst:HTMLAudioElement = null;
|
||||
playBase64Audio(base64:string, loop:boolean) {
|
||||
let substring = base64;
|
||||
let qianzhui = "data:audio/x-wav;base64,"
|
||||
if(base64.startsWith(qianzhui)) {
|
||||
substring = base64.substring(qianzhui.length, base64.length)
|
||||
}
|
||||
|
||||
// 解码 Base64 字符串为二进制数据
|
||||
const binaryData = atob(substring);
|
||||
|
||||
// 创建一个包含二进制数据的 Uint8Array
|
||||
const byteArray = new Uint8Array(binaryData.length);
|
||||
for (let i = 0; i < binaryData.length; i++) {
|
||||
byteArray[i] = binaryData.charCodeAt(i);
|
||||
}
|
||||
|
||||
// 创建 Blob 对象,指定 MIME 类型为音频格式(例如 mp3)
|
||||
const audioBlob = new Blob([byteArray], { type: 'audio/mp3' });
|
||||
|
||||
// 创建音频 URL
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
|
||||
console.log("web 播放base64音频", audioUrl)
|
||||
// 创建音频元素并播放
|
||||
if (this._audioInst == null) {
|
||||
this._audioInst = new Audio(audioUrl);
|
||||
} else {
|
||||
this._audioInst.src = audioUrl;
|
||||
}
|
||||
this._audioInst.play();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,475 @@
|
||||
import { randomRange } from "cc"
|
||||
import GlobalValue from "../Common/GlobalValue"
|
||||
import { I_SDK_UserInfo, I_SDK_UserInfo_Callback } from "./SDKManager"
|
||||
import SubManager from "../../Sub/SubManager"
|
||||
import Utils from "../Common/Utils"
|
||||
import { InnerMsgCode } from "../Config/InnerMsgCode"
|
||||
|
||||
//广告ID
|
||||
const AD_AWARD = "xxxxx"
|
||||
const AD_SPLASH = "xxxxx"
|
||||
const AD_BANNER = "xxxxx"
|
||||
const AD_BANNER_INTERVAL = 30
|
||||
const AD_BANNER_HEIGHT = 130
|
||||
|
||||
export class ByteDanceSDK{
|
||||
|
||||
private bd_video:any = null;
|
||||
private bd_splash:any = null;
|
||||
private bd_banner:any = null;
|
||||
private bd_video_callback:Function = null;
|
||||
private bd_video_tag:number = null;
|
||||
|
||||
private ShareSTime: any;
|
||||
private ShareCb: any; //分享回调
|
||||
private shareTxt = ["分享失败", "请分享到一个群", "请分享给一位好友", "分享过于频繁"]
|
||||
|
||||
|
||||
/**侧边栏状态 =0不显示 =1显示前往按钮 =2从侧边栏返回 */
|
||||
private static _SidebarState:number = 0;
|
||||
public static get SidebarState():number{
|
||||
return ByteDanceSDK._SidebarState;
|
||||
}
|
||||
|
||||
|
||||
/**检测侧边栏功能是否可用 */
|
||||
public static CheckSidebarState(cb:Function=null){
|
||||
if (ByteDanceSDK._SidebarState > 0){
|
||||
cb && cb(true);
|
||||
return;
|
||||
}
|
||||
window['tt'].checkScene({
|
||||
scene: "sidebar",
|
||||
success: (res) => {
|
||||
console.log("抖音 检测侧边栏功能->", res)
|
||||
if (res.isExist == true) {
|
||||
ByteDanceSDK._SidebarState = 1
|
||||
}
|
||||
cb && cb(res.isExist == true);
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("抖音 检测侧边栏功能失败->", res)
|
||||
cb && cb(false);
|
||||
}
|
||||
})
|
||||
}
|
||||
/**前往侧边栏 */
|
||||
public static GotoSidebar(cb:Function = null){
|
||||
console.log("抖音 正在前往侧边栏...")
|
||||
window["tt"].navigateToScene({
|
||||
scene: "sidebar",
|
||||
success(res) {
|
||||
console.log("抖音 前往侧边栏 成功")
|
||||
cb && cb(true);
|
||||
},
|
||||
fail(res) {
|
||||
console.log("抖音 前往侧边栏 失败", res)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//初始化
|
||||
init(cb: Function = null) {
|
||||
console.log("init 抖音 初始化...")
|
||||
// 保持屏幕常亮
|
||||
window["tt"].setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
success(res) {
|
||||
},
|
||||
fail(res) {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
//小游戏回到前台
|
||||
window['tt'].onShow((res)=>{
|
||||
console.log("抖音 小游戏回到前台->", res)
|
||||
if (!res) {
|
||||
return;
|
||||
}
|
||||
// console.log("启动参数:", res.query);
|
||||
// console.log("来源信息:", res.refererInfo);
|
||||
// console.log("场景值:", res.scene);
|
||||
// console.log("启动场景字段:", res.launch_from, ", ", res.location);
|
||||
|
||||
//返回小游戏场景值
|
||||
if (res.query && res.query.ShareCode) {
|
||||
GlobalValue.ShareTocusid = res.query.ShareCode
|
||||
}
|
||||
|
||||
//从侧边栏返回
|
||||
if (res.launch_from == "homepage" && res.location == "sidebar_card") {
|
||||
ByteDanceSDK._SidebarState = 2
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_BD_Sidebar, {})
|
||||
}
|
||||
|
||||
//处理分享事件
|
||||
if (this.ShareCb) {
|
||||
if (this.ShareSTime) {
|
||||
let nT = new Date().getTime();
|
||||
console.log("分享时间差 计算:",nT, this.ShareSTime);
|
||||
if (nT - this.ShareSTime > 1500) {
|
||||
let cb = this.ShareCb.succ
|
||||
cb && cb()
|
||||
} else {
|
||||
this.tostErr()
|
||||
}
|
||||
}
|
||||
this.ShareCb = null;
|
||||
}
|
||||
});
|
||||
//小游戏被隐藏 记个时间
|
||||
window['tt'].onHide(() => {
|
||||
if (this.ShareCb) {
|
||||
this.ShareSTime = new Date().getTime();
|
||||
console.log("分享时间差 记录:", this.ShareSTime);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.init_video();
|
||||
this.init_splash();
|
||||
this.init_banner();
|
||||
cb && cb();
|
||||
}
|
||||
|
||||
//分享失败
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
//检查权限
|
||||
checkAutoSetting(autoKey:string, cb:Function = null) {
|
||||
// cb && cb(true);
|
||||
if (autoKey == "userInfo") {
|
||||
autoKey = "scope.userInfo"
|
||||
}
|
||||
window['tt'].authorize({
|
||||
scope: autoKey,
|
||||
success(res:any) {
|
||||
console.log("抖音 - 检测权限状态 succ:", JSON.stringify(res))
|
||||
if (autoKey == "scope.userInfo" && res.data['scope.userInfo']) {
|
||||
cb && cb(true)
|
||||
} else {
|
||||
cb && cb(false)
|
||||
}
|
||||
},
|
||||
fail(res:any) {
|
||||
console.log("抖音 - 检测权限状态 fail:",JSON.stringify(res))
|
||||
cb && cb(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取用户信息
|
||||
getUserInfo(cb:I_SDK_UserInfo_Callback = null) {
|
||||
// cb && cb({ nickName:"", avatarUrl:"" });
|
||||
//getUserProfile报错未找到
|
||||
window["tt"].getUserInfo({
|
||||
force: false, //当宿主未登录时,是否强制拉起登录框
|
||||
success(res) {
|
||||
console.log("抖音 - 获取用户信息成功:", res);
|
||||
cb && cb({avatarUrl:res.userInfo.avatarUrl, nickName:res.userInfo.nickName}) //encryptedData
|
||||
},
|
||||
fail(res) {
|
||||
console.log("抖音 - 获取用户信息失败", res);
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//登录
|
||||
login(cb: Function = null) {
|
||||
// cb && cb({ platform:3, code: null });
|
||||
window["tt"].login({
|
||||
force: false, //未登录时, 是否强制调起登录框
|
||||
success(res) {
|
||||
console.log(`抖音 - 登录成功 code=${res.code}, anonymousCode=${res.anonymousCode}`);
|
||||
cb && cb({ platform:3, code: res.code });
|
||||
},
|
||||
fail(res) {
|
||||
console.log(`抖音 - 登录失败`, res);
|
||||
cb && cb({ platform:3, code: null });
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
private init_banner() {
|
||||
|
||||
if (!window["tt"] || !window["tt"].createBannerAd) return
|
||||
|
||||
const systemInfo = window["tt"].getSystemInfoSync();
|
||||
//if (systemInfo.appName.toUpperCase() == 'DOUYIN') return
|
||||
//if (systemInfo.appName.toUpperCase() == 'TOUTIAO' && systemInfo.platform == "ios") return
|
||||
|
||||
if (systemInfo.appName.toUpperCase() == 'DOUYIN' || systemInfo.platform == "ios") return
|
||||
|
||||
const { windowWidth, windowHeight } = window["tt"].getSystemInfoSync();
|
||||
var targetBannerAdWidth = 128+ 100
|
||||
var targetBannerAdHeight = AD_BANNER_HEIGHT
|
||||
// 创建一个居于屏幕底部正中的广告
|
||||
this.bd_banner = window["tt"].createBannerAd({
|
||||
adUnitId: AD_BANNER,
|
||||
adIntervals: AD_BANNER_INTERVAL,
|
||||
style: {
|
||||
width: targetBannerAdWidth,
|
||||
left:(windowWidth - targetBannerAdWidth) / 2,
|
||||
top: windowHeight - targetBannerAdHeight
|
||||
},
|
||||
});
|
||||
|
||||
// 尺寸调整时会触发回调
|
||||
// 注意:如果在回调里再次调整尺寸,要确保不要触发死循环!!!
|
||||
this.bd_banner.onResize(size => {
|
||||
this.bd_banner.style.left = (windowWidth - size.width) / 2;
|
||||
this.bd_banner.style.top = windowHeight - size.height;
|
||||
});
|
||||
|
||||
// bd_banner.onLoad(() => {
|
||||
// bd_banner
|
||||
// .show()
|
||||
// .then(() => {
|
||||
// console.log("init_banner 广告显示成功");
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log("init_banner 广告组件出现问题", err);
|
||||
// });
|
||||
// })
|
||||
}
|
||||
|
||||
private init_splash() {
|
||||
|
||||
this.preload_splash()
|
||||
}
|
||||
|
||||
private preload_splash() {
|
||||
if (!window["tt"] || !window["tt"].createInterstitialAd) return
|
||||
|
||||
if (this.bd_splash) {
|
||||
if (this.bd_splash['custom_show_stautus']) {
|
||||
this.bd_splash.destroy()
|
||||
this.bd_splash = null
|
||||
} else {
|
||||
if (!this.bd_splash['custom_load_stautus']) {
|
||||
this.bd_splash
|
||||
.load()
|
||||
.catch(err => {
|
||||
console.log("preload_splash err:",err);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.bd_splash) return
|
||||
|
||||
// 创建插屏广告实例,会自动进行一次load
|
||||
this.bd_splash = window["tt"].createInterstitialAd({
|
||||
adUnitId: AD_SPLASH
|
||||
})
|
||||
this.bd_splash.onLoad(function(){
|
||||
this.bd_splash['custom_load_stautus'] = true
|
||||
})
|
||||
this.bd_splash.onClose(function(){
|
||||
this.bd_splash.destroy()
|
||||
this.bd_splash = null
|
||||
|
||||
this.preload_splash()
|
||||
})
|
||||
this.bd_splash.onError(function(err){
|
||||
console.log("bd_splash err:",err)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private init_video() {
|
||||
|
||||
if (!window["tt"] || !window["tt"].createRewardedVideoAd) return
|
||||
|
||||
this.bd_video = window["tt"].createRewardedVideoAd({
|
||||
adUnitId: AD_AWARD,
|
||||
});
|
||||
|
||||
this.bd_video.onClose(res => {
|
||||
if (res.isEnded) {
|
||||
if (this.bd_video_callback) {
|
||||
this.bd_video_callback(this.bd_video_tag);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.bd_video.onError((err) => {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//显示视频广告
|
||||
show_video(callback:Function, tag:number) {
|
||||
if (!this.bd_video) return
|
||||
|
||||
this.bd_video_callback = callback;
|
||||
this.bd_video_tag = tag
|
||||
|
||||
this.bd_video
|
||||
.load()
|
||||
.then(() => {
|
||||
this.bd_video.show()
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//显示插屏
|
||||
show_splash() {
|
||||
|
||||
//已加载 未展示
|
||||
if (this.bd_splash && this.bd_splash['custom_load_stautus'] && !this.bd_splash['custom_show_stautus']) {
|
||||
this.bd_splash.show().then(() => {
|
||||
this.bd_splash['custom_show_stautus'] = true
|
||||
console.log("插屏广告展示成功");
|
||||
})
|
||||
} else {
|
||||
console.log("插屏广告展示失败");
|
||||
this.preload_splash()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//显示Banner
|
||||
show_banner() {
|
||||
if (this.bd_banner) {
|
||||
this.bd_banner.show(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏Banner
|
||||
hide_banner() {
|
||||
if (this.bd_banner) {
|
||||
this.bd_banner.hide(); //banner 默认隐藏(hide) 要打开
|
||||
}
|
||||
}
|
||||
|
||||
//移除
|
||||
clear_banner() {
|
||||
if (this.bd_banner) {
|
||||
this.bd_banner.destroy(); //banner 默认隐藏(hide) 要打开
|
||||
this.bd_banner = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//分享信息
|
||||
shareInfo() {
|
||||
return {
|
||||
title: "告白契约", //Resource.getText(_shareInfo.invite_des),
|
||||
query: "ShareCode=" + "user_default", //ModelPlayer.I.getPlayerId(),
|
||||
}
|
||||
}
|
||||
//主动拉起分享
|
||||
show_share(rewardCB?:Function) {
|
||||
// rewardCB && rewardCB()
|
||||
console.log("主动拉起分享");
|
||||
let info:any = this.shareInfo();
|
||||
info.succ = rewardCB;
|
||||
|
||||
info.success = (res) => {
|
||||
console.log("抖音 主动拉起分享成功", res);
|
||||
}
|
||||
info.fail = (err) => {
|
||||
console.log("抖音 主动拉起分享失败", err);
|
||||
}
|
||||
// info.complete = (res) => {
|
||||
// console.log("抖音 主动拉起分享完成", res);
|
||||
// }
|
||||
|
||||
this.ShareCb = info;
|
||||
window['tt'].shareAppMessage(info);
|
||||
}
|
||||
|
||||
//获取设备分辨率
|
||||
getWindowSize() {
|
||||
return {width:screen.width, height: screen.height};
|
||||
}
|
||||
|
||||
//显示游戏圈
|
||||
show_gameClub(leftRatio, topRatio, widthRatio, heightRatio) {
|
||||
|
||||
}
|
||||
//隐藏游戏圈
|
||||
hide_gameClub() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//检查是否支持base64音频播放
|
||||
checkSupportBase64Audio() {
|
||||
return true;
|
||||
}
|
||||
//播放base64音频
|
||||
private _innerAudioContext: any = null;
|
||||
private _iacIdx = 0 //音频播放索引
|
||||
playBase64Audio(base64, loop) {
|
||||
if (!this.checkSupportBase64Audio()) {
|
||||
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['tt'].getFileSystemManager();
|
||||
//1.删除上一个音频
|
||||
const lastPath = window['tt'].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['tt'].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['tt'].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);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
|
||||
/**
|
||||
* 公共配置文件
|
||||
*/
|
||||
|
||||
export const G_GlobalNode: string = '__GLobal_Node';
|
||||
|
||||
export namespace CommonConfig {
|
||||
//本地保存
|
||||
export enum StorageConfigUtil {
|
||||
BaseData = 'li_' + 1000, // 登录相关
|
||||
Channel = 2000, //渠道相关
|
||||
}
|
||||
export enum StorageConfig {
|
||||
SETTING_SHAKEON = StorageConfigUtil.BaseData + 1,
|
||||
SETTING_MUSIC = StorageConfigUtil.BaseData + 2,
|
||||
SETTING_SOUND = StorageConfigUtil.BaseData + 3,
|
||||
GAME_CITY = StorageConfigUtil.BaseData + 4, //所在省
|
||||
GAME_RANK_CITY = StorageConfigUtil.BaseData + 5, //省排行数据 AI
|
||||
GAME_RANK_USER = StorageConfigUtil.BaseData + 6, //玩家排行数据 AI
|
||||
GAME_RANK_CDTIME = StorageConfigUtil.BaseData + 7, //上次排行数据刷新时间戳 AI
|
||||
GAME_SCORE = StorageConfigUtil.BaseData + 8, //玩家积分
|
||||
GAME_SKIN_ID = StorageConfigUtil.BaseData + 9, //当前选择的皮肤id
|
||||
GAME_PASSLV = StorageConfigUtil.BaseData + 10, //已完成关卡
|
||||
DAILYCHALLENGE_PASSLV = StorageConfigUtil.BaseData + 11, //已完成每日挑战关卡
|
||||
TOOL_KAIKONG = StorageConfigUtil.BaseData + 12, //开孔工具使用过
|
||||
TOOL_RENYIZHI = StorageConfigUtil.BaseData + 13, //任意指工具使用过
|
||||
TOOL_RENYIGUAN = StorageConfigUtil.BaseData + 14, //任意罐工具使用过
|
||||
DD_REGISTTIME = StorageConfigUtil.BaseData + 15, //注册时间字符串
|
||||
DD_LEVELOPER = StorageConfigUtil.BaseData + 16, //进入关卡且首次进度>0时(或第一次操作)
|
||||
GUIDE_MAIN = StorageConfigUtil.BaseData + 17, //主界面引导是否完成
|
||||
GUIDE_TALK = StorageConfigUtil.BaseData + 18, //聊天界面引导是否完成
|
||||
|
||||
DOUYIN_SIDEBAR = StorageConfigUtil.Channel + 1, //抖音渠道侧边栏奖励是否领取
|
||||
}
|
||||
|
||||
|
||||
//UI层级
|
||||
export enum UILayerGroup {
|
||||
Layer_ground = 0,
|
||||
Layer_ui1 = 1,
|
||||
Layer_ui2 = 2,
|
||||
Layer_dialog = 3,
|
||||
Layer_tips = 4,
|
||||
Layer_top = 5,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**关卡配置信息 */
|
||||
export interface I_LevelConfig {
|
||||
/**是关卡场景图资源的名称,注意关卡选择界面选中关卡后展示的场景图资源也是这个 */
|
||||
bgImage: string;
|
||||
/**后续进入关卡后,关卡中需要播放的音乐资源名称 */
|
||||
bgm: string;
|
||||
/**在关卡中,聊天历史信息展示里,角色使用的头像,圆形 80*80 */
|
||||
characterAvatar: string;
|
||||
/**关卡中,提示信息界面里需要展示的角色性格文本 */
|
||||
characterDisposition: string;
|
||||
/**角色聊天切换的表情立绘,这个暂时先不处理,后面我们需要和你沟通下,资源改成英文名看你怎么匹配(Ai 返回的判断还是中文的) */
|
||||
characterEmojiSet: string;
|
||||
/**关卡中,提示信息界面,喜好话题部分需要展示的文本信息 */
|
||||
characterFavoriteTopic: string;
|
||||
/**角色默认立绘资源名称 */
|
||||
characterFullLengthPortrait: string;
|
||||
/**关卡提示信息界面里使用的角色半身胸像 */
|
||||
characterHalfLengthPortrait: string;
|
||||
/**关卡提示信息界面里,厌恶话题的展示文本信息 */
|
||||
characterHateTopic: string;
|
||||
/**角色名称,注意在关卡选择界面还有关卡中的聊天窗,关卡提示信息界面这几个地方都涉及展示 */
|
||||
characterName: string;
|
||||
/**角色职业设定信息,关卡提示信息界面里的职业部分展示 */
|
||||
characterRole: string;
|
||||
/**关卡选择界面里展示的关卡介绍文本信息 */
|
||||
description: string;
|
||||
/**关卡中对话得到高分后,额外向玩家展示的鼓励信息 */
|
||||
encourageMessage: string;
|
||||
/**结算图片 关卡 0 星,挑战失败的情况下在结算界面展示的 CG 资源名称 */
|
||||
failureCG: string;
|
||||
/**结算图片 关卡 1 星,挑战成功的情况下在结算界面展示的 CG 资源名称 */
|
||||
oneStarCG: string;
|
||||
/**结算图片 关卡 2 星,挑战成功的情况下在结算界面展示的 CG 资源名称 */
|
||||
twoStarCG: string;
|
||||
/**结算图片 关卡 3 星,那么需要展示的 CG 资源对应的名称 */
|
||||
threeStarCG: string;
|
||||
/**关卡中,对话得分特别低的情况下,额外给出的向玩家展示的鼓励信息 */
|
||||
hateMessage: string;
|
||||
/**关卡选择界面,菱形的头像资源名称 */
|
||||
icon: string;
|
||||
/**唯一的关卡 id 信息 */
|
||||
id: string;
|
||||
/**关卡是否已解锁,注意锁定状态仍然能够选择关卡,关卡选择界面中的背景和立绘需要切换做展示,但是玩家不能开启游戏哈 */
|
||||
is_unlock: boolean;
|
||||
/**npc名称 */
|
||||
name: string;
|
||||
/**关卡展示顺序 */
|
||||
no: number;
|
||||
/**关卡解锁需要通关的前置关卡 id 信息,对应id字段 */
|
||||
preLevelId: string;
|
||||
/**进入关卡后,角色发出给到玩家的开场白信息(历史聊天记录页面中也需要显示,一定是角色发出的第一句话) */
|
||||
prologueMessage: string;
|
||||
/**玩家在关卡中,点击随机填充按钮,需要随机选取一句,在输入框中填入,注意填入后不发送,玩家可修改,最终发送的信息还是以玩家点击发送按钮时,填入的信息为主 */
|
||||
randomInputPool: string[];
|
||||
/**关卡进行中的record_id,有值时要先获取一下之前的存档 */
|
||||
record_id: string;
|
||||
/**关卡历史最高分 */
|
||||
score: number;
|
||||
/**关卡历史最高星级 */
|
||||
star: number;
|
||||
/**关卡中,关卡提示信息界面里底部展示的提示信息文本,目前测试数据和关卡介绍信息一致,但后续会区分开来 */
|
||||
tips: string;
|
||||
/**Npc结算对话 3星时 */
|
||||
threeStarSummary: string;
|
||||
/**Npc结算对话 2星时 */
|
||||
twoStarSummary: string;
|
||||
/**Npc结算对话 1星时 */
|
||||
oneStarSummary: string;
|
||||
/**Npc结算对话 0星时 */
|
||||
failureSummary: string;
|
||||
/**Npc表情立绘 害羞 */
|
||||
characterShyPortrait: string;
|
||||
/**Npc表情立绘 厌恶 */
|
||||
characterHatePortrait: string;
|
||||
/**Npc表情立绘 开心 */
|
||||
characterHappyPortrait: string;
|
||||
/**关卡解锁类型 -1=未解锁 0=自动解锁 1=游戏通关解锁 2=手动解锁 */
|
||||
unlock_type: number;
|
||||
}
|
||||
|
||||
|
||||
/**关卡对话数据 */
|
||||
export interface I_LevelStepData {
|
||||
/**当前聊天次数 */
|
||||
current_cnt: number;
|
||||
/**结束评分 */
|
||||
end_star: number;
|
||||
/**关卡id */
|
||||
id: string;
|
||||
/**最大聊天次数 */
|
||||
max_cnt: number;
|
||||
/**当前状态 0:成功 1:进行中 2:失败 3:剩余聊天次数不足 */
|
||||
status: number;
|
||||
/**可用总聊天次数 */
|
||||
total_cnt: number;
|
||||
/**心动次数 */
|
||||
heartbeat_cnt: number;
|
||||
/**剩余可看广告次数 */
|
||||
ad_num: number;
|
||||
/**剩余可分享次数 */
|
||||
share_num: number;
|
||||
/**剩余可撤回次数 */
|
||||
can_use_cancel_cnt: number;
|
||||
/**剩余可暴击次数 */
|
||||
can_use_strength_cnt: number;
|
||||
/**暴击是否生效 */
|
||||
is_strength_take_effect: boolean;
|
||||
}
|
||||
|
||||
|
||||
/**npc长连接中的回复 */
|
||||
export interface I_NpcTalkBack {
|
||||
/**ai表情 */
|
||||
aiEmoji:string;
|
||||
/**ai回复 */
|
||||
aiResponse:string;
|
||||
/**ai评分 */
|
||||
aiScore:number;
|
||||
/**ai基础评分 */
|
||||
aiBaseScore:number;
|
||||
/**ai额外加分 */
|
||||
aiAdditionalScore:number;
|
||||
/**是否完成 */
|
||||
isFinished:boolean;
|
||||
/**聊天次数 */
|
||||
sourceCnt:number;
|
||||
/**玩家发的文本 */
|
||||
userInput: string;
|
||||
/**评价 -1=未生成 0=心动 1=普通 2=厌恶 */
|
||||
judgement: number;
|
||||
}
|
||||
|
||||
|
||||
/**对话历史记录数据 */
|
||||
export interface I_TalkRecordInfo {
|
||||
/**对话内容 */
|
||||
talk: string;
|
||||
/**是否是玩家自己 */
|
||||
isMe: boolean;
|
||||
/**评分 小于0时不显示 */
|
||||
score: number;
|
||||
/**基础分 */
|
||||
scoreBase: number;
|
||||
/**额外加分 */
|
||||
scoreAdditional: number;
|
||||
}
|
||||
|
||||
|
||||
/**玩家信息数据 */
|
||||
export interface I_UserInfo {
|
||||
id: number;
|
||||
score: number;
|
||||
status: number;
|
||||
/**头像url */
|
||||
avatar: string;
|
||||
/**昵称 */
|
||||
nickname: string;
|
||||
/**剩余进入关卡次数 */
|
||||
ticket: number;
|
||||
/**剩余可看广告次数 - 进入关卡 */
|
||||
game_ad_num: number;
|
||||
/**剩余可分享次数 - 进入关卡 */
|
||||
game_share_num: number;
|
||||
/**剩余可看广告次数 - 聊天 */
|
||||
level_ad_num: number;
|
||||
/**剩余可分享次数 - 聊天 */
|
||||
level_share_num: number;
|
||||
/**抖音侧边栏奖励是否已领取 0未领取 1已领取 */
|
||||
is_receive: number;
|
||||
/**友盟关卡记录 */
|
||||
levels: any[];
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "ccae1f9f-8dc9-4945-9452-383fc5e5bb3f",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "ccae1f9f-8dc9-4945-9452-383fc5e5bb3f@6c48a",
|
||||
"displayName": "novaxia_default",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "ccae1f9f-8dc9-4945-9452-383fc5e5bb3f",
|
||||
"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": "ccae1f9f-8dc9-4945-9452-383fc5e5bb3f@f9941",
|
||||
"displayName": "novaxia_default",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": -10,
|
||||
"offsetY": -58.5,
|
||||
"trimX": 142,
|
||||
"trimY": 117,
|
||||
"width": 496,
|
||||
"height": 912,
|
||||
"rawWidth": 800,
|
||||
"rawHeight": 1029,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-248,
|
||||
-456,
|
||||
0,
|
||||
248,
|
||||
-456,
|
||||
0,
|
||||
-248,
|
||||
456,
|
||||
0,
|
||||
248,
|
||||
456,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
142,
|
||||
912,
|
||||
638,
|
||||
912,
|
||||
142,
|
||||
0,
|
||||
638,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0.1775,
|
||||
0,
|
||||
0.7975,
|
||||
0,
|
||||
0.1775,
|
||||
0.8862973760932945,
|
||||
0.7975,
|
||||
0.8862973760932945
|
||||
],
|
||||
"minPos": [
|
||||
-248,
|
||||
-456,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
248,
|
||||
456,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "ccae1f9f-8dc9-4945-9452-383fc5e5bb3f@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "ccae1f9f-8dc9-4945-9452-383fc5e5bb3f@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "1fa85c1a-4423-4e00-ad88-f7164f718dff",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "1fa85c1a-4423-4e00-ad88-f7164f718dff@6c48a",
|
||||
"displayName": "coco_avatar",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "1fa85c1a-4423-4e00-ad88-f7164f718dff",
|
||||
"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": "1fa85c1a-4423-4e00-ad88-f7164f718dff@f9941",
|
||||
"displayName": "coco_avatar",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 80,
|
||||
"height": 80,
|
||||
"rawWidth": 80,
|
||||
"rawHeight": 80,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-40,
|
||||
-40,
|
||||
0,
|
||||
40,
|
||||
-40,
|
||||
0,
|
||||
-40,
|
||||
40,
|
||||
0,
|
||||
40,
|
||||
40,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
80,
|
||||
80,
|
||||
80,
|
||||
0,
|
||||
0,
|
||||
80,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-40,
|
||||
-40,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
40,
|
||||
40,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "1fa85c1a-4423-4e00-ad88-f7164f718dff@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "1fa85c1a-4423-4e00-ad88-f7164f718dff@6c48a"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user