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

fix slot jar when emit, fix slot drop, update debound hammer

parent 878d9177
...@@ -12495,9 +12495,7 @@ ...@@ -12495,9 +12495,7 @@
}, },
"_enabled": true, "_enabled": true,
"slotJarIndex": [ "slotJarIndex": [
1, 1
2,
4
], ],
"_id": "" "_id": ""
}, },
......
...@@ -36,7 +36,6 @@ export default class BehindFragment extends cc.Component { ...@@ -36,7 +36,6 @@ export default class BehindFragment extends cc.Component {
public onDrop() { public onDrop() {
console.log('onDrop',)
this._isDropped = true; this._isDropped = true;
cc.tween(this.node) cc.tween(this.node)
......
...@@ -26,6 +26,7 @@ export default class BreakingJarController extends cc.Component { ...@@ -26,6 +26,7 @@ export default class BreakingJarController extends cc.Component {
private _behindJarChild: BehindFragment[] = []; private _behindJarChild: BehindFragment[] = [];
private _behindJarChildPosition: cc.Vec3[] = []; private _behindJarChildPosition: cc.Vec3[] = [];
private _hamerAvatar: cc.Sprite = null; private _hamerAvatar: cc.Sprite = null;
private _isBreak = true;
onLoad() { onLoad() {
cc.director.getPhysicsManager().enabled = true; cc.director.getPhysicsManager().enabled = true;
...@@ -176,7 +177,13 @@ export default class BreakingJarController extends cc.Component { ...@@ -176,7 +177,13 @@ export default class BreakingJarController extends cc.Component {
const pos = event.getLocation(); const pos = event.getLocation();
const nodePos = this.node.convertToNodeSpaceAR(pos); const nodePos = this.node.convertToNodeSpaceAR(pos);
if (!this._isBreak) {
return;
}
eventTarget.emit(CHECK_TOUCH, nodePos); eventTarget.emit(CHECK_TOUCH, nodePos);
this._isBreak = false;
this.scheduleOnce(() => this._isBreak = true, 0.5);
} }
private onTouchEnd(event: cc.Event.EventTouch) { private onTouchEnd(event: cc.Event.EventTouch) {
......
...@@ -71,15 +71,16 @@ export default class FragmentJarController extends cc.Component { ...@@ -71,15 +71,16 @@ export default class FragmentJarController extends cc.Component {
eventTarget.emit(HAMMER, point); eventTarget.emit(HAMMER, point);
eventTarget.emit(SHOW_SLOT_JAR, this.slotJarIndex, 3 - this._numberOfBeats); this.scheduleOnce(() => {
eventTarget.emit(SHOW_SLOT_JAR, this.slotJarIndex, 3 - this._numberOfBeats);
this.node.scale = 1 - 0.02 * (3 - this._numberOfBeats);
}, 0.5);
if (this._numberOfBeats == 1) { if (this._numberOfBeats == 1) {
eventTarget.emit(SHOW_FOG, this.node.position); eventTarget.emit(SHOW_FOG, this.node.position);
} }
if (this._numberOfBeats > 0) { if (this._numberOfBeats > 0) {
cc.tween(this.node)
.to(0.1, { scale: 1 - 0.02 * (3 - this._numberOfBeats) })
.start();
return; return;
} }
...@@ -107,6 +108,7 @@ export default class FragmentJarController extends cc.Component { ...@@ -107,6 +108,7 @@ export default class FragmentJarController extends cc.Component {
cc.Tween.stopAllByTarget(this.node); cc.Tween.stopAllByTarget(this.node);
cc.tween(this.node) cc.tween(this.node)
.delay(0.5)
.repeat(4, cc.tween(this.node) .repeat(4, cc.tween(this.node)
.by(Global.getRandomTimeSkew(), { position: cc.v3(-5, -5) }) .by(Global.getRandomTimeSkew(), { position: cc.v3(-5, -5) })
.by(Global.getRandomTimeSkew(), { position: cc.v3(5, 5) }) .by(Global.getRandomTimeSkew(), { position: cc.v3(5, 5) })
...@@ -115,13 +117,15 @@ export default class FragmentJarController extends cc.Component { ...@@ -115,13 +117,15 @@ export default class FragmentJarController extends cc.Component {
eventTarget.emit(PLAY_DROP_SOUND); eventTarget.emit(PLAY_DROP_SOUND);
this.node.setSiblingIndex(-1); this.node.setSiblingIndex(-1);
}) })
.to(Global.getRandomTimeSkew() * 5, { position: cc.v3(pos.x, pos.y - Global.getRandomTimeSkew() * 50) })
.call(() => { .call(() => {
this._physicsCollider.enabled = true; this._physicsCollider.enabled = true;
this._rg.type = cc.RigidBodyType.Dynamic; this._rg.type = cc.RigidBodyType.Dynamic;
this._physicsCollider.enabled = false;
this._rg.gravityScale = 15; this._rg.gravityScale = 15;
}) })
.delay(1) .delay(0.4)
.call(() => this._physicsCollider.enabled = true)
.delay(0.6)
.to(0, { scale: 1 }) .to(0, { scale: 1 })
.start(); .start();
} }
......
...@@ -19,6 +19,10 @@ export default class SlotJar extends cc.Component { ...@@ -19,6 +19,10 @@ export default class SlotJar extends cc.Component {
private showSlotByIndex(indexs: number[], breakCount: number): void { private showSlotByIndex(indexs: number[], breakCount: number): void {
indexs.forEach(index => { indexs.forEach(index => {
if(this._slotShowder[index] > 1){
return;
}
this._slotShowder[index] = breakCount;
this._slotBreak1thNodes[index].active = true; this._slotBreak1thNodes[index].active = true;
this._slotBreak2thNodes[index].active = breakCount >= 2; this._slotBreak2thNodes[index].active = breakCount >= 2;
}) })
...@@ -32,5 +36,6 @@ export default class SlotJar extends cc.Component { ...@@ -32,5 +36,6 @@ export default class SlotJar extends cc.Component {
private resetSlots(): void { private resetSlots(): void {
this._slotBreak1thNodes.forEach(node => node.active = false); this._slotBreak1thNodes.forEach(node => node.active = false);
this._slotBreak2thNodes.map(node => node.active = false); this._slotBreak2thNodes.map(node => node.active = false);
this._slotShowder = {};
} }
} }
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