Files
18xchat/assets/Scripts/test/DemoManager.ts
T

61 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-07-22 16:43:10 +08:00
import { find } from "cc";
2025-07-21 22:14:06 +08:00
import { ChatContentsLayout } from "./ChatContentsLayout";
2025-07-22 16:43:10 +08:00
import { DemoData } from "./DemoData";
2025-07-25 15:20:02 +08:00
import {GirlDetailPanel} from "db://assets/Scripts/test/GirlDetailPanel";
import {ChatPanel} from "db://assets/Scripts/test/ChatPanel";
import {GirlListPanel} from "db://assets/Scripts/test/girlListPanel/GirlListPanel";
2025-07-22 16:43:10 +08:00
export class DemoManager {
private static _instance: DemoManager;
public static getInstance() {
if (!this._instance) {
this._instance = new DemoManager();
}
return this._instance;
}
private constructor() {
this.demoData = new DemoData();
}
2025-07-21 22:14:06 +08:00
demoData: DemoData;
public layoutout: ChatContentsLayout;
2025-07-25 15:20:02 +08:00
public detailPanel:GirlDetailPanel;
public chatPanel:ChatPanel;
public girlListPanel:GirlListPanel;
2025-07-21 22:14:06 +08:00
2025-07-22 16:43:10 +08:00
EnterChat(id: number) {
2025-07-25 15:20:02 +08:00
if(this.chatPanel==null)
{
this.chatPanel = find("Canvas/ChatPanel").getComponent(ChatPanel);
}
this.chatPanel.node.active = true;
this.detailPanel.node.active = false;
2025-07-22 16:43:10 +08:00
}
EnterDetail(id: number) {
2025-07-25 15:20:02 +08:00
if(this.girlListPanel==null)
{
this.girlListPanel =find("Canvas/GirlListPanel").getComponent(GirlListPanel);
}
this.girlListPanel.node.active = false;
if(this.detailPanel==null)
{
this.detailPanel = find("Canvas/GirlDetailPanel").getComponent(GirlDetailPanel);
}
this.detailPanel.refresh(id);
this.detailPanel.node.active = true;
2025-07-21 22:14:06 +08:00
}
public updateDialog(isPlayer: boolean, str: string) {
this.demoData.pushDialog(isPlayer, str);
console.log("update dialog");
this.layoutout.UpdateDialog(this.getDialogs());
}
public getDialogs() {
return this.demoData.GetDialogs();
}
}