123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import FqLogin from "../../../login/FqLogin";
- import { AudioMgr } from "../../../main/ViewManage";
- import FF from "../FF";
- import FMap from "../map/FMap";
- import FSprite from "../object/FSprite";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class FOpenTrigger extends cc.Component {
-
- @property([cc.Node])
- mFenceTrigger: Array<cc.Node> = [];
- @property([cc.Node])
- guides: Array<cc.Node> = [];
- @property(cc.SpriteFrame)
- closeFrame: cc.SpriteFrame = null;
- private fMap: FMap;
- private isOver = false;
- onLoad() {
- this.fMap = this.node.parent.parent.getComponent(FMap);
-
-
-
- }
- onBeginContact(contact: cc.PhysicsContact, selfCollider: cc.PhysicsCollider, other: cc.PhysicsCollider) {
- if (this.isOver) {
- return;
- }
- if (other.node.group == 'bullet') {
- return;
- }
- this.isOver = true;
- this.node.removeComponent(cc.PhysicsBoxCollider);
- let ff = this.fMap.ff;
- ff.pauseSprite(true);
- let camera = this.fMap.mCamera;
- let cameraPos = this.mFenceTrigger[0];
- let pos = cc.v2();
- let winsize = cc.winSize;
- pos.x = cameraPos.x - winsize.width / 2;
- pos.y = cameraPos.y - winsize.height / 2;
- for (let i = 0; i < this.guides.length; i++) {
- const element = this.guides[i];
- element.destroy();
- }
- this.guides = [];
- let sprite = this.node.getComponent(cc.Sprite);
- sprite.spriteFrame = this.closeFrame;
- cc.tween(camera.node).sequence(
- cc.moveTo(1.5, pos),
- cc.callFunc(() => {
- for (let i = 0; i < this.mFenceTrigger.length; i++) {
- const element = this.mFenceTrigger[i];
- this.showFence(element, 'close');
- }
- ff.main.playerEffectByPath(AudioMgr.openDoor);
- }),
- cc.delayTime(1),
- cc.callFunc(() => {
- ff.pauseSprite(false);
- for (let i = 0; i < this.mFenceTrigger.length; i++) {
- const element = this.mFenceTrigger[i];
- element.active = false;
- }
- FqLogin.commitEvent(this.node.name, '', '');
- })
- ).start();
- }
- private showFence(element, action) {
- let nodes = element.children;
- for (let i = 0; i < nodes.length; i++) {
- const element = nodes[i];
- let spine = element.getComponent(sp.Skeleton);
- if (spine) {
- spine.setAnimation(0, action, false);
- }
- }
- }
- }
|