Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -1,30 +1,34 @@
|
||||
|
||||
//消息枚举
|
||||
export enum InnerMsgCode {
|
||||
GM_UI_Close, //关闭GM界面
|
||||
SceneLayerBgUp, //刷新场景背景图
|
||||
UI_Talk_Back, //从聊天界面返回
|
||||
UI_BD_Sidebar, //抖音侧边栏状态刷新
|
||||
UI_Socket_Timeout, //socket超时
|
||||
UI_TalkStageUp, //更改聊天阶段
|
||||
UI_ResartGame, //重新开始游戏
|
||||
UI_ShowPrompt, //显示飘字提示
|
||||
UI_Tj_huiyi_Pic, //显示回忆大图
|
||||
UI_Tj_huiyi_Lv, //前往回忆对应关卡
|
||||
GM_UI_Close, //关闭GM界面
|
||||
SceneLayerBgUp, //刷新场景背景图
|
||||
UI_Talk_Back, //从聊天界面返回
|
||||
UI_BD_Sidebar, //抖音侧边栏状态刷新
|
||||
UI_Socket_Timeout, //socket超时
|
||||
UI_TalkStageUp, //更改聊天阶段
|
||||
UI_ResartGame, //重新开始游戏
|
||||
UI_ShowPrompt, //显示飘字提示
|
||||
UI_Tj_huiyi_Pic, //显示回忆大图
|
||||
UI_Tj_huiyi_Lv, //前往回忆对应关卡
|
||||
|
||||
Data_UserInfo_Up, //用户信息更新
|
||||
Data_NpcTalkBack, //NPC对话返回
|
||||
Data_LevelStarUp, //刷新关卡星级
|
||||
Data_ChehuiUp, //撤回消息
|
||||
Data_BDSidebarReward, //抖音侧边栏奖励领取消息
|
||||
Data_Redpoint, //红点刷新消息
|
||||
Data_ZhencangUp, //私家珍藏更新消息
|
||||
Data_UserInfo_Up, //用户信息更新
|
||||
Data_NpcTalkBack, //NPC对话返回
|
||||
Data_LevelStarUp, //刷新关卡星级
|
||||
Data_ChehuiUp, //撤回消息
|
||||
Data_BDSidebarReward, //抖音侧边栏奖励领取消息
|
||||
Data_Redpoint, //红点刷新消息
|
||||
Data_ZhencangUp, //私家珍藏更新消息
|
||||
|
||||
BgVideo_Ready, //背景视频准备完成
|
||||
BgVideo_End, //背景视频播放完毕
|
||||
BgVideo_Ready, //背景视频准备完成
|
||||
BgVideo_End, //背景视频播放完毕
|
||||
|
||||
Chat_DialogRefresh,
|
||||
SimplePlayVide,
|
||||
LanguageChange,
|
||||
}
|
||||
|
||||
Chat_DialogRefresh,
|
||||
SimplePlayVide,
|
||||
LanguageChange,
|
||||
}
|
||||
export enum InnerEventCode {
|
||||
DiamondCountChanged = 15618,
|
||||
IsVipChanged,
|
||||
VipEndDayChange,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import LanguageUtils from "../../Main/Common/LanguageUtils";
|
||||
import Utils from "../../Main/Common/Utils";
|
||||
import { InnerEventCode } from "../../Main/Config/InnerMsgCode";
|
||||
|
||||
export class CommercialData {
|
||||
private static _instance: CommercialData;
|
||||
public static get Instance(): CommercialData {
|
||||
if (!CommercialData._instance) {
|
||||
CommercialData._instance = new CommercialData();
|
||||
}
|
||||
return CommercialData._instance;
|
||||
}
|
||||
|
||||
private _diamondCount: number = 0;
|
||||
private _isVip: boolean = false;
|
||||
private _vipEndTime: number = 0;
|
||||
|
||||
public get diamondCount(): number {
|
||||
return this._diamondCount;
|
||||
}
|
||||
|
||||
public set diamondCount(value: number) {
|
||||
if (this._diamondCount !== value) {
|
||||
this._diamondCount = Math.max(0, value);
|
||||
Utils.sendInnerMsg(InnerEventCode.DiamondCountChanged, {
|
||||
count: this._diamondCount,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public get isVip(): boolean {
|
||||
return this._isVip;
|
||||
}
|
||||
|
||||
public set isVip(value: boolean) {
|
||||
if (this._isVip !== value) {
|
||||
this._isVip = value;
|
||||
Utils.sendInnerMsg(InnerEventCode.IsVipChanged, { isVip: this._isVip });
|
||||
}
|
||||
}
|
||||
|
||||
public get vipEndTime(): number {
|
||||
return this._vipEndTime;
|
||||
}
|
||||
|
||||
public set vipEndTime(value: number) {
|
||||
if (this._vipEndTime !== value) {
|
||||
this._vipEndTime = Math.max(0, value);
|
||||
Utils.sendInnerMsg(InnerEventCode.VipEndDayChange, {
|
||||
vipEndTime: this._vipEndTime,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private constructor() {
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
public addDiamonds(amount: number): void {
|
||||
if (amount > 0) {
|
||||
this.diamondCount += amount;
|
||||
}
|
||||
}
|
||||
|
||||
public spendDiamonds(amount: number): boolean {
|
||||
if (amount > 0 && this._diamondCount >= amount) {
|
||||
this.diamondCount -= amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public setVipTime(timeInSeconds: number): void {
|
||||
this._vipEndTime = timeInSeconds;
|
||||
if (timeInSeconds > 0) {
|
||||
this.isVip = true;
|
||||
}
|
||||
}
|
||||
public getVipLeftTime(): string {
|
||||
const dateNow = new Date();
|
||||
const timeDiff = Math.abs(this._vipEndTime - dateNow.getTime());
|
||||
const hours = Math.floor(timeDiff / (1000 * 60 * 60));
|
||||
|
||||
if (hours >= 24) {
|
||||
return (
|
||||
(hours % 24).toString() + LanguageUtils.getText("purchasepanel.day")
|
||||
);
|
||||
}
|
||||
const minutes = Math.floor((timeDiff / (1000 * 60)) % 60);
|
||||
//const seconds = Math.floor((timeDiff / 1000) % 60);
|
||||
return `${hours}${LanguageUtils.getText(
|
||||
"purchasepanel.hour"
|
||||
)}:${minutes}${LanguageUtils.getText("purchasepanel.minute")}`;
|
||||
}
|
||||
|
||||
private loadData(): void {
|
||||
//假数据
|
||||
this._diamondCount = 18556;
|
||||
this._isVip = true;
|
||||
|
||||
//const dateNow = new Date();
|
||||
const dateEndTime = new Date("2025-08-30T12:00:00Z");
|
||||
|
||||
this._vipEndTime = dateEndTime.getTime();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b63bfbf7-eac0-4713-84ca-dbb1d0ea1c5c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
import { _decorator, Component, Label, Node } from "cc";
|
||||
import li_BaseView from "../../../Main/Common/li_BaseView";
|
||||
import Utils from "../../../Main/Common/Utils";
|
||||
import { CommercialData } from "../../data/CommercialData";
|
||||
import ConfigManager from "../../manager/ConfigManager";
|
||||
import { GButton } from "../../../Main/Common/GButton";
|
||||
import { PurchasePanelItem } from "../../uiitems/PurchasePanelItem";
|
||||
import { ViewManager } from "../../../Main/Manager/ViewManager";
|
||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||
import { InnerEventCode } from "../../../Main/Config/InnerMsgCode";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PurchasePanel")
|
||||
export class PurchasePanel extends li_BaseView {
|
||||
private _nodeTab: any = {};
|
||||
|
||||
private diamondCount: Label;
|
||||
private vipLeftTime: Label;
|
||||
private vipPriceTag: Label;
|
||||
|
||||
private tryBuyId: number;
|
||||
|
||||
@property([PurchasePanelItem])
|
||||
public items: PurchasePanelItem[] = [];
|
||||
|
||||
onLoadCT(): void {
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
this.diamondCount = this._nodeTab.diamondNumber.getComponent(Label);
|
||||
this.vipLeftTime = this._nodeTab.vipText.getComponent(Label);
|
||||
this.vipPriceTag = this._nodeTab.vipPrice.getComponent(Label);
|
||||
this.bandBtn();
|
||||
|
||||
//订阅商业化数据事件
|
||||
Utils.addInnerEL(
|
||||
InnerEventCode.DiamondCountChanged,
|
||||
this,
|
||||
this.onDiamondCountChanged
|
||||
);
|
||||
Utils.addInnerEL(
|
||||
InnerEventCode.VipEndDayChange,
|
||||
this,
|
||||
this.onVipEndDayChange
|
||||
);
|
||||
|
||||
//获取商业化数据
|
||||
this.getPlayerMerData();
|
||||
|
||||
const cfg = ConfigManager.tables.TbPurchaseConfig;
|
||||
for (let index = 0; index < this.items.length; index++) {
|
||||
const element = this.items[index];
|
||||
element.init(this, cfg.get(1001 + index));
|
||||
}
|
||||
this.updateView();
|
||||
}
|
||||
bandBtn() {
|
||||
GButton.BandClick(
|
||||
this._nodeTab.BuyVipBtn,
|
||||
() => {
|
||||
//TODO:购买vip
|
||||
console.log("购买Vip");
|
||||
},
|
||||
this
|
||||
);
|
||||
GButton.BandClick(
|
||||
this._nodeTab.BuyDiamondBtn,
|
||||
() => {
|
||||
//TODO:购买钻石
|
||||
console.log("购买钻石,商品id:" + this.tryBuyId);
|
||||
},
|
||||
this
|
||||
);
|
||||
GButton.BandClick(
|
||||
this._nodeTab.QUIT,
|
||||
() => {
|
||||
//TODO:购买钻石
|
||||
ViewManager.I.closeView(this.node);
|
||||
},
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
updateView() {
|
||||
this.getPlayerMerData();
|
||||
|
||||
const vipPrice = ConfigManager.tables.TbPurchaseConfig.get(2001).count;
|
||||
this.vipPriceTag.string = `$ ${vipPrice}`;
|
||||
|
||||
this.items.forEach((item) => item.show());
|
||||
}
|
||||
|
||||
setDiamondTag(id: number) {
|
||||
this.tryBuyId = id;
|
||||
}
|
||||
|
||||
getPlayerMerData() {
|
||||
//todo: 获取服务器玩家商业化数据
|
||||
this.diamondCount.string = CommercialData.Instance.diamondCount.toString();
|
||||
const leftTime = CommercialData.Instance.getVipLeftTime();
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
|
||||
onDiamondCountChanged(data: any) {
|
||||
this.diamondCount.string = data.count.toString();
|
||||
}
|
||||
|
||||
onVipEndDayChange(data: any) {
|
||||
const leftTime = CommercialData.Instance.getVipLeftTime();
|
||||
this.vipLeftTime.string = LanguageUtils.getText(
|
||||
"purchasepanel.vip_left"
|
||||
).replace("${leftTime}", leftTime);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
Utils.removeInnerEL(
|
||||
InnerEventCode.DiamondCountChanged,
|
||||
this,
|
||||
this.onDiamondCountChanged
|
||||
);
|
||||
Utils.removeInnerEL(
|
||||
InnerEventCode.VipEndDayChange,
|
||||
this,
|
||||
this.onVipEndDayChange
|
||||
);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "c657f7a9-a2dc-42a6-80df-1d7dd729f268",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -97,11 +97,17 @@ export class ThemePanel extends li_BaseView {
|
||||
|
||||
GButton.BandClick(this._nodeTab.ChatWithRecBtn, this.chatWithRec, this);
|
||||
|
||||
GButton.BandClick(this._nodeTab.ShopPanelEntry, this.enterShop, this);
|
||||
|
||||
Utils.addInnerEL(InnerMsgCode.LanguageChange, this, () => {
|
||||
this.recName.string = LanguageUtils.getText(this.rectNameKey);
|
||||
});
|
||||
}
|
||||
|
||||
enterShop() {
|
||||
ViewManager.I.openBundlesView("PurchasePanel");
|
||||
}
|
||||
|
||||
chatWithRec() {
|
||||
NavigationManager.Instance.navigateToChat(this.recId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { _decorator, Component, Label, Node } from "cc";
|
||||
import { PurchasePanel } from "../ui/panels/PurchasePanel";
|
||||
import { PurchaseConfig } from "../../schema/schema";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("PurchasePanelItem")
|
||||
export class PurchasePanelItem extends Component {
|
||||
@property(Label)
|
||||
count: Label;
|
||||
@property(Label)
|
||||
price: Label;
|
||||
|
||||
baseView: PurchasePanel;
|
||||
data: PurchaseConfig;
|
||||
public init(base: PurchasePanel, data: PurchaseConfig) {
|
||||
this.baseView = base;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public show() {
|
||||
this.count.string = this.data.desc.toString();
|
||||
this.price.string = this.data.count.toString();
|
||||
}
|
||||
|
||||
onClickThis() {
|
||||
this.baseView.setDiamondTag(this.data.id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0c5a1f4a-a909-49dd-802c-06e27182eb79",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
+17801
-15460
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user