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

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

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

+ 16 - 10
tower_sanguo/assets/resources/data/turntable_data.json

@@ -4,26 +4,29 @@
 		"item": 1,
 		"type": 0,
 		"num": 500,
-		"des": "粮草",
+		"des": "少量粮草",
 		"weight": 35,
-		"upRewardInfo": "1,1000;5,1500;9,2000"
+		"upRewardInfo": "1,1000;5,1500;9,2000",
+		"icon": 3
 	},
 	"2": {
 		"index": 2,
 		"item": 1,
 		"type": 0,
 		"num": 1000,
-		"des": "粮草",
+		"des": "大量粮草",
 		"weight": 20,
-		"upRewardInfo": "3,1500;7,2500"
+		"upRewardInfo": "3,1500;7,2500",
+		"icon": 4
 	},
 	"3": {
 		"index": 3,
 		"item": 2,
 		"type": 0,
 		"num": 300,
-		"des": "元宝",
-		"weight": 15
+		"des": "少量元宝",
+		"weight": 15,
+		"icon": 6
 	},
 	"4": {
 		"index": 4,
@@ -31,7 +34,8 @@
 		"type": 1,
 		"num": 0.1,
 		"des": "少量红包币",
-		"weight": 15
+		"weight": 15,
+		"icon": 1
 	},
 	"5": {
 		"index": 5,
@@ -39,14 +43,16 @@
 		"type": 1,
 		"num": 0.3,
 		"des": "大量红包币",
-		"weight": 5
+		"weight": 5,
+		"icon": 2
 	},
 	"6": {
 		"index": 6,
 		"item": 2,
 		"type": 0,
 		"num": 1000,
-		"des": "元宝",
-		"weight": 10
+		"des": "大量元宝",
+		"weight": 10,
+		"icon": 7
 	}
 }

BIN
tower_sanguo/assets/resources/module/resIcons/icon1.png


+ 6 - 6
tower_sanguo/assets/resources/module/resIcons/icon1.png.meta

@@ -7,8 +7,8 @@
   "premultiplyAlpha": false,
   "genMipmaps": false,
   "packable": true,
