123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import BaseEvent from "../base/BaseEvent";
- /**
- * 完成开门条件
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FOpenDoorCheck extends BaseEvent {
- @property({
- displayName: '需要的物品id'
- })
- public goodId = 2002;
- @property(cc.Prefab)
- mMapDialog: cc.Prefab = null;
- @property({
- displayName:'对话内容',
- type:[cc.String]
- })
- text: Array<string> = [];
-
- @property({
- displayName: '提示图标',
- type:cc.SpriteFrame
- })
- mTipsIcon: cc.SpriteFrame = null;
- @property({
- displayName: '驱赶的对象',
- type:cc.Node
- })
- mDriveNode: cc.Node = null;
- @property({
- displayName: '棍子',
- type:cc.Node
- })
- mGunNode: cc.Node = null;
- @property({
- displayName: '乌鸦',
- type:sp.Skeleton
- })
- mSpine: sp.Skeleton = null;
- onLoad(){
- super.onLoad()
- this.mGunNode.active = false
- }
- onBegin(tag:number){
- if(tag == 1){
- if(!this.mDriveNode.active){
- return
- }
- this.showOpt(this.mTipsIcon,()=>{
- this.closeOpt()
- let head = this.ff.mFFheader;
- let count = head.getTmpCount(this.goodId);
- if(count > 0){
- this.ff.pauseSprite(true);
- this.ff.mBlockInputEvents.active = true;
- head.removeTmpGood(this.goodId,1);
- this.mGunNode.active = true
- this.mSpine.setAnimation(0, 'hurt', false);
- cc.tween(this.mGunNode).sequence(
- cc.moveBy(0.2,cc.v2(0,40)),
- cc.moveBy(0.2,cc.v2(0,-40)),
- cc.moveBy(0.2,cc.v2(0,40)),
- cc.moveBy(0.2,cc.v2(0,-40)),
- cc.moveBy(0.2,cc.v2(0,40)),
- cc.moveBy(0.2,cc.v2(0,-40)),
- cc.callFunc(()=>{
- this.flyGo()
- }),
- cc.moveBy(0.2,cc.v2(0,20)),
- cc.moveBy(0.2,cc.v2(0,-20)),
- cc.fadeOut(1),
- ).start()
- }else{
- this.dialog(0)
- }
- })
- }
- }
- private flyGo(){
- this.ff.pauseSprite(false);
- this.ff.mBlockInputEvents.active = false;
- this.mSpine.setCompleteListener(()=>{
- this.mDriveNode.active = false
- this.pause()
- this.showDialog(this.ff.mainSprite.node,['乌鸦被赶走了,去告诉神秘人吧'],()=>{
- this.resume()
- });
- })
- this.mSpine.setAnimation(0, 'fly', false);
-
- }
- onEnd(tag:number){
- if(tag == 1){
- this.closeOpt()
- }
- }
- private dialog(index:number){
- if(index >= this.text.length){
- this.closeOpt()
- this.ff.pauseSprite(false);
- this.ff.mBlockInputEvents.active = false;
- return;
- }
- let texts = this.text[index].split('|')
- let mid = parseInt(texts.shift());
- if(mid == -1){//主角
- let my = this.ff.mainSprite.node;
- this.showDialog(my,texts,()=>{
- index ++;
- this.dialog(index);
- });
- }
- }
- }
|