Browse Source

地图2解救宠物

chelios 3 years ago
parent
commit
fe2b62a784

+ 4 - 4
assets/Script/game/fight/FLoad.ts

@@ -58,10 +58,10 @@ export default class FLoad{
                     let node:cc.Node = cc.instantiate(prefab);
                     let sp = null;
                     let data = fDatas[i]
-                    // if(data.id != 2){
-                    //     continue
-                    // }
-                    // player.role.leader = 2
+                    if(data.id != 2){
+                        continue
+                    }
+                    player.role.leader = 2
                     if(data.id == player.role.leader){//此处需要根据用户设置
                         sp = node.addComponent(MSprite);
                     }else{

+ 3 - 3
assets/Script/game/fight/evnet/FDialogNone.ts

@@ -57,9 +57,9 @@ export default class FDialogNone extends BaseEvent {
 
     onLoad() {
         super.onLoad()
-        if (this.icon) {
-            this.icon.active = false;
-        }
+        // if (this.icon) {
+        //     this.icon.active = false;
+        // }
     }
 
     onBegin(tag: number) {

+ 203 - 0
assets/Script/game/fight/evnet/cage/FCagePet1.ts

@@ -0,0 +1,203 @@
+import FqLogin from "../../../../login/FqLogin";
+import { AudioMgr } from "../../../../main/ViewManage";
+import FFCalAttr from "../../../data/FFCalAttr";
+import AIPet from "../../object/AI/AIPet";
+import { GroupType } from "../../object/FObject";
+import { SpriteActionType } from "../../object/FSprite";
+import PSprite from "../../object/PSprite";
+import BaseEvent from "../base/BaseEvent";
+
+const { ccclass, property } = cc._decorator;
+/**
+ * 第一个宠物牢笼
+ */
+@ccclass
+export default class FCagePet1 extends BaseEvent {
+
+    @property({
+        displayName: '解救的伙伴id',
+    })
+    mPetId: number = 1;
+
+    @property({
+        displayName: '没有钥匙的对话',
+        type: [cc.String]
+    })
+    dialog1: Array<string> = [];
+
+    @property({
+        displayName: '牢笼动画',
+        tooltip: '显示牢笼的动画',
+        type: sp.Skeleton
+    })
+    spine: sp.Skeleton = null;//牢笼
+
+    @property({
+        displayName: '按钮图标',
+        type: cc.SpriteFrame
+    })
+    mTipsIcon: cc.SpriteFrame = null;
+
+    @property({
+        displayName: '靠近的提示',
+        type: cc.Sprite
+    })
+    mIcon: cc.Sprite = null;//靠近后的提示
+
+    @property({
+        type: [cc.SpriteFrame],
+        displayName: '不同状态的图标'
+    })
+    mIconFrame: Array<cc.SpriteFrame> = [];
+
+    @property({
+        displayName: '牢笼中的伙伴',
+        type: cc.Node
+    })
+    mPet: cc.Node = null;//伙伴
+    @property({
+        displayName: '解救出来的对话',
+        type: [cc.String]
+    })
+    dialog2: Array<string> = [];
+
+    @property({
+        displayName: '宠物预制体',
+        type: cc.Prefab
+    })
+    mPetPrefab: cc.Prefab = null;
+
+    @property({
+        type: [cc.Node],
+        displayName: '需要打开的门'
+    })
+    mFenceTrigger: Array<cc.Node> = [];
+
+    @property({
+        displayName: 'npc',
+        type: cc.Node
+    })
+    mNPC2: cc.Node = null;
+
+    private isOver = false;
+
+    onBegin(tag: number) {
+        if (this.isOver) {
+            return;
+        }
+        if (tag == 1) {
+            this.iconTips(true);
+            this.showOpt(this.mTipsIcon, () => {
+                this.iconTips(false);
+                this.closeOpt()
+                this.openCage()
+            })
+        }
+    }
+    onEnd(tag: number) {
+        if (tag == 1) {
+            this.iconTips(false);
+            this.closeOpt()
+        }
+    }
+
+    /**
+     * 
+     * @param show 是否显示提示
+     */
+    private iconTips(show) {
+        if (this.mIcon) {
+            if (show) {
+                this.mIcon.node.active = true;
+                let head = this.ff.mFFheader;
+                let count = head.getTmpCount(2001);
+                if (count > 0) {
+                    this.mIcon.spriteFrame = this.mIconFrame[0]
+                } else {
+                    this.mIcon.spriteFrame = this.mIconFrame[1]
+                }
+            } else {
+                this.mIcon.node.active = false;
+            }
+        }
+    }
+
+    //打开牢笼
+    private openCage() {
+        let head = this.ff.mFFheader;
+        let count = head.getTmpCount(2001);
+        if (count > 0) {
+            head.removeTmpGood(2001, 1);
+            this.isOver = true;
+
+            this.spine.setCompleteListener(() => {
+                this.spine.setCompleteListener(null);
+                this.showDialog(this.node,this.dialog2,()=>{
+                    this.movePet()
+                })
+            });
+            if (this.spine.findAnimation("open3")) {
+                this.spine.setAnimation(0, 'open3', false);
+            } else {
+                this.spine.setAnimation(0, 'open', false);
+            }
+            FqLogin.commitEvent(this.node.name, '', '');
+        } else {
+            // this.ff.main.showTips('需要一把牢笼钥匙');
+            this.showDialog(this.node,this.dialog1,()=>{
+
+            })
+        }
+    }
+
+    private movePet() {
+        let anim = this.mPet.getComponent(cc.Animation);
+        let spine = this.mPet.getComponent(sp.Skeleton);
+
+        spine.setAnimation(0, SpriteActionType.run, true);
+        anim.on('finished', this.onFinished, this);
+        anim.play('cage_pet_move');
+    }
+    private onFinished(num, string) {
+        let anim = this.mPet.getComponent(cc.Animation);
+        let spine = this.mPet.getComponent(sp.Skeleton);
+        anim.off('finished', this.onFinished, this);
+        spine.setAnimation(0, SpriteActionType.stand, true);
+        this.mPet.destroy()
+        this.openDoor()
+    }
+    
+    public openDoor(){
+        this.pause()
+        this.moveCamera(this.mFenceTrigger[0].getPosition(), 1, () => {
+            cc.tween(this.node).sequence(
+                cc.callFunc(() => {
+                    for (let i = 0; i < this.mFenceTrigger.length; i++) {
+                        const element = this.mFenceTrigger[i];
+                        this.showFence(element, 'open');
+                    }
+                    this.ff.main.playerEffectByPath(AudioMgr.openDoor);
+                }),
+                cc.delayTime(1),
+                cc.callFunc(() => {
+                    this.resume()
+                    for (let i = 0; i < this.mFenceTrigger.length; i++) {
+                        const element = this.mFenceTrigger[i];
+                        element.active = false;
+                    }
+                })
+            ).start();
+
+        })
+    }
+    private showFence(element, action) {
+        let nodes = element.children;
+        for (let i = 0; i < nodes.length; i++) {
+            const element = nodes[i];
+            let spine = element.getComponent(sp.Skeleton);
+            if (spine) {
+                spine.setAnimation(0, action, false);
+            }
+        }
+    }
+}

+ 9 - 0
assets/Script/game/fight/evnet/cage/FCagePet1.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "7d6a96b1-148c-4058-b491-c160d4809e09",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 2 - 6
assets/resources/prefab/map/animation/cage_pet_move.anim

@@ -5,7 +5,7 @@
   "_native": "",
   "_duration": 0.3333333333333333,
   "sample": 60,
-  "speed": 1,
+  "speed": 0.5,
   "wrapMode": 1,
   "curveData": {
     "props": {
@@ -14,13 +14,9 @@
           "frame": 0,
           "value": 15.425
         },
-        {
-          "frame": 0.16666666666666666,
-          "value": -47.339
-        },
         {
           "frame": 0.3333333333333333,
-          "value": -102.131
+          "value": -565.806
         }
       ]
     }

File diff suppressed because it is too large
+ 6377 - 5755
assets/resources/prefab/map/map2.prefab


File diff suppressed because it is too large
+ 4687 - 6137
assets/resources/prefab/map/map3.prefab