1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 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";
- /**
- * 带着小鹿走。
- 小鹿走到拿钥匙的地方不再走,趴在地上,肚子饿的咕咕声。
- 角色:或许它饿了。
- 角色:在附近找一找吃的。
- 采集浆果。
- 直到采集4个给小鹿吃,小鹿才起身,跟着角色走。
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class JG0106_1 extends BaseEvent {
- @property({
- type:cc.Node,
- displayName: '宠物碰撞位置'
- })
- public mPetNode:cc.Node = null;
- /**
- * 主角进入碰撞区域
- * @param tag 碰撞组件编号
- */
- public onBegin(tag: number) {
- this.pettl()
- this.pause()
- this.ff.mainSprite.stopMove()
- this.ff.mainSprite.playAction(SpriteActionType.run,true)
- cc.tween(this.ff.mainSprite.node).sequence(
- cc.moveBy(0.5,cc.v2(-20,0)),
- cc.callFunc(()=>{
- this.ff.mainSprite.playAction(SpriteActionType.stand,true)
- this.ff.mainSprite.setLR(1)
- this.dialog()
- let sprite:PSprite = this.getPet() as PSprite;
- this.mPetNode.x = sprite.node.x
- this.mPetNode.y = sprite.node.y
- })
- ).start()
-
- }
- /**
- * 宠物脱离队伍
- */
- private pettl(){
- let sprite:PSprite = this.getPet() as PSprite;
- sprite.inFront = null
- sprite.playAction(SpriteActionType.dead,false)
- sprite.node.removeComponent(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
- }
- }
- }
- private dialog(){
- let text = [
- '或许它饿了。',
- '在附近找一找吃的。',
- ]
- this.showDialog(this.ff.mainSprite.node,text,()=>{
- this.resume()
- this.node.destroy()
- })
- }
- }
|