[fix] HoldButton 點擊事件衝突

This commit is contained in:
建喵 2022-05-05 19:19:28 +08:00
parent 4aabd0b866
commit d771dd7593
20 changed files with 3594 additions and 6079 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,26 +30,26 @@
"__id__": 14 "__id__": 14
}, },
{ {
"__id__": 21 "__id__": 22
}, },
{ {
"__id__": 24 "__id__": 25
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 28
},
{ {
"__id__": 29 "__id__": 29
}, },
{ {
"__id__": 30 "__id__": 30
},
{
"__id__": 31
} }
], ],
"_prefab": { "_prefab": {
"__id__": 31 "__id__": 32
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -545,12 +545,18 @@
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 18
},
{ {
"__id__": 19 "__id__": 19
},
{
"__id__": 20
} }
], ],
"_prefab": { "_prefab": {
"__id__": 20 "__id__": 21
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -562,7 +568,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 170, "width": 141,
"height": 95 "height": 95
}, },
"_anchorPoint": { "_anchorPoint": {
@ -574,7 +580,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
24.968, 40.145,
0, 0,
0, 0,
0, 0,
@ -611,13 +617,10 @@
"_components": [ "_components": [
{ {
"__id__": 16 "__id__": 16
},
{
"__id__": 17
} }
], ],
"_prefab": { "_prefab": {
"__id__": 18 "__id__": 17
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -641,7 +644,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, -15.785,
6.2, 6.2,
0, 0,
0, 0,
@ -666,78 +669,6 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 0.9,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 1,
"transition": 1,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 230,
"g": 230,
"b": 230,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 230,
"g": 230,
"b": 230,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 120,
"g": 120,
"b": 120,
"a": 200
},
"_N$normalSprite": {
"__uuid__": "eacf7329-d93d-41c2-a973-4065b01b6041"
},
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 15
},
"_id": ""
},
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
@ -788,7 +719,7 @@
"node": { "node": {
"__id__": 14 "__id__": 14
}, },
"_enabled": false, "_enabled": true,
"_materials": [ "_materials": [
{ {
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
@ -801,6 +732,92 @@
"_N$inverted": false, "_N$inverted": false,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 1,
"transition": 1,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 245,
"g": 245,
"b": 245,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 245,
"g": 245,
"b": 245,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 15
},
"_id": ""
},
{
"__type__": "0d1d5HfnyFLAK2RYSpW387d",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"MaxTime": 0.3,
"IsHaveHoldLine": false,
"HoldLine": null,
"ProgressBG": null,
"ProgressLine": null,
"OnInvoke": [],
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
@ -823,11 +840,11 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 22 "__id__": 23
} }
], ],
"_prefab": { "_prefab": {
"__id__": 23 "__id__": 24
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -881,7 +898,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 21 "__id__": 22
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -931,14 +948,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 25 "__id__": 26
}, },
{ {
"__id__": 26 "__id__": 27
} }
], ],
"_prefab": { "_prefab": {
"__id__": 27 "__id__": 28
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
@ -992,7 +1009,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 24 "__id__": 25
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
@ -1055,7 +1072,7 @@
"hoverSprite": null, "hoverSprite": null,
"_N$disabledSprite": null, "_N$disabledSprite": null,
"_N$target": { "_N$target": {
"__id__": 24 "__id__": 25
}, },
"_id": "" "_id": ""
}, },
@ -1064,7 +1081,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 24 "__id__": 25
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
@ -1207,13 +1224,13 @@
}, },
"_enabled": true, "_enabled": true,
"MaxTime": 2, "MaxTime": 2,
"Button": { "IsHaveHoldLine": false,
"__id__": 16 "HoldLine": null,
}, "ProgressBG": null,
"holdLine": null, "ProgressLine": null,
"progressBG": null, "OnInvoke": [
"progressLine": null, null
"OnInvoke": [], ],
"_id": "" "_id": ""
}, },
{ {

File diff suppressed because it is too large Load Diff

View File

@ -114,22 +114,29 @@ export class Badminton extends cc.Component {
protected onLoad(): void { protected onLoad(): void {
Badminton._instance = this; Badminton._instance = this;
let self: this = this;
new LocalStorageData(); new LocalStorageData();
this.config.Init(); let AsyncFunction: () => IterableIterator<any> = function* (): IterableIterator<any> {
this.record.Init(); yield CoroutineV2.Parallel(
CoroutineV2.Parallel( self.config.Init(),
this.Lobby.Show(), self.record.Init(),
this.ScoreBoard.Show(), ).Start();
).Start(); CoroutineV2.Parallel(
if (this.HistoryPanel != null) { self.Lobby.Show(),
this.HistoryPanel.LoadRecord(); self.ScoreBoard.Show(),
this.HistoryPanel.Hide(); ).Start();
CoroutineV2.Single(this.HistoryPanel.Hide()).Start(); if (self.HistoryPanel != null) {
} self.HistoryPanel.LoadRecord();
// textToSpeech = FindObjectOfType<TextToSpeech>(); self.HistoryPanel.Hide();
CoroutineV2.Single(self.HistoryPanel.Hide()).Start();
}
// textToSpeech = FindObjectOfType<TextToSpeech>();
CoroutineV2.Single(self.Show()).Start();
};
CoroutineV2.Single(AsyncFunction()).Start();
} }
protected start(): void { public *Show(): IterableIterator<any> {
CoroutineV2.Single(this.ScoreBoard.Hide()).Start(); CoroutineV2.Single(this.ScoreBoard.Hide()).Start();
this._initUI(); this._initUI();
// LoadStatus(); // LoadStatus();
@ -147,6 +154,7 @@ export class Badminton extends cc.Component {
//#region Custom //#region Custom
private _initUI(): void { private _initUI(): void {
let self: this = this;
this._updateCurSelMember(); this._updateCurSelMember();
// this.toggleItem.gameObject.SetActive(false); // this.toggleItem.gameObject.SetActive(false);
// this.teamItem.gameObject.SetActive(false); // this.teamItem.gameObject.SetActive(false);
@ -166,20 +174,17 @@ export class Badminton extends cc.Component {
for (let idx: number = 0; idx < this.TeamMemberList.length; idx++) { for (let idx: number = 0; idx < this.TeamMemberList.length; idx++) {
let memberName: string = this.TeamMemberList[idx].Name; let memberName: string = this.TeamMemberList[idx].Name;
let item: cc.Toggle = parent.ExAddChild(this.toggleItem).getComponent(cc.Toggle); let item: cc.Toggle = parent.ExAddChild(this.toggleItem).getComponent(cc.Toggle);
item.node.getChildByName("Label").getComponent(cc.Label).string = memberName; item.node.getChildByName("Name").getComponent(cc.Label).string = memberName;
item.node.active = true; item.node.active = true;
item.node.getChildByName("Btn_Del").on("click", () => { this.OnDelMember(idx); }, this); item.node.getChildByName("Btn_Del").on("click", () => { this.OnDelMember(idx); }, this);
let picObj: cc.Node = item.node.getChildByName("Avatar").getChildByName("Pic"); let picObj: cc.Node = item.node.getChildByName("Avatar").getChildByName("Pic");
if (picObj != null) { 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);
// let EventHandler: cc.Component.EventHandler = new cc.Component.EventHandler(); picObj.parent.getComponent(HoldButton).OnInvoke.AddListener(() => { this.OnChangeAvatar(idx); });
// EventHandler.target = this.node; picObj.parent.on("click", () => {
// EventHandler.component = this.name.split("<")[1].split(">")[0]; item.isChecked = !item.isChecked;
// EventHandler.handler = "OnChangeAvatar"; self._onChangeSelMember(item);
// EventHandler.customEventData = idx.toString(); }, this);
// picObj.getComponent(HoldButton).OnInvoke.push(EventHandler);
picObj.getComponent(HoldButton).OnInvoke.AddListener(() => { this.OnChangeAvatar(idx); });
picObj.on("click", () => { item.isChecked = !item.isChecked; }, this);
} }
this._m_toggleList.push(item); this._m_toggleList.push(item);
@ -239,7 +244,7 @@ export class Badminton extends cc.Component {
this.CurMemberList.Clear(); this.CurMemberList.Clear();
this._m_toggleList.forEach((member: cc.Toggle) => { this._m_toggleList.forEach((member: cc.Toggle) => {
if (member.isChecked) { if (member.isChecked) {
this.CurMemberList.push(member.node.getChildByName("Label").getComponent(cc.Label).string); this.CurMemberList.push(member.node.getChildByName("Name").getComponent(cc.Label).string);
} }
}); });
if (this.TeamMemberList != null && this.TeamMemberList.length > 0) { if (this.TeamMemberList != null && this.TeamMemberList.length > 0) {
@ -255,7 +260,7 @@ export class Badminton extends cc.Component {
break; break;
} }
for (let j: number = 0; j < 2; j++) { for (let j: number = 0; j < 2; j++) {
let memberName: string = team.getChildByName("Member_" + (j + 1) + "/Text").getComponent(cc.Label).string; let memberName: string = team.getChildByName("Member_" + (j + 1)).getChildByName("Name").getComponent(cc.Label).string;
chkMemberList.push(memberName); chkMemberList.push(memberName);
} }
} }
@ -268,7 +273,7 @@ export class Badminton extends cc.Component {
} }
private _updateTeamShow(chkMemberList: string[]): void { private _updateTeamShow(chkMemberList: string[]): void {
let teamCount: number = chkMemberList.length / 2; let teamCount: number = Math.floor(chkMemberList.length / 2);
let maxTeam: number = Math.ceil(chkMemberList.length / 2.0); let maxTeam: number = Math.ceil(chkMemberList.length / 2.0);
while (this._m_teamList.length > maxTeam) { while (this._m_teamList.length > maxTeam) {
this._m_teamList[this._m_teamList.length - 1].destroy(); this._m_teamList[this._m_teamList.length - 1].destroy();
@ -285,8 +290,8 @@ export class Badminton extends cc.Component {
} else { } else {
obj = this._m_teamList[i]; obj = this._m_teamList[i];
} }
obj.getChildByName("Member_1").getChildByName("Text").getComponent(cc.Label).string = ""; obj.getChildByName("Member_1").getChildByName("Name").getComponent(cc.Label).string = "";
obj.getChildByName("Member_2").getChildByName("Text").getComponent(cc.Label).string = ""; obj.getChildByName("Member_2").getChildByName("Name").getComponent(cc.Label).string = "";
obj.getChildByName("Member_1").getComponent(cc.Sprite).enabled = false; obj.getChildByName("Member_1").getComponent(cc.Sprite).enabled = false;
obj.getChildByName("Member_2").getComponent(cc.Sprite).enabled = false; obj.getChildByName("Member_2").getComponent(cc.Sprite).enabled = false;
obj.active = false; obj.active = false;
@ -309,7 +314,7 @@ export class Badminton extends cc.Component {
chkMemberList.ExRemoveAt(0); chkMemberList.ExRemoveAt(0);
} }
team.getChildByName("Member_" + (j + 1) + "/Text").getComponent(cc.Label).string = name; 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).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; team.active = true;
@ -319,8 +324,8 @@ export class Badminton extends cc.Component {
let name_1: string = chkMemberList[0]; let name_1: string = chkMemberList[0];
let name_2: string = this.GetDefaultMemberName(); let name_2: string = this.GetDefaultMemberName();
let team: cc.Node = this._m_teamList[teamCount]; let team: cc.Node = this._m_teamList[teamCount];
team.getChildByName("Member_1").getChildByName("Text").getComponent(cc.Label).string = name_1; team.getChildByName("Member_1").getChildByName("Name").getComponent(cc.Label).string = name_1;
team.getChildByName("Member_2").getChildByName("Text").getComponent(cc.Label).string = name_2; 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).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.getChildByName("No").getComponent(cc.Label).string = (index + 1).toString();
@ -347,6 +352,55 @@ export class Badminton extends cc.Component {
// this.AvatarPanel.OpenChange(teamMemberList[index]); // this.AvatarPanel.OpenChange(teamMemberList[index]);
} }
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();
// 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);
// }
}
//#endregion //#endregion
} }

View File

@ -1,7 +1,9 @@
import LocalStorageData from "../Engine/Data/LocalStorageData"; import { CoroutineV2 } from "../Engine/CatanEngine/CoroutineV2/CoroutineV2";
import AvatarSettings from "../Settings/AvatarSettings";
import GameConfig from "../Settings/GameConfig";
import { Badminton } from "./Badminton"; import { Badminton } from "./Badminton";
import { AvatarData, AvatarSettings, GameConfig, MemberData } from "./MemberData"; import { AvatarData, MemberData } from "./MemberData";
/** ConfigManager */ /** ConfigManager */
export default class ConfigManager { export default class ConfigManager {
@ -24,17 +26,29 @@ export default class ConfigManager {
this.Main = mainControl; this.Main = mainControl;
} }
public Init(): void { public *Init(): IterableIterator<any> {
this.LoadMemberList(); yield CoroutineV2.Parallel(
this.LoadAvatarSettings(); this.LoadMemberList(),
this.LoadAvatarSettings()
).Start();
} }
public LoadMemberList(): void { public *LoadMemberList(): IterableIterator<any> {
let teamMemberList: MemberData[] = this.Main.TeamMemberList; let teamMemberList: MemberData[] = this.Main.TeamMemberList;
if (teamMemberList == null) { if (teamMemberList == null) {
this.Main.TeamMemberList = teamMemberList = []; this.Main.TeamMemberList = teamMemberList = [];
} }
let request: GameConfig = (<GameConfig>JSON.parse(LocalStorageData.Instance.GameConfig)); let request: GameConfig;
cc.resources.load("GameConfig", function (err: Error, prefab: cc.Prefab): void {
if (err) {
console.error(`resources.load GameConfig error: ${err}`);
return;
}
request = prefab.data.getComponent(GameConfig);
});
while (!request) {
yield null;
}
if (request != null) { if (request != null) {
let members: string[] = teamMemberList.map(m => Object.values(m)[0]); let members: string[] = teamMemberList.map(m => Object.values(m)[0]);
@ -43,11 +57,23 @@ export default class ConfigManager {
teamMemberList.push(new MemberData(request.Members[i])); teamMemberList.push(new MemberData(request.Members[i]));
} }
} }
this.Main.TeamMemberList = teamMemberList;
} }
} }
public LoadAvatarSettings(): void { public *LoadAvatarSettings(): IterableIterator<any> {
let request: AvatarSettings = (<AvatarSettings>JSON.parse(LocalStorageData.Instance.AvatarSettings)); // let request: AvatarSettings = (<AvatarSettings>JSON.parse(LocalStorageData.Instance.AvatarSettings));
let request: AvatarSettings;
cc.resources.load("AvatarSettings", function (err: Error, prefab: cc.Prefab): void {
if (err) {
console.error(`resources.load AvatarSettings error: ${err}`);
return;
}
request = prefab.data.getComponent(AvatarSettings);
});
while (!request) {
yield null;
}
if (request != null) { if (request != null) {
this.Avatars = request.Avatars; this.Avatars = request.Avatars;
} }

View File

@ -1,5 +1,16 @@
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
//#region Enum
/** AvatarColor */
export enum AvatarColor {
None,
Pink,
Yellow
}
//#endregion
//#region Class //#region Class
/** 成員資料 */ /** 成員資料 */
@ -21,25 +32,63 @@ export class MemberData {
} }
/** AvatarData */ /** AvatarData */
@ccclass("AvatarData")
export class AvatarData { export class AvatarData {
public ID: number; @property()
public ID: number = 0;
public Model: number; @property()
public Model: number = 0;
public Name: string; @property()
public Name: string = "";
public Desc: string; @property()
public Desc: string = "";
public Pic: cc.SpriteFrame; @property({ type: cc.SpriteFrame })
public Pic: cc.SpriteFrame = null;
public BigPic: cc.SpriteFrame; @property({ type: cc.SpriteFrame })
public BigPic: cc.SpriteFrame = null;
public BG: cc.SpriteFrame; @property({ type: cc.SpriteFrame })
public BG: cc.SpriteFrame = null;
public color: AvatarColor; @property({ type: cc.Enum(AvatarColor) })
public color: AvatarColor = AvatarColor.None;
} }
// /** AvatarData */
// @ccclass
// export class AvatarData extends cc.Component {
// // @property()
// // public ID: number = 0;
// // @property()
// // public Model: number = 0;
// // @property()
// // public Name: string = "";
// // @property()
// // public Desc: string = "";
// // @property({ type: cc.SpriteFrame })
// // public Pic: cc.SpriteFrame = null;
// // @property({ type: cc.SpriteFrame })
// // public BigPic: cc.SpriteFrame = null;
// // @property({ type: cc.SpriteFrame })
// // public BG: cc.SpriteFrame = null;
// // @property({ type: cc.Enum(AvatarColor) })
// // public color: AvatarColor;
// }
/** 分數結果 */ /** 分數結果 */
export class ScoreResult { export class ScoreResult {
@ -73,29 +122,4 @@ export class GameRecord {
public Score: number[]; 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 //#endregion

View File

@ -19,7 +19,7 @@ export default class RecordManager {
this.Main = badminton; this.Main = badminton;
} }
public Init(): any { public *Init(): IterableIterator<any> {
// //
} }

View File

@ -30,9 +30,6 @@ export default class HoldButton extends cc.Component {
//#region private //#region private
/** 按钮的点击事件列表 */
private _clickEvents: cc.Component.EventHandler[] = [];
private _isOnInvoke: boolean = false; private _isOnInvoke: boolean = false;
private _m_isMouseDown: boolean = false; private _m_isMouseDown: boolean = false;
@ -44,8 +41,6 @@ export default class HoldButton extends cc.Component {
//#region Lifecycle //#region Lifecycle
protected start(): void { protected start(): void {
this._clickEvents = Array.from(this.getComponent(cc.Button).clickEvents);
this.getComponent(cc.Button).clickEvents.Clear();
if (this.HoldLine != null) { if (this.HoldLine != null) {
this.HoldLine.active = false; this.HoldLine.active = false;
} }
@ -86,6 +81,8 @@ export default class HoldButton extends cc.Component {
} }
if (this._m_pressDeltaTime > this.MaxTime) { if (this._m_pressDeltaTime > this.MaxTime) {
this.node.pauseSystemEvents(true);
this._isOnInvoke = true; this._isOnInvoke = true;
this._m_isMouseDown = false; this._m_isMouseDown = false;
if (this.IsHaveHoldLine) { if (this.IsHaveHoldLine) {
@ -94,7 +91,7 @@ export default class HoldButton extends cc.Component {
this._m_pressDeltaTime = 0; this._m_pressDeltaTime = 0;
if (this.OnInvoke != null) { if (this.OnInvoke != null) {
this.OnInvoke.forEach((eventHandler: cc.Component.EventHandler) => { this.OnInvoke.forEach((eventHandler: cc.Component.EventHandler) => {
if (eventHandler.target === <any>"AddListener" && eventHandler.component === "AddListener" && eventHandler.handler) { if (eventHandler.target === <any>"Callback" && eventHandler.component === "Callback" && eventHandler.handler) {
(<Function><unknown>eventHandler.handler)(); (<Function><unknown>eventHandler.handler)();
} else { } else {
eventHandler.emit([this.node.getComponent(cc.Button)]); eventHandler.emit([this.node.getComponent(cc.Button)]);
@ -119,31 +116,23 @@ export default class HoldButton extends cc.Component {
} }
private _onTouchEnd(event: cc.Event.EventTouch): void { private _onTouchEnd(event: cc.Event.EventTouch): void {
this.node.resumeSystemEvents(true);
this._m_isMouseDown = false; this._m_isMouseDown = false;
this._m_pressDeltaTime = 0; this._m_pressDeltaTime = 0;
if (this.IsHaveHoldLine) { if (this.IsHaveHoldLine) {
this.HoldLine.active = false; this.HoldLine.active = false;
} }
if (!this._isOnInvoke) {
this._clickEvents.forEach((eventHandler: cc.Component.EventHandler) => {
eventHandler.emit([this.node.getComponent(cc.Button)]);
});
}
this._isOnInvoke = false; this._isOnInvoke = false;
this._checkHoldAutoStart(0); this._checkHoldAutoStart(0);
} }
private _onTouchCancel(event: cc.Event.EventTouch): void { private _onTouchCancel(event: cc.Event.EventTouch): void {
this.node.resumeSystemEvents(true);
this._m_isMouseDown = false; this._m_isMouseDown = false;
this._m_pressDeltaTime = 0; this._m_pressDeltaTime = 0;
if (this.IsHaveHoldLine) { if (this.IsHaveHoldLine) {
this.HoldLine.active = false; this.HoldLine.active = false;
} }
if (!this._isOnInvoke) {
this._clickEvents.forEach((eventHandler: cc.Component.EventHandler) => {
eventHandler.emit([this.node.getComponent(cc.Button)]);
});
}
this._isOnInvoke = false; this._isOnInvoke = false;
this._checkHoldAutoStart(0); this._checkHoldAutoStart(0);
} }

View File

@ -10,8 +10,8 @@ export default class LocalStorageData {
} }
// ======================================================================================= // =======================================================================================
public get GameConfig(): string { return cc.sys.localStorage.getItem("GameConfig"); } // public get GameConfig(): string { return cc.sys.localStorage.getItem("GameConfig"); }
public set GameConfig(value: string) { cc.sys.localStorage.setItem("GameConfig", value); } // public set GameConfig(value: string) { cc.sys.localStorage.setItem("GameConfig", value); }
public get AvatarSettings(): string { return cc.sys.localStorage.getItem("AvatarSettings"); } public get AvatarSettings(): string { return cc.sys.localStorage.getItem("AvatarSettings"); }
public set AvatarSettings(value: string) { cc.sys.localStorage.setItem("AvatarSettings", value); } public set AvatarSettings(value: string) { cc.sys.localStorage.setItem("AvatarSettings", value); }

View File

@ -22,18 +22,6 @@ declare interface Array<T> {
AddListener(call: Function): void; AddListener(call: Function): void;
} }
Array.prototype.AddListener || Object.defineProperty(Array.prototype, "AddListener", {
enumerable: false,
value: function (call: Function): void {
let EventHandler: cc.Component.EventHandler = new cc.Component.EventHandler();
EventHandler.target = <any>"AddListener";
EventHandler.component = "AddListener";
EventHandler.handler = <any>call;
this.push(EventHandler);
console.log(`AddListener`);
}
});
Array.prototype.ExRemoveAt || Object.defineProperty(Array.prototype, "ExRemoveAt", { Array.prototype.ExRemoveAt || Object.defineProperty(Array.prototype, "ExRemoveAt", {
enumerable: false, enumerable: false,
value: function (index: number): any { value: function (index: number): any {
@ -93,4 +81,15 @@ Array.prototype.ObjectSort || Object.defineProperty(Array.prototype, "ObjectSort
} }
return arr; return arr;
} }
});
Array.prototype.AddListener || Object.defineProperty(Array.prototype, "AddListener", {
enumerable: false,
value: function (call: Function): void {
let EventHandler: cc.Component.EventHandler = new cc.Component.EventHandler();
EventHandler.target = <any>"Callback";
EventHandler.component = "Callback";
EventHandler.handler = <any>call;
this.push(EventHandler);
}
}); });

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "3e53f15a-91ce-4567-8215-226ec95a0916",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,13 @@
import { AvatarData } from "../Badminton/MemberData";
const { ccclass, property } = cc._decorator;
@ccclass
export default class AvatarSettings extends cc.Component {
//#region property
@property({ type: [AvatarData] })
public Avatars: AvatarData[] = [];
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "fdefeb01-d27d-4efb-80b8-bc50efad3e18",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@ -0,0 +1,11 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class GameConfig extends cc.Component {
//#region property
@property({ type: [cc.String] })
public Members: string[] = [];
//#endregion
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "f71e5db1-de2b-4f7a-8f2b-27389a68724e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

12
assets/resources.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "f7cc2540-b077-41a4-a64d-885c9c9ee2f4",
"isBundle": true,
"bundleName": "resources",
"priority": 8,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,317 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "AvatarSettings",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "fdefesB0n1O+4C4vFDvrT4Y",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"Avatars": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
},
{
"__id__": 6
},
{
"__id__": 7
},
{
"__id__": 8
},
{
"__id__": 9
},
{
"__id__": 10
},
{
"__id__": 11
},
{
"__id__": 12
},
{
"__id__": 13
}
],
"_id": ""
},
{
"__type__": "AvatarData",
"ID": 0,
"Model": 1,
"Name": "卡比兔",
"Desc": "兔兔好可愛",
"Pic": {
"__uuid__": "591e9fe0-34ff-4ca9-936d-6224c67887ce"
},
"BigPic": {
"__uuid__": "8c088875-e4d4-4433-bd43-1d280263ee78"
},
"BG": {
"__uuid__": "1fd54956-5ef8-4cfb-b7c5-4b1ade8128e8"
},
"color": 1
},
{
"__type__": "AvatarData",
"ID": 1,
"Model": 1,
"Name": "棉花兔",
"Desc": "不可以吃兔兔",
"Pic": {
"__uuid__": "fc7e084c-7d37-4e27-a81b-e7b56f86d4d1"
},
"BigPic": {
"__uuid__": "b9875164-6bb3-4297-b469-2a6ca57be532"
},
"BG": {
"__uuid__": "849f5708-274e-4ef4-a572-4d4d390b8f3e"
},
"color": 2
},
{
"__type__": "AvatarData",
"ID": 2,
"Model": 2,
"Name": "皮卡兔",
"Desc": "皮卡皮卡",
"Pic": {
"__uuid__": "90a5bd2d-02a6-4edf-bd11-3216bd5000b2"
},
"BigPic": {
"__uuid__": "60e8d7df-297f-4b45-874e-e49348c3c335"
},
"BG": {
"__uuid__": "32a01273-503c-4b9f-bdf5-b7ea5ee80651"
},
"color": 1
},
{
"__type__": "AvatarData",
"ID": 3,
"Model": 2,
"Name": "兔卡丘",
"Desc": "皮卡丘~~",
"Pic": {
"__uuid__": "e1076035-6f5f-4675-b627-e18b8dfc3b85"
},
"BigPic": {
"__uuid__": "ec882c79-299f-4e0e-ba26-f7f9127a6c97"
},
"BG": {
"__uuid__": "244d62d1-4ef9-4ced-8cec-01cfd338d4f2"
},
"color": 2
},
{
"__type__": "AvatarData",
"ID": 4,
"Model": 3,
"Name": "樂樂兔",
"Desc": "勝利就是快樂",
"Pic": {
"__uuid__": "ae5dd508-202a-47e7-a96b-e82b6c61c20b"
},
"BigPic": {
"__uuid__": "f7fa0fc0-6918-447d-843d-050d6e647dfa"
},
"BG": {
"__uuid__": "16b86c24-e68a-494a-a3a0-762913e38658"
},
"color": 1
},
{
"__type__": "AvatarData",
"ID": 5,
"Model": 3,
"Name": "哈哈兔",
"Desc": "開心才是勝利",
"Pic": {
"__uuid__": "35c56232-f9d9-48a0-8fa8-a19d1275cb9c"
},
"BigPic": {
"__uuid__": "74167db6-7e35-486d-ab33-1ee37fac4734"
},
"BG": {
"__uuid__": "e2215105-e8b3-4af9-b3d5-ae5fa1b976ca"
},
"color": 2
},
{
"__type__": "AvatarData",
"ID": 6,
"Model": 4,
"Name": "跳跳兔",
"Desc": "直覺派的擊球手",
"Pic": {
"__uuid__": "169886b1-19de-475c-8906-b316d72e1801"
},
"BigPic": {
"__uuid__": "3f14a91c-f27f-4380-ae61-a0fdfa8de40f"
},
"BG": {
"__uuid__": "29ea7c34-4ccc-454e-be19-0fc15f78cdc9"
},
"color": 1
},
{
"__type__": "AvatarData",
"ID": 7,
"Model": 4,
"Name": "活潑兔",
"Desc": "擊球靠直覺",
"Pic": {
"__uuid__": "59a62929-7af3-4cf6-874f-4d1acb3549c4"
},
"BigPic": {
"__uuid__": "b7573c10-bd13-4431-b1e1-282fddca16db"
},
"BG": {
"__uuid__": "21066501-b444-411a-a42d-582b654008b5"
},
"color": 2
},
{
"__type__": "AvatarData",
"ID": 8,
"Model": 5,
"Name": "壯壯兔",
"Desc": "鍛鍊而獲得最強",
"Pic": {
"__uuid__": "df884dd1-1cbb-4f99-af72-968472a283a0"
},
"BigPic": {
"__uuid__": "e6f7519c-354b-464c-b9ca-1e7c712dd849"
},
"BG": {
"__uuid__": "cf5806e2-b31b-425b-acfb-c10fef5dd7be"
},
"color": 1
},
{
"__type__": "AvatarData",
"ID": 9,
"Model": 5,
"Name": "肌肉兔",
"Desc": "最強從鍛鍊獲得",
"Pic": {
"__uuid__": "d4871d0c-3e69-4048-b800-fb887dc6ed5a"
},
"BigPic": {
"__uuid__": "5b458791-4414-46f2-a7ac-b029310c12de"
},
"BG": {
"__uuid__": "083c296f-a94a-4598-80a9-dd201804cdc8"
},
"color": 2
},
{
"__type__": "AvatarData",
"ID": -1,
"Model": 0,
"Name": "隨機",
"Desc": "就是那個隨機",
"Pic": {
"__uuid__": "e14f92d4-2beb-4433-a54f-00bba5667508"
},
"BigPic": null,
"BG": {
"__uuid__": "345539cd-3c89-45fa-aadc-3446d4be1085"
},
"color": 0
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0512a942-c0c3-4605-a4de-a410dd3bdea0"
},
"fileId": "",
"sync": false
}
]

View File

@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "0512a942-c0c3-4605-a4de-a410dd3bdea0",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

View File

@ -0,0 +1,109 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "GameConfig",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "f71e52x3itPeo8rJziaaHJO",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"Members": [
"Tim",
"Yuki",
"克拉克",
"建喵",
"筑涵",
"阿湯",
"熊",
"冠群",
"岳儒",
"博約"
],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "",
"sync": false
}
]

View File

@ -0,0 +1,8 @@
{
"ver": "1.2.9",
"uuid": "7a177f8d-d09e-4eea-9fd8-dcad3cf9c64a",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}