init
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "df42502b-40fb-4286-94ae-541aba86198e",
|
||||
"files": [
|
||||
".jpg",
|
||||
".json"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "df42502b-40fb-4286-94ae-541aba86198e@6c48a",
|
||||
"displayName": "zeiterin_3_cg",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "df42502b-40fb-4286-94ae-541aba86198e",
|
||||
"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": "df42502b-40fb-4286-94ae-541aba86198e@f9941",
|
||||
"displayName": "zeiterin_3_cg",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 996,
|
||||
"height": 1280,
|
||||
"rawWidth": 996,
|
||||
"rawHeight": 1280,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-498,
|
||||
-640,
|
||||
0,
|
||||
498,
|
||||
-640,
|
||||
0,
|
||||
-498,
|
||||
640,
|
||||
0,
|
||||
498,
|
||||
640,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
1280,
|
||||
996,
|
||||
1280,
|
||||
0,
|
||||
0,
|
||||
996,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-498,
|
||||
-640,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
498,
|
||||
640,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "df42502b-40fb-4286-94ae-541aba86198e@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": false,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "df42502b-40fb-4286-94ae-541aba86198e@6c48a"
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.0 MiB |
|
After Width: | Height: | Size: 804 KiB |
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "audio-clip",
|
||||
"imported": true,
|
||||
"uuid": "2b5a406e-07ba-4c01-8029-0cc48377db56",
|
||||
"files": [
|
||||
".json",
|
||||
".wav"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"downloadMode": 0
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 433 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 440 KiB |
|
After Width: | Height: | Size: 1.0 MiB |
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "6b96e582-82c7-4b94-9e03-ef804468472c",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "6b96e582-82c7-4b94-9e03-ef804468472c@6c48a",
|
||||
"displayName": "youmiaoxiang_stage_icon",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "6b96e582-82c7-4b94-9e03-ef804468472c",
|
||||
"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": "6b96e582-82c7-4b94-9e03-ef804468472c@f9941",
|
||||
"displayName": "youmiaoxiang_stage_icon",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 138,
|
||||
"height": 138,
|
||||
"rawWidth": 138,
|
||||
"rawHeight": 138,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-69,
|
||||
-69,
|
||||
0,
|
||||
69,
|
||||
-69,
|
||||
0,
|
||||
-69,
|
||||
69,
|
||||
0,
|
||||
69,
|
||||
69,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
0,
|
||||
138,
|
||||
138,
|
||||
138,
|
||||
0,
|
||||
0,
|
||||
138,
|
||||
0
|
||||
],
|
||||
"nuv": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"minPos": [
|
||||
-69,
|
||||
-69,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
69,
|
||||
69,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "6b96e582-82c7-4b94-9e03-ef804468472c@6c48a",
|
||||
"atlasUuid": ""
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "6b96e582-82c7-4b94-9e03-ef804468472c@6c48a"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
import { _decorator, Color, isValid, Label, Node, RichText, Size, Sprite, UITransform, Vec3, view } from "cc";
|
||||
import li_EventManager from "./li_EventManager";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass
|
||||
export default class Utils {
|
||||
//log日志
|
||||
public static Log(msg: string | any, ...subst: any[]) {
|
||||
let IsLocalCSChanel = true
|
||||
if (IsLocalCSChanel) {
|
||||
console.log(msg, subst)
|
||||
}
|
||||
}
|
||||
//警告日志
|
||||
public static Warning(msg: string | any, ...subst: any[]) {
|
||||
let IsLocalCSChanel = true
|
||||
if (IsLocalCSChanel) {
|
||||
console.warn(msg, subst)
|
||||
}
|
||||
}
|
||||
//错误日志
|
||||
public static Error(msg: string | any, ...subst: any[]) {
|
||||
let IsLocalCSChanel = true
|
||||
if (IsLocalCSChanel) {
|
||||
console.error(msg, subst)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//解析节点
|
||||
public static parseNode = function (node: Node, oriObj?: any) {
|
||||
if (!node || !node.children) return;
|
||||
oriObj = oriObj || node;
|
||||
let chs = node.children;
|
||||
for (let i = 0; i < chs.length; i++) {
|
||||
let ch = chs[i];
|
||||
let chName = ch.name;
|
||||
if (chName && chName.length > 0) {
|
||||
try {
|
||||
oriObj[chName] = ch;
|
||||
} catch (error) {
|
||||
//hg_utils.hgLog("chName err:", chName);
|
||||
}
|
||||
}
|
||||
Utils.parseNode(ch, oriObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//更换父节点,保留原有的坐标和旋转
|
||||
public static changeNodeParent(node:Node, parentNode:Node) {
|
||||
let world_Q = node.getWorldRotation()
|
||||
let world_pos = node.getWorldPosition()//原来的世界坐标
|
||||
node.setParent(parentNode)
|
||||
node.setRotation(world_Q);
|
||||
node.setWorldPosition(world_pos)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 封装setString方法
|
||||
*/
|
||||
static setString(node: Node, str: string | number) {
|
||||
if (!isValid(node)) return;
|
||||
let lb:any = node.getComponent(Label);
|
||||
if (!lb) return;
|
||||
if(str == null) {str = ""}
|
||||
str += ""
|
||||
lb.string = str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加富文本
|
||||
* @param node
|
||||
* @param str
|
||||
* @param outLine
|
||||
* @param width
|
||||
* @returns
|
||||
*/
|
||||
static addRichText(node: Node, str: string, outLine: string | null = null, width: number | null = 2,max: number = 0) {
|
||||
if (!node) return;
|
||||
let comp = node.getComponent(RichText);
|
||||
if (!comp) return;
|
||||
str = Utils.replaceAll(str, "</>", "</color>");
|
||||
str = str.replace(/\<\/font\>/g, '</color>');
|
||||
str = Utils.replaceAll(str, "'>", ">");
|
||||
str = Utils.replaceAll(str, "<font", "<");
|
||||
str = Utils.replaceAll(str, "color='", "color=");
|
||||
str = Utils.replaceAll(str, "<br>", "\n");
|
||||
if (outLine) {
|
||||
str = `<outline color=${outLine} width=${width}>${str}</outline>`;
|
||||
}
|
||||
comp.string = str;
|
||||
// let csize:UITransform = comp.node.getComponent(UITransform)!
|
||||
// comp.maxWidth = Math.min(csize.width,max) ;
|
||||
}
|
||||
static replaceAll(str: string, ch1: string, ch2: string) {
|
||||
while (str.indexOf(ch1) >= 0) {
|
||||
str = str.replace(ch1, ch2);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**截取字符串,超过长度的用...代替
|
||||
* @param str 要处理的字符串
|
||||
* @param labelLimit 字符串长度限制
|
||||
* @param repStr 超过长度后代替的字符串
|
||||
*/
|
||||
static clampAiAnswer(ansStr: string, labelLimit:number, repStr:string = "...") {
|
||||
// let labelLimit = 20 //字符串长度限制
|
||||
let tempStr: string = "";
|
||||
let tempLen: number = 0;
|
||||
for (let i = 0; i < ansStr.length; i++) {
|
||||
tempLen += ansStr.charCodeAt(i) > 255 ? 2 : 1;
|
||||
if (tempLen > labelLimit) {
|
||||
return tempStr + repStr;
|
||||
}
|
||||
tempStr += ansStr.charAt(i);
|
||||
}
|
||||
return ansStr;
|
||||
}
|
||||
|
||||
|
||||
/**设置节点置灰 */
|
||||
static setNodeGray(node: Node, isGray: boolean, extra: any={}) {
|
||||
if (!isValid(node)) return;
|
||||
//图片
|
||||
let sp:Sprite = node.getComponent(Sprite);
|
||||
if (sp) {
|
||||
sp.grayscale = isGray;
|
||||
}
|
||||
//文字
|
||||
let lb:Label = node.getComponent(Label);
|
||||
if (lb) {
|
||||
if (isGray) {
|
||||
lb.color = extra.labClrGray ? extra.labClrGray : Color.GRAY;
|
||||
} else {
|
||||
lb.color = extra.labClrWhite ? extra.labClrWhite : Color.WHITE;
|
||||
}
|
||||
}
|
||||
//对子节点执行同样操作
|
||||
let children = node.children;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
Utils.setNodeGray(children[i], isGray, extra);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**适配背景图
|
||||
* @method node 背景图节点
|
||||
* @param mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
*/
|
||||
public static adjustBgPixelRatio(node:Node, mod:number = 1) {
|
||||
let windowSize = view.getVisibleSize();
|
||||
let bgTf = node.getComponent(UITransform)
|
||||
if (bgTf) {
|
||||
if (mod == 1 && bgTf.height < windowSize.height) {
|
||||
let scale = windowSize.height / bgTf.height
|
||||
bgTf.height = bgTf.height * scale
|
||||
bgTf.width = bgTf.width * scale
|
||||
} else if (mod == 2 && bgTf.width < windowSize.width) {
|
||||
let scale = windowSize.width / bgTf.width
|
||||
bgTf.height = bgTf.height * scale
|
||||
bgTf.width = bgTf.width * scale
|
||||
}
|
||||
}
|
||||
}
|
||||
/**适配背景图 按比例缩放 屏幕比设计分辨率小时缩小,反之则不缩放
|
||||
* @param node 背景图节点
|
||||
* @param mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
*/
|
||||
public static adjustBgScaleRatio(node:Node, mod:number = 1) {
|
||||
let windowSize = view.getVisibleSize();
|
||||
let designSize = view.getDesignResolutionSize();
|
||||
if (mod == 1 && windowSize.height < designSize.height) {
|
||||
let scale = windowSize.height / designSize.height
|
||||
node.scale = new Vec3(scale, scale, 1)
|
||||
} else if (mod == 2 && windowSize.width < designSize.width) {
|
||||
let scale = windowSize.width / designSize.width
|
||||
node.scale = new Vec3(scale, scale, 1)
|
||||
}
|
||||
}
|
||||
/**获取屏幕分辨率和设计分辨率的比例
|
||||
* @method mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
*/
|
||||
public static getScaleRatio(mod:number = 1) {
|
||||
let windowSize = view.getVisibleSize();
|
||||
let designSize = view.getDesignResolutionSize();
|
||||
// console.log("游戏分辨率:", windowSize, designSize);
|
||||
if (mod == 1) {
|
||||
return windowSize.height / designSize.height
|
||||
} else {
|
||||
return windowSize.width / designSize.width
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @method 浅复制一个对象
|
||||
* @param source 需要浅复制的对象
|
||||
* 合并对象,如果excludes中没有指明需要排除的字段,target也含有相同的字段,则会被object同名字段值覆盖掉
|
||||
* @param object
|
||||
* @param excludes 需要排除的字段
|
||||
*/
|
||||
static applyIf(object: any, target: any = {}, excludes: Array<string> = []): Object {
|
||||
if (!target) target = {};
|
||||
for (let key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
if (excludes.indexOf(key) < 0) {
|
||||
target[key] = object[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
/**
|
||||
* @method 浅复制一个对象
|
||||
* @param source 需要浅复制的对象
|
||||
* @return 返回一个新的对象
|
||||
* @log 1. vincent,2018-12-18, func、date、reg 和 err 类型不能正常拷贝
|
||||
*/
|
||||
static easyCopy(source: Object): Object {
|
||||
const newObject = [];
|
||||
return Utils.applyIf(source);
|
||||
}
|
||||
/**复制一个数据表 */
|
||||
static clone(data:any) {
|
||||
return Utils.easyCopy(data);
|
||||
}
|
||||
|
||||
|
||||
/**发送内部事件 */
|
||||
public static sendInnerMsg(innerId: number, param?: any) {
|
||||
li_EventManager.I.onInnerEL(innerId, param);
|
||||
}
|
||||
/**注册内部事件 */
|
||||
public static addInnerEL(innerId: number, i_target, i_callback: Function,) {
|
||||
li_EventManager.I.addInnerEL(innerId, i_callback, i_target);
|
||||
}
|
||||
/**移除内部事件 */
|
||||
public static removeInnerEL(innerId: number, i_target, i_callback: Function) {
|
||||
li_EventManager.I.removeInnerEL(innerId, i_callback, i_target)
|
||||
}
|
||||
|
||||
|
||||
//获取随机数
|
||||
public static getRandomInt(i_start:number, i_end:number) : number {
|
||||
i_start = Math.ceil(i_start);
|
||||
i_end = Math.floor(i_end);
|
||||
return Math.floor(Math.random() * (i_end - i_start + 1)) + i_start;
|
||||
}
|
||||
//数字转字符串,指定位数,位数不足前面补0
|
||||
public static PrefixInt(num, length) {
|
||||
return (Array(length).join('0') + num).slice(-length);
|
||||
}
|
||||
//数字保留几位小数
|
||||
public static DecimalPlaces(num:number, weishu:number) {
|
||||
return num.toFixed(weishu);
|
||||
}
|
||||
|
||||
|
||||
/**获取屏幕分辨率 */
|
||||
public static GetWinSize():Size {
|
||||
return view.getVisibleSize()
|
||||
}
|
||||
|
||||
|
||||
/**获取当前日期,格式YYYY-MM-DD */
|
||||
public static GetNowFormatDay(nowDate: Date | null = null, char: string = "-") {
|
||||
if (nowDate == null) {
|
||||
nowDate = new Date();
|
||||
}
|
||||
let day = nowDate.getDate();
|
||||
let month = nowDate.getMonth() + 1;//注意月份需要+1
|
||||
let year = nowDate.getFullYear();
|
||||
//补全0,并拼接
|
||||
return year + char + Utils.completeDate(month) + char + Utils.completeDate(day);
|
||||
}
|
||||
//补全0
|
||||
private static completeDate(value: number) {
|
||||
return value < 10 ? "0" + value : value;
|
||||
}
|
||||
|
||||
|
||||
//打印消耗时间===================================================================================================
|
||||
private static _eplTime = 0;
|
||||
/**记录当前时间 */
|
||||
public static ProfilerTimeRecord() {
|
||||
Utils._eplTime = new Date().getTime();
|
||||
}
|
||||
/**打印消耗时间 */
|
||||
public static ProfilerTimePrint(key:string = "") {
|
||||
let time = new Date().getTime();
|
||||
let timecha = time - Utils._eplTime;
|
||||
console.log(`${key}消耗时间:${timecha}毫秒`);
|
||||
Utils._eplTime = time;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,530 @@
|
||||
import { _decorator, instantiate, isValid, Label, Node, Prefab, Sprite } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import AudioManager from '../../Main/Manager/AudioManager';
|
||||
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 GameRootUI from '../../Main/Common/GameRootUI';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import ScrollViewList from '../../Main/Common/ScrollViewList';
|
||||
import GameManager, { E_TalkStage, E_TalkStatusType } from '../../Main/Manager/GameManager';
|
||||
import { I_LevelConfig } from '../../Main/Config/CommonConfig';
|
||||
import SubManager from '../SubManager';
|
||||
import { ByteDanceSDK } from '../../Main/Channel/bdSDK';
|
||||
import GlobalValue from '../../Main/Common/GlobalValue';
|
||||
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
|
||||
import { E_AD_TARGET } from './TalkAdDialog';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//主界面
|
||||
@ccclass('Start_UI')
|
||||
export class Start_UI extends li_BaseView {
|
||||
@property(ScrollViewList)
|
||||
private Level_List: ScrollViewList = null
|
||||
@property(Prefab)
|
||||
private Level_Item: Prefab = null
|
||||
private itemClone: any = null
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private levelData: I_LevelConfig[] = []; //关卡数据
|
||||
private curLevelIdx: number = 0; //当前关卡Idx
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
this.itemClone = instantiate(this.Level_Item)
|
||||
this.Level_List.setTemplateItem(this.itemClone)
|
||||
Utils.setString(this._nodeTab.labNpcName, "")
|
||||
Utils.setString(this._nodeTab.labNpcTalk, "")
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
Utils.addInnerEL(InnerMsgCode.UI_Talk_Back, this, this.resiveTalkBack)
|
||||
Utils.addInnerEL(InnerMsgCode.UI_BD_Sidebar, this, this.resiveBDSidebar)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnStart, this.onStartClick, this, 10002);
|
||||
GButton.BandClick(this._nodeTab.btnAddTZCount, this.onAddTZClick, this);
|
||||
GButton.BandClick(this._nodeTab.tzCountNode, this.onAddTZClick, this);
|
||||
GButton.BandClick(this._nodeTab.btnSetting, this.onSettingClick, this);
|
||||
GButton.BandClick(this._nodeTab.btnBDSidebar, this.onBDSidebarClick, this);
|
||||
GButton.BandClick(this._nodeTab.btnGM, this.onGMClick, this);
|
||||
|
||||
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("视频广告回调", tag)
|
||||
if (tag == 1) {
|
||||
// 加次数
|
||||
HttpUnit.ins.setUserAd({type:1}, (data) => {
|
||||
SubManager.ShowPrompt("观看视频成功,获得相亲次数")
|
||||
this.refreshXiangqinTicket()
|
||||
})
|
||||
}
|
||||
})
|
||||
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("分享回调", tag)
|
||||
if (tag == 1) {
|
||||
// 加次数
|
||||
HttpUnit.ins.setUserShare({type:1}, (data) => {
|
||||
SubManager.ShowPrompt("分享成功,获得相亲次数")
|
||||
this.refreshXiangqinTicket()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
AudioManager.I.PlayMusic(1, true) //背景乐
|
||||
GameRootUI.InitDisableOperUI(false)
|
||||
GameRootUI.InitCrossUI(false)
|
||||
this.setUIVisible(true)
|
||||
|
||||
//设置按钮
|
||||
if (GlobalValue.GMSwtitch) {
|
||||
this._nodeTab.btnSetting.active = true
|
||||
this._nodeTab.btnGM.active = true
|
||||
} else {
|
||||
this._nodeTab.btnSetting.active = false
|
||||
this._nodeTab.btnGM.active = false
|
||||
}
|
||||
|
||||
//抖音侧边栏
|
||||
this._nodeTab.btnBDSidebar.active = false
|
||||
if (SDKManager.isByteDance()) {
|
||||
this.refreshBdSidebarUI()
|
||||
ByteDanceSDK.CheckSidebarState((state) =>{
|
||||
if (state == true) {
|
||||
this.refreshBdSidebarUI()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//判断玩家权限是否已获取
|
||||
if (!HttpUnit.IsLogin()) {
|
||||
HttpUnit.ins.login((loginData) => {
|
||||
console.log("主界面: 获取授权并登录成功!")
|
||||
this.userInited()
|
||||
})
|
||||
} else {
|
||||
this.userInited()
|
||||
}
|
||||
|
||||
//判断是否需要显示引导
|
||||
this.resetGuide()
|
||||
this.checkGuide()
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//GM界面关闭消息
|
||||
resiveGMClose(data) {
|
||||
Utils.Log("收到GM界面关闭消息")
|
||||
}
|
||||
|
||||
//退出聊天消息
|
||||
resiveTalkBack(data) {
|
||||
Utils.Log("收到退出聊天消息")
|
||||
this.setUIVisible(true)
|
||||
this.refreshLevelList()
|
||||
HttpUnit.ins.getUserData((userData) => {
|
||||
this.refreshXiangqinTicket()
|
||||
})
|
||||
}
|
||||
|
||||
//抖音侧边栏消息
|
||||
resiveBDSidebar(data) {
|
||||
this.refreshBdSidebarUI()
|
||||
}
|
||||
|
||||
|
||||
//增加相亲次数
|
||||
private doAddXiangqinCnt(add:number = 1) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//显示主界面UI
|
||||
setUIVisible(vis: boolean) {
|
||||
this._nodeTab.UIRoot.active = vis
|
||||
}
|
||||
|
||||
//刷新抖音侧边栏按钮显示状态
|
||||
refreshBdSidebarUI() {
|
||||
if (!SDKManager.isByteDance()) {
|
||||
//不是抖音平台,不显示
|
||||
this._nodeTab.btnBDSidebar.active = false
|
||||
return
|
||||
}
|
||||
|
||||
let stage = ByteDanceSDK.SidebarState
|
||||
if (stage == 1) {
|
||||
//前往
|
||||
this._nodeTab.btnBDSidebar.active = true
|
||||
Utils.setString(this._nodeTab.labBDSidebar, "前往抖音侧边栏")
|
||||
} else if (stage == 2) {
|
||||
//领奖
|
||||
this._nodeTab.btnBDSidebar.active = true
|
||||
Utils.setString(this._nodeTab.labBDSidebar, "领取抖音侧边栏")
|
||||
} else {
|
||||
//版本不支持
|
||||
this._nodeTab.btnBDSidebar.active = false
|
||||
}
|
||||
}
|
||||
|
||||
//刷新玩家信息完毕
|
||||
userInited() {
|
||||
this.refreshSdkUI()
|
||||
this.refreshLevelList()
|
||||
this.refreshXiangqinTicket()
|
||||
}
|
||||
|
||||
//刷新剩余相亲次数
|
||||
private refreshXiangqinTicket() {
|
||||
let xqnum = HttpUnit.GetXiangqinTickets()
|
||||
// let xqmax = HttpUnit.GetXiangqinMaxTickets()
|
||||
Utils.setString(this._nodeTab.labTZCount, xqnum + "")
|
||||
Utils.setString(this._nodeTab.labBtnTZCount, "" + xqnum)
|
||||
}
|
||||
|
||||
//刷新关卡列表
|
||||
private refreshLevelList() {
|
||||
HttpUnit.ins.getLevelList((levelList) => {
|
||||
if (levelList) {
|
||||
GameManager.SetLevelCfg(levelList)
|
||||
this.levelData = levelList
|
||||
this.levelData.unshift({} as any) //在最前面插入一个占位数据,用于数组排版显示
|
||||
this.Level_List.numItems = this.levelData.length
|
||||
if (this.curLevelIdx < 1) {
|
||||
this.curLevelIdx = 1
|
||||
for (let i = 1; i < this.levelData.length; i++) {
|
||||
if (this.levelData[i].is_unlock == true) {
|
||||
if (this.curLevelIdx < i) {
|
||||
this.curLevelIdx = i
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (this.curLevelIdx > 2) {
|
||||
this.Level_List.scrollTo(this.curLevelIdx-2)
|
||||
}
|
||||
}
|
||||
this.changeLevel(this.curLevelIdx, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//刷新SDK相关的UI
|
||||
refreshSdkUI() {
|
||||
console.log("主界面:刷新SDK相关的UI...")
|
||||
SDKManager.getUserInfo((data) => {
|
||||
//头像
|
||||
let spt = this._nodeTab.headIcon.getComponent(Sprite)
|
||||
ResManager.I.changeRemoteSpriteFrame(spt, data.avatarUrl)
|
||||
//名字
|
||||
let nickName = this._nodeTab.nickName.getComponent(Label)
|
||||
nickName.string = data.nickName
|
||||
console.log("主界面 设置头像和名字:", data.avatarUrl, data.nickName)
|
||||
})
|
||||
//刷新id
|
||||
let id = HttpUnit.GetID()
|
||||
Utils.setString(this._nodeTab.userId, `ID:${id}`)
|
||||
}
|
||||
|
||||
|
||||
//关卡列表渲染
|
||||
onRenderItemList(node: any, idx: number) {
|
||||
if(!isValid(node)) {return}
|
||||
if (!node.inited) {
|
||||
node.inited = true;
|
||||
Utils.parseNode(node);
|
||||
}
|
||||
|
||||
GButton.RemoveClick(node)
|
||||
|
||||
//第一个是占位用的
|
||||
if (idx == 0) {
|
||||
node.l_rotateN.active = false
|
||||
node.zhanweiNode.active = true
|
||||
return
|
||||
}
|
||||
|
||||
node.l_rotateN.active = true
|
||||
node.zhanweiNode.active = false
|
||||
let data = this.levelData[idx]
|
||||
//头像
|
||||
let headPath = `headLevel/${data.icon}`
|
||||
ResManager.I.changeBundleSpriteFrame(node.head1.getComponent(Sprite), headPath, "Raw")
|
||||
//解锁状态
|
||||
node.lockNode.active = data.is_unlock ? false : true
|
||||
node.unlockNode.active = data.is_unlock ? true : false
|
||||
if (data.is_unlock) {
|
||||
//分数
|
||||
Utils.setString(node.labScore, data.score)
|
||||
//星级
|
||||
if (data.star == 3) {
|
||||
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_11", "Zhujiemian")
|
||||
} else if (data.star == 2) {
|
||||
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_10", "Zhujiemian")
|
||||
} else if (data.star == 1) {
|
||||
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_9", "Zhujiemian")
|
||||
} else {
|
||||
ResManager.I.changeBundleSpriteFrame(node.l_xingji.getComponent(Sprite), "zjm_8", "Zhujiemian")
|
||||
}
|
||||
//满星效果
|
||||
node.l_manxing.active = data.star == 3 ? true : false
|
||||
if (data.star == 3) {
|
||||
ResManager.I.changeBundleSpriteFrame(node.l_bg.getComponent(Sprite), "zjm_6", "Zhujiemian")
|
||||
} else {
|
||||
ResManager.I.changeBundleSpriteFrame(node.l_bg.getComponent(Sprite), "zjm_5", "Zhujiemian")
|
||||
}
|
||||
}
|
||||
GButton.BandClick(node, ()=>{
|
||||
this.changeLevel(idx)
|
||||
}, this)
|
||||
}
|
||||
|
||||
|
||||
//切换关卡
|
||||
changeLevel(idx:number, force:boolean = false) {
|
||||
if (this.curLevelIdx == idx && !force) {
|
||||
return
|
||||
}
|
||||
this.curLevelIdx = idx
|
||||
let data = this.levelData[idx]
|
||||
//名字
|
||||
Utils.setString(this._nodeTab.labNpcName, data.characterName)
|
||||
//介绍
|
||||
Utils.setString(this._nodeTab.labNpcTalk, data.description)
|
||||
|
||||
let bgPath = `bg/${data.bgImage}`
|
||||
let rolePath = `role/${data.characterFullLengthPortrait}`
|
||||
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {bgPath:bgPath, rolePath:rolePath})
|
||||
}
|
||||
|
||||
|
||||
//region 开始游戏
|
||||
onStartClick() {
|
||||
Utils.Log("点击开始游戏");
|
||||
|
||||
this.finishGuide()
|
||||
|
||||
if (this.curLevelIdx == 0) {
|
||||
console.error("当前关卡为0,此关卡是占位用的")
|
||||
return
|
||||
}
|
||||
let data = this.levelData[this.curLevelIdx]
|
||||
//未解锁
|
||||
if (data.is_unlock != true) {
|
||||
SubManager.ShowPrompt("关卡未解锁")
|
||||
return
|
||||
}
|
||||
|
||||
if (HttpUnit.GetXiangqinTickets() <= 0) {
|
||||
SubManager.ShowPrompt("今日相亲次数已用完");
|
||||
return;
|
||||
}
|
||||
|
||||
let level_id = data.id
|
||||
GameManager.EndGame()
|
||||
//检测存档
|
||||
if (GlobalValue.LvHuancun && data.record_id && data.record_id != "") {
|
||||
HttpUnit.ins.getTalkStage({record_id: data.record_id}, (_data) => {
|
||||
if (_data) {
|
||||
if (_data.level.status == E_TalkStatusType.talking) {
|
||||
this._continueLevel(level_id, _data)
|
||||
} else {
|
||||
this._startNewLevel(level_id)
|
||||
}
|
||||
} else {
|
||||
this._startNewLevel(level_id)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this._startNewLevel(level_id)
|
||||
}
|
||||
|
||||
|
||||
// let dongId = GameManager.CurLevelId //当前进行中的关卡
|
||||
// //有在进行的关卡
|
||||
// if (dongId != "") {
|
||||
// //功能没开放
|
||||
// if (!GlobalValue.LvHuancun) {
|
||||
// GameManager.EndGame()
|
||||
// this._startNewLevel(level_id)
|
||||
// //进入的还是上次没结束的关卡,则继续当前关卡
|
||||
// }else if (level_id == dongId) {
|
||||
// this.setUIVisible(false)
|
||||
// ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
|
||||
// //进入的是其他关卡,则提示是否要放弃当前关卡
|
||||
// } else {
|
||||
// SubManager.ShowConfirm({
|
||||
// content: "有进行中的关卡,是否中断当前关卡,开始新的关卡?",
|
||||
// yesCallback: () => {
|
||||
// GameManager.EndGame()
|
||||
// this._startNewLevel(level_id)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// //没有在进行的关卡,则直接进入
|
||||
// } else {
|
||||
// this._startNewLevel(level_id)
|
||||
// }
|
||||
}
|
||||
//开始新关卡
|
||||
private _startNewLevel(level_id) {
|
||||
GameManager.CurLevelId = level_id
|
||||
HttpUnit.ins.levelStart({level_id:level_id}, (data) => {
|
||||
GameManager.CurLevelData = data.level
|
||||
GameManager.RecordId = data.record_id
|
||||
GameManager.I.connetSorcket(data.record_id) //连接socket
|
||||
this.setUIVisible(false)
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
|
||||
})
|
||||
}
|
||||
//region 继续关卡存档
|
||||
private _continueLevel(level_id, data) {
|
||||
SubManager.ShowConfirm({
|
||||
content: "检测到进行中的记录,是否继续?",
|
||||
strYes: "继续",
|
||||
strNo: "重新开始",
|
||||
yesCallback: () => {
|
||||
//继续对话
|
||||
let lvCfg = this.levelData[this.curLevelIdx]
|
||||
let t_xindong = 0
|
||||
let t_xihuan = 0
|
||||
let t_taoyan = 0
|
||||
|
||||
//聊天记录
|
||||
GameManager.AddTalkRecord({talk:lvCfg.prologueMessage, isMe:false})
|
||||
let msg = data.messages || []
|
||||
for (let i = 0; i < msg.length; i++) {
|
||||
let m = msg[i]
|
||||
GameManager.AddStepScore(m.ai_score) //记录本次分数
|
||||
GameManager.AddTalkRecord({talk:m.user_input, isMe:true})
|
||||
GameManager.AddTalkRecord({talk:m.ai_response, isMe:false})
|
||||
if (m.judgement == 0) {
|
||||
t_xindong++
|
||||
t_xihuan++
|
||||
} else if (m.judgement == 2) {
|
||||
t_taoyan++
|
||||
}
|
||||
}
|
||||
|
||||
GameManager.CurLevelId = level_id
|
||||
GameManager.CurLevelData = data.level
|
||||
GameManager.RecordId = data.record_id
|
||||
GameManager.srouceCnt = data.level.current_cnt
|
||||
GameManager.xindongCishu = t_xindong
|
||||
GameManager.npcFixTalkCountXihuan = t_xihuan
|
||||
GameManager.npcFixTalkCountTaoyan = t_taoyan
|
||||
GameManager.TurnToStage(E_TalkStage.myTalk)
|
||||
GameManager.I.connetSorcket(data.record_id) //连接socket
|
||||
this.setUIVisible(false)
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
|
||||
},
|
||||
noCallback: () => {
|
||||
//重新开始
|
||||
this._startNewLevel(level_id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//增加相亲次数
|
||||
onAddTZClick() {
|
||||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||||
type: E_AD_TARGET.xiangqin, //加相亲次数
|
||||
content: "每天只有 5 次相亲次数,请谨慎使用。分享游戏,观看广告都可以获得 3 次相亲次数奖励,该奖励每日限领一次,每日 5:00 刷新相亲次数以及奖励获取次数。",
|
||||
adCallback: ()=>{
|
||||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||||
},
|
||||
shareCallback: ()=>{
|
||||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//设置
|
||||
onSettingClick() {
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Setting_UI")
|
||||
}
|
||||
|
||||
//gm
|
||||
onGMClick() {
|
||||
ViewManager.I.openBundlesView("UI/GM_UI")
|
||||
}
|
||||
|
||||
//点击抖音侧边栏按钮
|
||||
onBDSidebarClick() {
|
||||
if (!SDKManager.isByteDance()) {
|
||||
//不是抖音平台
|
||||
return
|
||||
}
|
||||
|
||||
ViewManager.I.openBundlesView("UI/StartUI/BDSidebar_UI")
|
||||
}
|
||||
|
||||
|
||||
//region 引导相关
|
||||
private _guideInterval: number = 0.5 //引导间隔
|
||||
//重置引导节点显示
|
||||
private resetGuide() {
|
||||
this._nodeTab.guideStep1.active = false
|
||||
this._nodeTab.guideStep2.active = false
|
||||
this._nodeTab.guideHandNode.active = false
|
||||
this._nodeTab.btnStart.parent = this._nodeTab.startParent1
|
||||
}
|
||||
//检查引导
|
||||
private checkGuide() {
|
||||
if (PlayerDataManager.I.GuideMainFinished) {
|
||||
return
|
||||
}
|
||||
this.doGuideStep1()
|
||||
}
|
||||
//引导步骤1 显示介绍弹窗
|
||||
private doGuideStep1() {
|
||||
GameRootUI.DisableOper(this._guideInterval)
|
||||
this.scheduleOnce(() => {
|
||||
this._nodeTab.guideStep1.active = true
|
||||
GButton.RemoveAndBandClick(this._nodeTab.btnGs1Ok, this.onGuide1OkClick, this);
|
||||
},this._guideInterval)
|
||||
|
||||
}
|
||||
//引导步骤2 显示手
|
||||
private doGuideStep2() {
|
||||
GameRootUI.DisableOper(this._guideInterval)
|
||||
this.scheduleOnce(() => {
|
||||
this._nodeTab.guideStep2.active = true
|
||||
this._nodeTab.guideHandNode.active = true
|
||||
this._nodeTab.btnStart.parent = this._nodeTab.startParent2
|
||||
},this._guideInterval)
|
||||
}
|
||||
//引导完成
|
||||
private finishGuide() {
|
||||
if (PlayerDataManager.I.GuideMainFinished) {
|
||||
return
|
||||
}
|
||||
PlayerDataManager.I.SetGuideMainFinish(true)
|
||||
this.resetGuide()
|
||||
}
|
||||
|
||||
onGuide1OkClick() {
|
||||
this._nodeTab.guideStep1.active = false
|
||||
this.doGuideStep2()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 13 KiB |