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

clear file script not use

parent c34169d1
const { ccclass, property } = cc._decorator;
@ccclass
export default class BacksideFragment extends cc.Component {
@property(cc.Node)
private frontSideNode: cc.Node = null;
private _offsetPos: cc.Vec3 = null;
protected onLoad(): void {
this._offsetPos = this.node.position.clone().sub(this.frontSideNode.position);
}
protected update(dt: number): void {
this.node.angle = this.frontSideNode.angle;
this.node.position = this.frontSideNode.position.clone().add(this._offsetPos);
}
}
{
"ver": "1.1.0",
"uuid": "fb50bcec-3182-46f0-9261-0b4788d40d5c",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { BEAT_GUILD, CHECK_FRAGMENT, CHECK_TOUCH, DROP_ALL_FRAGMENT, eventTarget, HAMMER, RESET_BOTTLE, RESET_FRAGMENT, SHOW_CARD_POPUP, STOP_GUILD_TAP } from "../Events";
import { Global } from "../Global";
import FragmentController from "./FragmentController";
const { ccclass, property } = cc._decorator;
@ccclass
export default class BreakingBottleController extends cc.Component {
@property(cc.Node)
private hammerNode: cc.Node = null;
private _spine: sp.Skeleton = null;
private _skins = ["Ga", "Gai_lung", "Gay", "Bua",];
private _countFragment = 0;
private _fragmentsPosition: cc.Vec3[] = [];
private _fragmentsNode: cc.Node[] = [];
private _bodyFragments: string[] = [];
private _isEnd = false;
onLoad() {
return;
cc.director.getPhysicsManager().enabled = true;
// cc.director.getPhysicsManager().debugDrawFlags = cc.PhysicsManager.DrawBits.e_aabbBit |
// cc.PhysicsManager.DrawBits.e_jointBit |
// cc.PhysicsManager.DrawBits.e_shapeBit;
this._spine = this.hammerNode.getComponentInChildren(sp.Skeleton);
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
eventTarget.on(CHECK_FRAGMENT, this.checkFragment, this);
eventTarget.on(HAMMER, this.onHammer, this);
eventTarget.on(RESET_BOTTLE, this.resetBottle, this);
eventTarget.on(BEAT_GUILD, this.beatGuild, this);
this._fragmentsNode = this.getComponentsInChildren(FragmentController).map(item => item.node);
this._fragmentsPosition = this._fragmentsNode.map(item => item.position.clone());
}
private beatGuild() {
// this.onHammer(cc.v2(100));
}
protected start(): void {
this.resetHammer();
}
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) {
cc.Tween.stopAllByTarget(this.hammerNode);
this._spine.setAnimation(0, "Dap4", false);
this.hammerNode.active = true;
cc.tween(this.hammerNode)
.to(0.5, { position: cc.v3(newPos.x, newPos.y, 0) })
.delay(0.3)
.to(0.3, { position: cc.v3(400, -400) })
.call(() => this.hammerNode.active = false)
.start();
}
private checkFragment(name: string) {
if (this._isEnd) {
return;
}
if (!name.includes('nap')) {
this._bodyFragments.push(name);
}
this._countFragment++;
if (this._countFragment == 8) {
this.scheduleOnce(() => eventTarget.emit(SHOW_CARD_POPUP), 1.5);
this._isEnd = true;
}
if (this._bodyFragments.length == 6) {
eventTarget.emit(DROP_ALL_FRAGMENT);
}
}
private onTouchStart(event: cc.Event.EventTouch) {
eventTarget.emit(STOP_GUILD_TAP);
const pos = event.getLocation();
const nodePos = this.node.convertToNodeSpaceAR(pos);
eventTarget.emit(CHECK_TOUCH, nodePos);
this._spine.setSkin(this._skins[Global.tool % this._skins.length]);
}
private onTouchEnd(event: cc.Event.EventTouch) {
}
private resetHammer() {
this.hammerNode.position = cc.v3(300);
this.hammerNode.active = false;
}
}
{
"ver": "1.1.0",
"uuid": "6fcd7f71-d097-4f64-a0f3-52bd35d14332",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { eventTarget, PLAY_ANIM_NUT1, PLAY_ANIM_NUT2, PLAY_ANIM_NUT3, PLAY_ANIM_NUT4, SHOW_ACTION_SCREEN, STOP_ANIM_CHUM } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ChumController extends cc.Component {
private spine: sp.Skeleton = null;
private _count = 0;
private _actions: Function[] = [];
protected onLoad(): void {
this.spine = this.node.getComponent(sp.Skeleton);
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
this._actions = [this.playAnimationNut1, this.playAnimationNut2, this.playAnimationNut3, this.playAnimationNut4];
eventTarget.on(STOP_ANIM_CHUM, this.stopAnimation, this);
eventTarget.on(PLAY_ANIM_NUT1, this.playAnimationNut1, this);
eventTarget.on(PLAY_ANIM_NUT2, this.playAnimationNut2, this);
eventTarget.on(PLAY_ANIM_NUT3, this.playAnimationNut3, this);
eventTarget.on(PLAY_ANIM_NUT4, this.playAnimationNut4, this);
}
private onTouchStart(): void {
}
private stopAnimation(): void {
this.spine.setAnimation(0, "default", true);
}
public playAnimationNut1(): void {
this.playAnimation("nut1")
this.spine.timeScale = 1;
}
public playAnimationNut2(): void {
this.playAnimation("nut2")
this.spine.timeScale = 1;
}
public playAnimationNut3(): void {
this.node.active = true;
this.playAnimation("nut3")
this.spine.timeScale = 0.5;
}
public playAnimationNut4(): void {
this.playAnimation("nut4", false)
this.spine.timeScale = 0.5;
}
private playAnimation(animName: string, isLoop: boolean = true): void {
this.node.active = true;
this.spine.setAnimation(0, animName, isLoop);
}
}
{
"ver": "1.1.0",
"uuid": "d7d732f5-a717-4c0f-83e2-e163c01d4306",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -3,7 +3,7 @@ import { eventTarget, PLAY_ROLLING_SOUND } from "../Events"; ...@@ -3,7 +3,7 @@ import { eventTarget, PLAY_ROLLING_SOUND } from "../Events";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
export default class HuController extends cc.Component { export default class DevicemotionController extends cc.Component {
private _x: number = 0; private _x: number = 0;
private _y: number = 0; private _y: number = 0;
......
import { eventTarget, CHECK_TOUCH, CHECK_FRAGMENT, HAMMER, RESET_FRAGMENT, PLAY_DROP_SOUND, DROP_ALL_FRAGMENT } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class FragmentController extends cc.Component {
private _collider: cc.PolygonCollider = null;
private _physicsCollider: cc.PhysicsPolygonCollider = null;
private _rg: cc.RigidBody = null;
private _siblingIndex: number = 0;
private _isDropped: boolean = false;
onLoad() {
this._collider = this.node.getComponent(cc.PolygonCollider);
this._physicsCollider = this.node.getComponent(cc.PhysicsPolygonCollider);
this._physicsCollider.points = this._collider.points;
this._rg = this.node.getComponent(cc.RigidBody);
this._siblingIndex = this.node.getSiblingIndex();
this.reset();
eventTarget.on(CHECK_TOUCH, this.checkTouch, this);
eventTarget.on(RESET_FRAGMENT, this.reset, this);
eventTarget.on(DROP_ALL_FRAGMENT, () => this.node.name.includes('nap') && this.dropFragment(), this);
}
public reset() {
this._physicsCollider.enabled = false;
this._rg.type = cc.RigidBodyType.Static;
this.node.angle = 0;
this.node.setSiblingIndex(this._siblingIndex);
this._isDropped = false;
}
private checkTouch(point: cc.Vec2) {
if (this._isDropped) {
return;
}
const pos = point.clone().subtract(cc.v2(this.node.position.x, this.node.position.y));
let isInside = cc.Intersection.pointInPolygon(pos, this._collider.points);
if (isInside) {
eventTarget.emit(HAMMER, point);
this.dropFragment();
}
}
private dropFragment() {
this._isDropped = true;
const pos = this.node.position;
this.node.setSiblingIndex(-1);
eventTarget.emit(CHECK_FRAGMENT, this.node.name);
cc.tween(this.node)
.delay(0.5)
.call(() => {
eventTarget.emit(PLAY_DROP_SOUND);
})
.to(0.1, { scale: 0.9 })
.to(0.1, { scale: 1.05 })
.to(0.2, { position: pos.clone().multiplyScalar(1.2) })
.call(() => {
this._physicsCollider.enabled = true;
this._rg.type = cc.RigidBodyType.Dynamic;
this._rg.gravityScale = 10;
})
.delay(1)
.to(0, { scale: 1 })
.start();
}
}
{
"ver": "1.1.0",
"uuid": "ad9b7183-781d-4ae6-ac93-79add38d57c7",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { eventTarget, ROTATE_GUILD, STOP_GUILD_ROTATE } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class RotateTutorialController extends cc.Component {
private _hand: cc.Node;
protected onLoad(): void {
[this._hand] = this.node.children;
eventTarget.on(STOP_GUILD_ROTATE, this.stopGuild, this);
this.tutorialRotate();
}
private stopGuild() {
cc.Tween.stopAllByTarget(this._hand);
this._hand.active = false;
}
private tutorialRotate() {
this._hand.active = true;
cc.tween(this._hand)
.repeatForever(cc.tween(this._hand)
.to(0, { position: cc.v3(350) })
.to(0.5, { angle: -10 })
.to(0.5, { angle: 15 })
.call(() => eventTarget.emit(ROTATE_GUILD))
.to(0.8, { position: cc.v3(-150) })
)
.start();
}
}
{
"ver": "1.1.0",
"uuid": "245c4f1c-7b7e-4244-b576-57d18ca4fec5",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { eventTarget, PLAY_ANIM_NUT1, PLAY_ANIM_NUT2, PLAY_ANIM_NUT3, PLAY_ANIM_NUT4, SHOW_ACTION_SCREEN, SHOW_START_SCREEN } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ActionScreen extends cc.Component {
@property(cc.Node)
private bottleIdle: cc.Node = null;
@property(cc.Node)
private bottleAction: cc.Node = null;
private _spine: sp.Skeleton = null;
onLoad() {
eventTarget.on(SHOW_ACTION_SCREEN, this.showScreen, this);
eventTarget.on(SHOW_START_SCREEN, this.hideScreen, this);
eventTarget.on(PLAY_ANIM_NUT1, this.hideBottle, this);
eventTarget.on(PLAY_ANIM_NUT2, this.hideBottle, this);
eventTarget.on(PLAY_ANIM_NUT3, this.hideBottle, this);
eventTarget.on(PLAY_ANIM_NUT4, this.hideBottle, this);
this._spine = this.bottleIdle.getComponent(sp.Skeleton);
}
private hideBottle() {
this.bottleAction.active = true;
this.bottleIdle.active = false;
}
private showScreen() {
this.bottleAction.active = false;
this.bottleIdle.active = true;
this._spine.setAnimation(0, 'Idle', true);
this.node.active = true;
this.node.position = cc.v3();
}
private hideScreen() {
this.node.active = false;
}
}
{
"ver": "1.1.0",
"uuid": "1310ba6a-8b39-40d7-9ed8-1a2b8ee3420a",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import { eventTarget, SHOW_ACTION_SCREEN, SHOW_SELECT_POPUP } from "../Events";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SelectPopup extends cc.Component {
private _okBtnNode: cc.Node = null;
onLoad() {
this._okBtnNode = this.getComponentInChildren(cc.Button).node;
this.node.active = false;
this.node.position = cc.v3();
eventTarget.on(SHOW_SELECT_POPUP, this.showPopup, this);
this._okBtnNode.on('click', this.onOkBtnClick, this);
}
private showPopup() {
this.node.active = true;
}
private onOkBtnClick() {
this.node.active = false;
eventTarget.emit(SHOW_ACTION_SCREEN);
}
}
{
"ver": "1.1.0",
"uuid": "1cbf36c1-b0bd-4527-b846-76e65bed930e",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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