Browse Source

Merge branch 'master' of http://git.mokasz.com/zouyong/mk_framework

薛鸿潇 5 years ago
parent
commit
e383ca75ae

+ 305 - 0
assets/resources/game/prefab/tips.prefab

@@ -0,0 +1,305 @@
+[
+  {
+    "__type__": "cc.Prefab",
+    "_name": "",
+    "_objFlags": 0,
+    "_native": "",
+    "data": {
+      "__id__": 1
+    },
+    "optimizationPolicy": 0,
+    "asyncLoadAssets": false,
+    "readonly": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "tips",
+    "_objFlags": 0,
+    "_parent": null,
+    "_children": [
+      {
+        "__id__": 2
+      },
+      {
+        "__id__": 5
+      }
+    ],
+    "_active": true,
+    "_components": [],
+    "_prefab": {
+      "__id__": 8
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 280,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "bg",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 3
+      }
+    ],
+    "_prefab": {
+      "__id__": 4
+    },
+    "_opacity": 20,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 227,
+      "g": 227,
+      "b": 227,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 200,
+      "height": 80
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_spriteFrame": {
+      "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
+    },
+    "_type": 0,
+    "_sizeMode": 0,
+    "_fillType": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__uuid__": "1c822cf1-c786-4767-bdce-797a0dea57f0"
+    },
+    "fileId": "ec6ZgK4ZlN6L7tbuM63yIW",
+    "sync": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "lbl",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 6
+      }
+    ],
+    "_prefab": {
+      "__id__": 7
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 97.87,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 5
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_string": "Label",
+    "_N$string": "Label",
+    "_fontSize": 40,
+    "_lineHeight": 40,
+    "_enableWrapText": true,
+    "_N$file": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_batchAsBitmap": false,
+    "_styleFlags": 0,
+    "_underlineHeight": 0,
+    "_N$horizontalAlign": 1,
+    "_N$verticalAlign": 1,
+    "_N$fontFamily": "Arial",
+    "_N$overflow": 0,
+    "_N$cacheMode": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__uuid__": "1c822cf1-c786-4767-bdce-797a0dea57f0"
+    },
+    "fileId": "65NUZpWApGdq6Ay+zLBxpD",
+    "sync": false
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__uuid__": "1c822cf1-c786-4767-bdce-797a0dea57f0"
+    },
+    "fileId": "",
+    "sync": false
+  }
+]

+ 8 - 0
assets/resources/game/prefab/tips.prefab.meta

@@ -0,0 +1,8 @@
+{
+  "ver": "1.2.9",
+  "uuid": "1c822cf1-c786-4767-bdce-797a0dea57f0",
+  "optimizationPolicy": "AUTO",
+  "asyncLoadAssets": false,
+  "readonly": false,
+  "subMetas": {}
+}

+ 41 - 6
assets/scene/MainScene.fire

@@ -81,18 +81,15 @@
         "__id__": 8
       },
       {
-        "__id__": 9
+        "__id__": 10
       },
       {
-        "__id__": 10
+        "__id__": 11
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 11
-      },
-      {
         "__id__": 12
       },
       {
@@ -100,6 +97,9 @@
       },
       {
         "__id__": 14
+      },
+      {
+        "__id__": 15
       }
     ],
     "_prefab": null,
@@ -387,7 +387,11 @@
     },
     "_children": [],
     "_active": true,
