Commit 878d9177 authored by Vũ Gia Vương's avatar Vũ Gia Vương

done fix show slot

parent 89976061
......@@ -5223,7 +5223,9 @@
"__id__": 112
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
0
],
"_id": ""
},
{
......@@ -6663,7 +6665,9 @@
"__id__": 152
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
2
],
"_id": ""
},
{
......@@ -8113,7 +8117,10 @@
"__id__": 192
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
0,
1
],
"_id": ""
},
{
......@@ -9588,7 +9595,9 @@
"__id__": 232
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
2
],
"_id": ""
},
{
......@@ -11038,7 +11047,9 @@
"__id__": 272
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
1
],
"_id": ""
},
{
......@@ -12483,7 +12494,11 @@
"__id__": 312
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
1,
2,
4
],
"_id": ""
},
{
......@@ -13958,7 +13973,10 @@
"__id__": 352
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
2,
4
],
"_id": ""
},
{
......@@ -15428,7 +15446,10 @@
"__id__": 392
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
3,
4
],
"_id": ""
},
{
......@@ -16888,7 +16909,10 @@
"__id__": 432
},
"_enabled": true,
"isBottom": false,
"slotJarIndex": [
3,
4
],
"_id": ""
},
{
......
......@@ -23,3 +23,4 @@ export const DROP_ALL_FRAGMENT = 'DROP_ALL_FRAGMENT';
export const DROP_TOP_FRAGMENT = 'DROP_TOP_FRAGMENT';
export const SHAKE_FRAGMENT = 'SHAKE_FRAGMENT';
export const SHOW_FOG = 'SHOW_FOG';
export const SHOW_SLOT_JAR = 'SHOW_SLOT_JAR';
\ No newline at end of file
import { CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, eventTarget, HAMMER, PLAY_DROP_SOUND, RESET_FRAGMENT, SHAKE_FRAGMENT, SHOW_FOG } from "../Events";
import { CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, eventTarget, HAMMER, PLAY_DROP_SOUND, RESET_FRAGMENT, SHAKE_FRAGMENT, SHOW_FOG, SHOW_SLOT_JAR } from "../Events";
import { Global } from "../Global";
import SlotJar from "./SlotJar";
......@@ -6,8 +6,8 @@ const { ccclass, property } = cc._decorator;
@ccclass
export default class FragmentJarController extends cc.Component {
@property
private isBottom: boolean = false;
@property([Number])
private slotJarIndex: number[] = [];
public isDropped: boolean = false;
......@@ -55,7 +55,7 @@ export default class FragmentJarController extends cc.Component {
}
private checkTouch(point: cc.Vec2) {
if (this.isDropped || this.isBottom) {
if (this.isDropped) {
return;
}
const jarPos = this.node.parent.position;
......@@ -71,8 +71,7 @@ export default class FragmentJarController extends cc.Component {
eventTarget.emit(HAMMER, point);
this._slotJar.showSlots(3 - this._numberOfBeats);
eventTarget.emit(SHOW_SLOT_JAR, this.slotJarIndex, 3 - this._numberOfBeats);
if (this._numberOfBeats == 1) {
eventTarget.emit(SHOW_FOG, this.node.position);
}
......
import { eventTarget, RESET_BOTTLE } from "../Events";
import { eventTarget, RESET_BOTTLE, SHOW_SLOT_JAR } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SlotJar extends cc.Component {
private _slotBreak2thNodes: cc.Node[] = [];
private _slotBreak1thNodes: cc.Node[] = [];
private _slotShowder: { [key: number]: number } = {};
protected onLoad(): void {
this._slotBreak1thNodes = this.node.children;
......@@ -14,6 +14,14 @@ export default class SlotJar extends cc.Component {
this.resetSlots();
eventTarget.on(RESET_BOTTLE, this.resetSlots, this);
eventTarget.on(SHOW_SLOT_JAR, this.showSlotByIndex, this);
}
private showSlotByIndex(indexs: number[], breakCount: number): void {
indexs.forEach(index => {
this._slotBreak1thNodes[index].active = true;
this._slotBreak2thNodes[index].active = breakCount >= 2;
})
}
public showSlots(breakCount: number): void {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment