浏览代码

Merge branch 'master' of http://120.92.132.192:23541/TDGame/TDGameClient3D

xiejing 4 年之前
父节点
当前提交
53a1a995a2

+ 33 - 0
assets/d3d/UnlitMaterial.mtl

@@ -0,0 +1,33 @@
+{
+  "__type__": "cc.Material",
+  "_name": "",
+  "_objFlags": 0,
+  "_native": "",
+  "_effectAsset": {
+    "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc"
+  },
+  "_techIdx": 0,
+  "_defines": [
+    {
+      "USE_TEXTURE": true
+    }
+  ],
+  "_states": [
+    {
+      "blendState": {
+        "targets": [
+          {}
+        ]
+      },
+      "depthStencilState": {},
+      "rasterizerState": {}
+    }
+  ],
+  "_props": [
+    {
+      "mainTexture": {
+        "__uuid__": "90d9ce53-bba7-4f74-aae2-cbcf3e7b1477@6c48a"
+      }
+    }
+  ]
+}

+ 11 - 0
assets/d3d/UnlitMaterial.mtl.meta

@@ -0,0 +1,11 @@
+{
+  "ver": "1.0.9",
+  "importer": "material",
+  "imported": true,
+  "uuid": "c4281467-2b47-441c-9fbb-8cd2f7223ac1",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {}
+}

+ 1 - 1
assets/resources/scenes/PrepareScene.scene

@@ -94,7 +94,7 @@
     "_staticSettings": {
       "__id__": 4
     },
-    "_illuminance": 65000,
+    "_illuminance": 100000,
     "_id": "597uMYCbhEtJQc0ffJlcgA"
   },
   {

+ 10 - 6
assets/resources/ui/PrepareUI.prefab

@@ -273,7 +273,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 378.518,
-      "y": 983.616,
+      "y": 968.794,
       "z": 0
     },
     "_lrot": {
@@ -285,9 +285,9 @@
     },
     "_lscale": {
       "__type__": "cc.Vec3",
-      "x": 500,
-      "y": 500,
-      "z": 500
+      "x": 650,
+      "y": 650,
+      "z": 650
     },
     "_layer": 1073741824,
     "_euler": {
@@ -327,7 +327,11 @@
       "__id__": 7
     },
     "_enabled": true,
