import FqLogin from "../../../login/FqLogin"; import { AudioMgr } from "../../../main/ViewManage"; import BaseEvent from "../../fight/evnet/base/BaseEvent"; import { SpriteActionType } from "../../fight/object/FSprite"; /** * 多组按钮控制开门-解救宠物剧情 */ const { ccclass, property } = cc._decorator; @ccclass export default class JG0111_1 extends BaseEvent { @property({ displayName: '替换的图片', type: cc.Sprite, }) mIcon: cc.Sprite = null; @property({ displayName: '未踩上图片', type: cc.SpriteFrame, }) mIcon0: cc.SpriteFrame = null; @property({ displayName: '踩上后的图片', type: cc.SpriteFrame, }) mIcon1: cc.SpriteFrame = null; /** * 控制的地刺 */ @property({ displayName: '控制的地刺', type: [cc.Node], }) mFenceTrigger: Array = []; @property({ displayName: '困住的宠物', type: cc.Node, }) mPet: cc.Node = null; @property({ displayName: '对话用NPC', type: cc.Node, }) mNpc: cc.Node = null; /** * 控制的地刺 */ @property({ displayName: '控制的机关', type: [cc.Node], }) mFenceTrigger1: Array = []; /** * 机关是否已经结束 */ public isOver = false; private count = 0; onLoad() { super.onLoad(); this.node.zIndex = -9999; this.mNpc.active = false; } onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) { if (other.node.group != 'bullet') { this.count++ this.onBegin(self.tag) } } onEndContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider) { if (other.node.group != 'bullet') { this.count-- if (this.count <= 0) { this.count = 0; this.onEnd(self.tag) } } } onBegin(tag: number) { this.mIcon.spriteFrame = this.mIcon1; this.checkOpen(); } onEnd(tag: number) { } private checkOpen() { if (this.isOver) { return } this.isOver = true; this.pause(); this.moveCamera(this.mFenceTrigger[0].getPosition(), 1, () => { cc.tween(this.node).sequence( cc.callFunc(() => { this.showFence(this.mFenceTrigger[0], 'down'); let nodes = this.mFenceTrigger[1].children for (let i = 0; i < nodes.length; i++) { const element = nodes[i]; this.showFence(element, 'down'); } this.ff.main.playerEffectByPath(AudioMgr.openDoor); }), cc.delayTime(1), cc.callFunc(() => { this.mFenceTrigger[0].getComponent(cc.PhysicsBoxCollider).enabled = false; this.startPlot() }) ).start(); }) } private showFence(element, action) { let nodes = element.children; for (let i = 0; i < nodes.length; i++) { const element = nodes[i]; let spine: sp.Skeleton = element.getComponent(sp.Skeleton); if (spine) { spine.setAnimation(0, action, false); } } } /** * 开始剧情 * 1.NPC从左边移动出现 */ private startPlot() { this.mNpc.active = true; cc.tween(this.mNpc).sequence( cc.moveTo(1, cc.v2(3180, 5870)), cc.callFunc(() => { this.dialog1() }) ).start() let mainSprite = this.ff.mainSprite mainSprite.setLR(-1) mainSprite.playAction(SpriteActionType.run, true) cc.tween(mainSprite.node).sequence( cc.moveTo(1, cc.v2(3388, 5813)), cc.callFunc(() => { mainSprite.playAction(SpriteActionType.stand, true) }) ).start() } /** * 落单的精灵:太好了太好了!!(落单的精灵鼓掌) 落单的精灵:你成功救出了这头小鹿,我之前尝试了很多次都无法成功。 落单的精灵:不得不承认,你出乎了我的意料。 */ private dialog1() { let text = [ '太好了太好了!!', '你成功救出了这头小鹿,我之前尝试了很多次都无法成功。', '不得不承认,你出乎了我的意料。' ] this.showDialog(this.mNpc, text, () => { this.escape() }) } /** * 小鹿逃跑 */ private escape() { for (let i = 0; i < this.mFenceTrigger1.length; i++) { const element = this.mFenceTrigger1[i]; element.active = false } let spine = this.mPet.getComponent(sp.Skeleton) spine.setAnimation(0, SpriteActionType.run, true); cc.tween(this.mPet).sequence( cc.moveBy(1,cc.v2(0,-500)), cc.callFunc(()=>{ this.dialog2() }), cc.destroySelf() ).start() } private dialog2() { let text = [ '逃跑了……', ] let mainSprite = this.ff.mainSprite this.showDialog(mainSprite.node, text, () => { this.dialog3() }) } private dialog3() { let text = [ '快追!!', ] this.showDialog(this.mNpc, text, () => { cc.tween(this.mNpc).sequence( cc.moveTo(1, cc.v2(3294, 5085)), cc.callFunc(() => { this.resume() }), cc.destroySelf() ).start() }) } }