2 Commits 2acaa7c2e8 ... 05c7557fd3

Autor SHA1 Mensagem Data
  chelios 05c7557fd3 推箱子优化 3 anos atrás
  chelios 0636f34a44 举起道具 3 anos atrás

+ 120 - 0
assets/Script/game/element/JG0109.ts

@@ -0,0 +1,120 @@
+import BaseEvent from "../fight/evnet/base/BaseEvent";
+
+/**
+ * 推箱子、石头
+ */
+const {ccclass, property} = cc._decorator;
+
+@ccclass
+export default class JG0109 extends BaseEvent {
+
+    @property({
+        displayName:'推图标',
+        type:cc.SpriteFrame
+    })
+    pullIcon: cc.SpriteFrame = null;
+
+    /**
+     * 推的方向
+     * 上下左右
+     * 1,2,3,4
+     */
+    private pullDir = -1;
+    /**
+     * 当前是否推的状态
+     */
+    private isPull = false
+    /**
+     * 主角进入碰撞区域
+     *  @param tag 碰撞组件编号
+     */
+    public onBegin(tag: number) {
+        let pullDir = this.getPullDir()
+        // cc.log('pullDir : ',pullDir)
+        if(pullDir > 0){
+            this.isPull = true;
+            this.pullDir = pullDir
+            this.showOptTouch(this.pullIcon,
+                () => {
+                   this.pull()
+               },()=>{
+                   this.isPull = false;
+               })
+        }
+    }
+    /**
+     * 主角离开碰撞区域
+     * @param tag 碰撞组件编号
+     */
+    public onEnd(tag: number) {
+        this.closeOptTouch()
+        this.isPull = false;
+    }
+    /**
+     * 接触到石头后确定方向
+     * @returns 
+     */
+    public getPullDir():number{
+        let mainSprite = this.ff.mainSprite
+        let pbc = this.node.getComponent(cc.PhysicsBoxCollider)
+        let x0,y0,x1,y1;
+        x0 = this.node.x + pbc.offset.x - pbc.size.width/2 - 10
+        x1 = this.node.x + pbc.offset.x + pbc.size.width/2 + 10
+        y0 = this.node.y + pbc.offset.y - pbc.size.height/2 - 20//下
+        y1 = this.node.y + pbc.offset.y + pbc.size.height/2 + 20//上
+
+        let x = mainSprite.node.x
+        let y = mainSprite.node.y
+
+        if(x > x0 && x < x1){//当前角色在上下2个方向
+           if(y > y1){
+                return 1;
+           }else{
+               return 2;
+           }
+        }else if(y > y0 && y < y1){
+            if(x < x0){
+                return 3
+            }else{
+                return 4
+            }
+        }
+        return -1
+    }
+
+    private pull(){
+        let pos = cc.v2()
+        if(this.pullDir == 1){
+            pos.y = -64
+        }else if(this.pullDir == 2){
+            pos.y = 64
+        }else if(this.pullDir == 3){
+            pos.x = 64
+        }else if(this.pullDir == 4){
+            pos.x = -64
+        }
+        let tx = this.node.x + pos.x
+        let ty = this.node.y + pos.y
+        if(this.ff.mMap.checkCollision(tx,ty)){
+            return
+        }
+        cc.tween(this.node).sequence(
+            cc.delayTime(0.6),
+            cc.callFunc(()=>{
+                if(this.isPull){
+                    cc.tween(this.node).sequence(
+                        cc.moveBy(0.5,pos),
+                        cc.callFunc(()=>{})
+                    ).start()
+                }
+            }),
+            cc.delayTime(0.5),
+            cc.callFunc(()=>{
+                if(this.isPull){
+                    this.pull()
+                }
+            })
+        ).start()
+    }
+
+}

+ 9 - 0
assets/Script/game/element/JG0109.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "d2b61c5a-ec3a-459b-8f3c-4b8e27d36110",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 27 - 32
assets/Script/game/element/JG0111_1.ts

@@ -3,14 +3,8 @@ import { AudioMgr } from "../../main/ViewManage";
 import BaseEvent from "../fight/evnet/base/BaseEvent";
 
 
