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

add slot jar in fragment

parent 96d5ab95
This diff is collapsed.
......@@ -13,7 +13,7 @@
},
{
"__type__": "cc.Node",
"_name": "Mask Frigment",
"_name": "Slot Jar",
"_objFlags": 0,
"_parent": null,
"_children": [
......@@ -37,10 +37,13 @@
"_components": [
{
"__id__": 32
},
{
"__id__": 33
}
],
"_prefab": {
"__id__": 33
"__id__": 34
},
"_opacity": 255,
"_color": {
......@@ -65,7 +68,7 @@
"ctor": "Float64Array",
"array": [
0,
107.087,
0,
0,
0,
0,
......@@ -91,7 +94,7 @@
},
{
"__type__": "cc.Node",
"_name": "top-left-1",
"_name": "0",
"_objFlags": 0,
"_parent": {
"__id__": 1
......@@ -261,7 +264,7 @@
"asset": {
"__id__": 0
},
"fileId": "efOZHP7CFGGqjj6t9YgAFS",
"fileId": "963oRWBaBJKYzQjkVgR3p3",
"sync": false
},
{
......@@ -304,12 +307,12 @@
"asset": {
"__id__": 0
},
"fileId": "78jSXvs1hEjpEmixVayhhX",
"fileId": "e0JBmCCkNN67IogvW4CHZW",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "left-center-1",
"_name": "1",
"_objFlags": 0,
"_parent": {
"__id__": 1
......@@ -479,7 +482,7 @@
"asset": {
"__id__": 0
},
"fileId": "52Qv/HqR9B8pvxU7YNCmXK",
"fileId": "d6kvGp9ylL9YOhZ+4fs91k",
"sync": false
},
{
......@@ -522,12 +525,12 @@
"asset": {
"__id__": 0
},
"fileId": "51Qw/wwLlD+oaeYl0HU4H2",
"fileId": "a0iDGpKyhPKYDUwE6bz2k9",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "right-center-1",
"_name": "2",
"_objFlags": 0,
"_parent": {
"__id__": 1
......@@ -697,7 +700,7 @@
"asset": {
"__id__": 0
},
"fileId": "898gR7uBJPJbHJzFio1hC0",
"fileId": "c6V49ouuRDFbiuPf+/6ExX",
"sync": false
},
{
......@@ -740,12 +743,12 @@
"asset": {
"__id__": 0
},
"fileId": "1aD2QzJIdGUaBKHuNhc8IS",
"fileId": "3fZ0IHcrFMIZByqRABl08R",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "left-bot-1",
"_name": "3",
"_objFlags": 0,
"_parent": {
"__id__": 1
......@@ -915,7 +918,7 @@
"asset": {
"__id__": 0
},
"fileId": "797N6z2qxHOrHgYFS3fsII",
"fileId": "910T0tu5JCZ6Fc7XEqoU7s",
"sync": false
},
{
......@@ -958,12 +961,12 @@
"asset": {
"__id__": 0
},
"fileId": "82ESYo9XdMMIexUlaL7emU",
"fileId": "aaLG7moclGlqNwStKxvQez",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "right-bot-1",
"_name": "4",
"_objFlags": 0,
"_parent": {
"__id__": 1
......@@ -1133,7 +1136,7 @@
"asset": {
"__id__": 0
},
"fileId": "966tbwaq1FcqG/4WpRHvhj",
"fileId": "a5tUSRASBHcpw89127dFcg",
"sync": false
},
{
......@@ -1176,7 +1179,7 @@
"asset": {
"__id__": 0
},
"fileId": "64l7i9oVBMO5e8ZigUwbyV",
"fileId": "d3A0356hxE+54gv59dspym",
"sync": false
},
{
......@@ -1192,15 +1195,52 @@
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_spriteFrame": {
"__uuid__": "a2dadd38-66b9-4fc5-8bb1-792cd8b267f6"
},
"_spriteFrame": null,
"_type": 2,
"_segments": 64,
"_N$alphaThreshold": 0.1,
"_N$alphaThreshold": 0.2,
"_N$inverted": false,
"_id": ""
},
{
"__type__": "35c38MoQkxHiJs43Jq5ANmu",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"slotFrames": [
{
"__uuid__": "a2dadd38-66b9-4fc5-8bb1-792cd8b267f6"
},
{
"__uuid__": "dfb6da8e-12eb-449c-86fb-3830b24fe1ed"
},
{
"__uuid__": "d0fe7dae-cf48-453b-9d0d-1a649bbcd684"
},
{
"__uuid__": "cb24393f-fa65-4c70-8917-f090aa42fff8"
},
{
"__uuid__": "3fb3fd71-b993-458b-8634-01f4fb618aeb"
},
{
"__uuid__": "276b1dcf-2bdc-419b-8282-746869f3fd84"
},
{
"__uuid__": "5275d624-3fc1-4ff2-9088-0512e5730292"
},
{
"__uuid__": "9e87901f-5894-4b48-8fbf-589d6689d0bf"
},
{
"__uuid__": "ab7b45db-efa6-4b84-bf46-e33889a3e460"
}
],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
......
{
"ver": "1.3.2",
"uuid": "a1b49066-ba1a-4e09-b5ee-9008f3f2c98f",
"uuid": "637ec680-5eb3-4392-83ff-9dc376e3feb6",
"importer": "prefab",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
......
......@@ -5,20 +5,12 @@ export const SHOW_START_SCREEN = 'SHOW_START_SCREEN';
export const SHOW_CARD_POPUP = 'SHOW_CARD_POPUP';
export const STOP_ANIM_CHUM = 'STOP_ANIM_CHUM';
export const SHOW_SELECT_POPUP = 'SHOW_SELECT_POPUP';
export const PLAY_ROLLING_SOUND = 'PLAY_ROLLING_SOUND';
export const PLAY_BREAKING_SOUND = 'PLAY_BREAKING_SOUND';
export const PLAY_DROP_SOUND = 'PLAY_DROP_SOUND';
export const PLAY_ANIM_NUT1 = 'PLAY_ANIM_NUT1';
export const PLAY_ANIM_NUT2 = 'PLAY_ANIM_NUT2';
export const PLAY_ANIM_NUT3 = 'PLAY_ANIM_NUT3';
export const PLAY_ANIM_NUT4 = 'PLAY_ANIM_NUT4';
export const ROTATE_GUILD = 'ROTATE_GUILD';
export const BEAT_GUILD = 'BEAT_GUILD';
export const STOP_GUILD_ROTATE = 'STOP_GUILD_ROTATE';
export const START_GUILD_TAP = 'START_GUILD_TAP';
export const STOP_GUILD_TAP = 'STOP_GUILD_TAP';
......@@ -29,6 +21,5 @@ export const RESET_BOTTLE = 'RESET_BOTTLE';
export const RESET_FRAGMENT = 'RESET_FRAGMENT';
export const DROP_ALL_FRAGMENT = 'DROP_ALL_FRAGMENT';
export const DROP_TOP_FRAGMENT = 'DROP_TOP_FRAGMENT';
export const DROP_BEHIND_FRAGMENT = 'DROP_BEHIND_FRAGMENT';
export const SHAKE_FRAGMENT = 'SHAKE_FRAGMENT';
export const SHOW_FOG = 'SHOW_FOG';
\ No newline at end of file
import { BEAT_GUILD, CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, DROP_TOP_FRAGMENT, eventTarget, HAMMER, PLAY_BREAKING_SOUND, RESET_BOTTLE, RESET_FRAGMENT, SHAKE_FRAGMENT, SHOW_CARD_POPUP, SHOW_FOG, STOP_GUILD_TAP } from "../Events";
import { Global } from "../Global";
import { BEAT_GUILD, CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, eventTarget, HAMMER, PLAY_BREAKING_SOUND, RESET_BOTTLE, RESET_FRAGMENT, SHAKE_FRAGMENT, SHOW_CARD_POPUP, SHOW_FOG, STOP_GUILD_TAP } from "../Events";
import BehindFragment from "./BehindFragment";
import FragmentJarController from "./FragmentJarController";
......@@ -7,8 +6,6 @@ const { ccclass, property } = cc._decorator;
@ccclass
export default class BreakingJarController extends cc.Component {
@property([cc.Node])
private fragmentSpecialNodes: cc.Node[] = [];
@property(cc.Node)
private hammerNode: cc.Node = null;
@property(cc.Node)
......@@ -30,9 +27,9 @@ export default class BreakingJarController extends cc.Component {
private _behindJarChildPosition: cc.Vec3[] = [];
private _hamerAvatar: cc.Sprite = null;
onLoad() {
cc.director.getPhysicsManager().enabled = true;
// cc.director.getPhysicsManager().debugDrawFlags = cc.PhysicsManager.DrawBits.e_aabbBit |
// cc.PhysicsManager.DrawBits.e_jointBit |
// cc.PhysicsManager.DrawBits.e_shapeBit;
......@@ -85,10 +82,6 @@ export default class BreakingJarController extends cc.Component {
}
private checkFragment(fragmentNode: cc.Node) {
const fontFragment = this._fontFragments.findIndex(item => item === fragmentNode);
const behindFragment = this._behindJarChild[fontFragment];
// behindFragment.onDrop();
if (this._isEnd) {
return;
}
......@@ -102,6 +95,8 @@ export default class BreakingJarController extends cc.Component {
.start();
}
// return;
if (this._countFragment == 3) {
this.particleFont.stopSystem();
this.particleBehind.stopSystem();
......@@ -118,14 +113,6 @@ export default class BreakingJarController extends cc.Component {
.start();
this._isEnd = true;
return;
}
const isSpecial = this.fragmentSpecialNodes.some(item => item === fragmentNode);
const isDropTop = this.fragmentSpecialNodes.every(item => item.getComponent(FragmentJarController).isDropped);
if (isSpecial && isDropTop) {
eventTarget.emit(DROP_TOP_FRAGMENT);
}
}
......
import { CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, DROP_TOP_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 } from "../Events";
import { Global } from "../Global";
import SlotJar from "./SlotJar";
const { ccclass, property } = cc._decorator;
@ccclass
export default class FragmentJarController extends cc.Component {
@property(cc.Node)
private fragmentLink: cc.Node = null;
@property
private isBottom: boolean = false;
public isDropped: boolean = false;
private _physicsCollider: cc.PhysicsPolygonCollider = null;
private _physicsColliderFragmentLink: cc.PhysicsPolygonCollider = null;
private _rg: cc.RigidBody = null;
private _siblingIndex: number = 0;
private _numberOfBeats = 3;
private _slots: cc.Node[] = [];
private _slotJar: SlotJar = null;
onLoad() {
this._slotJar = this.node.getComponentInChildren(SlotJar);
this._physicsCollider = this.node.getComponent(cc.PhysicsPolygonCollider);
this._physicsColliderFragmentLink = this.fragmentLink && this.fragmentLink.getComponent(cc.PhysicsPolygonCollider);
this._rg = this.node.getComponent(cc.RigidBody);
this._siblingIndex = this.node.getSiblingIndex();
this._slots = this.node.children;
this._slots.forEach(slot => slot.active = false);
this.reset();
eventTarget.on(CHECK_TOUCH, this.checkTouch, this);
eventTarget.on(RESET_FRAGMENT, this.reset, this);
eventTarget.on(DROP_ALL_FRAGMENT, this.dropFragment, this);
eventTarget.on(DROP_TOP_FRAGMENT, this.dropFragmentTop, this);
eventTarget.on(DROP_ALL_FRAGMENT, this.dropAllFragment, this);
eventTarget.on(SHAKE_FRAGMENT, this.shakeFragment, this);
}
......@@ -44,7 +39,6 @@ export default class FragmentJarController extends cc.Component {
this.node.setSiblingIndex(this._siblingIndex);
this.isDropped = false;
this._numberOfBeats = 3;
this.node.children.forEach(slot => slot.active = false);
}
public shakeFragment() {
......@@ -64,33 +58,21 @@ export default class FragmentJarController extends cc.Component {
if (this.isDropped || this.isBottom) {
return;
}
const pos = point.clone().subtract(cc.v2(this.node.position.x, this.node.position.y));
const jarPos = this.node.parent.position;
const pos = point.clone().subtract(cc.v2(jarPos.x, jarPos.y)).subtract(this._physicsCollider.offset);
const isInside = cc.Intersection.pointInPolygon(pos, this._physicsCollider.points);
let isInsideFragmentLink = false;
if (this._physicsColliderFragmentLink) {
const posFragmentLink = point.clone().subtract(cc.v2(this.fragmentLink.position.x, this.fragmentLink.position.y));
isInsideFragmentLink = cc.Intersection.pointInPolygon(posFragmentLink, this._physicsColliderFragmentLink.points);
}
if (!isInside && !isInsideFragmentLink) {
if (!isInside) {
return;
}
this._numberOfBeats--;
if (this._slots.length > 0) {
cc.tween(this)
.delay(0.5)
.call(() => {
this._slots[Math.min(2 - this._numberOfBeats, 1)].active = true
})
.start();
}
eventTarget.emit(HAMMER, point);
this._slotJar.showSlots(3 - this._numberOfBeats);
if (this._numberOfBeats == 1) {
eventTarget.emit(SHOW_FOG, this.node.position);
}
......@@ -105,10 +87,13 @@ export default class FragmentJarController extends cc.Component {
this.dropFragment();
}
private dropFragmentTop() {
if (this.isBottom) {
private dropAllFragment() {
if (this.isDropped) {
return;
}
this._slotJar.showSlots(3);
this.dropFragment();
}
......
import { eventTarget, RESET_BOTTLE } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SlotJar extends cc.Component {
private _slotBreak2thNodes: cc.Node[] = [];
private _slotBreak1thNodes: cc.Node[] = [];
protected onLoad(): void {
this._slotBreak1thNodes = this.node.children;
this._slotBreak2thNodes = this._slotBreak1thNodes.map(node => node.children[0]);
this.resetSlots();
eventTarget.on(RESET_BOTTLE, this.resetSlots, this);
}
public showSlots(breakCount: number): void {
this._slotBreak1thNodes.forEach(node => node.active = true);
this._slotBreak2thNodes.forEach(node => node.active = breakCount >= 2);
}
private resetSlots(): void {
this._slotBreak1thNodes.forEach(node => node.active = false);
this._slotBreak2thNodes.map(node => node.active = false);
}
}
{
"ver": "1.1.0",
"uuid": "35c38328-424c-4788-9b38-dc9ab900d9ae",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ export default class StartScreen extends cc.Component {
eventTarget.on(SHOW_START_SCREEN, () => this.node.active = true, this);
eventTarget.on(SHOW_ACTION_SCREEN, () => this.node.active = false, this);
this.scheduleOnce(this.onSelectBtnClick, 0.2);
}
private onSelectBtnClick() {
......
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