56 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2022-09-20 23:50:01 +08:00
cc.Class({
extends: cc.Component,
properties: {
modeButton: {
type: cc.Button,
default: null
},
mapNode: {
type: cc.Node,
default: null
},
2023-02-12 18:20:04 +08:00
characterSelectCells: {
type: cc.Node,
default: []
},
2023-02-12 23:04:20 +08:00
chosenSpeciesId: {
type: cc.Integer,
default: 0
},
2023-02-13 10:34:56 +08:00
loadingNode: {
default: null,
type: cc.Node
},
2022-09-20 23:50:01 +08:00
},
// LIFE-CYCLE CALLBACKS:
2023-02-13 10:34:56 +08:00
onLoad() {
},
2023-02-12 18:20:04 +08:00
2023-02-12 22:10:42 +08:00
onSpeciesSelected(evt, val) {
2023-02-12 18:20:04 +08:00
for (let cell of this.characterSelectCells) {
const comp = cell.getComponent("CharacterSelectCell");
2023-02-12 22:10:42 +08:00
if (comp.speciesId != val) {
comp.chosenFlag.node.active = false;
2023-02-12 18:20:04 +08:00
} else {
2023-02-12 22:10:42 +08:00
comp.chosenFlag.node.active = true;
2023-02-12 23:04:20 +08:00
this.chosenSpeciesId = val;
2023-02-12 18:20:04 +08:00
}
}
},
2023-02-12 23:04:20 +08:00
onModeButtonClicked(evt) {
2023-02-13 10:34:56 +08:00
for (let cell of this.characterSelectCells) {
const comp = cell.getComponent("CharacterSelectCell");
comp.setInteractable(false);
}
this.modeButton.node.active = false;
this.loadingNode.active = true;
this.loadingNode.runAction(
cc.repeatForever(cc.rotateBy(1.0, 360))
);
2023-02-12 23:04:20 +08:00
this.mapNode.getComponent("Map").onGameRule1v1ModeClicked(this.chosenSpeciesId);
},
2022-09-20 23:50:01 +08:00
});