[add] script

[add] HoldButton
This commit is contained in:
建喵 2022-05-02 21:04:23 +08:00
parent 26f0052207
commit 119db9b977
39 changed files with 5052 additions and 2726 deletions

View File

@ -31,10 +31,13 @@
"_components": [
{
"__id__": 79
},
{
"__id__": 80
}
],
"_prefab": {
"__id__": 80
"__id__": 81
},
"_opacity": 255,
"_color": {
@ -3006,6 +3009,16 @@
"_N$inverted": false,
"_id": ""
},
{
"__type__": "424db5d3RpBGIWSlkuF1LkT",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -34,9 +34,13 @@
}
],
"_active": false,
"_components": [],
"_prefab": {
"_components": [
{
"__id__": 67
}
],
"_prefab": {
"__id__": 68
},
"_opacity": 255,
"_color": {
@ -2510,6 +2514,16 @@
"fileId": "b15xl8x55JtoyhVbmZuONB",
"sync": false
},
{
"__type__": "2dae2ACVGFNNJ0iMg2U2HtX",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -33,10 +33,14 @@
"__id__": 221
}
],
"_active": true,
"_components": [],
"_prefab": {
"_active": false,
"_components": [
{
"__id__": 223
}
],
"_prefab": {
"__id__": 224
},
"_opacity": 255,
"_color": {
@ -263,7 +267,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "45hZtKVPFOioM46ol8FyZB",
"sync": false
@ -515,7 +519,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "42x/urwe5A6IhGBsBcpZoS",
"sync": false
@ -571,7 +575,7 @@
},
{
"__type__": "cc.Node",
"_name": "Member",
"_name": "Content",
"_objFlags": 0,
"_parent": {
"__id__": 14
@ -731,7 +735,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "22sV/qfF5B3LCwQNFiGeWt",
"sync": false
@ -1971,7 +1975,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "bfhRVOxr1Ndpppvka1Ucvy",
"sync": false
@ -2041,7 +2045,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "c8seq7tgZGR402ibkdWBq+",
"sync": false
@ -2052,7 +2056,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "14BdSts5pO6K2EB1KJHPA4",
"sync": false
@ -2160,7 +2164,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "b9+R89ckNFO729Y6rqTpu9",
"sync": false
@ -2371,7 +2375,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "84kNFHqz1DA7mbLTjIhjmK",
"sync": false
@ -2509,7 +2513,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "1daRUFeJBPg4myM+za10g/",
"sync": false
@ -2647,7 +2651,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "351qcVdepJ7KzaWx2kZibr",
"sync": false
@ -2688,7 +2692,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "201ds89x9LxJjzAjOc7jDr",
"sync": false
@ -2867,7 +2871,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "64PHUB6+5M95SjI3/6NZJ/",
"sync": false
@ -2982,7 +2986,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "6deZ0PrOBLtYHAMz33O51O",
"sync": false
@ -2993,7 +2997,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "69Z51faEpFZ51OPb3Aa3so",
"sync": false
@ -3245,7 +3249,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "a4MOT0/lxDs7uTVT4Hfzx8",
"sync": false
@ -3497,7 +3501,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "82m18AlFFNUbNjy1mZ4T5P",
"sync": false
@ -3713,7 +3717,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "5fokvWoT5P641YgrhVGOrA",
"sync": false
@ -4419,7 +4423,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "c2Y2S/N2lKpo/KeagdllUs",
"sync": false
@ -4489,7 +4493,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "4eInnd29dF+6Scx8dMkafX",
"sync": false
@ -4500,7 +4504,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "57gtqaME9IzpwrBIWqJDSW",
"sync": false
@ -4607,7 +4611,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "4eKmtO40tLr6YVoYl29Z/3",
"sync": false
@ -4650,7 +4654,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "82nLUx8etGqpwosBRE7eKu",
"sync": false
@ -4963,7 +4967,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "d7+mpCSSlHh7e3SBObjFOl",
"sync": false
@ -5078,7 +5082,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "4bf93NEE1GQ4ewYVStK/r3",
"sync": false
@ -5257,7 +5261,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "2bmfzDxHxJ0qLMccXnyWIJ",
"sync": false
@ -5372,7 +5376,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "a7YZvChklO0KCxvbepuybx",
"sync": false
@ -5383,7 +5387,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "0ft3ubbfpF9KWsWT/GbOsm",
"sync": false
@ -5626,7 +5630,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "f3CdVi62dPkaDcB84enE/h",
"sync": false
@ -5741,7 +5745,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "60lTRuKfBF4IROO3iWPdz4",
"sync": false
@ -5752,7 +5756,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "ebCBQjuz1Oe6hfKCkxFUEO",
"sync": false
@ -5763,7 +5767,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "4diEpc2rtGdaoaMYoxGazo",
"sync": false
@ -5834,7 +5838,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "abkBReTMtFCK5AFelvm2fD",
"sync": false
@ -5845,7 +5849,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "43yUIyR1RJDrS0JIf6fg+/",
"sync": false
@ -6100,7 +6104,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "76l/7bx1hGVbUGSRjv0de/",
"sync": false
@ -6215,7 +6219,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "34k3FZBV5Dh5BQSQtLVcHG",
"sync": false
@ -6394,7 +6398,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "19qggBEK5LIqcgbrQBZhL6",
"sync": false
@ -6509,7 +6513,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "1c+R2NE4hGZIKK/s+ScaYb",
"sync": false
@ -6688,7 +6692,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "74cl6dCu5JOZXOWcYWqT4I",
"sync": false
@ -6803,7 +6807,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "6f7ELeuv1E9J72aF0LTgX6",
"sync": false
@ -6982,7 +6986,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "0bc3wr/JJNrZk6QAyL+A2B",
"sync": false
@ -7099,7 +7103,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "a1mTVAv0hD56ZdC1Q90i88",
"sync": false
@ -7348,7 +7352,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "49m5KVdJlHFIz2abBxNrON",
"sync": false
@ -7463,7 +7467,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "d4EI48yF5I3LcsvtkTZXxL",
"sync": false
@ -7642,7 +7646,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "24Yi0piLlKXK4/vh2LQcrh",
"sync": false
@ -7757,7 +7761,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "2efMGG8CdGu7mMxhU4DE/h",
"sync": false
@ -7939,7 +7943,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "e61P4eifxL6baiPn5AiScQ",
"sync": false
@ -8113,7 +8117,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "ccFuMgXXtPVopFW4Ov3n1j",
"sync": false
@ -8220,7 +8224,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "18Oji1V41Anbiz8QQCjodM",
"sync": false
@ -8231,7 +8235,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "5ddRcHg2FLSJXTlpiY9b9S",
"sync": false
@ -8346,7 +8350,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "85lVwUjJJLUKldHpIWJF+L",
"sync": false
@ -8357,7 +8361,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "c2+MnJAqNFprN1Yj4qJJ6a",
"sync": false
@ -8368,7 +8372,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "5d8SMhZAVFCKHtLUvm2zTr",
"sync": false
@ -8552,7 +8556,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "04CpdR12FPBKfGYbteJv+g",
"sync": false
@ -8563,7 +8567,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "cc1/GPXkFAtLeE0xrab5KF",
"sync": false
@ -8634,18 +8638,28 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "08OOxJcqFPM63ZrraJ2Fxt",
"sync": false
},
{
"__type__": "83a728cly5CRIWi3CWlwwsU",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "e3769d9e-d27f-4355-8f6a-686382943afd"
},
"fileId": "",
"sync": false

View File

@ -43,10 +43,13 @@
},
{
"__id__": 29
},
{
"__id__": 30
}
],
"_prefab": {
"__id__": 30
"__id__": 31
},
"_opacity": 255,
"_color": {
@ -1195,6 +1198,24 @@
"_N$inverted": false,
"_id": ""
},
{
"__type__": "0d1d5HfnyFLAK2RYSpW387d",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"MaxTime": 2,
"Button": {
"__id__": 16
},
"holdLine": null,
"progressBG": null,
"progressLine": null,
"OnInvoke": [],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -43,9 +43,13 @@
}
],
"_active": false,
"_components": [],
"_prefab": {
"_components": [
{
"__id__": 319
}
],
"_prefab": {
"__id__": 320
},
"_opacity": 255,
"_color": {
@ -12477,6 +12481,16 @@
"fileId": "493o2z04pBGLyiOjLavwmO",
"sync": false
},
{
"__type__": "ad22bYtYwVED7WBCh0k+vFe",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -25,9 +25,13 @@
}
],
"_active": false,
"_components": [],
"_prefab": {
"_components": [
{
"__id__": 225
}
],
"_prefab": {
"__id__": 226
},
"_opacity": 255,
"_color": {
@ -8906,6 +8910,16 @@
"fileId": "dafmWNPC9GB6t5jdRftUmk",
"sync": false
},
{
"__type__": "9faf3mTtf5FEYt7k+Rn0lQh",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "9ed8e91f-a942-432a-993e-00ea678e64f3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
import UIPanel from "../Engine/Component/UIPanel/UIPanel";
const { ccclass, property } = cc._decorator;
/** AvatarPanel */
@ccclass
export default class AvatarPanel extends UIPanel {
//#region OnClick
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "424dbe5d-dd1a-4118-8592-964b85d4b913",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "4217e950-5b75-4ae1-affa-72d0f530e41c",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,859 @@
import AvatarPanel from "../AvatarPanel/AvatarPanel";
import { CoroutineV2 } from "../Engine/CatanEngine/CoroutineV2/CoroutineV2";
import HoldButton from "../Engine/Component/Button/HoldButton";
import LocalStorageData from "../Engine/Data/LocalStorageData";
import HistoryPanel from "../HistoryPanel/HistoryPanel";
import Lobby from "../Lobby/Lobby";
import ScoreBoard from "../ScoreBoard/ScoreBoard";
import VoicePanel from "../VoicePanel/VoicePanel";
import NodePackageManager from "../_BootLoader/Npm/NodePackageManager";
import ConfigManager from "./ConfigManager";
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
@property({ type: cc.Prefab })
private toggleItem: cc.Prefab = null;
@property({ type: cc.Prefab })
private teamItem: cc.Prefab = null;
@property({ type: cc.EditBox })
private inputNameText: cc.EditBox = null;
@property({ type: cc.Label })
private storageText: cc.Label = null;
@property({ type: cc.Node })
public ToggleItemContent: cc.Node = null;
@property({ type: cc.Node })
public TeamItemContent: cc.Node = null;
@property({ type: ScoreBoard })
public ScoreBoard: ScoreBoard = null;
@property({ type: AvatarPanel })
public AvatarPanel: AvatarPanel = null;
@property({ type: HistoryPanel })
public HistoryPanel: HistoryPanel = null;
@property({ type: VoicePanel })
public VoicePanel: VoicePanel = null;
@property({ type: Lobby })
public Lobby: Lobby = null;
// @property({ type: AudioListSwitch })
// public GameBGM: AudioListSwitch = null;
// @property({ type: AudioListSwitch })
// public TextToSpeech: TextToSpeech { get; private set; }
//#endregion
//#region 實例
/** Badminton實例 */
private static _instance: Badminton = null;
public static get Instance(): Badminton { return this._instance; }
//#endregion
//#region public
public TeamMemberList: MemberData[] = [];
/** 目前所有可用玩家名單 */
public CurMemberList: string[] = [];
/** 預設球員(塞空格) */
public defaultMember: MemberData = new MemberData("那個");
/** RecordManager */
public record: RecordManager = new RecordManager(this);
/** ConfigManager */
public config: ConfigManager = new ConfigManager(this);
//#endregion
//#region private
private _m_toggleList: cc.Toggle[] = [];
private _m_teamList: cc.Node[] = [];
/** 各玩家分數比賽次數記錄 */
private _dictionary: Map<string, ScoreResult> = new Map<string, ScoreResult>();
/** 比賽歷史記錄(記錄每場次的參賽玩家組合與順序) [{time,team:[[name1,name2],[name3,name4]],type,score:[t1,t2] },] */
private _m_history: GameRecord[] = [];
//#endregion
//#region get set
public static get Today(): string { return NodePackageManager.Instance.Dayjs().format("yyyyMMdd"); }
public get TeamCount(): number { return this._m_teamList.length; }
/** 比賽歷史記錄(記錄每場次的參賽玩家組合與順序) [{time,team:[[name1,name2],[name3,name4]],type,score:[t1,t2] },] */
public get History(): GameRecord[] { return this._m_history; }
//#endregion
//#region 初始化
protected onLoad(): void {
Badminton._instance = this;
new LocalStorageData();
this.config.Init();
this.record.Init();
CoroutineV2.Parallel(
this.Lobby.Show(),
this.ScoreBoard.Show(),
).Start();
if (this.HistoryPanel != null) {
this.HistoryPanel.LoadRecord();
this.HistoryPanel.Hide();
CoroutineV2.Single(this.HistoryPanel.Hide()).Start();
}
// textToSpeech = FindObjectOfType<TextToSpeech>();
}
protected start(): void {
CoroutineV2.Single(this.ScoreBoard.Hide()).Start();
this._initUI();
// LoadStatus();
// // 跨日後計分清除
// if (PlayerPrefs.GetString("date") != today)
// {
// Debug.LogWarning("跨日後計分清除");
// ClearAllGameResult();
// }
// URLSchemeHandler.Init();
}
//#endregion
//#region Custom
private _initUI(): void {
this._updateCurSelMember();
// this.toggleItem.gameObject.SetActive(false);
// this.teamItem.gameObject.SetActive(false);
let parent: cc.Node = this.TeamItemContent;
for (let i: number = parent.childrenCount - 1; i > 0; i--) {
parent.children[i].destroy();
}
this._m_teamList.Clear();
parent = this.ToggleItemContent;
for (let i: number = parent.childrenCount - 1; i > 0; i--) {
parent.children[i].destroy();
}
this._m_toggleList.Clear();
for (let idx: number = 0; idx < this.TeamMemberList.length; idx++) {
let memberName: string = this.TeamMemberList[idx].Name;
let item: cc.Toggle = parent.ExAddChild(this.toggleItem).getComponent(cc.Toggle);
item.node.getChildByName("Label").getComponent(cc.Label).string = memberName;
item.node.active = true;
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<HoldButton>().OnInvoke.AddListener(this.OnChangeAvatar(idx));
let EventHandler: cc.Component.EventHandler = new cc.Component.EventHandler();
EventHandler.target = this.node;
EventHandler.component = this.name.split("<")[1].split(">")[0];
EventHandler.handler = "OnChangeAvatar";
EventHandler.customEventData = idx.toString();
picObj.getComponent(HoldButton).OnInvoke.push(EventHandler);
picObj.on("click", () => { item.isChecked = !item.isChecked; }, this);
}
this._m_toggleList.push(item);
item.isChecked = this.CurMemberList.indexOf(memberName) !== -1;
item.node.on("toggle", this._onChangeSelMember, this);
}
}
public ReloadUI(): void {
let chkMemberList: string[] = this.GetMemberListFromTeamView();
this._initUI();
this._updateTeamShow(chkMemberList);
}
private _onChangeSelMember(toggle: cc.Toggle): void {
let val: boolean = toggle.isChecked;
this._updateCurSelMember();
let chkMemberList: string[] = this.GetMemberListFromTeamView();
let dName: string = this.GetDefaultMemberName();
let selName: string = null;
if (val) {
for (let i: number = 0; i < this.CurMemberList.length; i++) {
if (chkMemberList.indexOf(this.CurMemberList[i]) === -1) {
selName = this.CurMemberList[i];
break;
}
}
for (let i: number = 0; i < chkMemberList.length; i++) {
if (chkMemberList[i] === dName) {
chkMemberList[i] = selName;
this._updateTeamShow(chkMemberList);
return;
}
}
if (selName != null) {
chkMemberList.push(selName);
}
this._updateTeamShow(chkMemberList);
} else {
for (let i: number = 0; i < chkMemberList.length; i++) {
if (this.CurMemberList.indexOf(chkMemberList[i]) === -1) {
selName = chkMemberList[i];
if (i === chkMemberList.length - 1) {
chkMemberList.ExRemoveAt(chkMemberList.length - 1);
} else { chkMemberList[i] = this.GetDefaultMemberName(); }
this._updateTeamShow(chkMemberList);
break;
}
}
}
}
private _updateCurSelMember(): void {
this.CurMemberList.Clear();
this._m_toggleList.forEach((member: cc.Toggle) => {
if (member.isChecked) {
this.CurMemberList.push(member.node.getChildByName("Label").getComponent(cc.Label).string);
}
});
if (this.TeamMemberList != null && this.TeamMemberList.length > 0) {
this.CurMemberList.push(this.GetDefaultMemberName());
}
}
public GetMemberListFromTeamView(): string[] {
let chkMemberList: string[] = [];
for (let i: number = 0; i < this._m_teamList.length; i++) {
let team: cc.Node = this._m_teamList[i];
if (!team.active) {
break;
}
for (let j: number = 0; j < 2; j++) {
let memberName: string = team.getChildByName("Member_" + (j + 1) + "/Text").getComponent(cc.Label).string;
chkMemberList.push(memberName);
}
}
return chkMemberList;
}
public GetDefaultMemberName(): string {
return "那個";
}
private _updateTeamShow(chkMemberList: string[]): void {
let teamCount: number = chkMemberList.length / 2;
let maxTeam: number = Math.ceil(chkMemberList.length / 2.0);
while (this._m_teamList.length > maxTeam) {
this._m_teamList[this._m_teamList.length - 1].destroy();
this._m_teamList.ExRemoveAt(this._m_teamList.length - 1);
}
if (maxTeam === 0 || (chkMemberList.length === 1 && chkMemberList[0] === this.GetDefaultMemberName())) {
return;
}
for (let i: number = 0; i < maxTeam; i++) {
let obj: cc.Node;
if (i >= this._m_teamList.length) {
obj = this.TeamItemContent.ExAddChild(this.teamItem);
this._m_teamList.push(obj);
} else {
obj = this._m_teamList[i];
}
obj.getChildByName("Member_1").getChildByName("Text").getComponent(cc.Label).string = "";
obj.getChildByName("Member_2").getChildByName("Text").getComponent(cc.Label).string = "";
obj.getChildByName("Member_1").getComponent(cc.Sprite).enabled = false;
obj.getChildByName("Member_2").getComponent(cc.Sprite).enabled = false;
obj.active = false;
}
let index: number = 0;
for (let idx: number = 0; idx < teamCount && idx < maxTeam; idx++) {
if (chkMemberList[0] === chkMemberList[1] && chkMemberList[0] === this.GetDefaultMemberName()) {
chkMemberList.splice(0, 2);
continue;
}
let team: cc.Node = this._m_teamList[index++];
team.getChildByName("No").getComponent(cc.Label).string = index.toString();
for (let j: number = 0; j < 2; j++) {
let name: string = chkMemberList[0];
if (j === 0 && name === this.GetDefaultMemberName()) {
name = chkMemberList[1];
chkMemberList.ExRemoveAt(1);
} else {
chkMemberList.ExRemoveAt(0);
}
team.getChildByName("Member_" + (j + 1) + "/Text").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.active = true;
}
}
if (chkMemberList.length > 0 && teamCount < maxTeam) {
let name_1: string = chkMemberList[0];
let name_2: string = this.GetDefaultMemberName();
let team: cc.Node = this._m_teamList[teamCount];
team.getChildByName("Member_1").getChildByName("Text").getComponent(cc.Label).string = name_1;
team.getChildByName("Member_2").getChildByName("Text").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("No").getComponent(cc.Label).string = (index + 1).toString();
team.active = true;
}
}
public OnDelMember(index: number): void {
let viewTeamList: string[] = this.GetMemberListFromTeamView();
let player: MemberData = this.TeamMemberList[index];
let teamIndex: number = viewTeamList.indexOf(player.Name);
if (teamIndex !== -1) { viewTeamList[teamIndex] = this.GetDefaultMemberName(); }
this.TeamMemberList.ExRemoveAt(index);
this._initUI();
this._updateTeamShow(viewTeamList);
if (teamIndex !== -1) {
this._updateCurSelMember();
}
}
public OnChangeAvatar(index: number): void {
index = +index;
console.log("OnChangeAvatar");
// this.AvatarPanel.OpenChange(teamMemberList[index]);
}
public Log(a, b): void {
console.log("Log");
}
//#endregion
}
// //#region 初始化
// onLoad(): void {
// Badminton._instance = this;
// this.ElementCommonUI = this.getComponent(CommonElementUI);
// this.LastScene = SceneName.Loading;
// this.NowScene = SceneName.Login;
// this._cachErrorHandler();
// this._initialEngine();
// }
// 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

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "86aab78e-5add-4721-8358-778a5cd2c355",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,116 @@
import LocalStorageData from "../Engine/Data/LocalStorageData";
import { Badminton } from "./Badminton";
import { AvatarData, AvatarSettings, GameConfig, MemberData } from "./MemberData";
/** ConfigManager */
export default class ConfigManager {
//#region get
public Main: Badminton = null;
//#endregion
//#region public
public Avatars: AvatarData[] = [];
//#endregion
//#region Lifecycle
constructor(mainControl: Badminton) {
this.Main = mainControl;
}
public Init(): void {
this.LoadMemberList();
this.LoadAvatarSettings();
}
public LoadMemberList(): void {
let teamMemberList: MemberData[] = this.Main.TeamMemberList;
if (teamMemberList == null) {
this.Main.TeamMemberList = teamMemberList = [];
}
let request: GameConfig = (<GameConfig>JSON.parse(LocalStorageData.Instance.GameConfig));
if (request != null) {
let members: string[] = teamMemberList.map(m => Object.values(m)[0]);
for (let i: number = 0; i < request.Members.length; i++) {
if (!members.includes(request.Members[i])) {
teamMemberList.push(new MemberData(request.Members[i]));
}
}
}
}
public LoadAvatarSettings(): void {
let request: AvatarSettings = (<AvatarSettings>JSON.parse(LocalStorageData.Instance.AvatarSettings));
if (request != null) {
this.Avatars = request.Avatars;
}
}
//#endregion
//#region Get
public GetAvatarPicById(avatarId: number): cc.SpriteFrame {
for (let i: number = 0; i < this.Avatars.length; i++) {
if (this.Avatars[i].ID === avatarId) {
return this.Avatars[i].Pic;
}
}
return this.Avatars[this.Avatars.length - 1].Pic;
}
public GetAvatarPicByName(playerName: string): cc.SpriteFrame {
let teamMemberList: MemberData[] = this.Main.TeamMemberList;
let avatarId: number = 0;
for (let i: number = 0; i < teamMemberList.length; i++) {
if (teamMemberList[i].Name === playerName) {
avatarId = teamMemberList[i].AvatarId;
break;
}
}
for (let i: number = 0; i < this.Avatars.length; i++) {
if (this.Avatars[i].ID === avatarId) {
return this.Avatars[i].Pic;
}
}
return this.Avatars[this.Avatars.length - 1].Pic;
}
public GetMemberDataByName(playerName: string): MemberData {
let teamMemberList: MemberData[] = this.Main.TeamMemberList;
for (let i: number = 0; i < teamMemberList.length; i++) {
if (teamMemberList[i].Name === playerName) {
return teamMemberList[i];
}
}
return this.Main.defaultMember;
}
public GetAvatarDataByName(playerName: string): AvatarData {
let teamMemberList: MemberData[] = this.Main.TeamMemberList;
let avatarId: number = 0;
for (let i: number = 0; i < teamMemberList.length; i++) {
if (teamMemberList[i].Name === playerName) {
avatarId = teamMemberList[i].AvatarId;
break;
}
}
for (let i: number = 0; i < this.Avatars.length; i++) {
if (this.Avatars[i].ID === avatarId) {
return this.Avatars[i];
}
}
return this.Avatars[0];
}
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "b176ed63-8037-4fa5-8920-8e5024f56e45",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,101 @@
const { ccclass, property } = cc._decorator;
//#region Class
/** 成員資料 */
export class MemberData {
public Name: string;
public AvatarId: number;
public Score: ScoreResult;
/**
* @param {string} name
*/
constructor(name: string) {
this.Name = name;
}
}
/** AvatarData */
export class AvatarData {
public ID: number;
public Model: number;
public Name: string;
public Desc: string;
public Pic: cc.SpriteFrame;
public BigPic: cc.SpriteFrame;
public BG: cc.SpriteFrame;
public color: AvatarColor;
}
/** 分數結果 */
export class ScoreResult {
public Win: number;
public Total: number;
}
/**
*
* {time,team:[[name1,name2],[name3,name4]],type,score:[t1,t2] }
*/
export class GameRecord {
/** 場次 */
public Seq: number;
/** 記錄時間 */
public Time: number;
/** 遊戲類型(0:雙打,1:單打) */
public Type: number;
/** 玩家隊伍 [ [隊伍1成員], [隊伍2成員] ] */
public Team: string[][];
/** players */
public Players: string[];
/** 隊伍分數 [ [隊伍1分數], [隊伍2分數] ] */
public Score: number[];
}
/** GameConfig */
export class GameConfig {
/** Members */
public Members: string[];
}
/** AvatarSettings */
export class AvatarSettings {
/** Avatars */
public Avatars: AvatarData[];
}
//#endregion
//#region Enum
/** AvatarColor */
export enum AvatarColor {
None,
Pink,
Yellow
}
//#endregion

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "adfaf5ca-77f2-4eb0-9722-c9ae74edc851",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,33 @@
import { Badminton } from "./Badminton";
const { ccclass, property } = cc._decorator;
//#region class
/** RecordManager */
export default class RecordManager {
//#region get
public Main: Badminton = null;
//#endregion
//#region Custom
constructor(badminton: Badminton) {
this.Main = badminton;
}
public Init(): any {
//
}
public LoadStatus(): any {
//
}
//#endregion
}
//#endregion

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "d4f76ba2-6464-4043-8917-2e92db0997e6",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,127 @@
const { ccclass, requireComponent, menu, property } = cc._decorator;
@ccclass
@menu("Plug-in/Button/HoldButton")
@requireComponent(cc.Button)
export default class HoldButton extends cc.Component {
//#region public
@property()
public MaxTime: number = 2;
@property({ type: cc.Node })
public HoldLine: cc.Node = null;
@property({ type: cc.Sprite })
public ProgressBG: cc.Sprite = null;
@property({ type: cc.Sprite })
public ProgressLine: cc.Sprite = null;
@property({ type: [cc.Component.EventHandler] })
public OnInvoke: cc.Component.EventHandler[] = [];
//#endregion
//#region private
private _m_isMouseDown: boolean = false;
private _m_pressDeltaTime: number = 0;
private _m_noLineUI: boolean = true;
//#endregion
//#region Lifecycle
protected start(): void {
if (this.HoldLine != null) {
this.HoldLine.active = false;
}
}
protected update(dt: number): void {
if (this._m_isMouseDown) {
this._checkHoldAutoStart(dt);
} else {
if (!this._m_noLineUI) {
this.HoldLine.active = false;
}
}
}
protected onEnable(): void {
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
}
protected onDisable(): void {
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
}
//#endregion
//#region Custom
private _checkHoldAutoStart(deltaTime: number): void {
this._m_pressDeltaTime += deltaTime;
if (!this._m_noLineUI) {
// 蓄能條顯示特效
this.ProgressLine.fillRange = this._m_pressDeltaTime;
}
if (this._m_pressDeltaTime > this.MaxTime) {
this._m_isMouseDown = false;
if (!this._m_noLineUI) {
this.HoldLine.active = false;
}
this._m_pressDeltaTime = 0;
if (this.OnInvoke != null) {
this.OnInvoke.forEach((eventHandler: cc.Component.EventHandler) => {
eventHandler.emit([this.node.getComponent(cc.Button)]);
});
}
}
}
//#endregion
//#region EventT
private _onTouchStart(event: cc.Event.EventTouch): void {
if (this._m_isMouseDown) {
return;
}
this._m_isMouseDown = true;
this._m_noLineUI = this.HoldLine == null || this.ProgressBG == null || this.ProgressLine == null;
if (!this._m_noLineUI) {
this.HoldLine.active = true;
}
}
private _onTouchEnd(event: cc.Event.EventTouch): void {
this._m_isMouseDown = false;
this._m_pressDeltaTime = 0;
if (!this._m_noLineUI) {
this.HoldLine.active = false;
}
this._checkHoldAutoStart(0);
}
private _onTouchCancel(event: cc.Event.EventTouch): void {
this._m_isMouseDown = false;
this._m_pressDeltaTime = 0;
if (!this._m_noLineUI) {
this.HoldLine.active = false;
}
this._checkHoldAutoStart(0);
}
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "0d1d51df-9f21-4b00-ad91-612a56dfcedd",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -10,36 +10,9 @@ export default class LocalStorageData {
}
// =======================================================================================
public get RemoteVerList(): string { return cc.sys.localStorage.getItem("RemoteVerList"); }
public set RemoteVerList(value: string) { cc.sys.localStorage.setItem("RemoteVerList", value); }
public get LocalVerList(): string { return cc.sys.localStorage.getItem("LocalVerList"); }
public set LocalVerList(value: string) { cc.sys.localStorage.setItem("LocalVerList", value); }
public get ComboDeviceID(): string { return cc.sys.localStorage.getItem("ComboDeviceID"); }
public set ComboDeviceID(value: string) { cc.sys.localStorage.setItem("ComboDeviceID", value); }
public get BundleUrl(): string { return cc.sys.localStorage.getItem("BundleUrl"); }
public set BundleUrl(value: string) { cc.sys.localStorage.setItem("BundleUrl", value); }
public get Language(): string { return cc.sys.localStorage.getItem("language"); }
public set Language(value: string) { cc.sys.localStorage.setItem("language", value); }
public get MusicType(): string { return cc.sys.localStorage.getItem("MusicType"); }
public set MusicType(value: string) { cc.sys.localStorage.setItem("MusicType", value); }
public get SoundType(): string { return cc.sys.localStorage.getItem("SoundType"); }
public set SoundType(value: string) { cc.sys.localStorage.setItem("SoundType", value); }
public get DownloadList_Preview(): string { return cc.sys.localStorage.getItem("DownloadList_Preview"); }
public set DownloadList_Preview(value: string) { cc.sys.localStorage.setItem("DownloadList_Preview", value); }
public get GameConfig(): string { return cc.sys.localStorage.getItem("GameConfig"); }
public set GameConfig(value: string) { cc.sys.localStorage.setItem("GameConfig", value); }
/**
* key: id
* value: 是否開過卡
*/
public get BingoCardInfo(): Map<number, boolean> { return cc.sys.localStorage.getItem("BingoCardInfo") ? new Map(JSON.parse(cc.sys.localStorage.getItem("BingoCardInfo"))) : new Map<number, boolean>(); }
public set BingoCardInfo(value: Map<number, boolean>) { cc.sys.localStorage.setItem("BingoCardInfo", JSON.stringify(Array.from(value.entries()))); }
/**
* key: id
* value: 是否開過卡
*/
public get FiveCardInfo(): Map<number, boolean> { return cc.sys.localStorage.getItem("FiveCardInfo") ? new Map(JSON.parse(cc.sys.localStorage.getItem("FiveCardInfo"))) : new Map<number, boolean>(); }
public set FiveCardInfo(value: Map<number, boolean>) { cc.sys.localStorage.setItem("FiveCardInfo", JSON.stringify(Array.from(value.entries()))); }
// =======================================================================================
public get AvatarSettings(): string { return cc.sys.localStorage.getItem("AvatarSettings"); }
public set AvatarSettings(value: string) { cc.sys.localStorage.setItem("AvatarSettings", value); }
}

View File

@ -4,6 +4,8 @@ declare interface Array<T> {
* @param index
*/
ExRemoveAt(index: number): T;
/** 移除全部值 */
Clear(): void;
/**
* asc&key陣列長度請一樣
* PS. boolean false是先true在false
@ -22,6 +24,13 @@ Array.prototype.ExRemoveAt || Object.defineProperty(Array.prototype, "ExRemoveAt
}
});
Array.prototype.Clear || Object.defineProperty(Array.prototype, "Clear", {
enumerable: false,
value: function (): void {
this.length = 0;
}
});
Array.prototype.ObjectSort || Object.defineProperty(Array.prototype, "ObjectSort", {
enumerable: false,
/**

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "8e88a5ef-a6a9-45f2-b6e7-f2f9c23fd006",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,16 @@
import UIPanel from "../Engine/Component/UIPanel/UIPanel";
const { ccclass, property } = cc._decorator;
/** HistoryPanel */
@ccclass
export default class HistoryPanel extends UIPanel {
//#region Custom
public LoadRecord(): void {
// throw new Error("Method not implemented.");
}
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "2dae2002-5461-4d34-9d22-320d94d87b57",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

12
assets/Script/Lobby.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "03d0f56a-1e9c-4539-a5eb-19bc303350e9",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
import UIPanel from "../Engine/Component/UIPanel/UIPanel";
const { ccclass, property } = cc._decorator;
/** VoicePanel */
@ccclass
export default class Lobby extends UIPanel {
//#region OnClick
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "83a72f1c-972e-4244-85a2-dc25a5c30b14",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "e0045972-fc35-40b9-8a53-26af07bbf122",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
import UIPanel from "../Engine/Component/UIPanel/UIPanel";
const { ccclass, property } = cc._decorator;
/** ScoreBoard */
@ccclass
export default class ScoreBoard extends UIPanel {
//#region OnClick
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "ad22b62d-6305-440f-b581-0a1d24faf15e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "081269a7-fbfe-44c1-9612-1e3cd757b085",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
import UIPanel from "../Engine/Component/UIPanel/UIPanel";
const { ccclass, property } = cc._decorator;
/** VoicePanel */
@ccclass
export default class VoicePanel extends UIPanel {
//#region OnClick
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "9faf3993-b5fe-4511-8b7b-93e467d25421",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "8905dac9-7a98-4d41-83e3-5c1fa1e0d0ac",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "c003e05b-fa36-4f48-a9ad-3f8fc9ba04ed",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,36 @@
import dayjs = require("dayjs");
/** NPM管理包 */
export default class NodePackageManager {
//#region static 屬性
private static _instance: NodePackageManager = null;
public static get Instance(): NodePackageManager { return NodePackageManager._instance; }
//#endregion
//#region public 需require 屬性
public Dayjs: typeof dayjs = dayjs;
//#endregion
//#region Lifecycle
constructor() {
NodePackageManager._instance = this;
this._initDayjs();
}
//#endregion
//#region Custom Function
private _initDayjs(): void {
require("dayjs/locale/zh-tw");
this.Dayjs.locale("zh-tw");
}
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "a91a5df1-ac62-4993-a364-cf4b46cfb787",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}