-  "width": 94,
-  "height": 83,
+  "width": 62,
+  "height": 79,
   "platformSettings": {},
   "subMetas": {
     "icon1": {
@@ -22,10 +22,10 @@
       "offsetY": 0,
       "trimX": 0,
       "trimY": 0,
-      "width": 94,
-      "height": 83,
-      "rawWidth": 94,
-      "rawHeight": 83,
+      "width": 62,
+      "height": 79,
+      "rawWidth": 62,
+      "rawHeight": 79,
       "borderTop": 0,
       "borderBottom": 0,
       "borderLeft": 0,

BIN
tower_sanguo/assets/resources/module/resIcons/icon2.png


+ 6 - 6
tower_sanguo/assets/resources/module/resIcons/icon2.png.meta

@@ -7,8 +7,8 @@
   "premultiplyAlpha": false,
   "genMipmaps": false,
   "packable": true,
-  "width": 62,
-  "height": 79,
+  "width": 94,
+  "height": 83,
   "platformSettings": {},
   "subMetas": {
     "icon2": {
@@ -22,10 +22,10 @@
       "offsetY": 0,
       "trimX": 0,
       "trimY": 0,
-      "width": 62,
-      "height": 79,
-      "rawWidth": 62,
-      "rawHeight": 79,
+      "width": 94,
+      "height": 83,
+      "rawWidth": 94,
+      "rawHeight": 83,
       "borderTop": 0,
       "borderBottom": 0,
       "borderLeft": 0,

+ 34 - 13
tower_sanguo/assets/resources/module/turntable/prefabs/propIntroduce.prefab

@@ -21,20 +21,20 @@
         "__id__": 2
       },
       {
-        "__id__": 5
+        "__id__": 6
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 8
+        "__id__": 9
       },
       {
-        "__id__": 9
+        "__id__": 10
       }
     ],
     "_prefab": {
-      "__id__": 10
+      "__id__": 11
     },
     "_opacity": 255,
     "_color": {
@@ -95,23 +95,26 @@
     "_components": [
       {
         "__id__": 3
+      },
+      {
+        "__id__": 4
       }
     ],
     "_prefab": {
-      "__id__": 4
+      "__id__": 5
     },
     "_opacity": 255,
     "_color": {
       "__type__": "cc.Color",
-      "r": 0,
-      "g": 0,
-      "b": 0,
+      "r": 255,
+      "g": 255,
+      "b": 255,
       "a": 255
     },
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 195,
-      "height": 37.8
+      "height": 41.8
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -180,6 +183,24 @@
     "_id": ""
   },
   {
+    "__type__": "cc.LabelOutline",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_width": 2,
+    "_id": ""
+  },
+  {
     "__type__": "cc.PrefabInfo",
     "root": {
       "__id__": 1
@@ -201,11 +222,11 @@
     "_active": false,
     "_components": [
       {
-        "__id__": 6
+        "__id__": 7
       }
     ],
     "_prefab": {
-      "__id__": 7
+      "__id__": 8
     },
     "_opacity": 255,
     "_color": {
@@ -259,7 +280,7 @@
     "_name": "labTip<Label>",
     "_objFlags": 0,
     "node": {
-      "__id__": 5
+      "__id__": 6
     },
     "_enabled": true,
     "_materials": [
@@ -339,7 +360,7 @@
       "__id__": 3
     },
     "descLabel": {
-      "__id__": 6
+      "__id__": 7
     },
     "_id": ""
   },

+ 1 - 1
tower_sanguo/assets/resources/module/turntable/prefabs/turntableItem.prefab

@@ -367,7 +367,7 @@
       "__id__": 2
     },
     "_children": [],
-    "_active": true,
+    "_active": false,
     "_components": [
       {
         "__id__": 10

+ 16 - 29
tower_sanguo/assets/scripts/module/turntable/turntableItem.ts

@@ -38,9 +38,7 @@ export default class turntableItem extends cc.Component {
         this.num = data.num
         this.node.angle = (data.index - 1) * 60
         let self = this
-        // let path = 'module/resIcons/' + data.icon;
-        //test
-        let path = 'module/resIcons/icon1';
+        let path = 'module/resIcons/icon' + data.icon;
 
         this.rewardPrefab = await GameController.resM.loadResPromise('module/turntable/prefabs/turntableRewardTip', cc.Prefab);
 
@@ -52,42 +50,31 @@ export default class turntableItem extends cc.Component {
             self.icon.spriteFrame = assets;
         })
 
-        //惊喜宝箱
-        if (data.reward == 1) {
+        //粮草
+        if (data.item == 1) {
             this.labNum.string = '' + data.num
         }
-        //挂机收益
-        else if (data.reward == 2) {
-            this.labNum.string = '' + data.num + '分钟'
-        }
         //元宝
-        else if (data.reward == 3) {
+        else if (data.item == 2) {
             this.labNum.string = '' + data.num
         }
-        else if (data.reward == 4) {
-            this.labNum.string = '' + data.num
+        //红包币
+        else if (data.item == 3) {
+            this.labNum.string = data.des
         }
 
-        // if ((data.index - 1) % 2 == 0) {
-        //     this.labDes.node.color = cc.color(42, 81, 190)
-        //     this.labNum.node.color = cc.color(42, 81, 190)
-
-        // }
-        // else {
         this.labDes.node.color = cc.color(162, 93, 93);
         this.labNum.node.color = cc.color(162, 93, 93);
-        // }
 
-        this.labDes.string = data.txt
         let str = ""
-        if (data.reward == 2) {
-            str = "用于购买怪物"
-        } else if (data.reward == 3) {
+        if (data.item == 1) {
+            str = "用于武将训练"
+        } else if (data.item == 2) {
+            str = "用于武将抽卡"
+        } else if (data.item == 3) {
             str = "用于提现消耗"
-        } else if (data.reward == 4) {
-            str = "用于升级伙伴天赋"
         } else {
-            str = data.txt
+            str = data.des
         }
 
         this.icon.node.on(cc.Node.EventType.TOUCH_START, (touch) => {
@@ -136,7 +123,7 @@ export default class turntableItem extends cc.Component {
         }
 
         if (cc.isValid(this.labNum)) {
-            this.labNum.string = "" + this.animNum.toString() + "分钟"
+            this.labNum.string = "" + this.animNum.toString()
         }
     }
 
@@ -146,9 +133,9 @@ export default class turntableItem extends cc.Component {
         }
         let propIntroducePrefab = await GameController.resM.loadResPromise("module/turntable/prefabs/propIntroduce", cc.Prefab)
         let prop: cc.Node = cc.instantiate(propIntroducePrefab)
-        prop.parent = this.node.parent
+        prop.parent = this.node.parent.parent
         prop.name = "prop"
-        prop.position = this.node.parent.convertToNodeSpaceAR(worldPos)
+        prop.position = this.node.parent.parent.convertToNodeSpaceAR(worldPos)
         prop.y += 60
         prop.x -= 60
         prop.getComponent(propIntroduce).initView(name, desc)

+ 13 - 8
tower_sanguo/assets/scripts/module/turntable/turntableModel.ts

@@ -44,29 +44,34 @@ export default class turntableModel {
     getTurnTable(type): any {
         let weight = 0
         let weightArr = []
-        let len = this.turntable_data.length
-        let data = null
-        for (var i = 0; i < len; i++) {
-            data = this.turntable_data[i]
+        let dataArr = []
+        let len = 0
+
+        for (const key in this.turntable_data) {
+            const data = this.turntable_data[key];
             if (type == 0) {
                 if (data.type == 1) {
                     weight += data.weight
-                    weightArr[i] = weight
+                    weightArr[len] = weight
                 }
                 else {
-                    weightArr[i] = 0
+                    weightArr[len] = 0
                 }
             }
             else if (type == 1) {
                 weight += data.weight
-                weightArr[i] = weight
+                weightArr[len] = weight
             }
+
+            dataArr[len] = data;
+            len++;
         }
 
         let ran = Math.random() * weight
+        let data = null;
         for (var i = 0; i < weightArr.length; i++) {
             if (ran <= weightArr[i]) {
-                data = this.turntable_data[i]
+                data = dataArr[i]
                 break
             }
         }

+ 14 - 18
tower_sanguo/assets/scripts/module/turntable/turntableUI.ts

@@ -58,6 +58,7 @@ export default class turntableUI extends BaseUI {
 
     //需要视频次数
     private needVideoTimes = 8
+    private dataArr = []
 
     onEnable() {
         this.labLeftTimes.string = turntableModel.Instance.turntableTimes.toString()
@@ -89,10 +90,11 @@ export default class turntableUI extends BaseUI {
         this.runAni.node.active = false
         let turntable_data = turntableModel.Instance.turntable_data
 
-        let datas = new Array<any>()
+        this.dataArr = new Array<any>()
 
-        for (let entry of turntable_data) {
-            if (entry.reward == 2) {
+        for (const key in turntable_data) {
+            const entry = turntable_data[key];
+            if (entry.upRewardInfo) {
                 let upRewardInfo: string = entry.upRewardInfo
                 let a = upRewardInfo.split(";")
                 let currentArr = this.checkCurrentNum(a)
@@ -100,15 +102,12 @@ export default class turntableUI extends BaseUI {
                     entry.num = new Number(currentArr[1]).valueOf()
                 }
             }
-            datas.push(entry)
+            this.dataArr.push(entry)
         }
 
-
         let typeTemp = new Array<any>()
-        for (let entry of datas) {
-            if (entry.reward == 2) {
-                typeTemp.push(entry)
-            }
+        for (let entry of this.dataArr) {
+            typeTemp.push(entry)
         }
         typeTemp = typeTemp.sort((a, b) => {
             return a.num > b.num ? 1 : -1
@@ -124,16 +123,16 @@ export default class turntableUI extends BaseUI {
         let pre = await GameController.resM.loadResPromise('module/turntable/prefabs/turntableItem', cc.Prefab);
         let item;
         let s
-        for (var i = 0; i < datas.length; i++) {
+        for (var i = 0; i < this.dataArr.length; i++) {
             item = cc.instantiate(pre)
             s = item.getComponent(turntableItem)
             for (let entry of typeTemp) {
-                if (entry.index == datas[i].index) {
-                    datas[i] = entry
+                if (entry.index == this.dataArr[i].index) {
+                    this.dataArr[i] = entry
                     break
                 }
             }
-            s.init(datas[i])
+            s.init(this.dataArr[i])
             this.itemList.push(item)
             this.turnIn.addChild(item)
         }
@@ -157,11 +156,9 @@ export default class turntableUI extends BaseUI {
     }
 
     updateCurrentNum() {
-        let turntable_data = turntableModel.Instance.turntable_data
+        let turntable_data = this.dataArr
         for (let entry of turntable_data) {
-            if (entry.reward != 2) {
-                continue
-            } else {
+            if (entry.upRewardInfo) {
                 let upRewardInfo: string = entry.upRewardInfo
                 let a = upRewardInfo.split(";")
                 let currentArr = this.checkCurrentNum(a)
@@ -177,7 +174,6 @@ export default class turntableUI extends BaseUI {
                         }
                     }
                 }
-
             }
         }
     }