-const SpineName = {
-    CLOSE: "close",
-    OPEN: "open"
-}
-
-
 /**
- * 多组按钮控制开门
+ * 多组按钮控制开门-解救宠物剧情
  */
 const { ccclass, property } = cc._decorator;
 
@@ -53,10 +47,14 @@ export default class JG0111_1 extends BaseEvent {
     })
     mFenceTrigger: Array<cc.Node> = [];
 
-    /**
-     * 是否选中
-     */
-    public isHang = false;
+    @property({
+        displayName: '困住的宠物',
+        type: cc.Node,
+    })
+    mPet: cc.Node = null;
+
+
+
     /**
      * 机关是否已经结束
      */
@@ -88,48 +86,35 @@ export default class JG0111_1 extends BaseEvent {
     }
 
     onBegin(tag: number) {
-        this.isHang = true;
         this.mIcon.spriteFrame = this.mIcon1;
         this.checkOpen();
     }
 
     onEnd(tag: number) {
-        // this.isHang = false
-        // this.mIcon.spriteFrame = this.mIcon0
-        // this.isOver = false;
-        // for (let i = 0; i < this.mFenceTrigger.length; i++) {
-        //     const element = this.mFenceTrigger[i];
-        //     // element.active = true;
-        //     this.showFence(element, SpineName.CLOSE);
-        //     element.getComponent(cc.PhysicsBoxCollider).enabled = true;
-        // }
     }
 
     private checkOpen() {
         if (this.isOver) {
             return
         }
-        //检查其它开关是否打开
-        for (let i = 0; i < this.mButtons.length; i++) {
-            const element = this.mButtons[i];
-            let fdb = element.getComponent(JG0111_1)
-            if (!fdb.isHang) return
-        }
         this.isOver = true;
         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];
-                        element.active = false
-                        // this.showFence(element, SpineName.OPEN);
+                    this.showFence(this.mFenceTrigger[0], 'down');
+                    let nodes = this.mFenceTrigger[1].children
+                    for (let i = 0; i < nodes.length; i++) {
+                        const element = nodes[i];
+                        this.showFence(element, 'down');
                     }
                     this.ff.main.playerEffectByPath(AudioMgr.openDoor);
                 }),
                 cc.delayTime(1),
                 cc.callFunc(() => {
                     this.resume()
+                    this.mFenceTrigger[0].getComponent(cc.PhysicsBoxCollider).enabled = false;
+                   
                     // for (let i = 0; i < this.mFenceTrigger.length; i++) {
                     //     const element = this.mFenceTrigger[i];
                     //     // element.active = false;
@@ -137,7 +122,17 @@ export default class JG0111_1 extends BaseEvent {
                     // }
                 })
             ).start();
-
         })
     }
+
+    private showFence(element, action) {
+        let nodes = element.children;
+        for (let i = 0; i < nodes.length; i++) {
+            const element = nodes[i];
+            let spine:sp.Skeleton = element.getComponent(sp.Skeleton);
+            if (spine) {
+                spine.setAnimation(0, action, false);
+            }
+        }
+    }
 }

+ 30 - 0
assets/Script/game/element/JG0116.ts

@@ -0,0 +1,30 @@
+import BaseEvent from "../fight/evnet/base/BaseEvent";
+
+const {ccclass, property} = cc._decorator;
+/**
+ * 捡起物品,扔物品
+ */
+@ccclass
+export default class JG0116 extends BaseEvent {
+
+    @property({
+        displayName:'捡起图标',
+        type:cc.SpriteFrame
+    })
+    liftIcon: cc.SpriteFrame = null;
+
+    @property({
+        displayName:'扔出图标',
+        type:cc.SpriteFrame
+    })
+    throwIcon: cc.SpriteFrame = null;
+
+    
+    
+
+
+
+
+
+    
+}

+ 1 - 1
assets/Script/game/fight/evnet/FStoreTS.ts.meta

