123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import FqLogin from "../../login/FqLogin";
- import { AudioMgr } from "../../main/ViewManage";
- import BaseEvent from "../fight/evnet/base/BaseEvent";
- const SpineName = {
- CLOSE: "close",
- OPEN: "open"
- }
- /**
- * 多组按钮控制开门
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class OpenDoor extends BaseEvent {
- @property({
- displayName: '道具ID',
- })
- goodID: number = 2001;
- /**
- * 控制的栅栏机关
- */
- @property({
- displayName: '控制的机关',
- type: [cc.Node],
- })
- mFenceTrigger: Array<cc.Node> = [];
- @property({
- displayName: '提示图标',
- type:cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- private count = 0;
- onBegin(tag: number) {
- let head = this.ff.mFFheader;
- let count = head.getTmpCount(this.goodID);
- if (count > 0) {
- this.showOpt(this.mTipsIcon,()=>{
- head.removeTmpGood(this.goodID, 1);
- this.closeOpt();
- this.checkOpen();
- })
- }else{
- }
- }
- onEnd(tag: number) {
- this.closeOpt();
- }
- private checkOpen() {
- //检查其它开关是否打开
- this.pause();
- this.moveCamera(this.mFenceTrigger[0].getPosition(), 1, () => {
- cc.tween(this.node).sequence(
- cc.callFunc(() => {
- for (let i = 0; i < this.mFenceTrigger.length; i++) {
- const element = this.mFenceTrigger[i];
- this.showFence(element, SpineName.OPEN);
- }
- this.ff.main.playerEffectByPath(AudioMgr.openDoor);
- }),
- cc.delayTime(1),
- cc.callFunc(() => {
- this.resume()
- 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);
- }
- }
- }
- }
|