import FF from "../../FF"; import FSprite from "../../object/FSprite"; import WOneByone from "./WOneByone"; /** * 监狱事件提示 */ const {ccclass, property} = cc._decorator; @ccclass export default class FCageSign extends cc.Component { @property(cc.Prefab) mMapDialog: cc.Prefab = null; @property(cc.Node) mD1: cc.Node = null; @property(cc.Node) mD2: cc.Node = null; @property({ type:cc.Node, displayName: '摄像机移动的目标位置' }) mCameraPos: cc.Node = null; private ff:FF = null; onBeginContact(contact: cc.PhysicsContact, self: cc.PhysicsCollider, other: cc.PhysicsCollider){ if(other.node.group == 'A'){ let obj = other.node.getComponent(FSprite); this.ff = obj.ff; if(obj == this.ff.mainSprite){ this.node.removeComponent(cc.PhysicsBoxCollider); this.run(); } } } private run(){ this.ff.pauseSprite(true); this.ff.mBlockInputEvents.active = true; let map = this.ff.mMap; let winSize = cc.winSize let camera = map.mCamera; let cx = this.node.x + this.mCameraPos.x - winSize.width/2; let cy = this.node.y + this.mCameraPos.y - winSize.height/2; cc.tween(camera.node).sequence( cc.moveTo(0.7,cc.v2(cx,cy)), cc.callFunc(()=>{ this.d1(); }) ).start() } private d1(){ let dialogs = [ '救…救……,SOS', ]; let node = cc.instantiate(this.mMapDialog); node.group = 'map' node.zIndex = 9999; node.x = this.mD1.x; node.y = this.mD1.y + this.mD1.height; node.parent = this.ff.mMap.mSprites; let obo = node.getComponent(WOneByone); obo.dialogs = dialogs; obo.setCallback(()=>{ node.destroy(); this.ff.setBlockInputCallback(null); this.d2(); }); this.ff.setBlockInputCallback(()=>{ obo.jump(); }); obo._start(); } private d2(){ let dialogs = [ '别喊了,你就是叫破喉咙也没用的', ]; let node = cc.instantiate(this.mMapDialog); node.group = 'map' node.zIndex = 9999; node.x = this.mD2.x; node.y = this.mD2.y + this.mD2.height; node.parent = this.ff.mMap.mSprites; let obo = node.getComponent(WOneByone); obo.dialogs = dialogs; obo.setCallback(()=>{ node.destroy(); this.ff.setBlockInputCallback(null); this.ff.pauseSprite(false); this.ff.mBlockInputEvents.active = false; }); this.ff.setBlockInputCallback(()=>{ obo.jump(); }); obo._start(); } }