@@ -1,6 +1,6 @@
 {
   "ver": "1.0.8",
-  "uuid": "7cfebc90-b13c-4b3a-adac-669b5607425c",
+  "uuid": "6d91b210-120e-40f0-a1e4-4e8b05fcf077",
   "isPlugin": false,
   "loadPluginInWeb": true,
   "loadPluginInNative": true,

+ 34 - 0
assets/Script/game/fight/EventButton.ts

@@ -11,6 +11,9 @@ export default class EventButton extends cc.Component {
 
     private callback:()=>void;
 
+    private startCallback:()=>void;
+    private endCallback:()=>void;
+
     public setCallback(callback:()=>void){
         this.callback = callback;
     }
@@ -20,4 +23,35 @@ export default class EventButton extends cc.Component {
             this.callback();
         }
     }
+    /**
+     * 注册按压事件
+     */
+    public onTouchEvent(startCallback:()=>void,endCallback:()=>void){
+        this.startCallback = startCallback;
+        this.endCallback = endCallback;
+        this.node.on(cc.Node.EventType.TOUCH_START, this._touchShootStartEvent, this);
+        this.node.on(cc.Node.EventType.TOUCH_END, this._touchShootEndEvent, this);
+        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._touchShootEndEvent, this);
+    }
+    /**
+     * 取消注册
+     */
+    public offTouchEvent(){
+        this.startCallback = null;
+        this.endCallback = null;
+        this.node.off(cc.Node.EventType.TOUCH_START)
+        this.node.off(cc.Node.EventType.TOUCH_END)
+        this.node.off(cc.Node.EventType.TOUCH_CANCEL)
+    }
+
+    private _touchShootStartEvent() {
+        if(this.startCallback){
+            this.startCallback();
+        }
+    }
+    private _touchShootEndEvent() {
+        if(this.endCallback){
+            this.endCallback();
+        }
+    }
 }

+ 26 - 12
assets/Script/game/fight/FControl.ts

@@ -110,24 +110,14 @@ export default class FControl extends cc.Component {
             callback()
         })
     }
+    
+
     public closeEventBt() {
         this.mEventButton.node.active = false
         this.mShooting.active = true
         this.mEventButton.setCallback(null)
     }
 
-
-    private _touchRunningStartEvent() {
-        if (this.ff && this.ff.mainSprite) {
-            this.ff.mainSprite.setRuning(true);
-        }
-    }
-    private _touchRunningEndEvent() {
-        if (this.ff && this.ff.mainSprite) {
-            this.ff.mainSprite.setRuning(false);
-        }
-    }
-
     private _touchShootStartEvent() {
         if (this.ff && this.ff.mainSprite) {
             this.ff.mainSprite.setShooting(true);
@@ -138,6 +128,30 @@ export default class FControl extends cc.Component {
             this.ff.mainSprite.setShooting(false);
         }
     }
+   /**
+    * 注册长按事件按钮
+    * @param spriteFrame 事件按钮图标
+    * @param startCallback 事件按钮按下
+    * @param endCallback 事件按钮取消
+    */
+    public showEventBtTouch(spriteFrame: cc.SpriteFrame,startCallback:()=>void,endCallback:()=>void){
+        this.ff.mainSprite.setShooting(false);
+        this.ff.mainSprite.status == SpriteType.NONE
+        this.mEventButton.node.active = true
+        this.mEventButton.mIcon.spriteFrame = spriteFrame
+        this.mShooting.active = false
+
+        this.mEventButton.onTouchEvent(startCallback,endCallback)
+    }
+    /**
+     * 取消注册事件长按
+     */
+    public closeEventBtTouch(){
+        this.mEventButton.node.active = false
+        this.mShooting.active = true
+        this.mEventButton.offTouchEvent()
+    }
+
 
     public onclickSkill1() {
         if (!this.skillOK1) {

+ 0 - 118
assets/Script/game/fight/evnet/FStoreTS.ts

@@ -1,118 +0,0 @@
-import { SpriteActionType } from "../object/FSprite";
-import BaseEvent from "./base/BaseEvent";
-
-const {ccclass, property} = cc._decorator;
-/**
- * 推石头
- * 
- * tag == 1 左右推动
- * tag == 2 上下推动
- */
-@ccclass
-export default class FStoreTS extends BaseEvent {
-
-    @property({
-        displayName: '提示按钮图标',
-        type: cc.SpriteFrame
-    })
-    mTipsIcon: cc.SpriteFrame = null;
-
-    private mRigidBody:cc.RigidBody = null
-    /**
-     * 推动中
-     */
-    private isPull = false;
-    /**
-     * 当前移动方向
-     */
-    private moveVt = cc.v2()
-
-    start(){
-        this.mRigidBody = this.node.getComponent(cc.RigidBody);
-    }
-
-    onBegin(tag:number){
-        this.startEvent()
-        if(tag == 1){
-            this.moveVt.y = 0
-            let myX = this.ff.mainSprite.node.x
-            if(myX < this.node.x){
-                this.moveVt.x = 7
-            }else{
-                this.moveVt.x = -7
-            }
-        }else if(tag == 2){
-            this.moveVt.x = 0
-            let myY = this.ff.mainSprite.node.y
-            if(myY < this.node.y){
-                this.moveVt.y = 7
-            }else{
-                this.moveVt.y = -7
-            }
-        }
-    }
-
-    onEnd(tag:number){
-        this.endEvent()
-    }
-
-    private startEvent(){
-        let fControl = this.ff.control;
-        fControl.mEventButton.node.on(cc.Node.EventType.TOUCH_START, this._touchRunningStartEvent, this);
-        fControl.mEventButton.node.on(cc.Node.EventType.TOUCH_MOVE, this._touchRunningMoveEvent, this);
-        fControl.mEventButton.node.on(cc.Node.EventType.TOUCH_END, this._touchRunningEndEvent, this);
-        fControl.mEventButton.node.on(cc.Node.EventType.TOUCH_CANCEL, this._touchRunningEndEvent, this);
-        this.showOpt(this.mTipsIcon, () => {
-        })
-    }
-    private endEvent(){
-        this.closeOpt()
-        
-        let fControl = this.ff.control;
-        fControl.mEventButton.node.off(cc.Node.EventType.TOUCH_START);
-        fControl.mEventButton.node.off(cc.Node.EventType.TOUCH_MOVE);
-        fControl.mEventButton.node.off(cc.Node.EventType.TOUCH_END);
-        fControl.mEventButton.node.off(cc.Node.EventType.TOUCH_CANCEL);
-        this.isPull = false;
-    }
-    private  _touchRunningMoveEvent(){
-        cc.log('_touchRunningMoveEvent')
-    }
-    private  _touchRunningStartEvent(){
-        cc.log('_touchRunningStartEvent')
-        this.isPull = true;
-        cc.tween(this).sequence(
-            cc.delayTime(0.01),
-            cc.callFunc(()=>{
-                this.mRigidBody.type = cc.RigidBodyType.Dynamic
-            })
-        ).start()
-        
-        let mainSprite = this.ff.mainSprite
-
-        // mainSprite.spine.setAnimation(0, SpriteActionType.run, true);
-
-    }
-    private _touchRunningEndEvent(){
-        cc.log('_touchRunningEndEvent')
-        this.isPull = false;
-        cc.tween(this).sequence(
-            cc.delayTime(0.01),
-            cc.callFunc(()=>{
-                this.mRigidBody.type = cc.RigidBodyType.Static
-            })
-        ).start()
-        // let mainSprite = this.ff.mainSprite
-        // mainSprite.spine.setAnimation(0, SpriteActionType.stand, true);
-    }
-
-    public update(dt){
-        if(this.isPull){
-            let mainSprite = this.ff.mainSprite
-            mainSprite.node.x += this.moveVt.x
-            mainSprite.node.y += this.moveVt.y
-        }
-    }
-
-
-}

+ 11 - 0
assets/Script/game/fight/evnet/base/BaseEvent.ts

@@ -99,12 +99,23 @@ export default class BaseEvent extends cc.Component {
     public showOpt(spriteFrame: cc.SpriteFrame, callback: () => void) {
         this.ff.control.showEventBt(spriteFrame, callback)
     }
+    /**
+     * 
+     * @param spriteFrame 
+     * @param callback 
+     */
+    public showOptTouch(spriteFrame: cc.SpriteFrame, startCallback: () => void,endCallback: () => void){
+        this.ff.control.showEventBtTouch(spriteFrame,startCallback,endCallback)
+    }
     /**
      * 关闭界面上可操作按钮
      */
     public closeOpt() {
         this.ff.control.closeEventBt()
     }
+    public closeOptTouch(){
+        this.ff.control.closeEventBtTouch()
+    }
     /**
      * 全屏按钮(用于处理用户点击任意位置)
      * @param callback 

+ 29 - 12
assets/Script/game/fight/map/FMap.ts

@@ -51,26 +51,27 @@ export default class FMap extends cc.Component {
 
         this.rooms = this.mRooms.children
 
+        this.addCollider()
 
+        // cc.log('xxxxxxxxxxxxxx = ',this.checkCollision(64,64))
 
-        this.addCollider()
     }
     /**
      * 添加碰撞
      */
     private addCollider(){
         //地图边界碰撞墙
-        let width   = this.node.width;
-        let height  = this.node.height;
-        let node = new cc.Node();
-        node.group = 'map'
-        let body = node.addComponent(cc.RigidBody);
-        body.type = cc.RigidBodyType.Static;
-        this._addBound(node, width/2, height, width, 20);
-        this._addBound(node, width/2, 0, width, 20);
-        this._addBound(node, 0, height/2, 20, height);
-        this._addBound(node, width, height/2, 20, height);
-        node.parent = this.node;
+        // let width   = this.node.width;
+        // let height  = this.node.height;
+        // let node = new cc.Node();
+        // node.group = 'map'
+        // let body = node.addComponent(cc.RigidBody);
+        // body.type = cc.RigidBodyType.Static;
+        // this._addBound(node, width/2, height, width, 20);
+        // this._addBound(node, width/2, 0, width, 20);
+        // this._addBound(node, 0, height/2, 20, height);
+        // this._addBound(node, width, height/2, 20, height);
+        // node.parent = this.node;
         
         //地形碰撞处理
         if(this.mColliderTiled){
@@ -377,4 +378,20 @@ export default class FMap extends cc.Component {
 
         return false;
     }
+    /**
+     * 检查当前坐标是否在碰撞区域
+     * @param x 
+     * @param y 
+     */
+    public checkCollision(x,y){
+        let size = this.mColliderTiled.getLayerSize();
+        let dx = x/64
+        let dy = size.height - y/64
+        if(dy > size.height){
+            dy = size.height - 1
+        }
+        let t = this.mColliderTiled.getTileGIDAt(dx,dy);
+        return t > 0
+    }
+
 }

+ 21 - 2
assets/Script/game/fight/object/MSprite.ts

@@ -1,6 +1,5 @@
 
 import Joystick_mag, { SpeedType } from "../../../joystick/Joystick_mag";
-import Joystick from "../../../util/Joystick";
 import { FFAttr } from "../../data/FFCalAttr";
 import { __SkillData } from "../../data/sdata/SManage";
 import BObject from "../bullet/BObject";
@@ -35,7 +34,7 @@ export default class MSprite extends FSprite {
     /**
      * 移动速度
      */
-    private speedN = 120000;
+    private speedN = 80000;
 
     public start(){
         super.start()
@@ -287,6 +286,26 @@ export default class MSprite extends FSprite {
                 }
             }
         });
+    }
+    /**
+     * 临时捡起的东西
+     */
+    public tmpObject:cc.Node = null;
+    /**
+     * 角色举起物品
+     * @param object 
+     */
+    public liftObject(object:cc.Node){
+        
+    }
+    /**
+     * 将捡起来的东西扔出去
+     */
+    public throwObject(){
+
+
+
+
     }
 
 }

Diferenças do arquivo suprimidas por serem muito extensas
+ 2787 - 2858
assets/resources/prefab/map/map2.prefab


+ 1 - 1
settings/project.json

@@ -83,7 +83,7 @@
     "width": 960,
     "height": 640
   },
-  "last-module-event-record-time": 1622533918222,
+  "last-module-event-record-time": 1625451440015,
   "assets-sort-type": "name",
   "facebook": {
     "appID": "",