greg 4 年 前
コミット
98b1c13b27

+ 6 - 0
assets/resources/ui/components/ShopListItemRender.prefab

@@ -2625,9 +2625,15 @@
     "freeBuyButton": {
       "__id__": 40
     },
+    "freeBuyButtonLabel": {
+      "__id__": 60
+    },
     "diamondBuyButton": {
       "__id__": 54
     },
+    "diamondBuyButtonLabel": {
+      "__id__": 46
+    },
     "GlodBuyButton": {
       "__id__": 68
     },

+ 11 - 4
assets/scripts/games/models/GameModel.ts

@@ -214,11 +214,18 @@ export class GameModel extends DataModel{
     }
 
     /**
-     * 查询快捷购买价格
+     * 查询购买价格
      * @param weapon
      */
     public GetQuickBuyPrice():number{
-        let weaponId:number=this.CurrentQuickBuyWeaponId;
+        return this.GetWeaponBuyPrice(this.CurrentQuickBuyWeaponId);
+    }
+
+    /**
+     * 查询购买价格
+     * @param weaponId 
+     */
+    public GetWeaponBuyPrice(weaponId:number):number{
         //已购买的次数
         let buyCount:number=this.GetBuyCount(weaponId);
         let weaponConfig:any=GameConfigManager.GetWeaponConfig(weaponId);
@@ -226,8 +233,8 @@ export class GameModel extends DataModel{
         let price:number=weaponConfig.consumeGold;
         //系数
         let coefficient:number=weaponConfig.coefficient;
-        if(buyCount<=0){
-            buyCount=1;
+        if(buyCount<0){
+            buyCount=0;
         }
         return Math.floor(price*Math.pow(coefficient,buyCount));
     }

+ 13 - 0
assets/scripts/games/ui/shops/ShopItemRenderScript.ts

@@ -1,5 +1,6 @@
 import { _decorator, Component, Node, profiler, SpriteComponent, LabelComponent, ButtonComponent, loader, SpriteFrame } from 'cc';
 import GameConfigManager from '../../models/GameConfigManager';
+import { GameModel } from '../../models/GameModel';
 const { ccclass, property } = _decorator;
 
 @ccclass('ShopItemRenderScript')
@@ -25,11 +26,21 @@ export class ShopItemRenderScript extends Component {
     })
     freeBuyButton:ButtonComponent=null;
 
+    @property({
+        type:LabelComponent
+    })
+    freeBuyButtonLabel:LabelComponent=null;
+
     @property({
         type:ButtonComponent
     })
     diamondBuyButton:ButtonComponent=null;
 
+    @property({
+        type:LabelComponent
+    })
+    diamondBuyButtonLabel:LabelComponent=null;
+
 
     @property({
         type:ButtonComponent
@@ -74,9 +85,11 @@ export class ShopItemRenderScript extends Component {
             if(this.data.buyType==0){//金币购买
                 this.freeBuyButton.node.active=this.diamondBuyButton.node.active=false;
                 this.GlodBuyButton.node.active=true;
+                this.freeBuyButtonLabel.string=GameModel.single.GetWeaponBuyPrice(this.data.id).toString();
             }else if(this.data.buyType==1){//宝石购买
                 this.freeBuyButton.node.active=this.GlodBuyButton.node.active=false;
                 this.diamondBuyButton.node.active=true;
+                this.diamondBuyButtonLabel.string=weaponConfig.consumeDiamond.toString();
             }else{//广告购买
                 this.diamondBuyButton.node.active=this.GlodBuyButton.node.active=false;
                 this.freeBuyButton.node.active=true;