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

updatte drop lid

parent 00772bb5
......@@ -25,4 +25,5 @@ export const CHECK_TOUCH = 'CHECK_TOUCH';
export const CHECK_FRAGMENT = 'CHECK_FRAGMENT';
export const HAMMER = 'HAMMER';
export const RESET_BOTTLE = 'RESET_BOTTLE';
export const RESET_FRAGMENT = 'RESET_FRAGMENT';
\ No newline at end of file
export const RESET_FRAGMENT = 'RESET_FRAGMENT';
export const DROP_FRAGMENT = 'DROP_FRAGMENT';
\ No newline at end of file
import { BEAT_GUILD, CHECK_FRAGMENT, CHECK_TOUCH, eventTarget, HAMMER, RESET_BOTTLE, RESET_FRAGMENT, SHOW_CARD_POPUP, STOP_GUILD_TAP } from "../Events";
import { BEAT_GUILD, CHECK_FRAGMENT, CHECK_TOUCH, DROP_FRAGMENT, eventTarget, HAMMER, RESET_BOTTLE, RESET_FRAGMENT, SHOW_CARD_POPUP, STOP_GUILD_TAP } from "../Events";
import { Global } from "../Global";
import FragmentController from "./FragmentController";
......@@ -16,6 +16,8 @@ export default class BreakingBottleController extends cc.Component {
private _fragmentsPosition: cc.Vec3[] = [];
private _fragmentsNode: cc.Node[] = [];
private _bodyFragments: string[] = [];
private _isEnd = false;
onLoad() {
......@@ -39,7 +41,7 @@ export default class BreakingBottleController extends cc.Component {
}
private beatGuild() {
this.onHammer(cc.v2(100));
// this.onHammer(cc.v2(100));
}
protected start(): void {
......@@ -48,12 +50,14 @@ export default class BreakingBottleController extends cc.Component {
private resetBottle() {
this._countFragment = 0;
this._bodyFragments = [];
this._spine.setSkin(this._skins[Global.tool % this._skins.length]);
this._fragmentsNode.forEach((node, index) => {
node.position = this._fragmentsPosition[index];
})
eventTarget.emit(RESET_FRAGMENT);
this._isEnd = false;
}
private onHammer(newPos: cc.Vec2) {
......@@ -69,9 +73,22 @@ export default class BreakingBottleController extends cc.Component {
}
private checkFragment(name: string) {
if (this._isEnd) {
return;
}
if (!name.includes('nap')) {
this._bodyFragments.push(name);
}
this._countFragment++;
if (this._countFragment == 8) {
eventTarget.emit(SHOW_CARD_POPUP);
this._isEnd = true;
}
if (this._bodyFragments.length == 6) {
eventTarget.emit(DROP_FRAGMENT);
// this.schedule(() => eventTarget.emit(SHOW_CARD_POPUP), 2);
// this._bodyFragments = [];
// this._isEnd = true;
}
}
......@@ -92,7 +109,4 @@ export default class BreakingBottleController extends cc.Component {
this.hammerNode.position = cc.v3(300);
this.hammerNode.active = false;
}
}
import { eventTarget, CHECK_TOUCH, CHECK_FRAGMENT, HAMMER, RESET_FRAGMENT, PLAY_DROP_SOUND } from "../Events";
import { eventTarget, CHECK_TOUCH, CHECK_FRAGMENT, HAMMER, RESET_FRAGMENT, PLAY_DROP_SOUND, DROP_FRAGMENT } from "../Events";
const { ccclass, property } = cc._decorator;
......@@ -21,6 +21,7 @@ export default class FragmentController extends cc.Component {
eventTarget.on(CHECK_TOUCH, this.checkTouch, this);
eventTarget.on(RESET_FRAGMENT, this.reset, this);
eventTarget.on(DROP_FRAGMENT, () => this.node.name.includes('nap') && this.dropFragment(), this);
}
public reset() {
......@@ -60,6 +61,7 @@ export default class FragmentController extends cc.Component {
.to(0, { scale: 1 })
.call(() => {
eventTarget.emit(CHECK_FRAGMENT, this.node.name);
console.log('CHECK_FRAGMENT', CHECK_FRAGMENT)
})
.start();
}
......
......@@ -10,8 +10,8 @@ export default class TapTutorialController extends cc.Component {
[this._hand] = this.node.children;
eventTarget.on(STOP_GUILD_TAP, this.stopGuild, this);
// this.tutorialTap();
this.tutorialTapForFragements();
this.tutorialTap();
// this.tutorialTapForFragements();
}
private stopGuild() {
......
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