ソースを参照

飘字加上背景

greg 4 年 前
コミット
e497dec1b2

+ 163 - 6
assets/resources/ui/components/TextNoticeView.prefab

@@ -18,19 +18,22 @@
     "_children": [
       {
         "__id__": 2
+      },
+      {
+        "__id__": 7
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 6
+        "__id__": 11
       },
       {
-        "__id__": 7
+        "__id__": 12
       }
     ],
     "_prefab": {
-      "__id__": 8
+      "__id__": 13
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -62,7 +65,7 @@
   },
   {
     "__type__": "cc.Node",
-    "_name": "Label",
+    "_name": "Sprite",
     "_objFlags": 0,
     "_parent": {
       "__id__": 1
@@ -75,10 +78,13 @@
       },
       {
         "__id__": 4
+      },
+      {
+        "__id__": 5
       }
     ],
     "_prefab": {
-      "__id__": 5
+      "__id__": 6
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -117,6 +123,154 @@
     },
     "_enabled": true,
     "_priority": 0,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.SpriteComponent",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_sharedMaterial": null,
+    "_spriteFrame": {
+      "__uuid__": "72e319bc-562c-4474-b068-4d153e08dc18@f9941"
+    },
+    "_type": 1,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.WidgetComponent",
+    "_name": "Sprite<WidgetComponent>",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "_alignFlags": 45,
+    "_target": null,
+    "_left": 0,
+    "_right": 0,
+    "_top": 0,
+    "_bottom": 0,
+    "_horizontalCenter": 0,
+    "_verticalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": true,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 120,
+    "_originalHeight": 78,
+    "_alignMode": 2,
+    "_lockFlags": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "c1GiWCaqBKBrc7gOi/EpF7",
+    "sync": false,
+    "_synced": {
+      "default": false,
+      "serializable": false
+    }
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Label",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 8
+      },
+      {
+        "__id__": 9
+      }
+    ],
+    "_prefab": {
+      "__id__": 10
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransformComponent",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 7
+    },
+    "_enabled": true,
+    "_priority": 0,
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 42.26,
@@ -134,7 +288,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 2
+      "__id__": 7
     },
     "_enabled": true,
     "_srcBlendFactor": 2,
@@ -210,6 +364,9 @@
     },
     "_enabled": true,
     "label": {
+      "__id__": 9
+    },
+    "background": {
       "__id__": 4
     },
     "_id": ""

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

@@ -300,7 +300,7 @@ export class GameModel extends DataModel{
      * @param type 0 金币购买 1钻石购买 2视频购买 
      * @param weaponId 
      */
-    public BuyWeapon(type:number,weaponId:number):void{
+    public BuyWeapon(type:number,weaponId:number):boolean{
         let price:number;
         let weaponConfig:any
 
@@ -308,14 +308,14 @@ export class GameModel extends DataModel{
         let weaponCell:WeaponCell=this.FindWeaponEmptyCell();
         if(weaponCell==null){
             NoticeManager.ShowPrompt("没有空槽位了!");
-            return;
+            return false;
         }
 
         if(type==0){
             price=this.GetWeaponBuyPrice(weaponId);
             if(this.gold<price){
                 NoticeManager.ShowPrompt("金币不足,不能购买武器!");
-                return;
+                return false;
             }
             //扣钱
             let currentGold:number=this.gold;
@@ -337,7 +337,7 @@ export class GameModel extends DataModel{
             price=weaponConfig.consumeDiamond;
             if(this.diamond<price){
                 NoticeManager.ShowPrompt("宝石不足,不能购买武器!");
-                return;
+                return false;
             }
             //扣钱
             let currentDiamond:number=this.gold;
@@ -349,6 +349,7 @@ export class GameModel extends DataModel{
         }
         //发货
         this.AddWeapon(weaponCell.cellId,weaponId);
+        return true;
     }
 
     /**
@@ -373,6 +374,7 @@ export class GameModel extends DataModel{
     }
 
     protected OnReadByLocal(data:any):void{
+        let currentTime:number=director.getCurrentTime();
         //当前武器格
         this.__currentWeaponCell=new WeaponCell();
         for (const key in data.currentWeaponCell) {
@@ -381,6 +383,7 @@ export class GameModel extends DataModel{
                 this.__currentWeaponCell[key]=element;
             }
         }
+        this.__currentWeaponCell.lastOutputTime=currentTime;
         //武器格子
         let weaponCells:any[]=data.weaponCells;
         this.__weaponCells=[];
@@ -394,6 +397,7 @@ export class GameModel extends DataModel{
                         weaponCell[key]=item;
                     }
                 }
+                weaponCell.lastOutputTime=currentTime;
                 this.__weaponCells.push(weaponCell);
             });
         }

+ 12 - 1
assets/scripts/games/ui/prepares/TextNoticeView.ts

@@ -1,4 +1,4 @@
-import { _decorator, Component, Node, LabelComponent } from 'cc';
+import { _decorator, Component, Node, LabelComponent, SpriteComponent } from 'cc';
 import { NoticeViewScript } from '../../../engines/notices/NoticeViewScript';
 const { ccclass, property } = _decorator;
 
@@ -9,6 +9,11 @@ export class TextNoticeView extends NoticeViewScript {
     })
     label:LabelComponent=null;
 
+    @property({
+        type:SpriteComponent
+    })
+    background:SpriteComponent=null;
+
     start():void{
 
     }
@@ -16,4 +21,10 @@ export class TextNoticeView extends NoticeViewScript {
     OnStartMove():void{
         this.label.string=this.data;
     }
+
+    update(dt:number):void{
+        super.update(dt);
+        this.background.node.width=this.label.node.width+24;
+        this.background.node.height=this.label.node.height;
+    }
 }

+ 10 - 3
assets/scripts/games/ui/shops/ShopItemRenderScript.ts

@@ -1,4 +1,5 @@
 import { _decorator, Component, Node, profiler, SpriteComponent, LabelComponent, ButtonComponent, loader, SpriteFrame } from 'cc';
+import { NoticeManager } from '../../../engines/notices/NoticeManager';
 import GameConfigManager from '../../models/GameConfigManager';
 import { GameModel } from '../../models/GameModel';
 const { ccclass, property } = _decorator;
@@ -104,21 +105,27 @@ export class ShopItemRenderScript extends Component {
      * 金币购买
      */
     GlodBuy():void{
-        GameModel.single.BuyWeapon(this.data.buyType,this.data.id);
+        if(GameModel.single.BuyWeapon(this.data.buyType,this.data.id)){
+            NoticeManager.ShowPrompt("购买成功。");
+        }
     }
 
     /**
      * 钻石购买
      */
     DiamondBuy():void{
-        GameModel.single.BuyWeapon(this.data.buyType,this.data.id);
+        if(GameModel.single.BuyWeapon(this.data.buyType,this.data.id)){
+            NoticeManager.ShowPrompt("购买成功。");
+        }
     }
 
     /**
      * 视频购买
      */
     VideoBuy():void{
-        GameModel.single.BuyWeapon(this.data.buyType,this.data.id);
+        if(GameModel.single.BuyWeapon(this.data.buyType,this.data.id)){
+            NoticeManager.ShowPrompt("购买成功。");
+        }
     }
 
     // update (deltaTime: number) {