代码整理,ai相关配置转luban,聊天气泡缓存
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
import { _decorator, Node } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import { ByteDanceSDK } from '../../Main/Channel/bdSDK';
|
||||
import SubManager from '../SubManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//抖音侧边栏弹窗
|
||||
@ccclass('BDSidebar_UI')
|
||||
export class BDSidebar_UI extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.UI_BD_Sidebar, this, this.resiveBDSidebar)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
GButton.BandClick(this._nodeTab.bgmask, ()=>{
|
||||
this.onClose()
|
||||
}, this, null, null, null, false);
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
this.onClose()
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnGoto, ()=>{
|
||||
this.onGotoClick()
|
||||
}, this);
|
||||
|
||||
this.refreshState()
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//侧边栏状态变化回调
|
||||
resiveBDSidebar(data: any) {
|
||||
let stage = ByteDanceSDK.SidebarState
|
||||
if (stage >= 2) {
|
||||
this.onClose()
|
||||
}
|
||||
}
|
||||
|
||||
//刷新状态
|
||||
refreshState() {
|
||||
// let stage = ByteDanceSDK.SidebarState
|
||||
// if (stage == 2) {
|
||||
// Utils.setString(this._nodeTab.labGoto, "领奖")
|
||||
// } else {
|
||||
// Utils.setString(this._nodeTab.labGoto, "前往侧边栏")
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
//点击前往侧边栏按钮
|
||||
onGotoClick() {
|
||||
// let stage = ByteDanceSDK.SidebarState
|
||||
// if (stage == 2) {
|
||||
// SubManager.ShowPrompt("领取奖励")
|
||||
// } else {
|
||||
// ByteDanceSDK.GotoSidebar(()=>{
|
||||
// this.onClose()
|
||||
// })
|
||||
// }
|
||||
ByteDanceSDK.GotoSidebar(()=>{
|
||||
this.onClose()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "702d779d-476f-4507-ba23-e482bb32f8de",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import { _decorator, Component, Node } from "cc";
|
||||
import Utils from "../../Main/Common/Utils";
|
||||
import { GButton } from "../../Main/Common/GButton";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//紧张操作界面
|
||||
@ccclass('DisableOper_UI')
|
||||
export class DisableOper_UI extends Component {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
protected onLoad(): void {
|
||||
}
|
||||
start() {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
GButton.BandClick(this._nodeTab.BG, this.onBGClick, this);
|
||||
}
|
||||
|
||||
onBGClick() {
|
||||
// Utils.Log("DisableOper ui click")
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"a506c6be-dca1-41f6-8c78-c238a9da1575","files":[],"subMetas":{},"userData":{}}
|
||||
@@ -1,314 +0,0 @@
|
||||
import { _decorator, Node, Sprite, tween, UIOpacity, UITransform, Vec3, view } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameManager, { E_TalkStage } from '../../Main/Manager/GameManager';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import GameRootUI from '../../Main/Common/GameRootUI';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import { I_LevelStepData } from '../../Main/Config/CommonConfig';
|
||||
import AudioManager from '../../Main/Manager/AudioManager';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import SubManager from '../SubManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//结算界面
|
||||
@ccclass('Finish_UI')
|
||||
export class Finish_UI extends li_BaseView {
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data: I_LevelStepData = null;
|
||||
|
||||
private picDefScale:Vec3; //图片默认缩放
|
||||
private isPicFull:boolean = false; //图片是否全屏
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
this.picDefScale = (this._nodeTab.cgPic as Node).scale.clone();
|
||||
|
||||
GameRootUI.DisableOper(1)
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.UI_ResartGame, this, this.resiveResartGame)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
// GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
// this.onBackClick();
|
||||
// }, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.cgPic, ()=>{
|
||||
this.changePicScale();
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
this.onBackClick();
|
||||
}, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnBack, ()=>{
|
||||
this.onBackClick();
|
||||
}, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnShare, ()=>{
|
||||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnRestart, ()=>{
|
||||
this.onRestartClick();
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnContinue, ()=>{
|
||||
this.onContinueClick();
|
||||
}, this);
|
||||
|
||||
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("结算界面分享回调", tag)
|
||||
if (tag == 1) {
|
||||
SubManager.ShowPrompt("分享成功")
|
||||
// let sptShare:Sprite = this._nodeTab.btnShare.getComponent(Sprite)
|
||||
// sptShare.grayscale = true
|
||||
// GButton.RemoveClick(this._nodeTab.btnShare)
|
||||
this.backToMain()
|
||||
}
|
||||
})
|
||||
|
||||
let lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
|
||||
|
||||
//星级
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
let starSpt = this._nodeTab["star" + i].getComponent(Sprite)
|
||||
let starPath = ""
|
||||
let showAct = false
|
||||
if(this._data.end_star == 3) {
|
||||
starPath = "lv_23"
|
||||
showAct = true
|
||||
} else if (this._data.end_star < i) {
|
||||
starPath = "lv_21"
|
||||
} else {
|
||||
starPath = "lv_22"
|
||||
showAct = true
|
||||
}
|
||||
ResManager.I.changeBundleSpriteFrame(starSpt, starPath, "Zhujiemian")
|
||||
//动作
|
||||
let starNode = this._nodeTab["starNode"+i]
|
||||
if (showAct) {
|
||||
this.doStarAction1(starNode, (i-1)*0.2)
|
||||
} else {
|
||||
this.doStarAction2(starNode, (i-1)*0.2)
|
||||
}
|
||||
}
|
||||
|
||||
//成功失败
|
||||
let iswin = this._data.status == 0
|
||||
let endPath = iswin ? "lv_19" : "lv_20"
|
||||
let winSpt = this._nodeTab.winSpt.getComponent(Sprite)
|
||||
ResManager.I.changeBundleSpriteFrame(winSpt, endPath, "Zhujiemian")
|
||||
if (iswin) {
|
||||
AudioManager.I.PlayEffect(10003); //胜利音效
|
||||
} else {
|
||||
AudioManager.I.PlayEffect(10001); //失败音效
|
||||
}
|
||||
|
||||
//结算显示
|
||||
let picPath = "" //表情图
|
||||
let talkStr = "" //对话
|
||||
if (this._data.end_star == 3) {
|
||||
picPath = `cg3/${lvCfg.threeStarCG}`
|
||||
talkStr = lvCfg.threeStarSummary
|
||||
} else if (this._data.end_star == 2) {
|
||||
picPath = `cg2/${lvCfg.twoStarCG}`
|
||||
talkStr = lvCfg.twoStarSummary
|
||||
} else if (this._data.end_star == 1) {
|
||||
picPath = `cg1/${lvCfg.oneStarCG}`
|
||||
talkStr = lvCfg.oneStarSummary
|
||||
} else {
|
||||
picPath = `cg0/${lvCfg.failureCG}`
|
||||
talkStr = lvCfg.failureSummary
|
||||
}
|
||||
let cgPic = this._nodeTab.cgPic.getComponent(Sprite)
|
||||
ResManager.I.changeBundleSpriteFrame(cgPic, picPath, "Raw")
|
||||
Utils.setString(this._nodeTab.labTalk, talkStr)
|
||||
//保存关卡星级
|
||||
if (lvCfg.star < this._data.end_star) {
|
||||
GameManager.SetLevelStar(GameManager.CurLevelId, this._data.end_star)
|
||||
}
|
||||
|
||||
//按钮显示
|
||||
let swtRestart = false
|
||||
let swtContinue = false
|
||||
let swtShare = false
|
||||
if (this._data.end_star == 0) {
|
||||
swtRestart = true
|
||||
} else {
|
||||
let curCnt = GameManager.srouceCnt
|
||||
let stepData = GameManager.CurLevelData
|
||||
if (curCnt < stepData.total_cnt) {
|
||||
swtContinue = true
|
||||
} else {
|
||||
swtShare = true
|
||||
}
|
||||
}
|
||||
this._nodeTab.btnRestart.active = swtRestart
|
||||
this._nodeTab.btnContinue.active = swtContinue
|
||||
this._nodeTab.btnShare.active = swtShare
|
||||
this._nodeTab.labXQCount.active = swtRestart
|
||||
|
||||
//刷新npc表情
|
||||
let emoInfo = GameManager.GetNpcEmoPic("")
|
||||
let videoPath = HttpUnit.GetBgVideoUrl(emoInfo.emoName)
|
||||
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {rolePath:emoInfo.rolePath, videoPath:videoPath, videoType: emoInfo.videoType})
|
||||
|
||||
//刷新玩家数据
|
||||
Utils.setString(this._nodeTab.labXQCount, "")
|
||||
HttpUnit.ins.getUserData((userData) => {
|
||||
//剩余相亲次数
|
||||
let xqnum = HttpUnit.GetXiangqinTickets()
|
||||
Utils.setString(this._nodeTab.labXQCount, `剩余相亲次数:${xqnum}`)
|
||||
})
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//接收重玩消息
|
||||
resiveResartGame(data:any) {
|
||||
this.onClose()
|
||||
}
|
||||
|
||||
//返回主界面
|
||||
backToMain() {
|
||||
GameManager.EndGame()
|
||||
ViewManager.I.closeAllView();
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Talk_Back, {})
|
||||
}
|
||||
|
||||
//点击返回
|
||||
onBackClick() {
|
||||
this.backToMain()
|
||||
}
|
||||
|
||||
//点击重玩
|
||||
onRestartClick() {
|
||||
GameRootUI.DisableOper(1)
|
||||
GameManager.RestartGame()
|
||||
}
|
||||
|
||||
//点击继续
|
||||
onContinueClick() {
|
||||
this._doContinueGame()
|
||||
}
|
||||
//继续游戏
|
||||
private _doContinueGame() {
|
||||
GameRootUI.DisableOper(0.5)
|
||||
HttpUnit.ins.sendGameContinue({record_id:GameManager.RecordId, level_id:GameManager.CurLevelId}, (data) => {
|
||||
if (data == null) return
|
||||
Utils.sendInnerMsg(InnerMsgCode.Data_LevelStarUp, {level:GameManager.CurLevelId, star:this._data.end_star})
|
||||
GameManager.TurnToStage(E_TalkStage.upTalkStatus, true)
|
||||
this.onClose()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**肖像放大缩小 */
|
||||
changePicScale() {
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
if (this.isPicFull) {
|
||||
this.isPicFull = false;
|
||||
|
||||
tween((this._nodeTab.cgPic as Node))
|
||||
.to(ttime, { scale: this.picDefScale }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
let hideNodeOpa:UIOpacity = this._nodeTab.hideNode.getComponent(UIOpacity)
|
||||
tween(hideNodeOpa)
|
||||
.delay(ttime*0.7)
|
||||
.to(ttime*0.3, { opacity: 255 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
} else {
|
||||
this.isPicFull = true;
|
||||
let s = 1
|
||||
let windowSize = view.getVisibleSize(); // 获取窗口大小
|
||||
let picTf:UITransform = this._nodeTab.cgPic.getComponent(UITransform);
|
||||
if (picTf.height < windowSize.height) {
|
||||
s = windowSize.height / picTf.height;
|
||||
}
|
||||
let centerScale = this._nodeTab.center.scale;
|
||||
if (centerScale.y < 1) {
|
||||
s = s / centerScale.y; //根节点有做适配,这里还原适配做的缩放
|
||||
}
|
||||
|
||||
tween((this._nodeTab.cgPic as Node))
|
||||
.to(ttime, { scale: new Vec3(s, s, s) }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
let hideNodeOpa:UIOpacity = this._nodeTab.hideNode.getComponent(UIOpacity)
|
||||
tween(hideNodeOpa)
|
||||
.to(ttime*0.3, { opacity: 0 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**星星动作 */
|
||||
private doStarAction1(node:Node, tdelay:number) {
|
||||
let ttime = 0.5;
|
||||
//透明效果
|
||||
let opa = node.getComponent(UIOpacity)
|
||||
if (!opa) {
|
||||
opa = node.addComponent(UIOpacity)
|
||||
}
|
||||
opa.opacity = 0
|
||||
tween(opa)
|
||||
.delay(tdelay)
|
||||
.to(ttime, { opacity: 255 }, { easing: 'quadIn' })
|
||||
.start();
|
||||
|
||||
//缩放效果
|
||||
node.setScale(new Vec3(3, 3, 3))
|
||||
tween(node)
|
||||
.delay(tdelay)
|
||||
.to(ttime, { scale: new Vec3(1, 1, 1) }, { easing: 'quadIn' })
|
||||
.start();
|
||||
|
||||
//旋转效果
|
||||
tween(node)
|
||||
.delay(tdelay)
|
||||
// .to(ttime, { angle: 720 }, { easing: 'quadOut' })
|
||||
.to(ttime, { eulerAngles: new Vec3(0, 0, 360) }, { easing: 'quadIn' })
|
||||
.start();
|
||||
}
|
||||
private doStarAction2(node:Node, tdelay:number) {
|
||||
let ttime = 0.5;
|
||||
//透明效果
|
||||
let opa = node.getComponent(UIOpacity)
|
||||
if (!opa) {
|
||||
opa = node.addComponent(UIOpacity)
|
||||
}
|
||||
opa.opacity = 0
|
||||
tween(opa)
|
||||
.delay(tdelay)
|
||||
.to(ttime, { opacity: 255 }, { easing: 'quadIn' })
|
||||
.start();
|
||||
|
||||
//缩放效果
|
||||
tween(node)
|
||||
.delay(tdelay)
|
||||
.to(ttime*0.5, { scale: new Vec3(1.3, 1.3, 1.3) }, { easing: 'quadIn' })
|
||||
.to(ttime*0.5, { scale: new Vec3(1, 1, 1) }, { easing: 'quadOut' })
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "09d0b77a-3e95-42f9-be7d-f421c41c86fd",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import { _decorator, Label, Node, Toggle } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import AudioManager from '../../Main/Manager/AudioManager';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import SubManager from '../SubManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//GM命令
|
||||
@ccclass('GM_UI')
|
||||
export class GM_UI extends li_BaseView {
|
||||
|
||||
private _nodeTab: any = {};
|
||||
|
||||
onLoad() {
|
||||
this._nodeTab = {}
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
GButton.BandClick(this._nodeTab.BtnClose, this.onCloseClick, this);
|
||||
GButton.BandClick(this._nodeTab.btnClearCundang, this.onQingdangClick, this);
|
||||
|
||||
let musicTg: Toggle = this._nodeTab.musicTg.getComponent(Toggle)
|
||||
musicTg.isChecked = PlayerDataManager.I.IsMusicOn
|
||||
let soudTg: Toggle = this._nodeTab.soudTg.getComponent(Toggle)
|
||||
soudTg.isChecked = PlayerDataManager.I.IsSoundOn
|
||||
|
||||
//GM Log
|
||||
let gmLog = this._nodeTab.gmLogLable.getComponent(Label)
|
||||
gmLog.string = "GM Log:\n" + SDKManager.GMLogString
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//音效开关变化事件 prefab中调用
|
||||
onSoundEvent(target: Toggle, arg2) {
|
||||
if (target) {
|
||||
PlayerDataManager.I.SetSoundOn(target.isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
//音乐开关变化事件 prefab中调用
|
||||
onMusicEvent(target: Toggle, arg2) {
|
||||
if (target) {
|
||||
PlayerDataManager.I.SetMusicOn(target.isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//清除存档
|
||||
onQingdangClick() {
|
||||
PlayerDataManager.clearAll()
|
||||
SubManager.ShowPrompt("清除存档成功")
|
||||
}
|
||||
|
||||
//关闭按钮
|
||||
onCloseClick() {
|
||||
this.onClose()
|
||||
Utils.sendInnerMsg(InnerMsgCode.GM_UI_Close, {id:1})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "27c7dff8-734f-445e-b5f4-1c53224329bb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import { _decorator, Node } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import AudioManager from '../../Main/Manager/AudioManager';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameRootUI from '../../Main/Common/GameRootUI';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//游戏关卡界面
|
||||
@ccclass('Game_UI')
|
||||
export class Game_UI extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnBack, this.onBackClick, this);
|
||||
|
||||
AudioManager.I.PlayMusic(1, true) //背景乐
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//GM界面关闭消息
|
||||
resiveGMClose(data) {
|
||||
Utils.Log("收到GM界面关闭消息")
|
||||
}
|
||||
|
||||
|
||||
//返回按钮
|
||||
onBackClick() {
|
||||
Utils.Log("点击星级挑战");
|
||||
GameRootUI.ShowCrossUI()
|
||||
ResManager.I.goMainScene(); //进入下一个场景
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d5d7d0a6-17c1-46e4-b46c-6a4a4fecc87d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,378 +0,0 @@
|
||||
import { _decorator, instantiate, Label, Layout, Node, Prefab, RichText, ScrollView, Sprite, tween, UIOpacity, UITransform, Vec3 } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import { E_AD_TARGET } from './TalkAdDialog';
|
||||
import SubManager from '../SubManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**界面打开类型 */
|
||||
export enum E_RECORD_TYPE {
|
||||
Talk, //关卡中查看
|
||||
Jilu, //相遇记录里查看
|
||||
}
|
||||
|
||||
//聊天记录界面
|
||||
@ccclass('Record_UI')
|
||||
export class Record_UI extends li_BaseView {
|
||||
|
||||
@property(Prefab)
|
||||
private talkDescItem: Prefab = null;
|
||||
@property(Prefab)
|
||||
private talkNpcItem: Prefab = null;
|
||||
@property(Prefab)
|
||||
private talkUserItem: Prefab = null;
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private talkSV: ScrollView = null;
|
||||
private _data;
|
||||
|
||||
private itemNodeList: any[] = [];
|
||||
private itemDataList: any[] = [];
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
this.talkSV = this._nodeTab.talkSV.getComponent(ScrollView);
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data || {};
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
GButton.BandClick(this._nodeTab.btnBack, ()=>{
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
//撤回按钮
|
||||
GButton.BandClick(this._nodeTab.chehuiNode, ()=>{
|
||||
let cellLen = this.itemDataList.length
|
||||
if (cellLen <= 1) {
|
||||
SubManager.ShowPrompt("没有可以撤回的对话")
|
||||
return
|
||||
}
|
||||
|
||||
let contStr = ""
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (!levelData || levelData.can_use_cancel_cnt <= 0) {
|
||||
contStr = "关卡内撤回次数已用完"
|
||||
} else {
|
||||
contStr = `撤回最近 1 次对话,并返还 1 次对话次数,剩余 ${levelData.can_use_cancel_cnt} 次`
|
||||
}
|
||||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||||
type: E_AD_TARGET.chehui, //撤回,并加聊天次数
|
||||
content: contStr,
|
||||
adCallback: (isfree: any) => {
|
||||
if (isfree) {
|
||||
this.doChehuiTalk()
|
||||
} else {
|
||||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||||
}
|
||||
},
|
||||
shareCallback: ()=>{
|
||||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||||
}
|
||||
})
|
||||
}, this);
|
||||
|
||||
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("视频广告回调", tag)
|
||||
if (tag == 1) {
|
||||
// 撤回聊天
|
||||
this.doChehuiTalk()
|
||||
}
|
||||
})
|
||||
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("分享回调", tag)
|
||||
if (tag == 1) {
|
||||
// 撤回聊天
|
||||
this.doChehuiTalk()
|
||||
}
|
||||
})
|
||||
|
||||
let talkList = [] //要显示的对话列表
|
||||
let lvId = "" //关卡id
|
||||
let showChehui = false //是否显示撤回按钮
|
||||
let scrollBtm = false //是否滚动到底部
|
||||
if (this._data.mode == E_RECORD_TYPE.Talk) {
|
||||
talkList = GameManager.TalkRecordList
|
||||
lvId = GameManager.CurLevelId
|
||||
showChehui = true
|
||||
scrollBtm = true
|
||||
} else if (this._data.mode == E_RECORD_TYPE.Jilu) {
|
||||
talkList = this._data.talkList || []
|
||||
lvId = this._data.lvId || ""
|
||||
}
|
||||
this._nodeTab.chehuiNode.active = showChehui
|
||||
|
||||
let lvCfg = GameManager.getLevelCfg(lvId)
|
||||
//npc名字
|
||||
Utils.setString(this._nodeTab.npcName, lvCfg.name)
|
||||
|
||||
//介绍
|
||||
let descClone:any = instantiate(this.talkDescItem)
|
||||
this._nodeTab.talkLay.addChild(descClone);
|
||||
Utils.parseNode(descClone);
|
||||
Utils.setString(descClone.labDesc, lvCfg.tips)
|
||||
let descOpa:UIOpacity = descClone.getComponent(UIOpacity)
|
||||
descOpa.opacity = 0
|
||||
tween(descOpa).to(0.2, {opacity: 255}).start()
|
||||
|
||||
//聊天列表
|
||||
this.itemNodeList = []
|
||||
this.itemDataList = []
|
||||
let talkLay: Layout = this.talkSV.content.getComponent(Layout)
|
||||
talkLay.enabled = false;
|
||||
|
||||
let aniTime = 0 //滚动动作总时间
|
||||
let talkCellLen = talkList.length
|
||||
for (let i=0; i<talkCellLen; i++) {
|
||||
// for (let i=talkCellLen-1; i>=0; i--) {
|
||||
let info = talkList[i];
|
||||
let titem = info.isMe ? this.talkUserItem : this.talkNpcItem;
|
||||
let itemClone:any = instantiate(titem);
|
||||
this._nodeTab.talkLay.addChild(itemClone);
|
||||
|
||||
Utils.parseNode(itemClone);
|
||||
this.itemNodeList.push(itemClone);
|
||||
this.itemDataList.push(info);
|
||||
|
||||
let labpx = info.isMe ? -15 : 15;
|
||||
itemClone.zw1.position = new Vec3(0, 0, 0)
|
||||
itemClone.zw2.position = new Vec3(0, 0, 0)
|
||||
itemClone.labTalk1.position = new Vec3(labpx, 0, 0)
|
||||
itemClone.labTalk2.position = new Vec3(labpx, 0, 0)
|
||||
itemClone.zw1.active = false
|
||||
itemClone.zw2.active = false
|
||||
itemClone.labTalk1.active = false
|
||||
itemClone.labTalk2.active = false
|
||||
|
||||
//头像
|
||||
let spt = itemClone.headIcon.getComponent(Sprite)
|
||||
if (info.isMe) {
|
||||
let avatarUrl = SDKManager.avatarUrl;
|
||||
if (avatarUrl == "" || avatarUrl == null) {
|
||||
SDKManager.getUserInfo((data) => {
|
||||
ResManager.I.changeRemoteSpriteFrame(spt, data.avatarUrl)
|
||||
})
|
||||
} else {
|
||||
ResManager.I.changeRemoteSpriteFrame(spt, avatarUrl)
|
||||
}
|
||||
} else {
|
||||
let headPath = `head/${lvCfg.characterAvatar}`
|
||||
ResManager.I.changeBundleSpriteFrame(spt.getComponent(Sprite), headPath, "Raw")
|
||||
}
|
||||
|
||||
//对话文本前后有各有一个占位节点
|
||||
let zw1 = instantiate(itemClone.zw1)
|
||||
zw1.active = true
|
||||
itemClone.kuang.addChild(zw1)
|
||||
//对话文本 括号中间的文字用斜体
|
||||
let kidx = 0
|
||||
let clab
|
||||
for(let i=0; i<10; i++) {
|
||||
let kl = info.talk.indexOf("(", kidx) //左括号
|
||||
if (kl == -1) {
|
||||
if (kidx < info.talk.length) {
|
||||
clab = instantiate(itemClone.labTalk2)
|
||||
clab.active = true
|
||||
itemClone.kuang.addChild(clab)
|
||||
Utils.setString(clab, info.talk.substring(kidx, info.talk.length))
|
||||
kidx = info.talk.length
|
||||
}
|
||||
} else {
|
||||
let kr = info.talk.indexOf(")", kl) //右括号
|
||||
if (kr != -1) {
|
||||
//匹配到括号
|
||||
if (kidx < kl) {
|
||||
clab = instantiate(itemClone.labTalk2)
|
||||
clab.active = true
|
||||
itemClone.kuang.addChild(clab)
|
||||
Utils.setString(clab, info.talk.substring(kidx, kl))
|
||||
}
|
||||
clab = instantiate(itemClone.labTalk1)
|
||||
clab.active = true
|
||||
itemClone.kuang.addChild(clab)
|
||||
Utils.setString(clab, info.talk.substring(kl+1, kr))
|
||||
kidx = kr + 1
|
||||
} else {
|
||||
if (kidx < info.talk.length) {
|
||||
clab = instantiate(itemClone.labTalk2)
|
||||
clab.active = true
|
||||
itemClone.kuang.addChild(clab)
|
||||
Utils.setString(clab, info.talk.substring(kidx, info.talk.length))
|
||||
kidx = info.talk.length
|
||||
}
|
||||
}
|
||||
}
|
||||
if (kidx >= info.talk.length) {
|
||||
break
|
||||
}
|
||||
}
|
||||
let zw2 = instantiate(itemClone.zw1)
|
||||
zw2.active = true
|
||||
itemClone.kuang.addChild(zw2)
|
||||
//基础得分
|
||||
let scoreBase = info.scoreBase || -1;
|
||||
if (info.isMe || scoreBase < 0) {
|
||||
itemClone.labScore.active = false;
|
||||
} else {
|
||||
itemClone.labScore.active = true;
|
||||
Utils.setString(itemClone.labScore, `得分:${scoreBase}`)
|
||||
}
|
||||
//额外加分
|
||||
let scoreAdditional = info.scoreAdditional || 0;
|
||||
if (info.isMe || scoreAdditional <= 0) {
|
||||
itemClone.labScoreAdd.active = false;
|
||||
} else {
|
||||
itemClone.labScoreAdd.active = true;
|
||||
Utils.setString(itemClone.labScoreAdd, `加分:${scoreAdditional}`)
|
||||
}
|
||||
|
||||
//动作
|
||||
let kuangOpa:UIOpacity = itemClone.kuang.getComponent(UIOpacity)
|
||||
kuangOpa.opacity = 1;
|
||||
// let didx = talkCellLen-1-i;
|
||||
let didx = i;
|
||||
let tdelay = didx * 0.03;
|
||||
let self = this;
|
||||
if (i == talkCellLen-1) {
|
||||
aniTime = 0.2 + tdelay;
|
||||
}
|
||||
tween(kuangOpa)
|
||||
.delay(0.2 + tdelay)
|
||||
.call(()=>{
|
||||
//滚动到当前节点处
|
||||
if (scrollBtm) {
|
||||
self.talkSV.scrollToPercentVertical((talkCellLen-1-i) / talkCellLen, 0.1);
|
||||
}
|
||||
//调整框宽度
|
||||
let widthmax = 0;
|
||||
itemClone.kuang.children.forEach((item)=>{
|
||||
let tf = item.getComponent(UITransform);
|
||||
if (tf && tf.width > widthmax) {
|
||||
widthmax = tf.width;
|
||||
}
|
||||
})
|
||||
let kuangTf:UITransform = itemClone.kuang.getComponent(UITransform);
|
||||
kuangTf.width = widthmax + 30;
|
||||
})
|
||||
.to(0.2, { opacity: 255 })
|
||||
.start();
|
||||
}
|
||||
|
||||
//延迟一下,设置文本换行模式
|
||||
this.scheduleOnce(()=>{
|
||||
for (let i=0; i<this.itemNodeList.length; i++) {
|
||||
let item = this.itemNodeList[i];
|
||||
item.kuang.children.forEach((child)=>{
|
||||
let lab = child.getComponent(Label);
|
||||
if (lab) {
|
||||
let labTf:UITransform = child.getComponent(UITransform);
|
||||
if (labTf.height < 50) { //小于50,说明没换行,改为自动宽度
|
||||
lab.overflow = Label.Overflow.NONE;
|
||||
} else {
|
||||
lab.overflow = Label.Overflow.RESIZE_HEIGHT;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0.1)
|
||||
//延迟一下,都设置成一样宽,是右侧的文本左对齐
|
||||
this.scheduleOnce(()=>{
|
||||
for (let i=0; i<this.itemNodeList.length; i++) {
|
||||
let item = this.itemNodeList[i];
|
||||
|
||||
let widthmax = 0;
|
||||
item.kuang.children.forEach((item)=>{
|
||||
let tf = item.getComponent(UITransform);
|
||||
if (tf && tf.width > widthmax) {
|
||||
widthmax = tf.width;
|
||||
}
|
||||
})
|
||||
|
||||
item.kuang.children.forEach((child)=>{
|
||||
let lab = child.getComponent(Label);
|
||||
if (lab) {
|
||||
let labTf:UITransform = child.getComponent(UITransform);
|
||||
lab.overflow = Label.Overflow.RESIZE_HEIGHT;
|
||||
labTf.width = widthmax;
|
||||
// if (labTf.height < 50) { //小于50,说明没换行,改为自动宽度
|
||||
// lab.overflow = Label.Overflow.NONE;
|
||||
// } else {
|
||||
// lab.overflow = Label.Overflow.RESIZE_HEIGHT;
|
||||
// }
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0.12)
|
||||
|
||||
//延迟一下,调整文本框的宽度。高度由layout自动调整
|
||||
this.scheduleOnce(()=>{
|
||||
talkLay.enabled = true;
|
||||
}, 0.15)
|
||||
|
||||
//撤回按钮显示动画
|
||||
let chehuiOpa: UIOpacity = this._nodeTab.chehuiNode.getComponent(UIOpacity);
|
||||
chehuiOpa.opacity = 0;
|
||||
tween(chehuiOpa)
|
||||
.delay(aniTime)
|
||||
.to(0.2, {opacity: 255})
|
||||
.start();
|
||||
|
||||
//刷新撤回次数
|
||||
this.refreshChehuiCount()
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**刷新撤回次数 */
|
||||
refreshChehuiCount() {
|
||||
if (this._data.mode != E_RECORD_TYPE.Talk) {
|
||||
return
|
||||
}
|
||||
let levelData = GameManager.CurLevelData
|
||||
let n_cur = levelData.can_use_cancel_cnt || 0
|
||||
let n_max = 3
|
||||
Utils.setString(this._nodeTab.labChehui, n_cur + "/" + n_max)
|
||||
}
|
||||
|
||||
|
||||
/**撤回上一轮发言 */
|
||||
doChehuiTalk() {
|
||||
if (this._data.mode != E_RECORD_TYPE.Talk) {
|
||||
return
|
||||
}
|
||||
HttpUnit.ins.sendTalkChehui({record_id: GameManager.RecordId}, (data) => {
|
||||
if (data) {
|
||||
SubManager.ShowPrompt("撤回成功,已返还聊天次数")
|
||||
GameManager.CurLevelData = data.level
|
||||
GameManager.srouceCnt = data.level.current_cnt
|
||||
GameManager.RemoveLastRoundTalkRecord()
|
||||
GameManager.RemoveLastSetpScore()
|
||||
GameManager.removeLastNpcTalkData()
|
||||
Utils.sendInnerMsg(InnerMsgCode.Data_ChehuiUp, {})
|
||||
this.onClose()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "41e10794-984e-461a-b0cf-67fd76eeb65d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
import { _decorator, Node, Toggle } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import PlayerDataManager from '../../Main/Manager/PlayerDataManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//设置界面
|
||||
@ccclass('Setting_UI')
|
||||
export class Setting extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private _musicOn: boolean = true; //音乐开关
|
||||
private _soundOn: boolean = true; //音效开关
|
||||
private tgMusic: Toggle = null;
|
||||
private tgSound: Toggle = null;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
GButton.BandClick(this._nodeTab.bgmask, ()=>{
|
||||
this.onClose()
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
this.onClose()
|
||||
}, this);
|
||||
// GButton.BandClick(this._nodeTab.tgMusic, ()=>{
|
||||
// this.onClose()
|
||||
// }, this);
|
||||
// GButton.BandClick(this._nodeTab.tgSound, ()=>{
|
||||
// this.onClose()
|
||||
// }, this);
|
||||
|
||||
this.tgMusic = this._nodeTab.tgMusic.getComponent(Toggle);
|
||||
this.tgSound = this._nodeTab.tgSound.getComponent(Toggle);
|
||||
|
||||
this.tgMusic.isChecked = PlayerDataManager.I.IsMusicOn;
|
||||
this.tgSound.isChecked = PlayerDataManager.I.IsSoundOn;
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//背景乐开关,在UI里设置
|
||||
onTgMusicClick(tg:any, ev:any) {
|
||||
PlayerDataManager.I.SetMusicOn(this.tgMusic.isChecked)
|
||||
}
|
||||
//音效开关,在UI里设置
|
||||
onTgSoundClick(tg:any, ev:any) {
|
||||
PlayerDataManager.I.SetSoundOn(this.tgSound.isChecked)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a043359c-4439-4a5c-919c-705aadc3c5ce",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,794 +0,0 @@
|
||||
import { _decorator, instantiate, isValid, Label, Node, PageView, Prefab, Sprite, tween, Tween, UITransform, view } 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, I_NpcTalkBack } from '../../Main/Config/CommonConfig';
|
||||
import SubManager from '../SubManager';
|
||||
import { ByteDanceSDK } from '../../Main/Channel/bdSDK';
|
||||
import GlobalValue, { VideoRoleType } 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
|
||||
|
||||
@property(Prefab)
|
||||
private GuidePageItem: Prefab = null //引导选择角色页签
|
||||
private guidePageView: PageView = null //引导选择角色页签容器
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private levelData: I_LevelConfig[] = []; //关卡数据
|
||||
private curLevelIdx: number = 0; //当前关卡Idx
|
||||
|
||||
private lvUnlockId: string = ""; //解锁关卡id
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
this.itemClone = instantiate(this.Level_Item)
|
||||
this.Level_List.setTemplateItem(this.itemClone)
|
||||
this.guidePageView = this._nodeTab.guidePageView.getComponent(PageView)
|
||||
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)
|
||||
Utils.addInnerEL(InnerMsgCode.UI_Tj_huiyi_Lv, this, this.resiveHuiyiLv)
|
||||
Utils.addInnerEL(InnerMsgCode.Data_BDSidebarReward, this, this.resiveBDSidebarReward)
|
||||
Utils.addInnerEL(InnerMsgCode.Data_ZhencangUp, this, this.resiveZhencangUp)
|
||||
Utils.addInnerEL(InnerMsgCode.Data_Redpoint, this, this.resiveZhencangRedpoint)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnStart, this.onStartClick, this, 10002);
|
||||
GButton.BandClick(this._nodeTab.btnKefu, this.onKefuClick, this);
|
||||
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);
|
||||
GButton.BandClick(this._nodeTab.btnTujian, this.onTujianClick, this);
|
||||
GButton.BandClick(this._nodeTab.btnReward, this.onRewardClick, 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()
|
||||
})
|
||||
} else if (tag == 2) {
|
||||
// 解锁关卡
|
||||
HttpUnit.ins.levelUnlock({level_id: this.lvUnlockId}, (data) => {
|
||||
// SubManager.ShowPrompt("关卡解锁成功")
|
||||
this.refreshLevelList()
|
||||
this.enterLevelAfterUnlock()
|
||||
})
|
||||
}
|
||||
})
|
||||
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)
|
||||
this._nodeTab.rewardBox.active = false
|
||||
this._nodeTab.rp_tujian.active = false
|
||||
|
||||
// this._nodeTab.labStart2.active = false //快手去掉英文
|
||||
|
||||
//客服按钮
|
||||
this._nodeTab.btnKefu.active = SDKManager.KefuSupport()
|
||||
|
||||
//设置按钮
|
||||
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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//重置引导
|
||||
this.resetGuide()
|
||||
GameRootUI.DisableOper(2)
|
||||
|
||||
//判断玩家权限是否已获取
|
||||
if (!HttpUnit.IsLogin()) {
|
||||
HttpUnit.ins.login((loginData) => {
|
||||
console.log("主界面: 获取授权并登录成功!")
|
||||
this.userInited()
|
||||
})
|
||||
} else {
|
||||
this.userInited()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//GM界面关闭消息
|
||||
resiveGMClose(data) {
|
||||
Utils.Log("收到GM界面关闭消息")
|
||||
}
|
||||
|
||||
//退出聊天消息
|
||||
resiveTalkBack(data) {
|
||||
Utils.Log("收到退出聊天消息")
|
||||
AudioManager.I.PlayMusic(1, true) //背景乐
|
||||
this.setUIVisible(true)
|
||||
this.refreshLevelList()
|
||||
HttpUnit.ins.getUserData((userData) => {
|
||||
this.refreshXiangqinTicket()
|
||||
})
|
||||
}
|
||||
|
||||
//抖音侧边栏消息
|
||||
resiveBDSidebar(data) {
|
||||
this.refreshBdSidebarUI()
|
||||
}
|
||||
|
||||
//领取抖音侧边栏奖励消息
|
||||
resiveBDSidebarReward(data) {
|
||||
this.refreshXiangqinTicket()
|
||||
}
|
||||
|
||||
/**私家珍藏数据变化消息 */
|
||||
resiveZhencangUp(data:any) {
|
||||
this.refreshRewardUI()
|
||||
}
|
||||
|
||||
/**刷新珍藏红点 */
|
||||
resiveZhencangRedpoint(data: any) {
|
||||
this.refreshTujianRedpoint();
|
||||
}
|
||||
|
||||
|
||||
/**前往回忆对应关卡 */
|
||||
resiveHuiyiLv(data:any) {
|
||||
let gotoIdx = -1
|
||||
for (let i = 1; i < this.levelData.length; i++) {
|
||||
if (this.levelData[i].id == data.lvId) {
|
||||
gotoIdx = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if (gotoIdx == -1) {
|
||||
return
|
||||
}
|
||||
let scrollto = Math.max(0, gotoIdx - 2)
|
||||
this.scheduleOnce(() => {
|
||||
this.Level_List.scrollTo(scrollto)
|
||||
}, 0.1)
|
||||
// this.curLevelIdx = gotoIdx
|
||||
this.changeLevel(gotoIdx, true)
|
||||
}
|
||||
|
||||
|
||||
//增加相亲次数
|
||||
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 = false
|
||||
// Utils.setString(this._nodeTab.labBDSidebar, "领取抖音侧边栏")
|
||||
} else {
|
||||
//版本不支持或奖励已领取
|
||||
this._nodeTab.btnBDSidebar.active = false
|
||||
}
|
||||
}
|
||||
|
||||
//刷新玩家信息完毕
|
||||
userInited() {
|
||||
this.refreshSdkUI()
|
||||
this.refreshLevelList()
|
||||
this.refreshXiangqinTicket()
|
||||
this.refreshTujianRedpoint()
|
||||
GameManager.refreshZhencangCanget()
|
||||
}
|
||||
|
||||
//刷新剩余相亲次数
|
||||
private refreshXiangqinTicket() {
|
||||
let xqnum = HttpUnit.GetXiangqinTickets()
|
||||
// let xqmax = HttpUnit.GetXiangqinMaxTickets()
|
||||
Utils.setString(this._nodeTab.labTZCount, xqnum + "")
|
||||
Utils.setString(this._nodeTab.labBtnTZCount, "" + xqnum)
|
||||
}
|
||||
|
||||
//刷新奖励按钮显示
|
||||
private refreshRewardUI() {
|
||||
let haveReward = GameManager.zhencangCanget.length > 0
|
||||
this._dorefreshTujianReward(haveReward)
|
||||
}
|
||||
private _dorefreshTujianReward(haveReward:boolean) {
|
||||
this._nodeTab.rewardBox.active = haveReward
|
||||
if (haveReward) {
|
||||
let rewardBox:Node = this._nodeTab.rewardBox
|
||||
Tween.stopAllByTarget(rewardBox)
|
||||
tween(rewardBox)
|
||||
.delay(1.5)
|
||||
.to(0.2, {angle: -30})
|
||||
.to(0.2, {angle: 30})
|
||||
.to(0.18, {angle: -22})
|
||||
.to(0.18, {angle: 22})
|
||||
.to(0.16, {angle: -16})
|
||||
.to(0.16, {angle: 16})
|
||||
.to(0.14, {angle: -10})
|
||||
.to(0.14, {angle: 10})
|
||||
.to(0.12, {angle: -6})
|
||||
.to(0.12, {angle: 6})
|
||||
.to(0.1, {angle: -3})
|
||||
.to(0.1, {angle: 3})
|
||||
.to(0.08, {angle: 0})
|
||||
.union()
|
||||
.repeatForever()
|
||||
.start()
|
||||
}
|
||||
}
|
||||
|
||||
//刷新心动回忆入口红点
|
||||
private refreshTujianRedpoint() {
|
||||
let isshow = false
|
||||
//心动回忆
|
||||
if (!isshow) {
|
||||
isshow = HttpUnit.IsHaveHuiyiRedpoint()
|
||||
}
|
||||
//私家珍藏
|
||||
if (!isshow) {
|
||||
isshow = HttpUnit.IsHaveZhencangRedpoint()
|
||||
}
|
||||
this._nodeTab.rp_tujian.active = isshow
|
||||
}
|
||||
|
||||
//region 刷新关卡列表
|
||||
private refreshLevelList() {
|
||||
HttpUnit.ins.getLevelList((levelList) => {
|
||||
if (levelList) {
|
||||
GameRootUI.EnableOper()
|
||||
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
|
||||
//自动滚动只在引导后生效
|
||||
if (PlayerDataManager.I.GuideMainFinished) {
|
||||
for (let i = 1; i < this.levelData.length; i++) {
|
||||
if (this.levelData[i].is_unlock == true && this.levelData[i].star > 0) {
|
||||
if (this.curLevelIdx < i) {
|
||||
this.curLevelIdx = i
|
||||
}
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if (this.curLevelIdx > 2) {
|
||||
this.scheduleOnce(() => {
|
||||
this.Level_List.scrollTo(this.curLevelIdx-2)
|
||||
}, 0.1)
|
||||
}
|
||||
} else {
|
||||
this.checkGuide()
|
||||
}
|
||||
}
|
||||
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)
|
||||
SDKManager.avatarUrl = data.avatarUrl
|
||||
//名字
|
||||
let nickName = this._nodeTab.nickName.getComponent(Label)
|
||||
nickName.string = data.nickName
|
||||
SDKManager.nickName = data.nickName
|
||||
console.log("主界面 设置头像和名字:", data.avatarUrl, data.nickName)
|
||||
})
|
||||
//刷新id
|
||||
let id = HttpUnit.GetID()
|
||||
Utils.setString(this._nodeTab.userId, `ID:${id}`)
|
||||
// Utils.setString(this._nodeTab.userId, `${id}`) //快手去掉英文
|
||||
}
|
||||
|
||||
|
||||
//region 关卡列表渲染
|
||||
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]
|
||||
//npc名
|
||||
// console.log("关卡列表渲染:", idx, data.name)
|
||||
//头像
|
||||
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)
|
||||
//是否解锁
|
||||
if (data.is_unlock) {
|
||||
Utils.setString(this._nodeTab.labStart1, "游戏开始")
|
||||
Utils.setString(this._nodeTab.labStart2, "GAME\nSTART")
|
||||
} else {
|
||||
Utils.setString(this._nodeTab.labStart1, "解锁关卡")
|
||||
Utils.setString(this._nodeTab.labStart2, "UNLOCK\nGAME")
|
||||
}
|
||||
|
||||
let bgPath = `bg/${data.bgImage}`
|
||||
let rolePath = `role/${data.characterFullLengthPortrait}`
|
||||
let videoPath = HttpUnit.GetBgVideoUrl(data.characterStandbyPortrait) //视频路径
|
||||
Utils.sendInnerMsg(InnerMsgCode.SceneLayerBgUp, {bgPath:bgPath, rolePath:rolePath, videoPath:videoPath, videoType: VideoRoleType.Idle})
|
||||
}
|
||||
|
||||
|
||||
//region 开始游戏
|
||||
onStartClick() {
|
||||
Utils.Log("点击开始游戏");
|
||||
|
||||
this.finishGuide()
|
||||
|
||||
if (this.curLevelIdx == 0) {
|
||||
console.error("当前关卡为0,此关卡是占位用的")
|
||||
return
|
||||
}
|
||||
|
||||
let data = this.levelData[this.curLevelIdx]
|
||||
let level_id = data.id
|
||||
GameManager.EndGame()
|
||||
|
||||
//未解锁
|
||||
if (data.is_unlock != true) {
|
||||
if (HttpUnit.GetXiangqinTickets() <= 0) {
|
||||
SubManager.ShowPrompt("今日相亲次数已耗尽,无法提前解锁更多关卡");
|
||||
} else {
|
||||
this.lvUnlockId = level_id
|
||||
SubManager.ShowCommonAdDialog({
|
||||
content: "关卡未解锁,需要通过本关卡的前置关卡,或观看广告提前解锁关卡,并消耗 1 点相亲次数进入关卡",
|
||||
strAd: "观看广告",
|
||||
strLeft: "返回",
|
||||
adCallback: () => {
|
||||
SDKManager.show_reward_video_ad(this.node.uuid, 2)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//检测存档
|
||||
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 {
|
||||
SubManager.ShowConfirm({
|
||||
content: `确认消耗 1 点“相亲次数” 开始与【${data.name}】相亲吗?`,
|
||||
strYes: "确认",
|
||||
strNo: "返回",
|
||||
yesCallback: () => {
|
||||
this._startNewLevel(level_id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
//开始新关卡
|
||||
private _startNewLevel(level_id) {
|
||||
|
||||
if (HttpUnit.GetXiangqinTickets() <= 0) {
|
||||
SubManager.ShowPrompt("今日相亲次数已用完");
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
AudioManager.I.StopMusic() //停止背景音乐,进去后播放当前关卡音乐
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
|
||||
})
|
||||
}
|
||||
//region 继续关卡存档
|
||||
private _continueLevel(level_id, data) {
|
||||
|
||||
// //测试代码
|
||||
// if (true) {
|
||||
// let img = "132"
|
||||
// HttpUnit.ins.sendZhencangId({record_id:data.record_id, level_id:level_id, img:img}, (_data) => {
|
||||
// if (_data) {
|
||||
// SubManager.ShowPrompt("测试 获得珍藏卡:" + img)
|
||||
// GameManager.refreshZhencangCanget()
|
||||
// }
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
|
||||
|
||||
SubManager.ShowConfirm({
|
||||
content: "检测到进行中的记录,是否继续?",
|
||||
strYes: "继续",
|
||||
strNo: "重新开始",
|
||||
yesCallback: () => {
|
||||
//继续对话
|
||||
let lvCfg = this.levelData[this.curLevelIdx]
|
||||
let t_xindong = 0
|
||||
let t_jidong = 0
|
||||
let t_gandong = 0
|
||||
let t_xihuan = 0
|
||||
let t_taoyan = 0
|
||||
|
||||
//聊天记录
|
||||
GameManager.AddTalkRecord({talk:lvCfg.prologueMessage, isMe:false, score:-1, scoreBase:-1, scoreAdditional:0})
|
||||
let msg = data.messages || []
|
||||
for (let i = 0; i < msg.length; i++) {
|
||||
let m = msg[i]
|
||||
let talkData: I_NpcTalkBack = {
|
||||
aiEmoji: m.ai_emoji,
|
||||
aiResponse: m.ai_response,
|
||||
aiScore: m.ai_score || 0,
|
||||
aiBaseScore: m.ai_base_score || 0,
|
||||
aiAdditionalScore: m.ai_additional_score || 0,
|
||||
isFinished: m.is_finished,
|
||||
sourceCnt: m.source_cnt,
|
||||
userInput: m.user_input,
|
||||
judgement: m.judgement,
|
||||
}
|
||||
GameManager.CurNpcTalkData = talkData
|
||||
GameManager.AddStepScore(m.ai_score) //记录本次分数
|
||||
GameManager.AddTalkRecord({talk:m.user_input, isMe:true, score:-1, scoreBase:-1, scoreAdditional:0})
|
||||
GameManager.AddTalkRecord({talk:m.ai_response, isMe:false, score:m.ai_score, scoreBase:talkData.aiBaseScore, scoreAdditional:talkData.aiAdditionalScore})
|
||||
if (m.judgement == 0) {
|
||||
t_xindong++
|
||||
t_xihuan++
|
||||
} else if (m.judgement == 2) {
|
||||
t_taoyan++
|
||||
}
|
||||
if (m.ai_score >= 90) {
|
||||
t_jidong++
|
||||
}
|
||||
if (m.ai_score >= 100) {
|
||||
t_gandong++
|
||||
}
|
||||
}
|
||||
|
||||
GameManager.CurLevelId = level_id
|
||||
GameManager.CurLevelData = data.level
|
||||
GameManager.RecordId = data.record_id
|
||||
GameManager.srouceCnt = data.level.current_cnt
|
||||
GameManager.xindongCishu = t_xindong
|
||||
GameManager.jidongCishu = t_jidong
|
||||
GameManager.gandongCishu = t_gandong
|
||||
GameManager.npcFixTalkCountXihuan = t_xihuan
|
||||
GameManager.npcFixTalkCountTaoyan = t_taoyan
|
||||
GameManager.TurnToStage(E_TalkStage.myTalk)
|
||||
GameManager.I.connetSorcket(data.record_id) //连接socket
|
||||
this.setUIVisible(false)
|
||||
AudioManager.I.StopMusic() //停止背景音乐,进去后播放当前关卡音乐
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Talk_UI")
|
||||
},
|
||||
noCallback: () => {
|
||||
//结束上一次聊天
|
||||
HttpUnit.ins.sendLevelRestartReport({record_id: data.record_id}, (data) => {
|
||||
console.log("结束上一次聊天")
|
||||
})
|
||||
//重新开始
|
||||
this._startNewLevel(level_id)
|
||||
}
|
||||
})
|
||||
}
|
||||
/**手动解锁关卡后进入 */
|
||||
enterLevelAfterUnlock() {
|
||||
this._startNewLevel(this.lvUnlockId)
|
||||
this.lvUnlockId = ""
|
||||
}
|
||||
|
||||
|
||||
//点击客服
|
||||
onKefuClick() {
|
||||
SDKManager.OpenKefu()
|
||||
}
|
||||
|
||||
//增加相亲次数
|
||||
onAddTZClick() {
|
||||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||||
type: E_AD_TARGET.xiangqin, //加相亲次数
|
||||
content: GlobalValue.XiangQinAdTipsStr,
|
||||
adCallback: ()=>{
|
||||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||||
},
|
||||
shareCallback: ()=>{
|
||||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//心动回忆
|
||||
onTujianClick() {
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Tujian_UI")
|
||||
}
|
||||
|
||||
//设置
|
||||
onSettingClick() {
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Setting_UI")
|
||||
}
|
||||
|
||||
//gm
|
||||
onGMClick() {
|
||||
if (true) {
|
||||
SDKManager.startRecordRecognition()
|
||||
return
|
||||
}
|
||||
ViewManager.I.openBundlesView("UI/GM_UI")
|
||||
}
|
||||
|
||||
//领取珍藏奖励
|
||||
onRewardClick() {
|
||||
if (GameManager.zhencangCanget.length == 0) {
|
||||
SubManager.ShowConfirm({
|
||||
content: "暂无可领取的奖励,任意关卡任意聊天达到 100 分即可领取奖励",
|
||||
hideNo: true, //隐藏取消按钮
|
||||
yesCallback: () => {
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
ViewManager.I.openBundlesView("UI/StartUI/TujianReward_UI")
|
||||
}
|
||||
|
||||
//点击抖音侧边栏按钮
|
||||
onBDSidebarClick() {
|
||||
if (!SDKManager.isByteDance()) {
|
||||
//不是抖音平台
|
||||
return
|
||||
}
|
||||
ViewManager.I.openBundlesView("UI/StartUI/BDSidebar_UI")
|
||||
}
|
||||
|
||||
|
||||
//region 引导相关
|
||||
private _guideInterval: number = 0.3 //引导间隔
|
||||
//重置引导节点显示
|
||||
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.scheduleOnce(() => {
|
||||
let tempNode = instantiate(this.GuidePageItem)
|
||||
let tntf = tempNode.getComponent(UITransform)
|
||||
let wsize = view.getVisibleSize()
|
||||
tntf.setContentSize(wsize.width, tntf.height)
|
||||
//0号是占位的,从1开始
|
||||
for (let i=1; i<this.levelData.length; i++) {
|
||||
let data = this.levelData[i]
|
||||
if (data.is_unlock) {
|
||||
let node: any = instantiate(tempNode)
|
||||
this.guidePageView.addPage(node)
|
||||
Utils.parseNode(node)
|
||||
//背景图
|
||||
let bgPath = `bg/${data.bgImage}`
|
||||
ResManager.I.changeBundleSpriteFrame(node.guideBg.getComponent(Sprite), bgPath, "Raw")
|
||||
//角色立绘
|
||||
let rolePath = `role/${data.characterFullLengthPortrait}`
|
||||
ResManager.I.changeBundleSpriteFrame(node.guideRole.getComponent(Sprite), rolePath, "Raw")
|
||||
//名字
|
||||
Utils.setString(node.guideName, data.characterName)
|
||||
//介绍
|
||||
Utils.setString(node.guideDesc, data.description)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
GButton.RemoveAndBandClick(this._nodeTab.gs2BtnKaishi, this.onGuideKaishiClick, this);
|
||||
}, 0.1)
|
||||
|
||||
// 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()
|
||||
}
|
||||
//翻页容器事件回调
|
||||
guidePageViewEvent(param1, param2) {
|
||||
// console.log("guidePageViewEvent", param1, param2)
|
||||
this._nodeTab.gs2Zhisk.active = false
|
||||
let pageIdx = this.guidePageView.curPageIdx
|
||||
this.changeLevel(pageIdx+1)
|
||||
}
|
||||
//引导 下一步
|
||||
onGuide1OkClick() {
|
||||
this._nodeTab.guideStep1.active = false
|
||||
this.doGuideStep2()
|
||||
}
|
||||
//引导 开始游戏
|
||||
onGuideKaishiClick() {
|
||||
// this.finishGuide()
|
||||
|
||||
// let pageIdx = this.guidePageView.curPageIdx
|
||||
// let data = this.levelData[pageIdx+1]
|
||||
// let level_id = data.id
|
||||
// GameManager.EndGame()
|
||||
|
||||
// SubManager.ShowConfirm({
|
||||
// content: `确认消耗 1 点“相亲次数” 开始与【${data.name}】相亲吗?`,
|
||||
// strYes: "确认",
|
||||
// strNo: "返回",
|
||||
// yesCallback: () => {
|
||||
// this._startNewLevel(level_id)
|
||||
// }
|
||||
// })
|
||||
|
||||
this.onStartClick()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"c82c0121-ee1d-452d-a32c-17ffba4395ee","files":[],"subMetas":{},"userData":{}}
|
||||
@@ -1,231 +0,0 @@
|
||||
import { _decorator, Color, Label, Node, Sprite, view } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
import SubManager from '../SubManager';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**广告、分享的用途类型 */
|
||||
export enum E_AD_TARGET {
|
||||
/**加相亲次数 */
|
||||
xiangqin = 1,
|
||||
/**加聊天次数 */
|
||||
liaotian = 2,
|
||||
/**对话评分+10 */
|
||||
baoji = 3,
|
||||
/**撤回上一轮对话 */
|
||||
chehui = 4,
|
||||
/**收藏奖励 */
|
||||
shoucangJiangli = 5,
|
||||
}
|
||||
|
||||
//关卡内看广告弹窗界面
|
||||
@ccclass('TalkAdDialog')
|
||||
export class TalkAdDialog extends li_BaseView {
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data || {};
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
if (this._data.closeCallback) {
|
||||
this._data.closeCallback();
|
||||
}
|
||||
this.onClose();
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
if (this._data.closeCallback) {
|
||||
this._data.closeCallback();
|
||||
}
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnCancel, ()=>{
|
||||
if (this._data.closeCallback) {
|
||||
this._data.closeCallback();
|
||||
}
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnFree, ()=>{
|
||||
if (this._data.adCallback) {
|
||||
this._data.adCallback(true);
|
||||
}
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnShare, ()=>{
|
||||
if (this._data.type == E_AD_TARGET.liaotian) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData && levelData.share_num <= 0) {
|
||||
SubManager.ShowPrompt("今日分享次数已用完");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this._data.type == E_AD_TARGET.xiangqin && HttpUnit.GetXiangqinShareNum() <= 0) {
|
||||
SubManager.ShowPrompt("今日分享次数已用完");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._data.shareCallback) {
|
||||
this._data.shareCallback();
|
||||
}
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnAD, ()=>{
|
||||
if (this._data.type == E_AD_TARGET.liaotian) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData && levelData.ad_num <= 0) {
|
||||
SubManager.ShowPrompt("关卡内续航次数已用完");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this._data.type == E_AD_TARGET.xiangqin && HttpUnit.GetXiangqinAdNum() <= 0) {
|
||||
SubManager.ShowPrompt("今日广告次数已用完");
|
||||
return;
|
||||
}
|
||||
if (this._data.type == E_AD_TARGET.baoji) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData) {
|
||||
if (levelData.can_use_strength_cnt <= 0) {
|
||||
SubManager.ShowPrompt("关卡内加分次数已用完");
|
||||
return;
|
||||
}
|
||||
if (levelData.is_strength_take_effect == true) {
|
||||
SubManager.ShowPrompt("“甜蜜暴击”效果已生效,效果不可叠加");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._data.type == E_AD_TARGET.chehui) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData && levelData.can_use_cancel_cnt <= 0) {
|
||||
SubManager.ShowPrompt("关卡内撤回次数已用完");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._data.adCallback) {
|
||||
this._data.adCallback();
|
||||
}
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
Utils.setString(this._nodeTab.labContent, this._data.content);
|
||||
|
||||
//关卡内聊天不再显示分享按钮
|
||||
let showshare = false
|
||||
if (this._data.type == E_AD_TARGET.xiangqin) {
|
||||
showshare = true
|
||||
}
|
||||
this._nodeTab.btnShare.active = showshare;
|
||||
this._nodeTab.btnCancel.active = !showshare;
|
||||
|
||||
//免费使用次数逻辑
|
||||
let isfree = false
|
||||
if (this._data.type == E_AD_TARGET.baoji) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData) {
|
||||
if (levelData.first_strength == undefined || levelData.first_strength == 0) {
|
||||
isfree = true
|
||||
}
|
||||
}
|
||||
} else if (this._data.type == E_AD_TARGET.chehui) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData) {
|
||||
if (levelData.first_cancel == undefined || levelData.first_cancel == 0) {
|
||||
isfree = true
|
||||
}
|
||||
}
|
||||
}
|
||||
this._nodeTab.btnFree.active = isfree;
|
||||
this._nodeTab.btnAD.active = !isfree;
|
||||
|
||||
//次数用完后置灰按钮
|
||||
this.refreshBtnState()
|
||||
}
|
||||
|
||||
//刷新按钮状态
|
||||
private refreshBtnState() {
|
||||
//分享按钮
|
||||
let shareGray = false
|
||||
if (this._data.type == E_AD_TARGET.liaotian) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData && levelData.share_num <= 0) {
|
||||
shareGray = true
|
||||
}
|
||||
} else if (this._data.type == E_AD_TARGET.xiangqin) {
|
||||
if (HttpUnit.GetXiangqinShareNum() <= 0) {
|
||||
shareGray = true
|
||||
}
|
||||
}
|
||||
if (shareGray) {
|
||||
let shareSpt: Sprite = this._nodeTab.btnShare.getComponent(Sprite);
|
||||
shareSpt.grayscale = true;
|
||||
// shareSpt.color = new Color(173, 173, 173, 255);
|
||||
|
||||
}
|
||||
|
||||
//广告按钮
|
||||
let adGray = false
|
||||
if (this._data.type == E_AD_TARGET.liaotian) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData && levelData.ad_num <= 0) {
|
||||
Utils.setNodeGray(this._nodeTab.btnAD, true);
|
||||
adGray = true
|
||||
}
|
||||
} else if (this._data.type == E_AD_TARGET.xiangqin) {
|
||||
if (HttpUnit.GetXiangqinAdNum() <= 0) {
|
||||
Utils.setNodeGray(this._nodeTab.btnAD, true);
|
||||
adGray = true
|
||||
}
|
||||
} else if (this._data.type == E_AD_TARGET.baoji) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData) {
|
||||
if (levelData.can_use_strength_cnt <= 0 || levelData.is_strength_take_effect == true) {
|
||||
adGray = true
|
||||
}
|
||||
}
|
||||
} else if (this._data.type == E_AD_TARGET.chehui) {
|
||||
let levelData = GameManager.CurLevelData
|
||||
if (levelData && levelData.can_use_cancel_cnt <= 0) {
|
||||
adGray = true
|
||||
}
|
||||
}
|
||||
if (adGray) {
|
||||
let adSpt: Sprite = this._nodeTab.btnAD.getComponent(Sprite);
|
||||
adSpt.grayscale = true;
|
||||
// let adSpt1: Sprite = this._nodeTab.adSpt1.getComponent(Sprite);
|
||||
// adSpt1.color = new Color(255, 255, 255, 130);
|
||||
// let labYes: Label = this._nodeTab.labYes.getComponent(Label);
|
||||
// labYes.color = new Color(173, 173, 173, 255);
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5c295c71-fe3c-42b2-82b4-cc4d43866626",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c2aae745-c0e3-41c6-83d2-cca0e1ea02c9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import { _decorator, Node, Sprite } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//关卡提示界面
|
||||
@ccclass('Tips_UI')
|
||||
export class Tips_UI extends li_BaseView {
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
this.onClose();
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
let lvCfg = GameManager.getLevelCfg(GameManager.CurLevelId)
|
||||
//名字
|
||||
Utils.setString(this._nodeTab.labName, lvCfg.name)
|
||||
//职业名
|
||||
Utils.setString(this._nodeTab.labJob, lvCfg.characterRole)
|
||||
//喜欢话题
|
||||
Utils.setString(this._nodeTab.labXihuan, lvCfg.characterFavoriteTopic)
|
||||
//讨厌话题
|
||||
Utils.setString(this._nodeTab.labTaoyan, lvCfg.characterHateTopic)
|
||||
//性格
|
||||
Utils.setString(this._nodeTab.labXingge, `性格:${lvCfg.characterDisposition}`)
|
||||
//提示文本
|
||||
Utils.setString(this._nodeTab.labTips, lvCfg.tips)
|
||||
//半身像
|
||||
let halfPath = `halfPic/${lvCfg.characterHalfLengthPortrait}`
|
||||
let half = this._nodeTab.half.getComponent(Sprite)
|
||||
ResManager.I.changeBundleSpriteFrame(half, halfPath, "Raw")
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fba7776b-2a14-4690-81ea-8b727f2e9c36",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,327 +0,0 @@
|
||||
import { _decorator, instantiate, Node, PageView, Prefab, Sprite, tween, UIOpacity, UITransform, Vec3, view } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import GameRootUI from '../../Main/Common/GameRootUI';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import { E_AD_TARGET } from './TalkAdDialog';
|
||||
import { SDKManager } from '../../Main/Channel/SDKManager';
|
||||
import SubManager from '../SubManager';
|
||||
import { I_ZhengCangConfig } from '../../Main/Config/CommonConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
//图鉴奖励界面
|
||||
@ccclass('TujianReward_UI')
|
||||
export class TujianReward_UI extends li_BaseView {
|
||||
|
||||
@property(Prefab)
|
||||
private rewardPageItem: Prefab = null //角色页签节点
|
||||
private npcPageView: PageView = null //可领取角色页签容器
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
private rewardList: any[] = []; //可领取的奖励列表
|
||||
private targetPicId:number|null = null; //目标图片Id
|
||||
private isShowBigPic: boolean = false; //是否显示大图
|
||||
private autoClose: boolean = false; //是否自动关闭
|
||||
|
||||
/**缩放图片信息 */
|
||||
private bigPicInfo = {
|
||||
pageItem: null, //翻页item
|
||||
npcPic: null, //npc图片
|
||||
origScale: Vec3.ZERO, //原始缩放
|
||||
}
|
||||
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
this._nodeTab.BPMask1.active = false;
|
||||
this._nodeTab.labBPTalk.active = false;
|
||||
this.npcPageView = this._nodeTab.npcPageView.getComponent(PageView)
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.Data_ZhencangUp, this, this.resiveZhencangUp)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
this.onClose();
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnCancel, ()=>{
|
||||
this.onClose();
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnAD, ()=>{
|
||||
ViewManager.I.openBundlesView("UI/StartUI/TalkAdDialog", {
|
||||
type: E_AD_TARGET.shoucangJiangli, //收藏奖励
|
||||
content: "每日可以免费领取 1 次奖励,更多奖励需要“观看广告”领取",
|
||||
adCallback: (isfree:any)=>{
|
||||
if (isfree){
|
||||
this.doGetReward()
|
||||
} else {
|
||||
SDKManager.show_reward_video_ad(this.node.uuid, 1)
|
||||
}
|
||||
},
|
||||
shareCallback: ()=>{
|
||||
SDKManager.show_reward_share(this.node.uuid, 1)
|
||||
}
|
||||
})
|
||||
}, this);
|
||||
GButton.BandClick(this._nodeTab.btnFree, ()=>{
|
||||
this.doGetReward();
|
||||
}, this);
|
||||
|
||||
|
||||
SDKManager.register_video_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("视频广告回调", tag)
|
||||
if (tag == 1) {
|
||||
// 加次数
|
||||
SubManager.ShowPrompt("观看视频成功")
|
||||
this.doGetReward()
|
||||
}
|
||||
})
|
||||
SDKManager.register_share_reward(this.node.uuid, (tag:number)=>{
|
||||
console.log("分享回调", tag)
|
||||
if (tag == 1) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
this.scheduleOnce(()=>{
|
||||
this.refreshPageList()
|
||||
}, 0.1)
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
/**私家珍藏数据变化消息 */
|
||||
resiveZhencangUp(data:any) {
|
||||
this.refreshPageList()
|
||||
}
|
||||
|
||||
|
||||
/**刷新翻页容器 */
|
||||
refreshPageList() {
|
||||
let list = GameManager.zhencangCanget
|
||||
this._doRefreshWithData(list)
|
||||
}
|
||||
private _doRefreshWithData(data: any[]) {
|
||||
this.rewardList = []
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let item = data[i]
|
||||
let rcell = GameManager.getZhencangCfg(item.img)
|
||||
if (rcell) {
|
||||
this.rewardList.push(item)
|
||||
}
|
||||
}
|
||||
if (this.rewardList.length == 0) {
|
||||
if (this.isShowBigPic) {
|
||||
this.autoClose = true
|
||||
return
|
||||
}
|
||||
this.onClose();
|
||||
return;
|
||||
}
|
||||
|
||||
let wsize = view.getVisibleSize()
|
||||
let tempNode = instantiate(this.rewardPageItem)
|
||||
let tntf = tempNode.getComponent(UITransform)
|
||||
tntf.setContentSize(wsize.width, tntf.height)
|
||||
|
||||
let targetPageIdx = -1
|
||||
this.npcPageView.removeAllPages()
|
||||
for (let i=0; i<this.rewardList.length; i++) {
|
||||
let pnode: any = instantiate(tempNode)
|
||||
this.npcPageView.addPage(pnode)
|
||||
Utils.parseNode(pnode)
|
||||
let rewarddata = this.rewardList[i]
|
||||
let zhencangCfg: I_ZhengCangConfig = GameManager.getZhencangCfg(rewarddata.img)
|
||||
let lvcfg = GameManager.getLevelCfg(zhencangCfg.levelId)
|
||||
|
||||
//名字
|
||||
Utils.setString(pnode.labName, lvcfg.name)
|
||||
//简介
|
||||
Utils.setString(pnode.labDesc, zhencangCfg.giftSummary)
|
||||
|
||||
let cgPic: Sprite = pnode.npcPic.getComponent(Sprite)
|
||||
//图片
|
||||
let picUrl = `${HttpUnit.ZhenCangUrl}${zhencangCfg.giftImgName}.jpg`
|
||||
ResManager.I.changeRemoteSpriteFrame(cgPic, picUrl, "jpg")
|
||||
|
||||
//图片模糊
|
||||
ResManager.I.SetBlur(cgPic, true)
|
||||
|
||||
if (this.targetPicId && this.targetPicId == rewarddata.id) {
|
||||
targetPageIdx = i
|
||||
}
|
||||
|
||||
// GButton.RemoveAndBandClick(pnode.npcPic, ()=>{
|
||||
// this.changePicScale(pnode);
|
||||
// }, this, 0, null, null, false);
|
||||
}
|
||||
|
||||
//按钮状态
|
||||
let freecount = HttpUnit.GetZhencangFreeCount()
|
||||
let havefree = freecount > 0
|
||||
this._nodeTab.btnFree.active = havefree
|
||||
this._nodeTab.btnAD.active = !havefree
|
||||
|
||||
if (targetPageIdx >= 0) {
|
||||
this.scheduleOnce(()=>{
|
||||
this.npcPageView.scrollToPage(targetPageIdx, 0.5)
|
||||
}, 0)
|
||||
}
|
||||
this.targetPicId = null
|
||||
}
|
||||
// //翻页容器事件回调
|
||||
// guidePageViewEvent(param1, param2) {
|
||||
// let pageIdx = this.npcPageView.curPageIdx
|
||||
// this.changeLevel(pageIdx+1)
|
||||
// }
|
||||
|
||||
/**获取当前页奖励 */
|
||||
doGetReward() {
|
||||
let pageIdx = this.npcPageView.curPageIdx
|
||||
let data = this.rewardList[pageIdx]
|
||||
console.log("当前页奖励:", pageIdx, data)
|
||||
HttpUnit.ins.getZhencangReward({id: data.id}, (_data) => {
|
||||
if (_data) {
|
||||
let targetdata = this.rewardList[pageIdx+1]
|
||||
if (targetdata) {
|
||||
this.targetPicId = targetdata.id
|
||||
} else {
|
||||
targetdata = this.rewardList[pageIdx-1]
|
||||
if (targetdata) {
|
||||
this.targetPicId = targetdata.id
|
||||
}
|
||||
}
|
||||
|
||||
//region放大图片
|
||||
this.isShowBigPic = true
|
||||
let pnode:any = this.npcPageView.getPages()[pageIdx]
|
||||
let npcPic = pnode.npcPic
|
||||
let wpos = new Vec3(0,0,0);
|
||||
npcPic.getWorldPosition(wpos);
|
||||
let BigPicRoot:Node = this._nodeTab.BigPicRoot;
|
||||
let npos = BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
let npcPicClone = instantiate(npcPic);
|
||||
npcPicClone.setParent(BigPicRoot);
|
||||
npcPicClone.setPosition(npos);
|
||||
ResManager.I.SetBlur(npcPicClone.getComponent(Sprite), false)
|
||||
|
||||
let ttime = 0.2;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
let s = 1
|
||||
let windowSize = view.getVisibleSize(); // 获取窗口大小
|
||||
let picTf:UITransform = npcPicClone.getComponent(UITransform);
|
||||
if (picTf.height < windowSize.height) {
|
||||
s = windowSize.height / picTf.height;
|
||||
}
|
||||
tween((npcPicClone))
|
||||
.to(ttime, { scale: new Vec3(s, s, s), position: new Vec3(0, 0, 0) }, { easing: 'quadOut' })
|
||||
.call(() => {
|
||||
//刷新数据
|
||||
GameManager.refreshZhencangCanget()
|
||||
})
|
||||
.start();
|
||||
|
||||
//介绍背景
|
||||
this._nodeTab.BPMask1.active = true;
|
||||
this._nodeTab.BPMask1.setSiblingIndex(10)
|
||||
let opaMask = this._nodeTab.BPMask1.getComponent(UIOpacity);
|
||||
opaMask.opacity = 0;
|
||||
tween(opaMask)
|
||||
.to(ttime, { opacity: 255 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
//介绍文本
|
||||
this._nodeTab.labBPTalk.active = true;
|
||||
this._nodeTab.labBPTalk.setSiblingIndex(11)
|
||||
let zhencangCfg: I_ZhengCangConfig = GameManager.getZhencangCfg(data.img)
|
||||
Utils.setString(this._nodeTab.labBPTalk, zhencangCfg.giftSummary)
|
||||
let opaTalk = this._nodeTab.labBPTalk.getComponent(UIOpacity);
|
||||
opaTalk.opacity = 0;
|
||||
tween(opaTalk)
|
||||
.to(ttime, { opacity: 255 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
GButton.RemoveAndBandClick(npcPicClone, ()=>{
|
||||
npcPicClone.destroy();
|
||||
this._nodeTab.BPMask1.active = false;
|
||||
this._nodeTab.labBPTalk.active = false
|
||||
this.isShowBigPic = false;
|
||||
if (this.autoClose) {
|
||||
this.onClose();
|
||||
}
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//图片缩放逻辑
|
||||
changePicScale(item: any) {
|
||||
if (this.bigPicInfo.pageItem) {
|
||||
//缩小
|
||||
let npcPic = this.bigPicInfo.npcPic
|
||||
let wpos = new Vec3(0,0,0);
|
||||
this.bigPicInfo.pageItem.picRoot.getWorldPosition(wpos);
|
||||
let npos = this._nodeTab.BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
tween((npcPic))
|
||||
.to(ttime, { scale: this.bigPicInfo.origScale, position: npos }, { easing: 'quadOut' })
|
||||
.call(() => {
|
||||
npcPic.setParent(this.bigPicInfo.pageItem.picRoot);
|
||||
npcPic.setPosition(new Vec3(0,0,0));
|
||||
this.bigPicInfo.pageItem = null;
|
||||
this.bigPicInfo.npcPic = null;
|
||||
})
|
||||
.start();
|
||||
|
||||
} else {
|
||||
//放大
|
||||
let npcPic:Node = item.npcPic;
|
||||
this.bigPicInfo.pageItem = item;
|
||||
this.bigPicInfo.npcPic = npcPic;
|
||||
this.bigPicInfo.origScale = npcPic.scale.clone();
|
||||
|
||||
let wpos = new Vec3(0,0,0);
|
||||
npcPic.getWorldPosition(wpos);
|
||||
let BigPicRoot:Node = this._nodeTab.BigPicRoot;
|
||||
let npos = BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
npcPic.setParent(BigPicRoot);
|
||||
npcPic.setPosition(npos);
|
||||
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
//放大图片
|
||||
let s = 1
|
||||
let windowSize = view.getVisibleSize(); // 获取窗口大小
|
||||
let picTf:UITransform = npcPic.getComponent(UITransform);
|
||||
if (picTf.height < windowSize.height) {
|
||||
s = windowSize.height / picTf.height;
|
||||
}
|
||||
tween((npcPic))
|
||||
.to(ttime, { scale: new Vec3(s, s, s), position: new Vec3(0, 0, 0) }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "99d3359e-383e-40c0-8012-85029af777b1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,282 +0,0 @@
|
||||
import { _decorator, isValid, Node, Sprite, Toggle, tween, UIOpacity, UITransform, Vec3, view } from 'cc';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import li_BaseView from '../../Main/Common/li_BaseView';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import { tj_huiyi } from './tj_huiyi';
|
||||
import GameRootUI from '../../Main/Common/GameRootUI';
|
||||
import { tj_zhencang } from './tj_zhencang';
|
||||
import { tj_jilu } from './tj_jilu';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**宠物主界面页签类型 */
|
||||
export enum TujianPageType {
|
||||
None, //未知
|
||||
huiyi, //心动回忆
|
||||
zhencang, //私房珍藏
|
||||
jilu, //相遇记录
|
||||
}
|
||||
|
||||
//心动回忆界面
|
||||
@ccclass('Tujian_UI')
|
||||
export class Tujian_UI extends li_BaseView {
|
||||
|
||||
private _nodeTab: any = {};
|
||||
private _data;
|
||||
|
||||
private _pageType: TujianPageType = TujianPageType.huiyi;
|
||||
private tgHuiyi: Toggle = null!;//回忆
|
||||
private tgZhencang: Toggle = null!;//珍藏
|
||||
private tgJilu: Toggle = null!;//记录
|
||||
|
||||
private _btmHuiyi?: tj_huiyi;
|
||||
private _btmZhencang?: tj_zhencang;
|
||||
private _btmJilu?: tj_jilu;
|
||||
|
||||
/**缩放图片信息 */
|
||||
private bigPicInfo = {
|
||||
hyItem: null, //回忆item
|
||||
npcPic: null, //npc图片
|
||||
origScale: Vec3.ZERO, //原始缩放
|
||||
}
|
||||
|
||||
//----重写父类接口---------------------------------------
|
||||
onLoadCT() {
|
||||
this.registerListenner();
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
this.tgHuiyi = this._nodeTab.tjPage1.getComponent(Toggle)
|
||||
this.tgZhencang = this._nodeTab.tjPage2.getComponent(Toggle)
|
||||
this.tgJilu = this._nodeTab.tjPage3.getComponent(Toggle)
|
||||
}
|
||||
openUIDataCT(data: any): void {
|
||||
this._data = data
|
||||
}
|
||||
|
||||
|
||||
registerListenner() {
|
||||
Utils.addInnerEL(InnerMsgCode.UI_Tj_huiyi_Pic, this, this.resiveHuiyiPic)
|
||||
Utils.addInnerEL(InnerMsgCode.UI_Tj_huiyi_Lv, this, this.resiveHuiyiLv)
|
||||
Utils.addInnerEL(InnerMsgCode.Data_Redpoint, this, this.resiveZhencangRedpoint)
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
GButton.BandClick(this._nodeTab.mask, ()=>{
|
||||
this.onClose();
|
||||
}, this, 0, null, null, false);
|
||||
|
||||
GButton.BandClick(this._nodeTab.btnBack, ()=>{
|
||||
this.onClose();
|
||||
}, this);
|
||||
|
||||
GButton.RemoveAndBandClick(this._nodeTab.tjPage1,()=>{
|
||||
this.changePageType(TujianPageType.huiyi);
|
||||
},this)
|
||||
GButton.RemoveAndBandClick(this._nodeTab.tjPage2,()=>{
|
||||
this.changePageType(TujianPageType.zhencang);
|
||||
},this)
|
||||
GButton.RemoveAndBandClick(this._nodeTab.tjPage3,()=>{
|
||||
this.changePageType(TujianPageType.jilu);
|
||||
},this)
|
||||
|
||||
//回忆
|
||||
GButton.BandClick(this._nodeTab.btnBPBack, ()=>{
|
||||
this.doHideBigPic();
|
||||
}, this);
|
||||
this._nodeTab.BigPicUI.active = false;
|
||||
|
||||
|
||||
this.changePageType(TujianPageType.huiyi, true);
|
||||
this.refreshRedpointHuiyi();
|
||||
this.refreshRedpointZhencang();
|
||||
this.refreshRedpointJilu();
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
/**回忆显示大图 */
|
||||
resiveHuiyiPic(data: any) {
|
||||
this.doShowBigPic(data);
|
||||
}
|
||||
|
||||
/**前往回忆对应关卡 */
|
||||
resiveHuiyiLv(data: any) {
|
||||
this.onClose();
|
||||
}
|
||||
|
||||
resiveZhencangRedpoint(data: any) {
|
||||
this.refreshRedpointHuiyi();
|
||||
this.refreshRedpointZhencang();
|
||||
this.refreshRedpointJilu();
|
||||
}
|
||||
|
||||
|
||||
//region 切换页面
|
||||
changePageType(type: TujianPageType, isFroce: boolean = false) {
|
||||
if (this._pageType == type && !isFroce) {
|
||||
return
|
||||
}
|
||||
|
||||
//页签改变了,先隐藏所有节点
|
||||
if (this._pageType != type) {
|
||||
if(this._btmHuiyi) this._btmHuiyi.node.active = false;
|
||||
if(this._btmZhencang) this._btmZhencang.node.active = false;
|
||||
if(this._btmJilu) this._btmJilu.node.active = false;
|
||||
|
||||
}
|
||||
|
||||
this._pageType = type;
|
||||
|
||||
if (type == TujianPageType.huiyi) {//回忆
|
||||
this.tgHuiyi.isChecked = true;
|
||||
if (this._btmHuiyi) {
|
||||
this._btmHuiyi.node.active = true;
|
||||
} else {
|
||||
ResManager.I.loadSubpackagePrefab("UI/StartUI/TJ_Huiyi", (res:Node)=>{
|
||||
if (isValid(this._nodeTab.MidNode)) {
|
||||
this._nodeTab.MidNode.addChild(res)
|
||||
this._btmHuiyi = res.getComponent(tj_huiyi)
|
||||
if (this._pageType == TujianPageType.huiyi) {
|
||||
this._btmHuiyi.node.active = true;
|
||||
} else {
|
||||
this._btmHuiyi.node.active = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (type == TujianPageType.zhencang) { //珍藏
|
||||
this.tgZhencang.isChecked = true;
|
||||
if (this._btmZhencang) {
|
||||
this._btmZhencang.node.active = true;
|
||||
} else {
|
||||
ResManager.I.loadSubpackagePrefab("UI/StartUI/TJ_Zhencang", (res:Node)=>{
|
||||
if (isValid(this._nodeTab.MidNode)) {
|
||||
this._nodeTab.MidNode.addChild(res)
|
||||
this._btmZhencang = res.getComponent(tj_zhencang)
|
||||
if (this._pageType == TujianPageType.zhencang) {
|
||||
this._btmZhencang.node.active = true;
|
||||
} else {
|
||||
this._btmZhencang.node.active = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (type == TujianPageType.jilu) { //记录
|
||||
this.tgJilu.isChecked = true;
|
||||
if (this._btmJilu) {
|
||||
this._btmJilu.node.active = true;
|
||||
} else {
|
||||
ResManager.I.loadSubpackagePrefab("UI/StartUI/TJ_Jilu", (res:Node)=>{
|
||||
if (isValid(this._nodeTab.MidNode)) {
|
||||
this._nodeTab.MidNode.addChild(res)
|
||||
this._btmJilu = res.getComponent(tj_jilu)
|
||||
if (this._pageType == TujianPageType.jilu) {
|
||||
this._btmJilu.node.active = true;
|
||||
} else {
|
||||
this._btmJilu.node.active = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**显示大图 */
|
||||
doShowBigPic(data:any) {
|
||||
if (!data.hyItem) {
|
||||
return
|
||||
}
|
||||
let npcPic:Node = data.hyItem.npcPic;
|
||||
this.bigPicInfo.hyItem = data.hyItem;
|
||||
this.bigPicInfo.npcPic = npcPic;
|
||||
this.bigPicInfo.origScale = npcPic.scale.clone();
|
||||
|
||||
let wpos = new Vec3(0,0,0);
|
||||
npcPic.getWorldPosition(wpos);
|
||||
let BigPicRoot:Node = this._nodeTab.BigPicRoot;
|
||||
let npos = BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
npcPic.setParent(BigPicRoot);
|
||||
npcPic.setPosition(npos);
|
||||
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
//放大图片
|
||||
let s = 1
|
||||
let windowSize = view.getVisibleSize(); // 获取窗口大小
|
||||
let picTf:UITransform = npcPic.getComponent(UITransform);
|
||||
if (picTf.height < windowSize.height) {
|
||||
s = windowSize.height / picTf.height;
|
||||
}
|
||||
tween((npcPic))
|
||||
.to(ttime, { scale: new Vec3(s, s, s), position: new Vec3(0, 0, 0) }, { easing: 'quadOut' })
|
||||
.start();
|
||||
|
||||
//显示UI
|
||||
this._nodeTab.BigPicUI.active = true;
|
||||
Utils.setString(this._nodeTab.labBPTalk, data.talk);
|
||||
let bigPicUIOpa:UIOpacity = this._nodeTab.BigPicUI.getComponent(UIOpacity)
|
||||
bigPicUIOpa.opacity = 0;
|
||||
tween(bigPicUIOpa)
|
||||
.delay(ttime*0.7)
|
||||
.to(ttime*0.3, { opacity: 255 }, { easing: 'quadOut' })
|
||||
.start();
|
||||
}
|
||||
|
||||
/**隐藏大图 */
|
||||
doHideBigPic() {
|
||||
if (!this.bigPicInfo.hyItem) return;
|
||||
|
||||
let npcPic = this.bigPicInfo.npcPic
|
||||
let wpos = new Vec3(0,0,0);
|
||||
this.bigPicInfo.hyItem.picRoot.getWorldPosition(wpos);
|
||||
let npos = this._nodeTab.BigPicRoot.getComponent(UITransform).convertToNodeSpaceAR(wpos);
|
||||
// npcPic.setParent(this.bigPicInfo.hyItem.picRoot);
|
||||
// npcPic.setPosition(npos);
|
||||
|
||||
let ttime = 0.3;
|
||||
GameRootUI.DisableOper(ttime+0.1)
|
||||
tween((npcPic))
|
||||
.to(ttime, { scale: this.bigPicInfo.origScale, position: npos }, { easing: 'quadOut' })
|
||||
.call(() => {
|
||||
npcPic.setParent(this.bigPicInfo.hyItem.picRoot);
|
||||
npcPic.setPosition(new Vec3(0,0,0));
|
||||
this.bigPicInfo.hyItem = null;
|
||||
this.bigPicInfo.npcPic = null;
|
||||
})
|
||||
.start();
|
||||
|
||||
let bigPicUIOpa:UIOpacity = this._nodeTab.BigPicUI.getComponent(UIOpacity)
|
||||
tween(bigPicUIOpa)
|
||||
.to(ttime*0.3, { opacity: 0 }, { easing: 'quadOut' })
|
||||
.call(() => {
|
||||
this._nodeTab.BigPicUI.active = false;
|
||||
})
|
||||
.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 刷新红点 回忆
|
||||
refreshRedpointHuiyi() {
|
||||
let isshow = HttpUnit.IsHaveHuiyiRedpoint()
|
||||
this._nodeTab.rp_1.active = isshow;
|
||||
}
|
||||
// 刷新红点 珍藏
|
||||
refreshRedpointZhencang() {
|
||||
let isshow = HttpUnit.IsHaveZhencangRedpoint()
|
||||
this._nodeTab.rp_2.active = isshow;
|
||||
}
|
||||
// 刷新红点 记录
|
||||
refreshRedpointJilu() {
|
||||
let isshow = false
|
||||
this._nodeTab.rp_3.active = isshow;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "eb7c1524-b668-4a53-afb0-4b43fa9bdd44",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
import { _decorator, Component, instantiate, isValid, Label, Material, Node, Prefab, Sprite, tween, UIOpacity, v3 } from 'cc';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import HXZ_ScrollViewList from '../../Main/Common/ScrollViewList';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import { I_HuiyiInfo } from '../../Main/Config/CommonConfig';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import SubManager from '../SubManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**图鉴 - 心动回忆 */
|
||||
@ccclass('tj_huiyi')
|
||||
export class tj_huiyi extends Component {
|
||||
|
||||
private itemClone!: any;
|
||||
@property(HXZ_ScrollViewList)
|
||||
Item_List: HXZ_ScrollViewList = null!; // 回忆列表
|
||||
@property(Prefab)
|
||||
Item_Temp: Prefab = null!;//被克隆的模板
|
||||
|
||||
private _nodeTab:any = {}
|
||||
private huiyiDataList: I_HuiyiInfo[] = []
|
||||
|
||||
protected onLoad(): void {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
this.itemClone = instantiate(this.Item_Temp);
|
||||
this.Item_List.setTemplateItem(this.itemClone);
|
||||
|
||||
}
|
||||
start() {
|
||||
|
||||
this.huiyiDataList = []
|
||||
let lvlist = GameManager.getLevelCfgList()
|
||||
let isunlock = false
|
||||
for (let i = 0; i < lvlist.length; i++) {
|
||||
let data = lvlist[i]
|
||||
if (data.id) {
|
||||
for (let j=0; j<4; j++) {
|
||||
isunlock = false
|
||||
// if (data.is_unlock && data.star >= j) {
|
||||
// isunlock = true
|
||||
// }
|
||||
if (j > 0) {
|
||||
if (data.star >= j) {
|
||||
isunlock = true
|
||||
}
|
||||
} else {
|
||||
if (data.is_played == true) {
|
||||
isunlock = true
|
||||
}
|
||||
}
|
||||
let item: I_HuiyiInfo = {
|
||||
lvId: data.id,
|
||||
star: j,
|
||||
unlock: isunlock,
|
||||
}
|
||||
this.huiyiDataList.push(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
let cellnum = Math.ceil(this.huiyiDataList.length / 2)
|
||||
this.Item_List.numItems = cellnum
|
||||
|
||||
//已读红点 回忆
|
||||
let isshow = HttpUnit.IsHaveHuiyiRedpoint()
|
||||
if (isshow) {
|
||||
HttpUnit.ins.readRedpointHuiyi({}, (data) => {
|
||||
if (data) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//region 列表渲染
|
||||
onRenderItemList(node: any, idx: number) {
|
||||
if(!isValid(node)) {return}
|
||||
if (!node.inited) {
|
||||
node.inited = true;
|
||||
Utils.parseNode(node);
|
||||
|
||||
let opa1:UIOpacity = node.hyItem1.getComponent(UIOpacity)
|
||||
let opa2:UIOpacity = node.hyItem2.getComponent(UIOpacity)
|
||||
|
||||
opa1.opacity = 0
|
||||
tween(opa1)
|
||||
.delay(0.1)
|
||||
.to(0.2, {opacity: 255})
|
||||
.start()
|
||||
|
||||
opa2.opacity = 0
|
||||
tween(opa2)
|
||||
.delay(0.15)
|
||||
.to(0.2, {opacity: 255})
|
||||
.start()
|
||||
}
|
||||
|
||||
let startIdx = idx * 2
|
||||
this.refreshHuiyiCell(node.hyItem1, startIdx)
|
||||
this.refreshHuiyiCell(node.hyItem2, startIdx+1)
|
||||
}
|
||||
//刷新单个节点
|
||||
private refreshHuiyiCell(hyItem:any, idx:number) {
|
||||
let data = this.huiyiDataList[idx]
|
||||
if (!data) {
|
||||
hyItem.active = false
|
||||
return
|
||||
}
|
||||
hyItem.active = true
|
||||
if (!hyItem.inited) {
|
||||
hyItem.inited = true;
|
||||
Utils.parseNode(hyItem);
|
||||
}
|
||||
|
||||
let lvCfg = GameManager.getLevelCfg(data.lvId)
|
||||
//名字
|
||||
Utils.setString(hyItem.npcName, lvCfg.name)
|
||||
|
||||
let picPath = "" //表情图
|
||||
let showPicName = "" //显示的图片名称
|
||||
let talkStr = "" //对话
|
||||
let lockStr = "" //解锁提示
|
||||
if (data.star == 3) {
|
||||
picPath = `cg3/${lvCfg.threeStarCG}`
|
||||
showPicName = lvCfg.threeStarCG
|
||||
talkStr = lvCfg.threeStarSummary
|
||||
lockStr = "3星成功结婚解锁"
|
||||
} else if (data.star == 2) {
|
||||
picPath = `cg2/${lvCfg.twoStarCG}`
|
||||
showPicName = lvCfg.twoStarCG
|
||||
talkStr = lvCfg.twoStarSummary
|
||||
lockStr = "2星成为恋人解锁"
|
||||
} else if (data.star == 1) {
|
||||
picPath = `cg1/${lvCfg.oneStarCG}`
|
||||
showPicName = lvCfg.oneStarCG
|
||||
talkStr = lvCfg.oneStarSummary
|
||||
lockStr = "1星通过相亲解锁"
|
||||
} else {
|
||||
picPath = `cg0/${lvCfg.failureCG}`
|
||||
showPicName = lvCfg.failureCG
|
||||
talkStr = lvCfg.failureSummary
|
||||
lockStr = "0星通关失败解锁"
|
||||
}
|
||||
let cgPic: Sprite = hyItem.npcPic.getComponent(Sprite)
|
||||
ResManager.I.changeBundleSpriteFrame(cgPic, picPath, "Raw")
|
||||
|
||||
if (data.unlock) {
|
||||
//已解锁
|
||||
hyItem.LockNode.active = false
|
||||
Utils.setString(hyItem.labTalk, talkStr)
|
||||
ResManager.I.SetBlur(cgPic, false)
|
||||
} else {
|
||||
//未解锁
|
||||
hyItem.LockNode.active = true
|
||||
Utils.setString(hyItem.labTalk, lockStr)
|
||||
ResManager.I.SetBlur(cgPic, true)
|
||||
}
|
||||
//星级
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
let starSpt = hyItem["star" + i].getComponent(Sprite)
|
||||
let starPath = ""
|
||||
if(data.star == 3) {
|
||||
starPath = "lv_23"
|
||||
} else if (data.star < i) {
|
||||
starPath = "lv_21"
|
||||
} else {
|
||||
starPath = "lv_22"
|
||||
}
|
||||
ResManager.I.changeBundleSpriteFrame(starSpt, starPath, "Zhujiemian")
|
||||
}
|
||||
|
||||
GButton.RemoveAndBandClick(hyItem, ()=>{
|
||||
if (data.unlock) {
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Tj_huiyi_Pic, {hyItem:hyItem, talk:talkStr})
|
||||
HttpUnit.ins.sendEventTujian({type:1, img:showPicName}) //type: 1=心动回忆 2=私房珍藏
|
||||
} else {
|
||||
SubManager.ShowConfirm({
|
||||
content: "该奖励尚未解锁,是否跳转至对应关卡进行攻略?",
|
||||
strYes: "前往攻略",
|
||||
yesCallback: () => {
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Tj_huiyi_Lv, {lvId:data.lvId})
|
||||
}
|
||||
})
|
||||
}
|
||||
}, this, 0, null, null, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3df5275c-73ad-4ab9-a5f3-ed34668cc230",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
import { _decorator, Component, instantiate, isValid, Label, Material, Node, Prefab, Sprite, tween, UIOpacity, v3 } from 'cc';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import HXZ_ScrollViewList from '../../Main/Common/ScrollViewList';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import { I_HuiyiInfo, I_TalkRecordInfo } from '../../Main/Config/CommonConfig';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import SubManager from '../SubManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
import { ViewManager } from '../../Main/Manager/ViewManager';
|
||||
import { E_RECORD_TYPE } from './Record_UI';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**图鉴 - 相遇记录 */
|
||||
@ccclass('tj_jilu')
|
||||
export class tj_jilu extends Component {
|
||||
|
||||
private itemClone!: any;
|
||||
@property(HXZ_ScrollViewList)
|
||||
Item_List: HXZ_ScrollViewList = null!; // 回忆列表
|
||||
@property(Prefab)
|
||||
Item_Temp: Prefab = null!;//被克隆的模板
|
||||
|
||||
private _nodeTab:any = {}
|
||||
private huiyiDataList: any[] = []
|
||||
private nextPage = 1 // 当前页数,每10个记录为一页
|
||||
|
||||
protected onLoad(): void {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
this.itemClone = instantiate(this.Item_Temp);
|
||||
this.Item_List.setTemplateItem(this.itemClone);
|
||||
|
||||
}
|
||||
start() {
|
||||
this._nodeTab.EmptyNode.active = false
|
||||
this.getNextPage()
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
/**获取下一批列表 */
|
||||
getNextPage() {
|
||||
HttpUnit.ins.getTalkJilu({limit:10, page: this.nextPage}, (data) => {
|
||||
if (data && data.length > 0) {
|
||||
this.nextPage++
|
||||
this.huiyiDataList = this.huiyiDataList.concat(data)
|
||||
let len = this.huiyiDataList.length;
|
||||
this.Item_List.numItems = len
|
||||
} else {
|
||||
if (this.nextPage == 1) {
|
||||
this._nodeTab.EmptyNode.active = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//region 列表渲染
|
||||
onRenderItemList(node: any, idx: number) {
|
||||
if(!isValid(node)) {return}
|
||||
if (!node.inited) {
|
||||
node.inited = true;
|
||||
Utils.parseNode(node);
|
||||
}
|
||||
|
||||
let data = this.huiyiDataList[idx]
|
||||
let lvCfg = GameManager.getLevelCfg(data.level.id)
|
||||
//名字
|
||||
Utils.setString(node.labName, lvCfg.name)
|
||||
//头像
|
||||
let headPath = `headLevel/${lvCfg.icon}`
|
||||
ResManager.I.changeBundleSpriteFrame(node.head1.getComponent(Sprite), headPath, "Raw")
|
||||
//时间
|
||||
Utils.setString(node.labTime, data.level.end_time)
|
||||
//最后一句对话
|
||||
let lastSay = ""
|
||||
if (data.messages && data.messages.length > 0) {
|
||||
lastSay = data.messages[data.messages.length - 1].ai_response || ""
|
||||
}
|
||||
lastSay = Utils.clampAiAnswer(lastSay, 32)
|
||||
Utils.setString(node.labTalk, lastSay)
|
||||
|
||||
GButton.RemoveAndBandClick(node, ()=>{
|
||||
this.showTalkDetail(idx);
|
||||
}, this);
|
||||
|
||||
//翻到底部加载下一页
|
||||
if (idx >= this.huiyiDataList.length-1) {
|
||||
this.getNextPage()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**显示详细聊天 */
|
||||
showTalkDetail(idx: number) {
|
||||
let data = this.huiyiDataList[idx]
|
||||
let lvCfg = GameManager.getLevelCfg(data.level.id)
|
||||
let talkRecordList: I_TalkRecordInfo[] = []; //对话记录
|
||||
//开场白
|
||||
talkRecordList.push({talk:lvCfg.prologueMessage, isMe:false, score:-1, scoreBase:-1, scoreAdditional:0})
|
||||
//对话
|
||||
let messages = data.messages || []
|
||||
for (let i = 0; i < messages.length; i++) {
|
||||
let m = messages[i]
|
||||
let aiBaseScore = m.ai_base_score || 0
|
||||
let aiAdditionalScore = m.ai_additional_score || 0
|
||||
talkRecordList.push({talk:m.user_input, isMe:true, score:-1, scoreBase:-1, scoreAdditional:0})
|
||||
talkRecordList.push({talk:m.ai_response, isMe:false, score:m.ai_score, scoreBase:aiBaseScore, scoreAdditional:aiAdditionalScore})
|
||||
}
|
||||
ViewManager.I.openBundlesView("UI/StartUI/Record_UI", {mode:E_RECORD_TYPE.Jilu, talkList:talkRecordList, lvId:data.level.id})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "096b97ad-8ffd-4565-89aa-f6c563b08aa7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
import { _decorator, Component, instantiate, isValid, Label, Material, Node, Prefab, Sprite, tween, UIOpacity, v3 } from 'cc';
|
||||
import Utils from '../../Main/Common/Utils';
|
||||
import HXZ_ScrollViewList from '../../Main/Common/ScrollViewList';
|
||||
import GameManager from '../../Main/Manager/GameManager';
|
||||
import { I_HuiyiInfo, I_ZhengCangConfig } from '../../Main/Config/CommonConfig';
|
||||
import ResManager from '../../Main/Manager/ResManager';
|
||||
import { GButton } from '../../Main/Common/GButton';
|
||||
import { InnerMsgCode } from '../../Main/Config/InnerMsgCode';
|
||||
import SubManager from '../SubManager';
|
||||
import HttpUnit from '../../Main/Common/HttpUnit';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**图鉴 - 私房珍藏 */
|
||||
@ccclass('tj_zhencang')
|
||||
export class tj_zhencang extends Component {
|
||||
|
||||
private itemClone!: any;
|
||||
@property(HXZ_ScrollViewList)
|
||||
Item_List: HXZ_ScrollViewList = null!; // 回忆列表
|
||||
@property(Prefab)
|
||||
Item_Temp: Prefab = null!;//被克隆的模板
|
||||
|
||||
private _nodeTab:any = {}
|
||||
private huiyiDataList: any[] = []
|
||||
private nextPage = 1 // 当前页数,每10个记录为一页
|
||||
|
||||
protected onLoad(): void {
|
||||
Utils.parseNode(this.node, this._nodeTab)
|
||||
|
||||
this.itemClone = instantiate(this.Item_Temp);
|
||||
this.Item_List.setTemplateItem(this.itemClone);
|
||||
|
||||
}
|
||||
start() {
|
||||
this._nodeTab.EmptyNode.active = false;
|
||||
this.getNextPage()
|
||||
|
||||
//已读红点 珍藏
|
||||
let isshow = HttpUnit.IsHaveZhencangRedpoint()
|
||||
if (isshow) {
|
||||
HttpUnit.ins.readRedpointZhencang({}, (data) => {
|
||||
if (data) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
//刷新列表
|
||||
getNextPage() {
|
||||
let self = this
|
||||
HttpUnit.ins.getZhencangList({limit:10, page:this.nextPage, type:1}, (data) => {
|
||||
let lastPage = self.nextPage
|
||||
let lastlen = self.huiyiDataList.length
|
||||
if (data && data.data && data.data.length > 0) {
|
||||
self.nextPage++
|
||||
for (let i = 0; i < data.data.length; i++) {
|
||||
let item = data.data[i]
|
||||
let rcell = GameManager.getZhencangCfg(item.img)
|
||||
if (rcell) {
|
||||
this.huiyiDataList.push(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let thislen = self.huiyiDataList.length
|
||||
if (thislen > lastlen) {
|
||||
let len = Math.ceil(self.huiyiDataList.length / 2);
|
||||
self.Item_List.numItems = len
|
||||
} else {
|
||||
if (lastPage == self.nextPage) {
|
||||
if (thislen == 0) {
|
||||
self._nodeTab.EmptyNode.active = true
|
||||
}
|
||||
} else {
|
||||
self.getNextPage()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//region 列表渲染
|
||||
onRenderItemList(node: any, idx: number) {
|
||||
if(!isValid(node)) {return}
|
||||
if (!node.inited) {
|
||||
node.inited = true;
|
||||
Utils.parseNode(node);
|
||||
|
||||
let opa1:UIOpacity = node.zcItem1.getComponent(UIOpacity)
|
||||
let opa2:UIOpacity = node.zcItem2.getComponent(UIOpacity)
|
||||
|
||||
opa1.opacity = 0
|
||||
tween(opa1)
|
||||
.delay(0.1)
|
||||
.to(0.2, {opacity: 255})
|
||||
.start()
|
||||
|
||||
opa2.opacity = 0
|
||||
tween(opa2)
|
||||
.delay(0.15)
|
||||
.to(0.2, {opacity: 255})
|
||||
.start()
|
||||
}
|
||||
|
||||
let startIdx = idx * 2
|
||||
this.refreshHuiyiCell(node.zcItem1, startIdx)
|
||||
this.refreshHuiyiCell(node.zcItem2, startIdx+1)
|
||||
|
||||
//翻到底部加载下一页
|
||||
if (startIdx+1 >= this.huiyiDataList.length-1) {
|
||||
this.getNextPage()
|
||||
}
|
||||
}
|
||||
//刷新单个节点
|
||||
private refreshHuiyiCell(zcItem:any, idx:number) {
|
||||
let data = this.huiyiDataList[idx]
|
||||
if (!data) {
|
||||
zcItem.active = false
|
||||
return
|
||||
}
|
||||
zcItem.active = true
|
||||
if (!zcItem.inited) {
|
||||
zcItem.inited = true;
|
||||
Utils.parseNode(zcItem);
|
||||
}
|
||||
|
||||
let zhencangCfg: I_ZhengCangConfig = GameManager.getZhencangCfg(data.img)
|
||||
let lvcfg = GameManager.getLevelCfg(zhencangCfg.levelId)
|
||||
|
||||
//名字
|
||||
Utils.setString(zcItem.npcName, lvcfg.name)
|
||||
//简介
|
||||
let talkstr = Utils.clampAiAnswer(zhencangCfg.giftSummary, 54)
|
||||
Utils.setString(zcItem.labTalk, talkstr)
|
||||
|
||||
let cgPic: Sprite = zcItem.npcPic.getComponent(Sprite)
|
||||
//图片
|
||||
let picUrl = `${HttpUnit.ZhenCangUrl}${zhencangCfg.giftImgName}.jpg`
|
||||
ResManager.I.changeRemoteSpriteFrame(cgPic, picUrl, "jpg")
|
||||
|
||||
GButton.RemoveAndBandClick(zcItem, ()=>{
|
||||
Utils.sendInnerMsg(InnerMsgCode.UI_Tj_huiyi_Pic, {hyItem:zcItem, talk:zhencangCfg.giftSummary})
|
||||
HttpUnit.ins.sendEventTujian({type:2, img:zhencangCfg.giftImgName}) //type: 1=心动回忆 2=私房珍藏
|
||||
}, this, 0, null, null, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "7706b8b5-0af0-4916-a9ea-579b3c15ecbb",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user