-    "_materials": [],
+    "_materials": [
+      {
+        "__uuid__": "c4281467-2b47-441c-9fbb-8cd2f7223ac1"
+      }
+    ],
     "_visFlags": 0,
     "lightmapSettings": {
       "__id__": 10
@@ -971,7 +975,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 375.849,
-      "y": 1067.467,
+      "y": 1106.993,
       "z": 0
     },
     "_lrot": {

+ 1 - 1
assets/resources/ui/ShopUI.prefab

@@ -792,7 +792,7 @@
     "bounceDuration": 1,
     "brake": 0.5,
     "elastic": false,
-    "inertia": true,
+    "inertia": false,
     "horizontal": false,
     "vertical": true,
     "cancelInnerEvents": true,

+ 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": ""

+ 2 - 2
assets/scripts/engines/notices/NoticeManager.ts

@@ -59,13 +59,13 @@ export class NoticeManager
     /**
      * 显示提示
      * @param data          提示内容
-     * @param posType       位置类型789,456,123
+     * @param posType       位置类型678,345,012
      * @param type          类型
      * @param moveType      移动类型
      * @param time          持续时间
      * @param dis           移动距离
      */
-    public static ShowPrompt(data:any,posType:number=4,type:string="Text",moveType:number=1,time:number=1000,dis:number=100):void{
+    public static ShowPrompt(data:any,posType:number=7,type:string="Text",moveType:number=1,time:number=1000,dis:number=100):void{
         let startPos:Vec3=this.startPos[posType];
         this.ShowPromptByPos(data,startPos,type,moveType,time,dis);
     }

+ 53 - 39
assets/scripts/games/models/GameModel.ts

@@ -29,6 +29,40 @@ export class GameModel extends DataModel{
         super();
     }
 
+        /**
+     * 设置默认属性
+     */
+    SetDefaultPropertys():void{
+        //默认武器
+        this.__currentWeaponCell=new WeaponCell();
+        this.__currentWeaponCell.cellId=-1;
+        this.__currentWeaponCell.lastOutputTime=director.getCurrentTime();
+        this.__currentWeaponCell.weaponId=10101;
+
+        //默认关卡
+        this.currentLevel=1;
+        //默认栅栏
+        this.currentFenceId=30001;
+
+        //默认最大已合成枪ID
+        this.synthesisMaxWeaponId=10101;
+
+        this.gold=0;
+        this.diamond=0;
+        //12个默认格子
+        let weaponCell:WeaponCell;
+        for (let index = 0; index < 12; index++) {
+            weaponCell=new WeaponCell();
+            weaponCell.cellId=index;
+            weaponCell.weaponId=10101;
+            weaponCell.lastOutputTime=0;
+            this.__weaponCells.push(weaponCell);
+        }
+
+        //保存到本地
+        this.SaveToLoacl();
+    }
+
     private lastTime:number=0;
 
     /**
@@ -76,6 +110,16 @@ export class GameModel extends DataModel{
             this.gold+=fullEarnings*earningsIntervarS;
         }
         this.fullEarnings=fullEarnings;
+
+        if(this.DataChanged){
+            this.SaveToLoacl();
+        }
+    }
+
+    private DataChanged:boolean;
+    DispatchEvent(key: string, data?: any):void{
+        super.DispatchEvent(key,data);
+        this.DataChanged=true;
     }
 
     /**
@@ -256,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
 
@@ -264,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;
@@ -293,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;
@@ -305,6 +349,7 @@ export class GameModel extends DataModel{
         }
         //发货
         this.AddWeapon(weaponCell.cellId,weaponId);
+        return true;
     }
 
     /**
@@ -328,41 +373,8 @@ export class GameModel extends DataModel{
         return this.__weaponCells;
     }
 
-    /**
-     * 设置默认属性
-     */
-    SetDefaultPropertys():void{
-        //默认武器
-        this.__currentWeaponCell=new WeaponCell();
-        this.__currentWeaponCell.cellId=-1;
-        this.__currentWeaponCell.lastOutputTime=director.getCurrentTime();
-        this.__currentWeaponCell.weaponId=10101;
-
-        //默认关卡
-        this.currentLevel=1;
-        //默认栅栏
-        this.currentFenceId=30001;
-
-        //默认最大已合成枪ID
-        this.synthesisMaxWeaponId=10101;
-
-        this.gold=0;
-        this.diamond=0;
-        //12个默认格子
-        let weaponCell:WeaponCell;
-        for (let index = 0; index < 12; index++) {
-            weaponCell=new WeaponCell();
-            weaponCell.cellId=index;
-            weaponCell.weaponId=10101;
-            weaponCell.lastOutputTime=0;
-            this.__weaponCells.push(weaponCell);
-        }
-
-        //保存到本地
-        this.SaveToLoacl();
-    }
-
     protected OnReadByLocal(data:any):void{
+        let currentTime:number=director.getCurrentTime();
         //当前武器格
         this.__currentWeaponCell=new WeaponCell();
         for (const key in data.currentWeaponCell) {
@@ -371,6 +383,7 @@ export class GameModel extends DataModel{
                 this.__currentWeaponCell[key]=element;
             }
         }
+        this.__currentWeaponCell.lastOutputTime=currentTime;
         //武器格子
         let weaponCells:any[]=data.weaponCells;
         this.__weaponCells=[];
@@ -382,9 +395,10 @@ export class GameModel extends DataModel{
                     if (Object.prototype.hasOwnProperty.call(element, key)&&Object.prototype.hasOwnProperty.call(weaponCell, key)) {
                         const item = element[key];
                         weaponCell[key]=item;
-                        this.__weaponCells.push(weaponCell);
                     }
                 }
+                weaponCell.lastOutputTime=currentTime;
+                this.__weaponCells.push(weaponCell);
             });
         }
     }

+ 1 - 1
assets/scripts/games/scenes/PreloadingScene.ts

