3 Commits a824d0f7da ... ad10003806

Author SHA1 Message Date
  Citrus ad10003806 111 4 months ago
  Citrus 22c8128794 111 4 months ago
  Citrus deb9996bc4 修复重力和重复吃金币的bug 5 months ago

+ 5 - 7
assets/Script/GameProp/GameProp1000.ts

@@ -8,11 +8,12 @@
 import Character from "../Character/Character";
 import EventName from "../EventName/EventName";
 import RewardMnr from "../Template/RewardMnr";
+import Prop from "./Prop";
 
 const { ccclass, property } = cc._decorator;
 
 @ccclass
-export default class GameProp1000 extends cc.Component {
+export default class GameProp1000 extends Prop {
 
     // onLoad () {}
     //触发几次获得奖励
@@ -23,7 +24,7 @@ export default class GameProp1000 extends cc.Component {
 
 
     protected onEnable(): void {
-        this.node.active = RewardMnr.getInstance().isEnable(this.getName())
+        this.node.active = RewardMnr.getInstance().isEnable(this.Flag())
     }
 
 
@@ -44,13 +45,10 @@ export default class GameProp1000 extends cc.Component {
         }
     }
 
-    getName(): string {
-        return this.node.parent.name + this.name + this.node.getPosition().x + this.node.getPosition().y
-    }
-
+ 
     //奖励的方法
     Reaward() {
-        RewardMnr.getInstance().addParabola(this.getName(), 3)
+        RewardMnr.getInstance().addParabola(this.Flag(), 3)
         this.node.destroy()
     }
 } 

+ 5 - 8
assets/Script/GameProp/GameProp1001.ts

@@ -9,11 +9,12 @@ import AudioManager from "../AudioManager";
 import Character from "../Character/Character";
 import EventName from "../EventName/EventName";
 import RewardMnr from "../Template/RewardMnr";
+import Prop from "./Prop";
 
 const { ccclass, property } = cc._decorator;
 
 @ccclass
-export default class GameProp1001 extends cc.Component {
+export default class GameProp1001 extends Prop {
 
     // onLoad () {}
     //触发几次获得奖励
@@ -23,11 +24,11 @@ export default class GameProp1001 extends cc.Component {
     IsDeleteMe = true
 
     protected onEnable(): void {
-        this.node.active = RewardMnr.getInstance().isEnable(this.getName())
+        this.node.active = RewardMnr.getInstance().isEnable(this.Flag())
     }
 
     onCollisionEnter(other: cc.CircleCollider, self: cc.BoxCollider) {
-       
+
         if (this.triggerCount <= 0) {
             console.error('失效了');
             this.getComponent(cc.BoxCollider).enabled = false
@@ -43,10 +44,6 @@ export default class GameProp1001 extends cc.Component {
         }
     }
 
-    getName(): string {
-        return this.node.parent.name + this.name + this.node.getPosition().x + this.node.getPosition().y
-    }
-
     //奖励的方法
     Reaward() {
 
@@ -61,7 +58,7 @@ export default class GameProp1001 extends cc.Component {
         cc.tween(this.node)
             .to(0.4, { position: cc.v3(NodePos, 0) })
             .call(() => {
-                RewardMnr.getInstance().addGold(this.getName(), 1)
+                RewardMnr.getInstance().addGold(this.Flag(), 1)
                 this.node.destroy()
             })
             .start()

+ 35 - 0
assets/Script/GameProp/Prop.ts

@@ -0,0 +1,35 @@
+// Learn TypeScript:
+//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
+// Learn Attribute:
+//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
+// Learn life-cycle callbacks:
+//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
+
+const { ccclass, property } = cc._decorator;
+
+@ccclass
+export default class Prop extends cc.Component {
+
+    //道具ID标识
+    id_Flag = ''
+
+    //子地图的id序号
+    SubMap = ''
+
+
+    //元素道具的fs信息
+    fs: {
+        sp: number,
+        ro: number,
+        sc: number,
+        x: number,
+        y: number,
+    } = null
+
+
+    Flag(): string {
+        // return this.node.parent.name + this.name + this.node.getPosition().x + this.node.getPosition().y
+        return this.SubMap + this.fs?.sp.toString() + this.fs?.x.toString() + this.fs?.y.toString()
+    }
+
+}

+ 10 - 0
assets/Script/GameProp/Prop.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "22d64623-5aa0-4837-a455-a6a86c7d2b9f",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 4 - 4
assets/Script/Global.ts

@@ -44,16 +44,16 @@ export class Global {
 
     //游戏物理层
     /**跳跃的XY的力量的缩放 */
-    static Xscale: number = 5;
+    static Xscale: number = 6;
     static Yscale: number = 5;
     /**跳跃的力量值 */
-    static UpPower: number = 130//130;
+    static UpPower: number = 175//130;
     /**世界的重力G值 */
-    static G: number = -320;
+    static G: number = -800;
 
 
     //摇杆灵敏度缩放
-    static YaoGanSpeed: number = 2;
+    static YaoGanSpeed: number = 1.2;
 
     //障碍物的碰撞盒的摩檫力 基础定为 0.5
 

+ 18 - 22
assets/Script/Map/MyMap.ts

@@ -6,6 +6,7 @@
 //  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
 
 import CanmeraScrpts from "../Canmera/CanmeraScrpts";
+import Prop from "../GameProp/Prop";
 import LoadManager from "../LoadManager";
 import LocalData from "../LocalData";
 import RewardMnr from "../Template/RewardMnr";
@@ -187,6 +188,8 @@ export default class MyMap extends cc.Component {
 
                 cc.Camera.main.node.getComponent(CanmeraScrpts).Character = PrefabNode
 
+                // PrefabNode.getComponent(cc.RigidBody).type = cc.RigidBodyType.Static
+
                 this.CharacterNode = PrefabNode
 
                 let wordpos = this.node.getChildByName('bg' + this.MapjsonData['BronID']).convertToWorldSpaceAR(
@@ -382,14 +385,6 @@ export default class MyMap extends cc.Component {
         if (this.node.getChildByName('bg' + SubMap.Id).getComponent(cc.Sprite)?.spriteFrame?.name == 'bg' + SubMap.SubMapData.bg) {
 
         } else {
-            // cc.resources.load('bg/bg' + SubMap.SubMapData.bg, cc.SpriteFrame, (err, SpriteFrame) => {
-            //     if (err) {
-            //         console.log("bg_error:" + err);
-            //         return
-            //     }
-            //     this.node.getChildByName('bg' + SubMap.Id).getComponent(cc.Sprite).spriteFrame = SpriteFrame
-            // });
-
             let bundle = cc.assetManager.getBundle("sub");
             bundle.load('res/bg/bg' + SubMap.SubMapData.bg, cc.SpriteFrame, (err: Error, SpriteFrame) => {
                 if (err) {
@@ -398,24 +393,17 @@ export default class MyMap extends cc.Component {
                 }
                 this.node.getChildByName('bg' + SubMap.Id).getComponent(cc.Sprite).spriteFrame = SpriteFrame
             });
-
-
         }
+
         for (let j = 0; j < SubMap.SubMapData.fs.length; j++) {
             const fs = SubMap.SubMapData.fs[j];
 
-            // cc.resources.load('footstep/footstep' + fs.sp, cc.Prefab, (err, Prefab) => {
-            //     if (err) {
-            //         console.log("bg_error:" + err);
-            //         return
-            //     }
-            //     let SubPrefab = cc.instantiate(Prefab)
-            //     SubPrefab.setPosition(fs.x, fs.y)
-            //     SubPrefab.angle = -fs.ro
-            //     SubPrefab.setScale(fs.sc)
-            //     SubPrefab.active = true
-            //     this.node.getChildByName('bg' + SubMap.Id).addChild(SubPrefab)
-            // });
+            // let id_Flag = SubMap.Id + '' + parseInt(fs.x.toString()) + '-' + parseInt(fs.y.toString())
+            let id_Flag = SubMap.Id.toString() + fs.sp.toString() + fs.x.toString() + fs.y.toString()
+
+            if (!RewardMnr.getInstance().isEnable(id_Flag)) {
+                continue
+            }
 
             let bundle = cc.assetManager.getBundle("sub");
             bundle.load('res/footstep/footstep' + fs.sp, cc.Prefab, (err: Error, Prefab) => {
@@ -424,10 +412,18 @@ export default class MyMap extends cc.Component {
                     return
                 }
                 let SubPrefab = cc.instantiate(Prefab)
+                //@ts-ignore
+                SubPrefab.getComponent(Prop)?.id_Flag = id_Flag
+                //@ts-ignore
+                SubPrefab.getComponent(Prop)?.SubMap = SubMap.Id.toString()
+                //@ts-ignore
+                SubPrefab.getComponent(Prop)?.fs = fs
+
                 SubPrefab.setPosition(fs.x, fs.y)
                 SubPrefab.angle = -fs.ro
                 SubPrefab.setScale(fs.sc)
                 SubPrefab.active = true
+
                 this.node.getChildByName('bg' + SubMap.Id).addChild(SubPrefab)
             });
 

+ 3 - 0
assets/Script/Template/RewardMnr.ts

@@ -45,6 +45,9 @@ export default class RewardMnr {
     addGold(name: string, Count: number) {
         if (!this.HasPropName.includes(name)) {
             this.HasPropName.push(name)
+
+            console.error(this.HasPropName);
+            
             LocalData.getInstance().setGold(Count, '+')
             cc.systemEvent.emit(EventName.Tips, `您获得了 ${Count} 枚金币`)
         }

File diff suppressed because it is too large
+ 313 - 278
assets/sub/res/json/map4.json


+ 1 - 1
settings/project.json

@@ -56,7 +56,7 @@
     "width": 960,
     "height": 640
   },
-  "last-module-event-record-time": 1729769090070,
+  "last-module-event-record-time": 1736679488440,
   "assets-sort-type": "name",
   "facebook": {
     "enable": false,

Some files were not shown because too many files changed in this diff