1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { SpriteActionType } from "../../object/FSprite";
- import FHitBox from "./FHitBox";
- /**
- * 打碎一组箱子后打开门
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FHitBoxOpenDoor extends FHitBox {
- @property({
- displayName:'需要打碎的其它箱子',
- type:[cc.Node]
- })
- mOtherBox: Array<cc.Node> = [];
- private isClose = false
- public hitBox() {
- this.onEnd(1)
- this.ff.pauseSprite(true)
- this.node.removeComponent(cc.PhysicsBoxCollider)
- this.node.removeComponent(cc.PhysicsBoxCollider)
- let element = this.ff.mainSprite
- element.useHammer()
- element.playAction2(SpriteActionType.chuizi, false, () => {
- this.ff.pauseSprite(false)
- element.playAction2(SpriteActionType.stand, true);
- element.updateSkin()
- })
- this.isClose = true
- cc.tween(element.node).sequence(
- cc.delayTime(0.2),
- cc.callFunc(() => {
- this.spine.setCompleteListener(() => {
- this.node.destroy();
- })
- this.openDoor()
- this.spine.setAnimation(0, 'boom', false);
- })
- ).start();
- }
- public openDoor(){
- for (let i = 0; i < this.mOtherBox.length; i++) {
- const element = this.mOtherBox[i];
- if(element.isValid && !element.getComponent(FHitBoxOpenDoor).isClose){
- return
- }
- }
- this.pause()
- this.moveCamera(this.hide.getPosition(),1,()=>{
- this.resume()
- if (this.hide && this.hide.isValid) {
- this.hide.active = true;
- }
- })
- }
-
- }
|