@@ -54,7 +54,7 @@ export class PreloadingScene extends Component {
     }
 
     private initAds():void{
-        GameModel.single.ClearLocalData();
+        // GameModel.single.ClearLocalData();
         GameModel.single.gameName="gregGame";
         GameModel.single.userId="guest";
 

+ 14 - 9
assets/scripts/games/ui/prepares/PrepareMediator.ts

@@ -1,4 +1,4 @@
-import { ButtonComponent, Color, find, instantiate, LabelComponent, LayoutComponent, loader, ModelComponent, Node, Prefab, Quat, SpriteComponent, SpriteFrame, systemEvent, SystemEventType, Touch, Vec2, view, _decorator } from 'cc';
+import { ButtonComponent, Color, EventTouch, find, instantiate, LabelComponent, LayoutComponent, loader, Material, ModelComponent, Node, Prefab, Quat, SpriteComponent, SpriteFrame, systemEvent, SystemEventType, Touch, Vec2, view, _decorator } from 'cc';
 import { GUIManager } from '../../../engines/gui/GUIManager';
 import { GUIMediator } from '../../../engines/gui/GUIMediator';
 import { DataModelEventType } from '../../../engines/models/DataModelEventType';
@@ -15,7 +15,7 @@ const { ccclass, property } = _decorator;
 
 @ccclass('PrepareMediator')
 export class PrepareMediator extends GUIMediator {
-    
+
     @property({
         type:LabelComponent
     })
@@ -112,7 +112,6 @@ export class PrepareMediator extends GUIMediator {
 
     private weaponCellListView:WeaponCellListView;
 
-
     onLoad():void{
         this.weaponCellListView=new WeaponCellListView(this);
     }
@@ -141,7 +140,6 @@ export class PrepareMediator extends GUIMediator {
         let weaponConfig:any=GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
         if(this.prefabInstance){
             this.modelView.mesh=null;
-            this.modelView.setMaterial(null,0);
             this.prefabInstance.destroy();
         }
         loader.loadRes(weaponConfig.prefab,Prefab,(err,prefab)=>{
@@ -150,8 +148,13 @@ export class PrepareMediator extends GUIMediator {
             }
             this.prefabInstance=instantiate(prefab);
             this.prefabModelComponent=this.prefabInstance.getComponentInChildren(ModelComponent);
+            //更换贴图
+            let source=this.prefabModelComponent.materials[0];
+            let target=this.modelView.materials[0];
+            let texture=source.getProperty("mainTexture");
+            target.setProperty("mainTexture",texture);
+            //更换模型
             this.modelView.mesh=this.prefabModelComponent.mesh;
-            this.modelView.setMaterial(this.prefabModelComponent.getMaterial(0),0);
         });
         if(this.gunNameLabel!=null){
             this.gunNameLabel.string=weaponConfig.name;
@@ -281,19 +284,21 @@ export class PrepareMediator extends GUIMediator {
     private currentPoint:Vec2=new Vec2();
 
     private TouchStartHandler(touch:Touch,touchEvent):void{
-        let pos:Vec2=touch.getLocation();
+        let pos:Vec2=touch.getUILocation();
         console.log(pos);
         this.startPoint.set(pos.x,pos.y);
         this.startRotation.x=this.modelView.node.rotation.x;
         this.startRotation.set(this.modelView.node.rotation.x,this.modelView.node.rotation.y,this.modelView.node.rotation.z,this.modelView.node.rotation.w);
     }
 
-    private TouchMoveHandler(touch,touchEvent):void{
-        let pos:Vec2=touch.getLocation();
+    private TouchMoveHandler(touch:EventTouch,touchEvent):void{
+        let pos:Vec2=touch.getUILocation();
         this.currentPoint.set(pos.x,pos.y);
         let dis:number=Vec2.distance(this.currentPoint,this.startPoint);
         let value:number=dis/view.getCanvasSize().width;
-
+        if(this.currentPoint.x<this.startPoint.x){
+            value=-value;
+        }
         Quat.rotateY(this.currentRotation,this.startRotation,value);
         
         Quat.normalize(this.currentRotation,this.currentRotation);

+ 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) {