import BaseEvent from "../../fight/evnet/base/BaseEvent"; import AIPet from "../../fight/object/AI/AIPet"; import { SpriteActionType } from "../../fight/object/FSprite"; import PSprite from "../../fight/object/PSprite"; const { ccclass, property } = cc._decorator; /** * 采集浆果。 直到采集4个给小鹿吃,小鹿才起身,跟着角色走。 */ @ccclass export default class JG0106_2 extends BaseEvent { @property({ type: cc.SpriteFrame, displayName: '图标' }) public mTipsIcon: cc.SpriteFrame = null; /** * 主角进入碰撞区域 * @param tag 碰撞组件编号 */ public onBegin(tag: number) { this.showOpt(this.mTipsIcon, () => { let head = this.ff.mFFheader; let count = head.getTmpCount(5001); this.closeOpt() if(count >= 4){ head.removeTmpGood(5001,4) this.dialog() }else{ let sprite:PSprite = this.getPet() as PSprite; let text = [ '饿饿..饿饿..', ] this.showDialog(sprite.node, text, () => { }) } }) } public onEnd(tag: number) { this.closeOpt() } private dialog(){ this.pause() let sprite:PSprite = this.getPet() as PSprite; let text = [ '嗷嗷..嗷嗷..', ] this.showDialog(sprite.node, text, () => { this.resume() this.petBack() this.node.destroy() }) } /** * 宠物脱离队伍 */ private petBack(){ let sprite:PSprite = this.getPet() as PSprite; sprite.inFront = this.ff.mainSprite sprite.playAction(SpriteActionType.stand,true) sprite.node.addComponent(AIPet) } private getPet(){ let sprites = this.ff.getGroupBy('A') for (let i = 0; i < sprites.length; i++) { const element = sprites[i]; if(element != this.ff.mainSprite){ return element } } } }