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

done fix show slot

parent 89976061
...@@ -5223,7 +5223,9 @@ ...@@ -5223,7 +5223,9 @@
"__id__": 112 "__id__": 112
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
0
],
"_id": "" "_id": ""
}, },
{ {
...@@ -6663,7 +6665,9 @@ ...@@ -6663,7 +6665,9 @@
"__id__": 152 "__id__": 152
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
2
],
"_id": "" "_id": ""
}, },
{ {
...@@ -8113,7 +8117,10 @@ ...@@ -8113,7 +8117,10 @@
"__id__": 192 "__id__": 192
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
0,
1
],
"_id": "" "_id": ""
}, },
{ {
...@@ -9588,7 +9595,9 @@ ...@@ -9588,7 +9595,9 @@
"__id__": 232 "__id__": 232
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
2
],
"_id": "" "_id": ""
}, },
{ {
...@@ -11038,7 +11047,9 @@ ...@@ -11038,7 +11047,9 @@
"__id__": 272 "__id__": 272
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
1
],
"_id": "" "_id": ""
}, },
{ {
...@@ -12483,7 +12494,11 @@ ...@@ -12483,7 +12494,11 @@
"__id__": 312 "__id__": 312
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
1,
2,
4
],
"_id": "" "_id": ""
}, },
{ {
...@@ -13958,7 +13973,10 @@ ...@@ -13958,7 +13973,10 @@
"__id__": 352 "__id__": 352
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
2,
4
],
"_id": "" "_id": ""
}, },
{ {
...@@ -15428,7 +15446,10 @@ ...@@ -15428,7 +15446,10 @@
"__id__": 392 "__id__": 392
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
3,
4
],
"_id": "" "_id": ""
}, },
{ {
...@@ -16888,7 +16909,10 @@ ...@@ -16888,7 +16909,10 @@
"__id__": 432 "__id__": 432
}, },
"_enabled": true, "_enabled": true,
"isBottom": false, "slotJarIndex": [
3,
4
],
"_id": "" "_id": ""
}, },
{ {
......
...@@ -23,3 +23,4 @@ export const DROP_ALL_FRAGMENT = 'DROP_ALL_FRAGMENT'; ...@@ -23,3 +23,4 @@ export const DROP_ALL_FRAGMENT = 'DROP_ALL_FRAGMENT';
export const DROP_TOP_FRAGMENT = 'DROP_TOP_FRAGMENT'; export const DROP_TOP_FRAGMENT = 'DROP_TOP_FRAGMENT';
export const SHAKE_FRAGMENT = 'SHAKE_FRAGMENT'; export const SHAKE_FRAGMENT = 'SHAKE_FRAGMENT';
export const SHOW_FOG = 'SHOW_FOG'; 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 { Global } from "../Global";
import SlotJar from "./SlotJar"; import SlotJar from "./SlotJar";
...@@ -6,8 +6,8 @@ const { ccclass, property } = cc._decorator; ...@@ -6,8 +6,8 @@ const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class FragmentJarController extends cc.Component { export default class FragmentJarController extends cc.Component {
@property @property([Number])
private isBottom: boolean = false; private slotJarIndex: number[] = [];
public isDropped: boolean = false; public isDropped: boolean = false;
...@@ -55,7 +55,7 @@ export default class FragmentJarController extends cc.Component { ...@@ -55,7 +55,7 @@ export default class FragmentJarController extends cc.Component {
} }
private checkTouch(point: cc.Vec2) { private checkTouch(point: cc.Vec2) {
if (this.isDropped || this.isBottom) { if (this.isDropped) {
return; return;
} }
const jarPos = this.node.parent.position; const jarPos = this.node.parent.position;
...@@ -71,8 +71,7 @@ export default class FragmentJarController extends cc.Component { ...@@ -71,8 +71,7 @@ export default class FragmentJarController extends cc.Component {
eventTarget.emit(HAMMER, point); eventTarget.emit(HAMMER, point);
this._slotJar.showSlots(3 - this._numberOfBeats); eventTarget.emit(SHOW_SLOT_JAR, this.slotJarIndex, 3 - this._numberOfBeats);
if (this._numberOfBeats == 1) { if (this._numberOfBeats == 1) {
eventTarget.emit(SHOW_FOG, this.node.position); 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; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class SlotJar extends cc.Component { export default class SlotJar extends cc.Component {
private _slotBreak2thNodes: cc.Node[] = []; private _slotBreak2thNodes: cc.Node[] = [];
private _slotBreak1thNodes: cc.Node[] = []; private _slotBreak1thNodes: cc.Node[] = [];
private _slotShowder: { [key: number]: number } = {};
protected onLoad(): void { protected onLoad(): void {
this._slotBreak1thNodes = this.node.children; this._slotBreak1thNodes = this.node.children;
...@@ -14,6 +14,14 @@ export default class SlotJar extends cc.Component { ...@@ -14,6 +14,14 @@ export default class SlotJar extends cc.Component {
this.resetSlots(); this.resetSlots();
eventTarget.on(RESET_BOTTLE, this.resetSlots, this); 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 { 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