import FqLogin from "../../login/FqLogin"; import { AudioMgr } from "../../main/ViewManage"; import BaseEvent from "../fight/evnet/base/BaseEvent"; /** * 多组按钮控制开门-解救宠物剧情 */ 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], }) mButtons: Array = []; /** * 控制的栅栏机关 */ @property({ displayName: '控制的机关', type: [cc.Node], }) mFenceTrigger: Array = []; @property({ displayName: '困住的宠物', type: cc.Node, }) mPet: cc.Node = null; /** * 机关是否已经结束 */ public isOver = false; private count = 0; onLoad(){ super.onLoad(); this.node.zIndex = -9999; } 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.resume() this.mFenceTrigger[0].getComponent(cc.PhysicsBoxCollider).enabled = false; // for (let i = 0; i < this.mFenceTrigger.length; i++) { // const element = this.mFenceTrigger[i]; // // element.active = false; // element.getComponent(cc.PhysicsBoxCollider).enabled = false; // } }) ).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); } } } }