Просмотр исходного кода

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

薛鸿潇 5 лет назад
Родитель
Сommit
d0d04b8f2f

+ 336 - 3
mk_framework/assets/scene/MainScene.fire

@@ -70,18 +70,36 @@
     "_children": [
       {
         "__id__": 3
+      },
+      {
+        "__id__": 5
+      },
+      {
+        "__id__": 6
+      },
+      {
+        "__id__": 8
+      },
+      {
+        "__id__": 9
+      },
+      {
+        "__id__": 10
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 5
+        "__id__": 11
       },
       {
-        "__id__": 6
+        "__id__": 12
       },
       {
-        "__id__": 7
+        "__id__": 13
+      },
+      {
+        "__id__": 14
       }
     ],
     "_prefab": null,
@@ -231,6 +249,310 @@
     "_id": "81GN3uXINKVLeW4+iKSlim"
   },
   {
+    "__type__": "cc.Node",
+    "_name": "主容器",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_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": "81dsAN/u5C47JLRqaeJFBH"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "界面层",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 7
+      }
+    ],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_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": "feed4Ygc5Mh52Eu+0uixiP"
+  },
+  {
+    "__type__": "d0ea1+IO0BKJoZMInS6d9dy",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 6
+    },
+    "_enabled": true,
+    "_id": "28M/hEEcFHZqi/h+X6U+Jt"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "提示层",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_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": "75aso/yzBLpLz+LJ97b9pt"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "特效层",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_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": "a1JvNq9l1GDZtQfj46I+eB"
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "引导层",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [],
+    "_prefab": null,
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_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": "00l+e+JEJA2YTFgORvtX+s"
+  },
+  {
     "__type__": "cc.Canvas",
     "_name": "",
     "_objFlags": 0,
@@ -284,5 +606,16 @@
     "_enabled": true,
     "mainfestUrl": null,
     "_id": "6fbJRZsUhE4p90rFOw/XX3"
+  },
+  {
+    "__type__": "a0fd9gYXhZMJ46ArqYj2wBy",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "ifShowAd": true,
+    "_id": "47/AwonetJ3rlH9QZE1+cJ"
   }
 ]

+ 33 - 16
mk_framework/assets/script/mk/system/UISystem.ts

@@ -1,12 +1,14 @@
+
+const { ccclass, property } = cc._decorator;
+@ccclass
 /**
  * UI管理类
  * @author 冯聪
  */
-export default class UISystem {
+export default class UISystem extends cc.Component {
 
     /** panel父节点 */
-    public panelParent: cc.Node = null;
-
+    private panelParent: cc.Node = null;
     /** 界面预制体路径 */
     private panelPrefanbUrl: string = './prefab/uiPanel/'
     /** 是否正在打开界面 */
@@ -17,6 +19,16 @@ export default class UISystem {
     private curOnPanelDic: { [key: string]: cc.Node } = {};
     /** 上一个打开的界面名称 */
     private lastOpenPanelName: string = "";
+    
+    onLoad() {
+        mk.ui = this;
+    }
+  
+    start() {
+        if (!this.panelParent) {
+            this.panelParent = this.node;
+        }
+    }
 
     /**
      * 打开panel界面
@@ -25,47 +37,52 @@ export default class UISystem {
      */
     openPanel(panelName: string, openAction: OpenActionType = OpenActionType.normal): Promise<any> {
 
-        if (this.isPanelOpening || this.getCurOnPanel(panelName)) {
+        let self = this;
+        if (self.isPanelOpening || self.getCurOnPanel(panelName)) {
             return;
         }
 
-        this.isPanelOpening = true;
+        self.isPanelOpening = true;
 
         return new Promise((resolve, reject) => {
 
-            mk.loader.load(`${this.panelPrefanbUrl}` + panelName, cc.Prefab)
+            mk.loader.load(`${self.panelPrefanbUrl}` + panelName, cc.Prefab)
                 .then((prefab) => {
 
-                    this.isPanelOpening = false;
+                    self.isPanelOpening = false;
                     let node_panel = cc.instantiate(prefab);
-                    this.curOnPanelDic[panelName] = node_panel;
+                    self.curOnPanelDic[panelName] = node_panel;
+
+                    if (self.panelParent) {
+                        self.panelParent = self.node;
+                    }
 
                     //如果父节点不存在,就默认把该节点定为panel的父节点
-                    if (!this.panelParent) {
-                        console.error("[UISystem] UI的父节点panelParent为null,需指定UI打开的父节点");
+                    if (!self.panelParent) {
+                        console.error("[UISystem] UI的父节点panelParent为null,请检查脚本挂载情况");
                         return;
                     }
 
-                    this.panelParent.addChild(node_panel);
+                    self.panelParent.addChild(node_panel);
 
                     switch (openAction) {
                         case OpenActionType.normal:
                             break;
                         case OpenActionType.closeLast:
-                            if (this.lastOpenPanelName) {
-                                this.closePanel(this.lastOpenPanelName);
+                            if (self.lastOpenPanelName) {
+                                self.closePanel(self.lastOpenPanelName);
                             }
                             break;
                         case OpenActionType.closeOther:
-                            let keys = Object.keys(this.curOnPanelDic).filter((key) => { key != panelName });
+                            let keys = Object.keys(self.curOnPanelDic).filter((key) => { key != panelName });
                             for (var i = 0; i < keys.length; i++) {
                                 let key = keys[i];
-                                this.closePanel(key);
+                                self.closePanel(key);
                             }
                             break;
                     }
 
-                    this.lastOpenPanelName = panelName;
+                    self.lastOpenPanelName = panelName;
 
                     //返回panel
                     resolve(node_panel);

+ 2 - 1
mk_framework/assets/script/mk/utils/LogUtil.ts

@@ -40,7 +40,7 @@ export default class LogUtil {
             return;
         }
         let totalTag = tag + this._tagChar;
-        console.log("%c " + totalTag, "color: " + LogTagColor.bule, ...data);
+        console.log("%c " + totalTag, "color: " + LogTagColor.skyblue, ...data);
     }
 
     /**
@@ -157,6 +157,7 @@ export enum LogTagColor {
     yellow = "yellow;font-weight:bold",
     green = "green;font-weight:bold",
     bule = "blue;font-weight:bold",
+    skyblue = "#3DB2EF;font-weight:bold",
     orange = "orange;font-weight:bold",
     black = "black;font-weight:bold"
 }