[add] Lobby 按鈕功能
This commit is contained in:
@@ -45,7 +45,7 @@ export default class AvatarPanel extends UIPanel {
|
||||
protected ImplementInitial(...initData: any[]): void {
|
||||
let self: this = this;
|
||||
this.Main = initData[0];
|
||||
this._avatars = this.Main.config.Avatars;
|
||||
this._avatars = this.Main.Config.Avatars;
|
||||
let btnItem: cc.Node = cc.instantiate(this.BtnItem);
|
||||
btnItem.active = false;
|
||||
// 載入兔兔設定 更新UI
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import AvatarPanel from "../AvatarPanel/AvatarPanel";
|
||||
import CSMessage from "../Common/Message/CSMessage";
|
||||
import { CoroutineV2 } from "../Engine/CatanEngine/CoroutineV2/CoroutineV2";
|
||||
import HoldButton from "../Engine/Component/Button/HoldButton";
|
||||
import LocalStorageData from "../Engine/Data/LocalStorageData";
|
||||
@@ -13,7 +14,7 @@ import { GameRecord, MemberData, ScoreResult } from "./MemberData";
|
||||
import RecordManager from "./RecordManager";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
/** 最上層彈跳試窗與各場景間傳參數(因為熱更新APP在LOGING才能加入) */
|
||||
|
||||
@ccclass
|
||||
export class Badminton extends cc.Component {
|
||||
//#region property
|
||||
@@ -75,13 +76,13 @@ export class Badminton extends cc.Component {
|
||||
public CurMemberList: string[] = [];
|
||||
|
||||
/** 預設球員(塞空格) */
|
||||
public defaultMember: MemberData = new MemberData("那個");
|
||||
public DefaultMember: MemberData = new MemberData("那個");
|
||||
|
||||
/** RecordManager */
|
||||
public record: RecordManager = new RecordManager(this);
|
||||
public Record: RecordManager = new RecordManager(this);
|
||||
|
||||
/** ConfigManager */
|
||||
public config: ConfigManager = new ConfigManager(this);
|
||||
public Config: ConfigManager = new ConfigManager(this);
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -92,16 +93,18 @@ export class Badminton extends cc.Component {
|
||||
private _m_teamList: cc.Node[] = [];
|
||||
|
||||
/** 各玩家分數比賽次數記錄 */
|
||||
private _dictionary: Map<string, ScoreResult> = new Map<string, ScoreResult>();
|
||||
private _m_results: Map<string, ScoreResult> = new Map<string, ScoreResult>();
|
||||
|
||||
/** 比賽歷史記錄(記錄每場次的參賽玩家組合與順序) [{time,team:[[name1,name2],[name3,name4]],type,score:[t1,t2] },] */
|
||||
private _m_history: GameRecord[] = [];
|
||||
|
||||
private _isLoopStartDistribution: boolean = false;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region get set
|
||||
|
||||
public static get Today(): string { return NodePackageManager.Instance.Dayjs().format("yyyyMMdd"); }
|
||||
public static get Today(): string { return NodePackageManager.Instance.Dayjs().format("YYYYMMDD"); }
|
||||
|
||||
public get TeamCount(): number { return this._m_teamList.length; }
|
||||
|
||||
@@ -115,11 +118,12 @@ export class Badminton extends cc.Component {
|
||||
protected onLoad(): void {
|
||||
Badminton._instance = this;
|
||||
let self: this = this;
|
||||
new NodePackageManager();
|
||||
new LocalStorageData();
|
||||
let AsyncFunction: () => IterableIterator<any> = function* (): IterableIterator<any> {
|
||||
yield CoroutineV2.Parallel(
|
||||
self.config.Init(),
|
||||
self.record.Init(),
|
||||
self.Config.Init(),
|
||||
self.Record.Init(),
|
||||
).Start();
|
||||
CoroutineV2.Parallel(
|
||||
self.Lobby.Show(),
|
||||
@@ -137,6 +141,12 @@ export class Badminton extends cc.Component {
|
||||
CoroutineV2.Single(AsyncFunction()).Start();
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
if (this._isLoopStartDistribution) {
|
||||
this.OnClickStartDistribution();
|
||||
}
|
||||
}
|
||||
|
||||
public *Show(): IterableIterator<any> {
|
||||
CoroutineV2.Single(this.ScoreBoard.Hide()).Start();
|
||||
this._initUI();
|
||||
@@ -182,7 +192,7 @@ export class Badminton extends cc.Component {
|
||||
item.node.getChildByName("Btn_Del").on("click", () => { this.OnDelMember(idx); }, this);
|
||||
let picObj: cc.Node = item.node.getChildByName("Avatar").getChildByName("Pic");
|
||||
if (picObj != null) {
|
||||
picObj.getComponent(cc.Sprite).spriteFrame = this.config.GetAvatarPicById(this.TeamMemberList[idx].AvatarId);
|
||||
picObj.getComponent(cc.Sprite).spriteFrame = this.Config.GetAvatarPicById(this.TeamMemberList[idx].AvatarId);
|
||||
picObj.parent.getComponent(HoldButton).OnInvoke.AddListener(() => { this.OnChangeAvatar(+idx); });
|
||||
picObj.parent.on("click", () => {
|
||||
item.isChecked = !item.isChecked;
|
||||
@@ -255,6 +265,22 @@ export class Badminton extends cc.Component {
|
||||
}
|
||||
}
|
||||
|
||||
public OnClickStartDistribution(): void {
|
||||
this.CurMemberList.Clear();
|
||||
let chkMemberList: string[] = [];
|
||||
for (let member of this._m_toggleList) {
|
||||
if (member.isChecked) {
|
||||
chkMemberList.push(member.node.getChildByName("Name").getComponent(cc.Label).string);
|
||||
}
|
||||
}
|
||||
chkMemberList = this.GetListRandomize(chkMemberList);
|
||||
this._updateTeamShow(chkMemberList);
|
||||
}
|
||||
|
||||
public OnClickLoopStartDistribution(): void {
|
||||
this._isLoopStartDistribution = !this._isLoopStartDistribution;
|
||||
}
|
||||
|
||||
public GetMemberListFromTeamView(): string[] {
|
||||
let chkMemberList: string[] = [];
|
||||
for (let i: number = 0; i < this._m_teamList.length; i++) {
|
||||
@@ -319,7 +345,7 @@ export class Badminton extends cc.Component {
|
||||
|
||||
team.getChildByName("Member_" + (j + 1)).getChildByName("Name").getComponent(cc.Label).string = name;
|
||||
team.getChildByName("Member_" + (j + 1)).getComponent(cc.Sprite).enabled = name !== this.GetDefaultMemberName();
|
||||
team.getChildByName("Member_" + (j + 1)).getComponent(cc.Sprite).spriteFrame = this.config.GetAvatarPicByName(name);
|
||||
team.getChildByName("Member_" + (j + 1)).getComponent(cc.Sprite).spriteFrame = this.Config.GetAvatarPicByName(name);
|
||||
team.active = true;
|
||||
}
|
||||
}
|
||||
@@ -330,12 +356,19 @@ export class Badminton extends cc.Component {
|
||||
team.getChildByName("Member_1").getChildByName("Name").getComponent(cc.Label).string = name_1;
|
||||
team.getChildByName("Member_2").getChildByName("Name").getComponent(cc.Label).string = name_2;
|
||||
team.getChildByName("Member_1").getComponent(cc.Sprite).enabled = true;
|
||||
team.getChildByName("Member_1").getComponent(cc.Sprite).spriteFrame = this.config.GetAvatarPicByName(name_1);
|
||||
team.getChildByName("Member_1").getComponent(cc.Sprite).spriteFrame = this.Config.GetAvatarPicByName(name_1);
|
||||
team.getChildByName("No").getComponent(cc.Label).string = (index + 1).toString();
|
||||
team.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
public OnClickCleanTeam(): void {
|
||||
for (let obj of this._m_toggleList) {
|
||||
obj.isChecked = false;
|
||||
this._onChangeSelMember(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public OnDelMember(index: number): void {
|
||||
let viewTeamList: string[] = this.GetMemberListFromTeamView();
|
||||
let player: MemberData = this.TeamMemberList[index];
|
||||
@@ -349,562 +382,173 @@ export class Badminton extends cc.Component {
|
||||
}
|
||||
}
|
||||
|
||||
public GetListRandomize(list: any[]): any[] {
|
||||
list.sort(function (): number {
|
||||
return (0.5 - Math.random());
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public OnClickAddMember(): void {
|
||||
let newName: string = this.inputNameText.string;
|
||||
if (String.IsNullOrWhiteSpace(newName)) {
|
||||
return;
|
||||
}
|
||||
let members: string[] = this.TeamMemberList.map(m => m.Name);
|
||||
if (members.includes(newName)) {
|
||||
CSMessage.CreateYesMsg(newName + "已經在名單內");
|
||||
return;
|
||||
}
|
||||
this.TeamMemberList.push(new MemberData(newName));
|
||||
this.inputNameText.string = "";
|
||||
let viewTeamList: string[] = this.GetMemberListFromTeamView();
|
||||
this._initUI();
|
||||
this._updateTeamShow(viewTeamList);
|
||||
this._updateGameResult();
|
||||
}
|
||||
|
||||
public OnChangeAvatar(index: number): void {
|
||||
CoroutineV2.Single(this.AvatarPanel.Show(this.TeamMemberList[index])).Start();
|
||||
}
|
||||
|
||||
public LoadStatus(): void {
|
||||
// console.log("LoadStatus ======= ");
|
||||
// try {
|
||||
// let members: string[] = this.TeamMemberList.map(m => Object.values(m)[0]);
|
||||
// var str_member = PlayerPrefs.GetString("member", "[]");
|
||||
// var str_avatar = PlayerPrefs.GetString("avatar", "[]");
|
||||
// List < string > member_list = ((List<object>)MiniJSON.Json.Deserialize(str_member)).ConvertAll((val) => ((string)val).Trim());
|
||||
// List < int > avatar_list = ((List<object>)MiniJSON.Json.Deserialize(str_avatar)).ConvertAll((val) => (int)(long)val);
|
||||
// for (int i = 0; i < member_list.Count; i++)
|
||||
// {
|
||||
// string member = member_list[i];
|
||||
// if (!members.Contains(member)) {
|
||||
// if (member != GetDefaultMemberName()) {
|
||||
// teamMemberList.Add(new MemberData() { name = member, avatarId = avatar_list[i] });
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// teamMemberList.Find((m) => m.name == member).avatarId = avatar_list[i];
|
||||
// }
|
||||
// }
|
||||
// curMemberList.Clear();
|
||||
// foreach(Toggle member in m_toggleList) { member.isOn = false; }
|
||||
// curMemberList = member_list.ConvertAll(v => v);
|
||||
// //curMemberList = member_list;
|
||||
// InitUI();
|
||||
public SaveStatus(): void {
|
||||
// member
|
||||
let member_list: string[] = this.GetMemberListFromTeamView();
|
||||
LocalStorageData.Instance.Member = member_list;
|
||||
|
||||
// for (int i = 0; i < member_list.Count; i++)
|
||||
// {
|
||||
// string member = member_list[i];
|
||||
// int index = members.IndexOf(member);
|
||||
// if (index != -1) {
|
||||
// m_toggleList[index].isOn = true;
|
||||
// }
|
||||
// else {
|
||||
// // 那個
|
||||
// }
|
||||
// }
|
||||
// UpdateTeamShow(member_list);
|
||||
// //updateCurSelMember();
|
||||
// LoadScoreResult();
|
||||
// voicePanel.SetProps(MiniJSON.Json.Deserialize(PlayerPrefs.GetString("voice", "null")) as Dictionary<string, object>);
|
||||
// UpdateGameResult();
|
||||
// }
|
||||
// catch (System.Exception err)
|
||||
// {
|
||||
// Debug.Log(err);
|
||||
// }
|
||||
let avatar_list: number[] = member_list.map(m => this.Config.GetAvatarDataByName(m).ID);
|
||||
LocalStorageData.Instance.Avatar = avatar_list;
|
||||
|
||||
LocalStorageData.Instance.IsSingleMode = this.ScoreBoard.isSingleMode ? 1 : 0;
|
||||
let selected_list: string[] = this.ScoreBoard.selectedList;
|
||||
LocalStorageData.Instance.Selected = selected_list;
|
||||
|
||||
let firstTeam: number = this.ScoreBoard.firstTeam;
|
||||
LocalStorageData.Instance.FirstTeam = firstTeam;
|
||||
|
||||
// TODO ScoreBoard
|
||||
// let score_list = this.ScoreBoard.GetScoreWinList();
|
||||
// LocalStorageData.Instance.Score = score_list;
|
||||
|
||||
let result_dict: Map<string, Object> = new Map<string, Object>();
|
||||
this._m_results.forEach((item: ScoreResult, key: string, map: Map<string, ScoreResult>) => {
|
||||
let obj: Object = {
|
||||
win: item.Win,
|
||||
total: item.Total,
|
||||
};
|
||||
result_dict.set(key, obj);
|
||||
});
|
||||
LocalStorageData.Instance.Results = result_dict;
|
||||
// // 增加紀錄日期
|
||||
LocalStorageData.Instance.Date = Badminton.Today;
|
||||
|
||||
if (this.HistoryPanel != null) {
|
||||
// 增加隊伍歷史紀錄
|
||||
// 格式 json: {"日期":[玩家1,玩家2,...],"日期":[玩家1,玩家2,...]}
|
||||
let history_dict: Map<string, string[]> = this.HistoryPanel.History;
|
||||
LocalStorageData.Instance.HistoryTeam = history_dict;
|
||||
}
|
||||
}
|
||||
|
||||
public LoadStatus(): void {
|
||||
console.log("LoadStatus ======= ");
|
||||
try {
|
||||
let members: string[] = this.TeamMemberList.map(m => m.Name);
|
||||
let member_list: string[] = LocalStorageData.Instance.Member;
|
||||
let avatar_list: number[] = LocalStorageData.Instance.Avatar;
|
||||
for (let i: number = 0; i < member_list.length; i++) {
|
||||
let member: string = member_list[i];
|
||||
if (!members.includes(member)) {
|
||||
if (member !== this.GetDefaultMemberName()) {
|
||||
this.TeamMemberList.push(new MemberData(member, avatar_list[i]));
|
||||
}
|
||||
} else {
|
||||
this.TeamMemberList.find((m) => m.Name === member).AvatarId = avatar_list[i];
|
||||
}
|
||||
}
|
||||
this.CurMemberList.Clear();
|
||||
for (const members of this._m_toggleList) {
|
||||
members.isChecked = false;
|
||||
}
|
||||
this.CurMemberList = member_list.Copy();
|
||||
this._initUI();
|
||||
|
||||
for (let i: number = 0; i < member_list.length; i++) {
|
||||
let member: string = member_list[i];
|
||||
let index: number = members.indexOf(member);
|
||||
if (index !== -1) {
|
||||
this._m_toggleList[index].isChecked = true;
|
||||
this._onChangeSelMember(this._m_toggleList[index]);
|
||||
} else {
|
||||
// 那個
|
||||
}
|
||||
}
|
||||
this._updateTeamShow(member_list);
|
||||
this._loadScoreResult();
|
||||
// TODO voicePanel
|
||||
// voicePanel.SetProps(MiniJSON.Json.Deserialize(PlayerPrefs.GetString("voice", "null")) as Dictionary<string, object>);
|
||||
this._updateGameResult();
|
||||
} catch (err: any) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
private _loadScoreResult(): void {
|
||||
let self: this = this;
|
||||
this.ScoreBoard.isSingleMode = LocalStorageData.Instance.IsSingleMode === 1;
|
||||
|
||||
let selected_list: string[] = LocalStorageData.Instance.Selected;
|
||||
|
||||
if (selected_list.length > 0) {
|
||||
// TODO ScoreBoard
|
||||
// this.ScoreBoard.ResetScore();
|
||||
// this.ScoreBoard.SetPlayerList(selected_list);
|
||||
|
||||
let firstTeam: number = LocalStorageData.Instance.FirstTeam;
|
||||
this.ScoreBoard.firstTeam = firstTeam;
|
||||
|
||||
// TODO ScoreBoard
|
||||
// if (firstTeam !== -1) {
|
||||
// let score_list: number[] = LocalStorageData.Instance.Score;
|
||||
// this.ScoreBoard.SetScoreWinList(score_list);
|
||||
// }
|
||||
}
|
||||
this._m_results.clear();
|
||||
let result_list: Map<string, Object> = LocalStorageData.Instance.Results;
|
||||
if (result_list.size > 0) {
|
||||
result_list.forEach((item: Object, key: string) => {
|
||||
let val: Object = item;
|
||||
let result: ScoreResult = new ScoreResult(+item["win"], +item["total"]);
|
||||
self._m_results.set(key, result);
|
||||
this.Config.GetMemberDataByName(key).Score = result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _updateGameResult(): void {
|
||||
let self: this = this;
|
||||
this._m_toggleList.forEach((member: cc.Toggle, index: number, array: cc.Toggle[]) => {
|
||||
if (self._m_results.has(member.node.Find("Name").getComponent(cc.Label).string)) {
|
||||
let result: ScoreResult = self._m_results.get(member.node.Find("Name").getComponent(cc.Label).string);
|
||||
member.node.Find("Score").getComponent(cc.Label).string = "" + result.Total;
|
||||
} else {
|
||||
member.node.Find("Score").getComponent(cc.Label).string = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public OnClickClearAllGameResult(): void {
|
||||
this._m_results.clear();
|
||||
this._m_history.Clear();
|
||||
this._updateGameResult();
|
||||
// 清除計分後 寫入紀錄
|
||||
this.SaveStatus();
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
// //#region 初始化
|
||||
// onLoad(): void {
|
||||
// Badminton._instance = this;
|
||||
// this.ElementCommonUI = this.getComponent(CommonElementUI);
|
||||
// this.LastScene = SceneName.Loading;
|
||||
// this.NowScene = SceneName.Login;
|
||||
// this._cachErrorHandler();
|
||||
// this._initialEngine();
|
||||
// }
|
||||
public Log(a: any, b: any): void {
|
||||
console.log(b);
|
||||
}
|
||||
|
||||
// onDestroy(): void {
|
||||
// Badminton._instance = null;
|
||||
// }
|
||||
// private _initialEngine(): void {
|
||||
// if (cc.sys.isBrowser) {
|
||||
// this._createIframeCloseBtn();
|
||||
// }
|
||||
// cc.game.addPersistRootNode(this.node);
|
||||
// // 多点触摸事件屏蔽
|
||||
// cc.macro.ENABLE_MULTI_TOUCH = false;
|
||||
// // WEBVIEW
|
||||
// this._setWeb();
|
||||
// //
|
||||
// CSResource.Initialize();
|
||||
// CSMessage.Initialize(this.SourceMessage, this.MessageContent);
|
||||
// if (cc.sys.isBrowser) {
|
||||
// this.node.removeComponent(cc.Mask);
|
||||
// }
|
||||
// // MASK
|
||||
// let maskNode: cc.Node = null;
|
||||
// if (this.ElementCommonUI.DelayLoadMask) {
|
||||
// maskNode = cc.instantiate(this.ElementCommonUI.DelayLoadMask);
|
||||
// this.Masks.addChild(maskNode, 0, "DelayLoadMask");
|
||||
// }
|
||||
// if (this.ElementCommonUI.LoginLoadMask) {
|
||||
// maskNode = cc.instantiate(this.ElementCommonUI.LoginLoadMask);
|
||||
// this.Masks.addChild(maskNode, 0, "LoginLoadMask");
|
||||
// }
|
||||
// CSMask.Initialize(this.Masks);
|
||||
// // 所有專案共用
|
||||
// new LocalStorageData();
|
||||
// new ScreenResize();
|
||||
// new CSAudio();
|
||||
// // 同類型專案共用
|
||||
// new UserStorageData();
|
||||
// new UserData();
|
||||
// // 同類型專案各取所需(只接DispatchCallback)
|
||||
// new (require("../../ElementUI/DataReceived/BadmintonData") as typeof
|
||||
// import("../../ElementUI/DataReceived/BadmintonData")).default();
|
||||
// new (require("../../ElementUI/DataReceived/GameCheckData") as typeof
|
||||
// import("../../ElementUI/DataReceived/GameCheckData")).default();
|
||||
// // 監聽
|
||||
// UIManager.DireEvent.AddCallback(this._changeDire, this);
|
||||
// ScreenResize.Instance.AddEven();
|
||||
|
||||
// }
|
||||
|
||||
// public CheckAddEven(): void {
|
||||
// this.ElementCommonUI.RemoveAllClickEffect();
|
||||
// if (cc.Canvas.instance && !cc.Canvas.instance.node.hasEventListener(cc.Node.EventType.TOUCH_START)) {
|
||||
// cc.Canvas.instance.node.on(cc.Node.EventType.TOUCH_START, this.ElementCommonUI.ShowClickEffect, this.ElementCommonUI, true);
|
||||
// cc.Canvas.instance.node.on(cc.Node.EventType.TOUCH_END, this.ElementCommonUI.ShowClickEffect, this.ElementCommonUI, true);
|
||||
// cc.Canvas.instance.node.on(cc.Node.EventType.TOUCH_CANCEL, this.ElementCommonUI.ShowClickEffect, this.ElementCommonUI, true);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private _changeDire(param: any[] = null): void {
|
||||
// if (!this.node) {
|
||||
// return;
|
||||
// }
|
||||
// this.node.setPosition(ScreenResize.CanvasSize[ScreenResize.IsPortrait].x / 2, ScreenResize.CanvasSize[ScreenResize.IsPortrait].y / 2);
|
||||
// this.node.SetSizeDelta(ScreenResize.CanvasSize[ScreenResize.IsPortrait]);
|
||||
// //this.WebContent.node.SetSizeDelta(cc.v2(ScreenResize.CanvasSize[ScreenResize.IsPortrait].x + 0, ScreenResize.CanvasSize[ScreenResize.IsPortrait].y + 0));
|
||||
// if (!CC_PREVIEW && CC_DEBUG && this.LogContent) {
|
||||
// this.LogContent.SetSizeDelta(ScreenResize.CanvasSize[ScreenResize.IsPortrait]);
|
||||
// this.LogContent.getComponentInChildren(cc.EditBox).node.setPosition(-ScreenResize.CanvasSize[ScreenResize.IsPortrait].x / 2, -ScreenResize.CanvasSize[ScreenResize.IsPortrait].y / 2);
|
||||
// this.LogContent.getComponentInChildren(cc.EditBox).node.SetSizeDelta(cc.v2(ScreenResize.CanvasSize[ScreenResize.IsPortrait].x - 200, ScreenResize.CanvasSize[ScreenResize.IsPortrait].y));
|
||||
// this.LogContent.getChildByName("CLOSE").setPosition(ScreenResize.CanvasSize[ScreenResize.IsPortrait].x / 2 - 100, ScreenResize.CanvasSize[ScreenResize.IsPortrait].y / 2 - 100);
|
||||
// this.LogContent.getChildByName("CLEAR").setPosition(ScreenResize.CanvasSize[ScreenResize.IsPortrait].x / 2 - 100, ScreenResize.CanvasSize[ScreenResize.IsPortrait].y / 2 - 300);
|
||||
// }
|
||||
// this.ElementContent.scale = (ScreenResize.IsPortrait == 1) ? 1 : UIManager.ScreenScale;
|
||||
// Badminton.DataReceivedEvent.DispatchCallback([Badminton.DataType.ChangeDire]);
|
||||
// }
|
||||
|
||||
// private _cachErrorHandler(): void {
|
||||
// if (!this.LogContent) {
|
||||
// return;
|
||||
// }
|
||||
// this.LogContent.active = false;
|
||||
// this.LogContent.getComponentInChildren(cc.EditBox).string = "";
|
||||
// if (CC_PREVIEW || !CC_DEBUG) {
|
||||
// return;
|
||||
// }
|
||||
// let self = this;
|
||||
// if (cc.sys.isNative) {
|
||||
// let __handler
|
||||
// if (window['__errorHandler']) {
|
||||
// __handler = window['__errorHandler']
|
||||
// }
|
||||
// window['__errorHandler'] = function (...args) {
|
||||
// self._cachError(...args);
|
||||
// if (__handler) {
|
||||
// __handler(...args)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (cc.sys.isBrowser) {
|
||||
// let __handler;
|
||||
// if (window.onerror) {
|
||||
// __handler = window.onerror
|
||||
// }
|
||||
// window.onerror = function (...args) {
|
||||
// self._cachError(...args);
|
||||
// if (__handler) {
|
||||
// __handler(...args)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// cc.error = (msg: any, ...subst: any[]) => {
|
||||
// console.error(msg, ...subst);
|
||||
// this._cachError(msg, ...subst);
|
||||
// }
|
||||
// }
|
||||
// private _cachError(...args): void {
|
||||
// this.LogContent.active = true;
|
||||
// if (args && args[0]) {
|
||||
// for (let con of args) {
|
||||
// Badminton.Instance.LogContent.getComponentInChildren(cc.EditBox).string += "\n" + con;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// public CloseLogPanel(): void {
|
||||
// this.LogContent.active = false;
|
||||
// }
|
||||
// public ClearLogPanel(): void {
|
||||
// this.LogContent.getComponentInChildren(cc.EditBox).string = "";
|
||||
// }
|
||||
// //#endregion
|
||||
|
||||
// //#region WEBVIEW
|
||||
// private _setWeb(): void {
|
||||
// /*this.WebContent.node.active = false;
|
||||
// if (cc.sys.isNative) {
|
||||
// this.WebContent.setJavascriptInterfaceScheme(this.SCHEME);
|
||||
// this.WebContent.setOnJSCallback(this._webViewCallback.bind(this));
|
||||
// if (cc.sys.isBrowser) {
|
||||
// window["closeWebContent"] = this._closeWebContent.bind(this);
|
||||
// window.addEventListener('message', function (e) {
|
||||
// cc.log("cocos log1=" + e.data);
|
||||
// window["closeWebContent"](e);
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// window["closeWebContent"] = this._closeWebContent.bind(this);
|
||||
// window.addEventListener('message', function (e) {
|
||||
// cc.log("cocos log1=" + e.data);
|
||||
// window["closeWebContent"](e);
|
||||
// });
|
||||
// }*/
|
||||
// }
|
||||
|
||||
// private _closeWebContent(e, url): void {
|
||||
// /*this.WebContent.node.active = false;
|
||||
// cc.log("cocos log2=" + e.data);
|
||||
// */
|
||||
// }
|
||||
|
||||
// private _webViewCallback(target, url): void {
|
||||
// /*
|
||||
// // webview target
|
||||
// let str: string = url.replace(this.SCHEME + '://', '');
|
||||
// cc.log(str);
|
||||
// this.WebContent.node.active = false;
|
||||
// */
|
||||
// }
|
||||
|
||||
// public OpenWebPage(url: string): void {
|
||||
// /*this.WebContent.node.active = true;
|
||||
// let checkUrl: string = BusinessTypeSetting.UsePatch + "closePage.html?" + url + "&v=" + Date.now();
|
||||
// this.WebContent.url = checkUrl;
|
||||
// */
|
||||
// }
|
||||
|
||||
// private _createIframeCloseBtn(): void {
|
||||
// let currentDiv = document.getElementById("ScreenRotation");
|
||||
// var historyBTn = document.createElement("input");
|
||||
// historyBTn.setAttribute("type", "button");
|
||||
// historyBTn.setAttribute("id", "historyBtn");
|
||||
// historyBTn.setAttribute("class", "closeBtn");
|
||||
// historyBTn.setAttribute("onclick", "javascript:(()=>{var ifr=document.querySelector('#historyIfr');ifr.parentNode.removeChild(ifr);var ifrBtn= document.querySelector('#historyBtn');ifrBtn.style.visibility = 'hidden';document.querySelector('#ifrDiv').style.visibility='hidden';})()");
|
||||
// if (!BusinessTypeSetting.CheckOnServer) {
|
||||
// historyBTn.setAttribute("style", "background:url(" + BusinessTypeSetting.UsePatch + BusinessTypeSetting.FolderUrlImg + "historyBtn.png);z-index:1100;top:80%;left:90%;position:fixed;overflow:unset;width:40px;height:40px;;-webkit-appearance: none;background-position: center;background-size: 100%;background-repeat: no-repeat;visibility: visible;border-width:0;background-color: rgba(0,0,0,0);outline: none;");
|
||||
// }
|
||||
// historyBTn.textContent = "X";
|
||||
// historyBTn.style.visibility = "hidden";
|
||||
// document.body.insertBefore(historyBTn, currentDiv);
|
||||
// let ifrDiv = document.createElement("div");
|
||||
// ifrDiv.setAttribute("id", "ifrDiv");
|
||||
// ifrDiv.setAttribute("class", "scroll-wrapper");
|
||||
// ifrDiv.setAttribute("style", "position:fixed;width:100%;height:100%;z-index: 1000;overflow-y: scroll;overflow-x: hidden;-webkit-overflow-scrolling: touch;margin:0;");
|
||||
// ifrDiv.style.visibility = "hidden";
|
||||
// document.body.insertBefore(ifrDiv, currentDiv);
|
||||
// }
|
||||
|
||||
// public CreateIframePage(urlStr: string): void {
|
||||
// let historyIfr = document.createElement("iframe");
|
||||
// historyIfr.setAttribute("id", "historyIfr");
|
||||
// historyIfr.setAttribute("src", urlStr);
|
||||
// historyIfr.setAttribute("frameborder", "0");
|
||||
// historyIfr.setAttribute("style", "width:100%;height:100%;z-index: 1000;;");
|
||||
// let ifrDiv = document.getElementById("ifrDiv");
|
||||
// ifrDiv.appendChild(historyIfr);
|
||||
// ifrDiv.style.visibility = "visible";
|
||||
// let historyBTn = document.getElementById("historyBtn");
|
||||
// historyBTn.style.visibility = "visible";
|
||||
// }
|
||||
// //#endregion
|
||||
|
||||
// //#region 網路相關
|
||||
// /**連線(目前沒有重連機制) */
|
||||
// public * ConnectAsync(host: string, port: number) {
|
||||
// var url = "https://api.ipify.org/?format=json";
|
||||
// var xhr = new XMLHttpRequest();
|
||||
// let ip: string = "";
|
||||
// xhr.onreadystatechange = function () {
|
||||
// if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
|
||||
// ip = JSON.parse(xhr.responseText)["ip"];
|
||||
// }
|
||||
// };
|
||||
// xhr.open("GET", url, true);
|
||||
// xhr.send();
|
||||
// cc.log("[事件]準備連線...");
|
||||
// while (ip == "") {
|
||||
// yield null;
|
||||
// }
|
||||
// this._conn = new NetConnector(host, port, ip);
|
||||
// this._conn.OnDataReceived.AddCallback(this._onNetDataReceived, this);
|
||||
// this._conn.OnDisconnected.AddCallback(this._onNetDisconnected, this);
|
||||
// this._conn.OnLoadUIMask.AddCallback(this._oOnLoadUIMask, this);
|
||||
// NetManager.Initialize(this._conn);
|
||||
// cc.log("[事件]連線中...");
|
||||
// // 同個connector要再次連線, 可以不用叫CasinoNetManager.Initialize(), 但要先叫CasinoNetManager.Disconnect()
|
||||
// yield NetManager.ConnectAsync();
|
||||
// cc.log(String.Format("[事件]連線狀態: {0}", NetManager.IsConnected));
|
||||
// }
|
||||
|
||||
// private _onNetDisconnected() {
|
||||
// cc.log("[事件] 收到連線中斷事件");
|
||||
// if (CSAudio.Instance) {
|
||||
// CSAudio.Instance.StopMusic();
|
||||
// }
|
||||
// this._conn.OnDataReceived.RemoveAllCallbacks();
|
||||
// Badminton.Instance.LastPlayGameID = 0;
|
||||
// // UIManager.DireEvent.RemoveAllCallbacks();
|
||||
// cc.view.setResizeCallback(null);
|
||||
// Badminton.DataReceivedEvent.DispatchCallback([Badminton.DataType.NetDisconnected]);
|
||||
// }
|
||||
|
||||
// private _onNetDataReceived(resp: INetResponse<any>) {
|
||||
// //cc.log(`[事件] 收到server呼叫: ${resp.Method}(${JSON.stringify(resp.Data)}), 狀態: ${resp.Status}`);
|
||||
// Badminton.DataReceivedEvent.DispatchCallback([Badminton.DataType.ServerData, resp]);
|
||||
// }
|
||||
|
||||
// private _oOnLoadUIMask(value: boolean) {
|
||||
// //cc.log(`[事件] LoadUIMask: ${value}`);
|
||||
// if (value) {
|
||||
// CSMask.ShowMask(CSMask.MaskType.DelayLoadMask);
|
||||
// } else {
|
||||
// CSMask.HideMask(CSMask.MaskType.DelayLoadMask);
|
||||
// }
|
||||
// }
|
||||
|
||||
// //#endregion
|
||||
|
||||
// //#region 硬幣特效
|
||||
// @property({ displayName: "硬幣數量", type: cc.Integer })
|
||||
// public CoinAmount: number = 0;
|
||||
// @property({ displayName: "硬幣飛行路徑", type: cc.Node })
|
||||
// public CoinPathPoint: cc.Node[] = [];
|
||||
// @property({ displayName: "硬幣飛行時間", type: cc.Float })
|
||||
// public FlyCoinTime: number = 0;
|
||||
// @property({ type: cc.Float })
|
||||
// public CircleMin: number = 0;
|
||||
// @property({ type: cc.Float })
|
||||
// public CircleMax: number = 0;
|
||||
// @property({ type: cc.Float })
|
||||
// public CircleTime: number = 0;
|
||||
// @property({ type: cc.Float })
|
||||
// public CircleDelayRange: number = 0;
|
||||
// @property({ type: cc.Float })
|
||||
// public FadeOutTime: number = 0;
|
||||
|
||||
// public PlayCoinEffect(data: any[]): void {
|
||||
// CoroutineV2.Serial(
|
||||
// this.FlyMoneyEffect(data[0]),
|
||||
// this.UpdateMoney(data[1])
|
||||
// ).Start();
|
||||
// }
|
||||
|
||||
// private *UpdateMoney(money: number): IterableIterator<any> {
|
||||
// UserData.Instance.Money += money;
|
||||
// }
|
||||
|
||||
// public *FlyMoneyEffect(StartPos: cc.Vec2): IterableIterator<any> {
|
||||
// for (let i: number = 0; i < this.CoinAmount; i++) {
|
||||
// let coinInfo: CoinEffectInfo = new CoinEffectInfo();
|
||||
// coinInfo.StartPos = StartPos;
|
||||
// let normalized: cc.Vec2 = new cc.Vec2(Math.random(), Math.random());
|
||||
// coinInfo.SecondPos = StartPos.add(normalized.mul(RandomEx.GetInt(this.CircleMin, this.CircleMax)));
|
||||
// let date: Date = new Date();
|
||||
// let sec: number = date.getTime() / 1000;
|
||||
// coinInfo.StartTime = sec;
|
||||
// coinInfo.DelayTime = this.CircleDelayRange * Math.random();
|
||||
// coinInfo.FadeOutTime = this.FadeOutTime;
|
||||
// CoroutineV2.Single(this._coinFly(coinInfo)).Start();
|
||||
// }
|
||||
// yield CoroutineV2.WaitTime(this.FlyCoinTime).Start();
|
||||
// }
|
||||
|
||||
// private *_coinFly(coin: CoinEffectInfo): IterableIterator<any> {
|
||||
// let date: Date = new Date();
|
||||
// let sec: number = date.getTime() / 1000;
|
||||
// // 算延遲起動
|
||||
// while (sec - coin.StartTime < coin.DelayTime) {
|
||||
// let newDate: Date = new Date();
|
||||
// sec = newDate.getTime() / 1000;
|
||||
// yield null;
|
||||
// }
|
||||
// coin.GO = this.node.ExAddChild(this.ElementCommonUI.PrefabCoinEffect);
|
||||
// coin.GO.SetWorldPosition(coin.StartPos);
|
||||
// coin.GO.ExSetOrderOverTheObj(this.ElementCommonUI.node);
|
||||
// // 延遲結束更新開始時間
|
||||
// coin.StartTime += coin.DelayTime;
|
||||
// // 正式開始飛
|
||||
// while (sec - coin.StartTime <= this.FlyCoinTime) {
|
||||
// let newDate: Date = new Date();
|
||||
// sec = newDate.getTime() / 1000;
|
||||
// // 正規化
|
||||
// let t: number = (sec - coin.StartTime) / this.FlyCoinTime;
|
||||
// let newPos: cc.Vec2 = new cc.Vec2();
|
||||
// if (!this.IsInGame) {
|
||||
// if (this.CoinPathPoint[0] != null && this.CoinPathPoint[1] != null) {
|
||||
// newPos = Bezier.GetPoint(coin.StartPos, coin.SecondPos, this.CoinPathPoint[0].GetWorldPosition(), this.CoinPathPoint[1].GetWorldPosition(), t);
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// if (this.CoinPathPoint[2] != null && this.CoinPathPoint[3] != null) {
|
||||
// newPos = Bezier.GetPoint(coin.StartPos, coin.SecondPos, this.CoinPathPoint[2].GetWorldPosition(), this.CoinPathPoint[3].GetWorldPosition(), t);
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// let dir: cc.Vec2 = newPos.sub(coin.GO.GetWorldPosition());
|
||||
// let angle: number = Math.round(Math.atan2(dir.y, dir.x) * 57.29578);
|
||||
// coin.GO.angle = angle;
|
||||
// coin.GO.SetWorldPosition(newPos);
|
||||
// yield null;
|
||||
// }
|
||||
// coin.GO.destroy();
|
||||
// }
|
||||
// //#endregion
|
||||
|
||||
// //#region 切換場景
|
||||
// public *RunSwichScene(sceneName: string, scene: cc.Scene = null): IterableIterator<any> {
|
||||
// let source: any;
|
||||
// if (!scene) {
|
||||
// source = yield* AssetBundleMamagerV2.Instance.GetBundleSource(sceneName, sceneName, "scene");
|
||||
// } else {
|
||||
// source = scene;
|
||||
// }
|
||||
// if (!source) {
|
||||
// cc.warn("cannot finc scene.");
|
||||
// return;
|
||||
// }
|
||||
// this.LastScene = this.NowScene;
|
||||
// this.NowScene = sceneName;
|
||||
// switch (sceneName) {
|
||||
// case SceneName.Lobby:
|
||||
// CSMask.HideMask(CSMask.MaskType.LoginLoadMask);
|
||||
// CSMask.ShowMask(CSMask.MaskType.LoginLoadMask);
|
||||
// ScreenResize.PL = 1;
|
||||
// ScreenResize.IsPortrait = ScreenResize.PL;
|
||||
// break;
|
||||
// case SceneName.Login:
|
||||
// ScreenResize.PL = 1;
|
||||
// ScreenResize.IsPortrait = ScreenResize.PL;
|
||||
// break;
|
||||
// default:
|
||||
// // 遊戲
|
||||
// this.NowScene = SceneName.Game;
|
||||
// break;
|
||||
// }
|
||||
// cc.director.runSceneImmediate(source);
|
||||
// }
|
||||
// //#endregion
|
||||
|
||||
// //#region DownloadForm Function
|
||||
|
||||
// /**
|
||||
// * 載入外載表設定檔
|
||||
// * @param formtype FormType
|
||||
// */
|
||||
// public *DownloadForm(formtype: DownloadForm.FormType): IterableIterator<any> {
|
||||
// if (DownloadForm.DownloadFormData.DownloadSuccess.has(formtype)) {
|
||||
// console.warn(`CSSettingsV3 ${formtype} 已經載過`);
|
||||
// return;
|
||||
// }
|
||||
// DownloadForm.DownloadFormData.DownloadSuccess.set(formtype, true);
|
||||
// let needForm: string[] = DownloadForm.DownloadFormData[`${formtype}Form`];
|
||||
// let parallel: Iterator<any, any, undefined>[] = [];
|
||||
// for (let i: number = 0; i < needForm.length; i++) {
|
||||
// parallel.push(this.DownloadFormSetting(needForm[i]));
|
||||
// }
|
||||
// // set Form
|
||||
// yield CoroutineV2.Parallel(...parallel).Start();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 載入外載表設定檔
|
||||
// * @param formname 設定檔名稱
|
||||
// */
|
||||
// public *DownloadFormSetting(formname: string): IterableIterator<any> {
|
||||
// let fileUrl: string = `${formname}.json`;
|
||||
// fileUrl = BusinessTypeSetting.UsePatch + BusinessTypeSetting.FolderUrlJson + fileUrl;
|
||||
// fileUrl = fileUrl + "?v=" + Date.now();
|
||||
// let isdownloading: boolean = true;
|
||||
// cc.assetManager.loadRemote(fileUrl, (err, res) => {
|
||||
// if (err == null) {
|
||||
// res.name = formname;
|
||||
// TableManager.AddJsonAsset(<cc.JsonAsset>res);
|
||||
// cc.assetManager.cacheManager?.removeCache(res.nativeUrl);
|
||||
// } else {
|
||||
// console.error(`[Error] ${formname}.json載入失敗`);
|
||||
// }
|
||||
// isdownloading = false;
|
||||
// });
|
||||
// while (isdownloading) {
|
||||
// yield null;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //#endregion
|
||||
// }
|
||||
|
||||
// /** S2CEvent類型 */
|
||||
// export enum S2CEventType {
|
||||
// /** SlotIn */
|
||||
// SlotIn,
|
||||
|
||||
// /** CardUse */
|
||||
// CardUse
|
||||
// }
|
||||
|
||||
// export class CoinEffectInfo {
|
||||
// public StartPos: cc.Vec2;
|
||||
// /** 往外噴的點位 */
|
||||
// public SecondPos: cc.Vec2;
|
||||
// public GO: cc.Node;
|
||||
// public StartTime: number;
|
||||
// public DelayTime: number;
|
||||
// public FadeOutTime: number;
|
||||
// }
|
||||
|
||||
// export module Badminton {
|
||||
// export enum DataType {
|
||||
// ServerData,
|
||||
// ChangeDire,
|
||||
// NetDisconnected,
|
||||
// }
|
||||
// }
|
||||
// export default Badminton;
|
||||
|
||||
// export enum SceneName {
|
||||
// Loading = "SplashScreen",
|
||||
// Login = "Login",
|
||||
// Lobby = "Lobby",
|
||||
// Game = "Game_"
|
||||
// }
|
||||
|
||||
// //#region DownloadForm
|
||||
// export module DownloadForm {
|
||||
// export enum FormType {
|
||||
// Bag = "Bag",
|
||||
// Bingo = "Bingo",
|
||||
// Five = "Five",
|
||||
// Operation = "Operation"
|
||||
// }
|
||||
|
||||
// export class DownloadFormData {
|
||||
|
||||
// /** 已下載的表 */
|
||||
// public static DownloadSuccess: Map<string, boolean> = new Map<string, boolean>();
|
||||
|
||||
// /** Bag需要的表(xxxx.json) */
|
||||
// public static BagForm: string[] = ["packet", "composite", "itemmoney"];
|
||||
// public static BingoForm: string[] = ["bingo"];
|
||||
// public static FiveForm: string[] = ["five"];
|
||||
// public static OperationForm: string[] = ["operation"];
|
||||
// }
|
||||
// }
|
||||
|
||||
// //#endregion
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export default class ConfigManager {
|
||||
return teamMemberList[i];
|
||||
}
|
||||
}
|
||||
return this.Main.defaultMember;
|
||||
return this.Main.DefaultMember;
|
||||
}
|
||||
|
||||
public GetAvatarDataByName(playerName: string): AvatarData {
|
||||
|
||||
@@ -97,6 +97,11 @@ export class ScoreResult {
|
||||
public Win: number;
|
||||
|
||||
public Total: number;
|
||||
|
||||
constructor(win: number, total: number) {
|
||||
this.Win = win;
|
||||
this.Total = total;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
12
assets/Script/Common.meta
Normal file
12
assets/Script/Common.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.2",
|
||||
"uuid": "4dfc6711-68fb-40cc-98e7-02f5182f23c2",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
12
assets/Script/Common/MainControl.meta
Normal file
12
assets/Script/Common/MainControl.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.2",
|
||||
"uuid": "bb9ff296-9ba2-4946-8d9f-423fdeb6ef39",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
29
assets/Script/Common/MainControl/MainControl.ts
Normal file
29
assets/Script/Common/MainControl/MainControl.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import CSMessage from "../Message/CSMessage";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export class MainControl extends cc.Component {
|
||||
//#region property
|
||||
|
||||
@property({ displayName: "訊息窗位置", type: cc.Node })
|
||||
public MessageContent: cc.Node = null;
|
||||
|
||||
@property({ displayName: "MessageNormal", type: cc.Prefab })
|
||||
public SourceMessage: cc.Prefab = null;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 初始化
|
||||
|
||||
onLoad(): void {
|
||||
// MainControl._instance = this;
|
||||
this._initialEngine();
|
||||
}
|
||||
|
||||
private _initialEngine(): void {
|
||||
CSMessage.Initialize(this.SourceMessage, this.MessageContent);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
9
assets/Script/Common/MainControl/MainControl.ts.meta
Normal file
9
assets/Script/Common/MainControl/MainControl.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "ec0e4b2c-5018-4f84-9062-70403d8383e1",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
12
assets/Script/Common/Message.meta
Normal file
12
assets/Script/Common/Message.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.2",
|
||||
"uuid": "a77a0b3c-4746-4581-aa25-10cd2a95ce30",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
51
assets/Script/Common/Message/CSMessage.ts
Normal file
51
assets/Script/Common/Message/CSMessage.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// import CSSettingsV3 from "../../FormTable/CSSettingsV3";
|
||||
import { MessageNormal, MessageNormalData } from "./MessageNormal";
|
||||
|
||||
/** 訊息框相關 */
|
||||
export default class CSMessage {
|
||||
private static _sourceUI: cc.Prefab;
|
||||
private static _parent: cc.Node;
|
||||
|
||||
public static Initialize(sourceUI: cc.Prefab, parent: cc.Node): void {
|
||||
this._sourceUI = sourceUI;
|
||||
this._parent = parent;
|
||||
}
|
||||
|
||||
/** 一個按鈕的訊息框 */
|
||||
public static CreateYesMsg(content: string, yesCallback: () => void = null, enterStr: string = null): void {
|
||||
// enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(3);
|
||||
enterStr = enterStr ? enterStr : "確定";
|
||||
let data: MessageNormalData = {
|
||||
content: content,
|
||||
isShowCancel: false,
|
||||
yesCallback: yesCallback,
|
||||
noCallback: null,
|
||||
enterName: enterStr,
|
||||
cancelName: null
|
||||
};
|
||||
MessageNormal.Create(this._sourceUI, this._parent, data);
|
||||
}
|
||||
|
||||
/** 兩個按鈕的訊息框 */
|
||||
public static CreateYesNoMsg(content: string, yesCallback: () => void = null, noCallback: () => void = null, enterStr: string = null, cancelStr: string = null): void {
|
||||
// enterStr = enterStr ? enterStr : CSSettingsV3.prototype.CommonString(3);
|
||||
// cancelStr = cancelStr ? cancelStr : CSSettingsV3.prototype.CommonString(4);
|
||||
enterStr = enterStr ? enterStr : "確定";
|
||||
cancelStr = cancelStr ? cancelStr : "取消";
|
||||
let data: MessageNormalData = {
|
||||
content: content,
|
||||
isShowCancel: true,
|
||||
yesCallback: yesCallback,
|
||||
noCallback: noCallback,
|
||||
enterName: enterStr,
|
||||
cancelName: cancelStr
|
||||
};
|
||||
MessageNormal.Create(this._sourceUI, this._parent, data);
|
||||
}
|
||||
|
||||
/** 網路錯誤訊息 */
|
||||
public static NetError(method: string, state: number, str: string = ""): void {
|
||||
let error: string = String.Format("[{0}] state:{1} {2}", method, state, str);
|
||||
cc.warn("網路錯誤訊息: ", error);
|
||||
}
|
||||
}
|
||||
9
assets/Script/Common/Message/CSMessage.ts.meta
Normal file
9
assets/Script/Common/Message/CSMessage.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "3f92822f-2324-4f9f-9480-0c1a5b16815f",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
71
assets/Script/Common/Message/MessageNormal.ts
Normal file
71
assets/Script/Common/Message/MessageNormal.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { CoroutineV2 } from "../../Engine/CatanEngine/CoroutineV2/CoroutineV2";
|
||||
import UIPanel from "../../Engine/Component/UIPanel/UIPanel";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
export interface MessageNormalData {
|
||||
content: string;
|
||||
// title: string;
|
||||
isShowCancel: boolean;
|
||||
yesCallback: () => void;
|
||||
noCallback: () => void;
|
||||
enterName: string;
|
||||
cancelName: string;
|
||||
}
|
||||
|
||||
@ccclass
|
||||
export class MessageNormal extends UIPanel {
|
||||
@property({ displayName: "訊息內容", type: cc.Label })
|
||||
public Content: cc.Label = null;
|
||||
// @property({ displayName: "標題", type: cc.Label })
|
||||
// public Title: cc.Label = null;
|
||||
@property({ displayName: "確定鈕", type: cc.Button })
|
||||
public EnterBtn: cc.Button = null;
|
||||
@property({ displayName: "取消鈕", type: cc.Button })
|
||||
public CancalBtn: cc.Button = null;
|
||||
@property({ displayName: "確定鈕文字", type: cc.Label })
|
||||
public EnterText: cc.Label = null;
|
||||
@property({ displayName: "取消鈕文字", type: cc.Label })
|
||||
public CancalText: cc.Label = null;
|
||||
private _data: MessageNormalData;
|
||||
|
||||
protected ImplementInitial(...initData: any[]): void {
|
||||
this._data = initData[0];
|
||||
this.Content.string = this._data.content;
|
||||
// this.Title.string = this._data.title;
|
||||
if (this._data.enterName) {
|
||||
this.EnterText.string = this._data.enterName;
|
||||
} else {
|
||||
this._data.enterName = "";
|
||||
}
|
||||
this.EnterText.string = this._data.enterName;
|
||||
if (this._data.cancelName) {
|
||||
this.CancalText.string = this._data.cancelName;
|
||||
} else {
|
||||
this.CancalText.string = "";
|
||||
}
|
||||
|
||||
this.CancalBtn.node.active = this._data.isShowCancel;
|
||||
}
|
||||
|
||||
public OnEnter(): void {
|
||||
if (this._data.yesCallback) {
|
||||
this._data.yesCallback();
|
||||
}
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
public OnCancel(): void {
|
||||
if (this._data.noCallback) {
|
||||
this._data.noCallback();
|
||||
}
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
public static Create(sourceUI: cc.Prefab, parent: cc.Node, data: MessageNormalData): void {
|
||||
let node: cc.Node = parent.ExAddChild(sourceUI);
|
||||
let script: MessageNormal = node.getComponent(MessageNormal);
|
||||
script.Initial(data);
|
||||
CoroutineV2.Single(script.Show()).Start();
|
||||
}
|
||||
}
|
||||
9
assets/Script/Common/Message/MessageNormal.ts.meta
Normal file
9
assets/Script/Common/Message/MessageNormal.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "539c898e-ee41-414a-a279-7ec1a8a9f5be",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -1,16 +1,25 @@
|
||||
interface StringConstructor {
|
||||
interface StringConstructor {
|
||||
IsNullOrEmpty: (value: string) => boolean;
|
||||
Format: (format: string, ...args: any[]) => string;
|
||||
IsNullOrWhiteSpace: (input: string) => boolean;
|
||||
}
|
||||
|
||||
String.IsNullOrEmpty = function (value: string): boolean {
|
||||
return value === undefined || value === null || value.trim() === '';
|
||||
String.IsNullOrEmpty = function (value: string): boolean {
|
||||
return value === undefined || value === null || value.trim() === "";
|
||||
};
|
||||
|
||||
String.Format = function (format: string, ...args: any[]): string {
|
||||
return format.replace(/{(\d+)}/g, (match, index) => {
|
||||
let value = args[index];
|
||||
if (value === null || value === undefined) return '';
|
||||
return '' + value;
|
||||
if (value === null || value === undefined) { return ""; }
|
||||
return "" + value;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
String.IsNullOrWhiteSpace = function (input: string): boolean {
|
||||
if (typeof input === "undefined" || input == null) {
|
||||
return true;
|
||||
}
|
||||
return input.replace(/\s/g, "").length < 1;
|
||||
};
|
||||
@@ -10,9 +10,30 @@ export default class LocalStorageData {
|
||||
}
|
||||
|
||||
// =======================================================================================
|
||||
// public get GameConfig(): string { return cc.sys.localStorage.getItem("GameConfig"); }
|
||||
// public set GameConfig(value: string) { cc.sys.localStorage.setItem("GameConfig", value); }
|
||||
public get Date(): string { return cc.sys.localStorage.getItem("date"); }
|
||||
public set Date(value: string) { cc.sys.localStorage.setItem("date", value); }
|
||||
|
||||
public get AvatarSettings(): string { return cc.sys.localStorage.getItem("AvatarSettings"); }
|
||||
public set AvatarSettings(value: string) { cc.sys.localStorage.setItem("AvatarSettings", value); }
|
||||
public get Member(): string[] { return cc.sys.localStorage.getItem("member") ? JSON.parse(cc.sys.localStorage.getItem("member")) : []; }
|
||||
public set Member(value: string[]) { cc.sys.localStorage.setItem("member", JSON.stringify(value)); }
|
||||
|
||||
public get Avatar(): number[] { return cc.sys.localStorage.getItem("avatar") ? JSON.parse(cc.sys.localStorage.getItem("avatar")) : []; }
|
||||
public set Avatar(value: number[]) { cc.sys.localStorage.setItem("avatar", JSON.stringify(value)); }
|
||||
|
||||
public get IsSingleMode(): number { return cc.sys.localStorage.getItem("isSingleMode") ? +cc.sys.localStorage.getItem("isSingleMode") : 0; }
|
||||
public set IsSingleMode(value: number) { cc.sys.localStorage.setItem("isSingleMode", value.toString()); }
|
||||
|
||||
public get Selected(): string[] { return cc.sys.localStorage.getItem("selected") ? JSON.parse(cc.sys.localStorage.getItem("selected")) : []; }
|
||||
public set Selected(value: string[]) { cc.sys.localStorage.setItem("selected", JSON.stringify(value)); }
|
||||
|
||||
public get FirstTeam(): number { return cc.sys.localStorage.getItem("firstTeam") ? +cc.sys.localStorage.getItem("firstTeam") : -1; }
|
||||
public set FirstTeam(value: number) { cc.sys.localStorage.setItem("firstTeam", value.toString()); }
|
||||
|
||||
public get Score(): number[] { return cc.sys.localStorage.getItem("score") ? JSON.parse(cc.sys.localStorage.getItem("score")) : []; }
|
||||
public set Score(value: number[]) { cc.sys.localStorage.setItem("score", JSON.stringify(value)); }
|
||||
|
||||
public get Results(): Map<string, Object> { return cc.sys.localStorage.getItem("results") ? new Map(JSON.parse(cc.sys.localStorage.getItem("results"))) : new Map<string, Object>(); }
|
||||
public set Results(value: Map<string, Object>) { cc.sys.localStorage.setItem("results", JSON.stringify(Array.from(value.entries()))); }
|
||||
|
||||
public get HistoryTeam(): Map<string, string[]> { return cc.sys.localStorage.getItem("historyTeam") ? new Map(JSON.parse(cc.sys.localStorage.getItem("historyTeam"))) : new Map<string, string[]>(); }
|
||||
public set HistoryTeam(value: Map<string, string[]>) { cc.sys.localStorage.setItem("historyTeam", JSON.stringify(Array.from(value.entries()))); }
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ declare interface Array<T> {
|
||||
* @param call Callback function.
|
||||
*/
|
||||
AddListener(call: Function): void;
|
||||
/** 深拷貝 */
|
||||
Copy(): any[];
|
||||
}
|
||||
|
||||
Array.prototype.ExRemoveAt || Object.defineProperty(Array.prototype, "ExRemoveAt", {
|
||||
@@ -92,4 +94,11 @@ Array.prototype.AddListener || Object.defineProperty(Array.prototype, "AddListen
|
||||
EventHandler.handler = <any>call;
|
||||
this.push(EventHandler);
|
||||
}
|
||||
});
|
||||
|
||||
Array.prototype.Copy || Object.defineProperty(Array.prototype, "Copy", {
|
||||
enumerable: false,
|
||||
value: function (): any[] {
|
||||
return Array.from(this);
|
||||
}
|
||||
});
|
||||
12
assets/Script/Engine/Utils/Object.meta
Normal file
12
assets/Script/Engine/Utils/Object.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.2",
|
||||
"uuid": "a726d04f-4b2c-4e8f-9160-ef0fb6d11625",
|
||||
"isBundle": false,
|
||||
"bundleName": "",
|
||||
"priority": 1,
|
||||
"compressionType": {},
|
||||
"optimizeHotUpdate": {},
|
||||
"inlineSpriteFrames": {},
|
||||
"isRemoteBundle": {},
|
||||
"subMetas": {}
|
||||
}
|
||||
10
assets/Script/Engine/Utils/Object/ObjectEx.ts
Normal file
10
assets/Script/Engine/Utils/Object/ObjectEx.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
export module ObjectEx {
|
||||
|
||||
/**
|
||||
* 深拷貝
|
||||
*/
|
||||
export function Copy(any: any): any {
|
||||
return JSON.parse(JSON.stringify(any));
|
||||
}
|
||||
}
|
||||
9
assets/Script/Engine/Utils/Object/ObjectEx.ts.meta
Normal file
9
assets/Script/Engine/Utils/Object/ObjectEx.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.8",
|
||||
"uuid": "8d75fc79-4886-48fc-8350-e2f3ae19a079",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
@@ -5,6 +5,20 @@ const { ccclass, property } = cc._decorator;
|
||||
/** HistoryPanel */
|
||||
@ccclass
|
||||
export default class HistoryPanel extends UIPanel {
|
||||
//#region get set
|
||||
|
||||
public get History(): Map<string, string[]> { return this._m_history; }
|
||||
private _m_history: Map<string, string[]> = new Map<string, string[]>();
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Lifecycle
|
||||
|
||||
protected *ImplementReadyShow(...param: any[]): IterableIterator<any> {
|
||||
cc.log("HistoryPanel ImplementReadyShow");
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Custom
|
||||
|
||||
|
||||
@@ -6,7 +6,19 @@ const { ccclass, property } = cc._decorator;
|
||||
@ccclass
|
||||
export default class ScoreBoard extends UIPanel {
|
||||
|
||||
//#region OnClick
|
||||
//#region public
|
||||
|
||||
public isSingleMode: boolean = false;
|
||||
public firstTeam: number = 0;
|
||||
public selectedList: string[] = [];
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Lifecycle
|
||||
|
||||
protected *ImplementReadyShow(...param: any[]): IterableIterator<any> {
|
||||
cc.log("ScoreBoard ImplementReadyShow");
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user