-    "_components": [],
+    "_components": [
+      {
+        "__id__": 9
+      }
+    ],
     "_prefab": null,
     "_opacity": 255,
     "_color": {
@@ -437,6 +441,37 @@
     "_id": "75aso/yzBLpLz+LJ97b9pt"
   },
   {
+    "__type__": "5b808c7i9JMAJCR/OQTRrlG",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 8
+    },
+    "_enabled": true,
+    "tween_time": 3,
+    "src_x": 0,
+    "src_y": 0,
+    "tar_x": 0,
+    "tar_y": 100,
+    "bg_opacity": 255,
+    "bg_color": {
+      "__type__": "cc.Color",
+      "r": 200,
+      "g": 200,
+      "b": 200,
+      "a": 255
+    },
+    "tip_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "tip_size": 40,
+    "_id": "41Yz88THFLQYf9GACa9dX1"
+  },
+  {
     "__type__": "cc.Node",
     "_name": "特效层",
     "_objFlags": 0,

+ 4 - 0
assets/script/game/data/GameData.ts

@@ -19,6 +19,10 @@ export class GameData {
 
     public props: Map<number, number>;
 
+    public pools = [
+        { url: "game/prefab/tips", num: 20 }
+    ];
+
 
     /**
      * 初始化游戏数据:网络配置信息,用户信息

+ 1 - 0
assets/script/game/data/LoginData.ts

@@ -44,6 +44,7 @@ export class LoginData {
      */
     public async login() {
         this.isLogin = true;
+        mk.pool.init(gData.gameData.pools);
         gData.appData.init();
         gData.adData.init();
 

+ 8 - 0
assets/script/game/data/module/RedBagCashData.ts

@@ -4,4 +4,12 @@
  */
 export class RedBagCashData {
     
+
+    public async getRecord(){
+        let response = await mk.http.sendData('getCashRecord', {});
+        if (response.errcode != 0) {
+            return;
+        }
+        console.log(response.data);
+    }
 }

+ 1 - 0
assets/script/game/module/module/turntable/Turnable.ts

@@ -19,6 +19,7 @@ export default class Turnable extends cc.Component {
 
     onLoad() {
         this.initData();
+        mk.tip.pop("dafdfafsafdasf");
     }
 
     /**

+ 5 - 3
assets/script/mk/system/MKSystem.ts

@@ -16,6 +16,8 @@ import AdSystem from "./AdSystem";
 import JsbSystem from "./JsbSystem";
 import ATSDKMgr from "../sdk/ad/toppon/AnyThinkAdsMgr/ATSDKMgr";
 import AudioSystem from "./AudioSystem";
+import TipSystem from "./TipSystem";
+import PoolSystem from "./PoolSystem";
 
 /**
  * @description mk系统
@@ -48,9 +50,11 @@ class MKSystem {
     audio: AudioSystem;
     timer: TimerSystem;
     event: EventSystem;
+    pool:PoolSystem;
 
     /** 挂载在MainScene的界面上,不需要new */
     ui: UISystem;
+    tip:TipSystem;
 
     init() {
         //工具
@@ -72,11 +76,9 @@ class MKSystem {
         this.audio = new AudioSystem();
         this.ad = new AdSystem(ATSDKMgr.getInstance());
         this.jsb = new JsbSystem();
-
         this.timer = new TimerSystem();
         this.event = new EventSystem();
-
-
+        this.pool = new PoolSystem();
     }
 }
 

+ 69 - 0
assets/script/mk/system/PoolSystem.ts

@@ -0,0 +1,69 @@
+/**
+ * @description 对象池管理类
+ * @author 邹勇
+ */
+export default class PoolSystem {
+    constructor() {
+
+    }
+
+    private poolList: Map<string, cc.NodePool>;
+
+    public async init(pools: { url: string, num: number }[]) {
+        this.poolList = new Map<string, cc.NodePool>();
+        for (let i = 0; i < pools.length; i++) {
+            let item = pools[i];
+            let prefab = await mk.loader.load(item.url, cc.Prefab);
+            if (!prefab) {
+                console.log("没有找到该prefab", item.url);
+                continue;
+            }
+            var pool: cc.NodePool = new cc.NodePool();
+            for (let i = 0; i < item.num; ++i) {
+                let node = cc.instantiate(prefab);
+                pool.put(node);
+            }
+            let arr = item.url.split("/");
+            this.poolList.set(arr[arr.length - 1], pool);
+        }
+    }
+
+    /**
+    * 获取prefab的node
+    * @param url
+    * @returns 
+    */
+    public async getPrefab(url: string) {
+        let arr = url.split("/");
+        let name = arr[arr.length - 1];
+        var pool = this.poolList.get(name);
+        let node: cc.Node = null;
+        if (pool && pool.size() > 0) { // 通过 size 接口判断对象池中是否有空闲的对象
+            node = pool.get();
+        } else {
+            let prefab = await mk.loader.load(url, cc.Prefab);
+            node = cc.instantiate(prefab);
+            pool.put(node);
+        }
+        return node;
+    }
+
+    /**
+     * 退回对象池
+     * @param name prefab名字
+     * @param node 
+     */
+    return(name, node: cc.Node) {
+        let pool = this.poolList[name];
+        if (pool) {
+            pool.put(node);
+        }
+    }
+
+    clearPool(name) {
+        if (this.poolList[name]) {
+            this.poolList[name].clear();
+        }
+    }
+
+}

+ 9 - 0
assets/script/mk/system/PoolSystem.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "13087320-64a2-4b69-95e2-6c0fcd7bc06a",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 51 - 0
assets/script/mk/system/TipSystem.ts

@@ -0,0 +1,51 @@
+
+const { ccclass, property } = cc._decorator;
+@ccclass
+/**
+ * 提示管理类
+ * @author 邹勇
+ */
+export default class TipSystem extends cc.Component {
+    @property({ type: cc.Integer, displayName: "飘动时间" })
+    tween_time: number = 3;
+    @property({ type: cc.Integer, displayName: "开始坐标x" })
+    src_x: number = 0;
+    @property({ type: cc.Integer, displayName: "开始坐标y" })
+    src_y: number = 0;
+    @property({ type: cc.Integer, displayName: "目标坐标x" })
+    tar_x: number = 0;
+    @property({ type: cc.Integer, displayName: "目标坐标y" })
+    tar_y: number = 100;
+    @property({ type: cc.Integer, displayName: "背景透明度" })
+    bg_opacity: number = 40;
+    @property({ type: cc.Color, displayName: "背景颜色" })
+    bg_color: cc.Color = new cc.Color(200, 200, 200);
+    @property({ type: cc.Color, displayName: "文本颜色" })
+    tip_color: cc.Color = new cc.Color(255, 255, 255);
+    @property({ type: cc.Integer, displayName: "文本字体" })
+    tip_size: number = 40;
+
+    private labels: cc.Label[];
+
+    onLoad() {
+        mk.tip = this;
+        this.labels = [];
+    }
+
+    start() {
+
+    }
+
+    public async pop(str: string) {
+        let node = await mk.pool.getPrefab("game/prefab/tips");
+        node.getChildByName("bg")
+        console.log(node);
+    }
+
+
+}
+
+
+export enum TipType {
+    label = 1,
+}

+ 9 - 0
assets/script/mk/system/TipSystem.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "5b80873b-8bd2-4c00-9091-fce41346b946",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}