ソースを参照

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

xiejing 4 年 前
コミット
693d01f935

+ 2 - 6
assets/resources/scenes/FightingScene.scene

@@ -158,9 +158,7 @@
         "__uuid__": "57122fad-a4bb-4503-99b7-f7738db893f6@8c0dc"
       }
     ],
-    "_defaultClip": {
-      "__uuid__": "57122fad-a4bb-4503-99b7-f7738db893f6@c2696"
-    },
+    "_defaultClip": null,
     "_id": "25yTsB/wFBCJYFX9FK31cT"
   },
   {
@@ -1279,9 +1277,7 @@
         "__uuid__": "57122fad-a4bb-4503-99b7-f7738db893f6@8c0dc"
       }
     ],
-    "_defaultClip": {
-      "__uuid__": "57122fad-a4bb-4503-99b7-f7738db893f6@c2696"
-    },
+    "_defaultClip": null,
     "_id": "2cG+L9EnlJTZBGH8sNec0Y"
   },
   {

+ 8 - 8
assets/resources/ui/PrepareUI.prefab

@@ -279,7 +279,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 375,
-      "y": 968.7940000000017,
+      "y": 968.7939999999944,
       "z": 0
     },
     "_lrot": {
@@ -385,7 +385,7 @@
     "_target": null,
     "_left": 0,
     "_right": 0,
-    "_top": -32134.794,
+    "_top": -32134.793999999998,
     "_bottom": -31531.206,
     "_horizontalCenter": 0,
     "_verticalCenter": 0,
@@ -958,7 +958,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 480,
-      "height": 250.0000000000001
+      "height": 250
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -975,12 +975,12 @@
       "__id__": 30
     },
     "_enabled": true,
-    "_alignFlags": 21,
+    "_alignFlags": 17,
     "_target": null,
     "_left": 0,
     "_right": 0,
-    "_top": 234.58899999999994,
-    "_bottom": 849.411,
+    "_top": 234.589,
+    "_bottom": 849.4110000000001,
     "_horizontalCenter": 0,
     "_verticalCenter": 0,
     "_isAbsLeft": true,
@@ -1147,11 +1147,11 @@
       "__id__": 34
     },
     "_enabled": true,
-    "_alignFlags": 21,
+    "_alignFlags": 17,
     "_target": null,
     "_left": 0,
     "_right": 0,
-    "_top": 232.80000000000007,
+    "_top": 232.8,
     "_bottom": 1050.8,
     "_horizontalCenter": 0,
     "_verticalCenter": 0,

+ 256 - 6
assets/resources/ui/components/WeaponCell.prefab

@@ -39,19 +39,22 @@
       },
       {
         "__id__": 34
+      },
+      {
+        "__id__": 38
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 38
+        "__id__": 46
       },
       {
-        "__id__": 39
+        "__id__": 47
       }
     ],
     "_prefab": {
-      "__id__": 40
+      "__id__": 48
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -636,7 +639,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0.039,
-      "y": 2.978,
+      "y": -2.982,
       "z": 0
     },
     "_lrot": {
@@ -673,7 +676,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 22.25,
-      "height": 45.2
+      "height": 25.2
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -701,7 +704,7 @@
     },
     "_sharedMaterial": null,
     "_useOriginalSize": true,
-    "_string": "15\n",
+    "_string": "15",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
     "_actualFontSize": 20,
@@ -1165,6 +1168,250 @@
       "serializable": false
     }
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "Selected",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [
+      {
+        "__id__": 39
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 43
+      },
+      {
+        "__id__": 44
+      }
+    ],
+    "_prefab": {
+      "__id__": 45
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": -84,
+      "y": 54,
+      "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.Node",
+    "_name": "Label",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 38
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 40
+      },
+      {
+        "__id__": 41
+      }
+    ],
+    "_prefab": {
+      "__id__": 42
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 40,
+      "y": -14,
+      "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__": 39
+    },
+    "_enabled": true,
+    "_priority": 0,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 72,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.LabelComponent",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 39
+    },
+    "_enabled": true,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_sharedMaterial": null,
+    "_useOriginalSize": true,
+    "_string": "当前使用",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 18,
+    "_fontSize": 18,
+    "_fontFamily": "Arial",
+    "_lineHeight": 40,
+    "_overflow": 0,
+    "_enableWrapText": true,
+    "_font": null,
+    "_isSystemFontUsed": true,
+    "_isItalic": false,
+    "_isBold": false,
+    "_isUnderline": false,
+    "_cacheMode": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "3azlpgWn1JO5fr6CnHm3+L",
+    "sync": false,
+    "_synced": {
+      "default": false,
+      "serializable": false
+    }
+  },
+  {
+    "__type__": "cc.UITransformComponent",
+    "_name": "Selected<UITransformComponent>",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 38
+    },
+    "_enabled": true,
+    "_priority": 0,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 80,
+      "height": 26
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 1
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.SpriteComponent",
+    "_name": "Selected<SpriteComponent>",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 38
+    },
+    "_enabled": true,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_sharedMaterial": null,
+    "_spriteFrame": {
+      "__uuid__": "a9724646-58a1-4e6f-a4f5-0921baca226f@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.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "62mSW3gGZCYYKLbS1QwOOh",
+    "sync": false,
+    "_synced": {
+      "default": false,
+      "serializable": false
+    }
+  },
   {
     "__type__": "cc.UITransformComponent",
     "_name": "ButtonGun01<UITransformComponent>",
@@ -1194,6 +1441,9 @@
       "__id__": 1
     },
     "_enabled": true,
+    "useing": {
+      "__id__": 38
+    },
     "levelLabel": {
       "__id__": 21
     },

+ 37 - 7
assets/scripts/Platform/WeChat/WeChatPlatform.ts

@@ -149,13 +149,43 @@ export class WeChatPlatform extends BasePlatform {
         throw new Error('Method not implemented.');
     }
 
+    /**
+     * 通用打点
+     * @param str 打点数据
+     * @param num 参数
+     */
+    branchAnalytics(str: string, num?: string): void {
+        try {
+            if (this.wx) {
+                let Analytics = {}
+                if (num) {
+                    Analytics = {
+                        branchId: str,
+                        branchDim: num,
+                        eventType: 1
+                    }
+                } else {
+                    Analytics = {
+                        branchId: str,
+                        eventType: 1
+                    }
+                }
+                this.wx.reportUserBehaviorBranchAnalytics(Analytics);
+            }
+        } catch (error) {
+            console.log("打点失败:", str)
+        }
+    }
+
+    ///////////下面的版本,如果上面成功,即下个版本删除2020-10-19, 1.0.7//////////////////////
+
     /**
      * 开始游戏
      * @param num 
      */
     startBranchAnalytics(num: string): void {
         try {
-            if(this.wx){
+            if (this.wx) {
                 this.wx.reportUserBehaviorBranchAnalytics({
                     branchId: 'BCBgAAoXHx5d0WLb_vUvr7',
                     branchDim: num,
@@ -163,7 +193,7 @@ export class WeChatPlatform extends BasePlatform {
                 });
             }
         } catch (error) {
-            
+
         }
     }
 
@@ -172,7 +202,7 @@ export class WeChatPlatform extends BasePlatform {
      */
     successBranchAnalytics(num: string): void {
         try {
-            if(this.wx){
+            if (this.wx) {
                 this.wx.reportUserBehaviorBranchAnalytics({
                     branchId: 'BCBgAAoXHx5d0WLb_vUvr-',
                     branchDim: num,
@@ -180,16 +210,16 @@ export class WeChatPlatform extends BasePlatform {
                 });
             }
         } catch (error) {
-            
+
         }
     }
-    
+
     /**
      * 失败
      */
     failBranchAnalytics(num: string): void {
         try {
-            if(this.wx){
+            if (this.wx) {
                 this.wx.reportUserBehaviorBranchAnalytics({
                     branchId: 'BCBgAAoXHx5d0WLb_vUvr9',
                     branchDim: num,
@@ -197,7 +227,7 @@ export class WeChatPlatform extends BasePlatform {
                 });
             }
         } catch (error) {
-            
+
         }
     }
 }

+ 16 - 0
assets/scripts/Platform/WeChat/branchIdType.ts

@@ -0,0 +1,16 @@
+export class branchIdType {
+    public static EnterGame: 'BCBgAAoXHx5d0WLb_vUvr7';              //进入游戏
+    public static FailGame: 'BCBgAAoXHx5d0WLb_vUvr9';               //游戏失败
+    public static SuccessGame: 'BCBgAAoXHx5d0WLb_vUvr-';            //游戏失败
+    public static AdGet: 'BCBgAAoXHx5d0WLb_vUvr0';                  //视频获得
+
+    public static EnterHall: 'BCBgAAoXHx5d0WLb_vUvry';              //进入主场景
+    public static FreeGold: 'BCBgAAoXHx5d0WLb_vUvr1';               //免费金币
+    public static AdAutoSynthetic: 'BCBgAAoXHx5d0WLb_vUvr2';        //视频自动合成
+
+    public static Synthetic: 'BCBgAAoXHx5d0WLb_vUvr_';              //合成
+
+    public static GoldExchange: 'BCBgAAoXHx5d0WLb_vUvro';           //兑换收益
+}
+
+

+ 15 - 0
assets/scripts/Platform/WeChat/branchIdType.ts.meta

@@ -0,0 +1,15 @@
+{
+  "ver": "2.0.14",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "79277a2e-3622-418b-b9f3-b4c4d84462e9",
+  "files": [
+    ".js",
+    ".trans"
+  ],
+  "subMetas": {},
+  "userData": {
+    "importAsPlugin": false,
+    "moduleId": "project:///assets/scripts/Platform/WeChat/branchIdType.js"
+  }
+}

+ 266 - 253
assets/scripts/games/models/GameModel.ts

@@ -5,6 +5,9 @@ import { EventDispatcher } from '../../engines/events/EventDispatcher';
 import { DataModel } from '../../engines/models/DataModel';
 import { DataModelEventType } from '../../engines/models/DataModelEventType';
 import { NoticeManager } from '../../engines/notices/NoticeManager';
+import { PlatformManager } from '../../Platform/PlatformManager';
+import { branchIdType } from '../../Platform/WeChat/branchIdType';
+import { WeChatPlatform } from '../../Platform/WeChat/WeChatPlatform';
 import AccelerateBuffer from '../buffers/AccelerateBuffer';
 import AutoSyntheticBuffer from '../buffers/AutoSyntheticBuffer';
 import GameConfigManager from './GameConfigManager';
@@ -12,78 +15,74 @@ import { GamePropertys } from './GamePropertys';
 import { WeaponCell } from './weapons/WeaponCell';
 const { ccclass, property } = _decorator;
 
-export class GameModel extends DataModel{
+export class GameModel extends DataModel {
 
     /**
      * 武器格子列表
      */
-    private __weaponCells:WeaponCell[]=[];
+    private __weaponCells: WeaponCell[] = [];
 
     /**
      * 购买记录
      */
-    private __buyHistory:Map<number,number>=new Map<number,number>();
-    
+    private __buyHistory: Map<number, number> = new Map<number, number>();
+
     /**
      * 当前武器格子
      */
-    private __currentWeaponCell:WeaponCell;
+    currentWeaponCell: WeaponCell;
 
-    constructor(){
+    constructor() {
         super();
     }
 
-        /**
+    /**
      * 设置默认属性
      */
-    SetDefaultPropertys():void{
-        //默认武器
-        this.__currentWeaponCell=new WeaponCell();
-        this.__currentWeaponCell.cellId=-1;
-        this.__currentWeaponCell.lastOutputTime=director.getCurrentTime();
-        this.__currentWeaponCell.weaponId=10101;
-
+    SetDefaultPropertys(): void {
         //默认关卡
-        this.currentLevel=1;
+        this.currentLevel = 1;
         //默认栅栏
-        this.currentFenceId=30001;
+        this.currentFenceId = 30001;
 
         //默认最大已合成枪ID
-        this.synthesisMaxWeaponId=10101;
+        this.synthesisMaxWeaponId = 10101;
 
-        this.gold=0;
-        this.diamond=0;
+        this.gold = 0;
+        this.diamond = 0;
         //12个默认格子
-        let weaponCell:WeaponCell;
+        let weaponCell: WeaponCell;
         for (let index = 0; index < 12; index++) {
-            weaponCell=new WeaponCell();
-            weaponCell.cellId=index;
-            weaponCell.weaponId=index<2?10101:-1;
-            weaponCell.lastOutputTime=0;
+            weaponCell = new WeaponCell();
+            weaponCell.cellId = index;
+            weaponCell.weaponId = index < 2 ? 10101 : -1;
+            weaponCell.lastOutputTime = 0;
             this.__weaponCells.push(weaponCell);
         }
-        
+        //默认武器
+        this.currentWeaponCell=this.__weaponCells[0];
+
         //保存到本地
         this.SaveToLoacl();
     }
 
-    private lastTime:number=0;
+    private lastTime: number = 0;
 
     /**
      * 计算收益
      */
-    CheckEarnings():void{
-        let currentTime:number=director.getCurrentTime();
-        if(currentTime-this.lastTime<this.earningTime){
+    CheckEarnings(): void {
+        let currentTime: number = director.getCurrentTime();
+        if (currentTime - this.lastTime < this.earningTime) {
             return;
         }
-        this.lastTime=currentTime;
-        let fullEarnings:number=this.fullEarnings;
-        if(fullEarnings>0){
-            console.log("产出金币:"+fullEarnings);
-            this.gold+=fullEarnings*(this.earningTime/1000);
+        this.lastTime = currentTime;
+        let fullEarnings: number = this.fullEarnings;
+        if (fullEarnings > 0) {
+            console.log("产出金币:" + fullEarnings);
+            this.gold += fullEarnings * (this.earningTime / 1000);
         }
-        if(this.DataChanged){
+        if (this.DataChanged) {
             this.SaveToLoacl();
         }
     }
@@ -91,61 +90,58 @@ export class GameModel extends DataModel{
     /**
      * 每秒总收益
      */
-    get fullEarnings():number{
-        let result:number=0;
+    get fullEarnings(): number {
+        let result: number = 0;
         this.__weaponCells.forEach(weaponCell => {
-            if(weaponCell.weaponId>=0){
-                result+=weaponCell.weaponConfig.earnings;
+            if (weaponCell.weaponId >= 0) {
+                result += weaponCell.weaponConfig.earnings;
             }
         });
-        if(this.__currentWeaponCell.weaponId>=0){
-            result+=this.__currentWeaponCell.weaponConfig.earnings;
-        }
         return result;
     }
 
     /**
      * 收益计算间隔
      */
-    get earningsInterval():number{
+    get earningsInterval(): number {
         return GameConfigManager.getGlobalValue("earningsInterval");
     }
 
     /**
      * 收益间隔时间
      */
-    get earningTime():number{
-        let bufferList:IBuffer[]=BufferManager.GetBufferGroup("Accelerate");
-        if(bufferList==null||bufferList.length==0){
+    get earningTime(): number {
+        let bufferList: IBuffer[] = BufferManager.GetBufferGroup("Accelerate");
+        if (bufferList == null || bufferList.length == 0) {
             return this.earningsInterval;
         }
-        let buffer:AccelerateBuffer=bufferList[0] as AccelerateBuffer;
-        return this.earningsInterval*buffer.rate;
+        let buffer: AccelerateBuffer = bufferList[0] as AccelerateBuffer;
+        return this.earningsInterval * buffer.rate;
     }
 
     /**
      * 自动合成武器
      */
-    public AutoSynthetic(max:number=1):void{
-        let a:WeaponCell;
-        let b:WeaponCell;
-        let synIndex:number=0;
+    public AutoSynthetic(max: number = 1): void {
+        let a: WeaponCell;
+        let b: WeaponCell;
+        let synIndex: number = 0;
         for (let aIndex = 0; aIndex < this.weaponCells.length; aIndex++) {
             a = this.weaponCells[aIndex];
-            if(a.weaponId<0||GameConfigManager.WeaponIsMaxLevel(a.weaponId)){
+            if (a.weaponId < 0 || GameConfigManager.WeaponIsMaxLevel(a.weaponId)) {
                 continue;
             }
-            for (let bIndex = aIndex+1; bIndex < this.weaponCells.length; bIndex++) {
+            for (let bIndex = aIndex + 1; bIndex < this.weaponCells.length; bIndex++) {
                 b = this.weaponCells[bIndex];
-                if(b.weaponId<0||GameConfigManager.WeaponIsMaxLevel(b.weaponId)){
+                if (b.weaponId < 0 || GameConfigManager.WeaponIsMaxLevel(b.weaponId)) {
                     continue;
                 }
                 //可以合成
-                if(a.weaponId==b.weaponId){
-                    this.SynthesisWeapon(a.cellId,b.cellId);
+                if (a.weaponId == b.weaponId) {
+                    this.SynthesisWeapon(a.cellId, b.cellId);
                     synIndex++;
                     //如果大于最大数
-                    if(synIndex>=max){
+                    if (synIndex >= max) {
                         return;
                     }
                 }
@@ -153,22 +149,25 @@ export class GameModel extends DataModel{
         }
     }
 
-    private DataChanged:boolean;
-    DispatchEvent(key: string, data?: any):void{
-        super.DispatchEvent(key,data);
-        this.DataChanged=true;
+    private DataChanged: boolean;
+    DispatchEvent(key: string, data?: any): void {
+        super.DispatchEvent(key, data);
+        this.DataChanged = true;
     }
 
-    /**
-     * 设置当前武器ID
-     */
-    set currentWeaponId(value:number){
-        this.__currentWeaponCell.weaponId=value;
-        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED,GamePropertys.currentWeaponId);
-    }
+    // /**
+    //  * 设置当前武器ID
+    //  */
+    // set currentWeaponId(value: number) {
+    //     this.__currentWeaponCell.weaponId = value;
+    //     this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.currentWeaponId);
+    // }
 
-    get currentWeaponId():number{
-        return this.__currentWeaponCell.weaponId;
+    get currentWeaponId(): number {
+        if(this.currentWeaponCell==null){
+            return -1;
+        }
+        return this.currentWeaponCell.weaponId;
     }
 
     /**
@@ -176,35 +175,55 @@ export class GameModel extends DataModel{
      * @param sourceCellId 
      * @param targetCellId 
      */
-    public SynthesisWeapon(sourceCellId:number,targetCellId:number):void{
-        let sourceCell:WeaponCell=this.FindCell(sourceCellId);
-        let targetCell:WeaponCell=this.FindCell(targetCellId);
-        if(sourceCell.weaponId!=targetCell.weaponId){
+    public SynthesisWeapon(sourceCellId: number, targetCellId: number): void {
+        let sourceCell: WeaponCell = this.FindCell(sourceCellId);
+        let targetCell: WeaponCell = this.FindCell(targetCellId);
+        if (sourceCell.weaponId != targetCell.weaponId) {
             console.error("要合成的武器ID不同!");
             return;
         }
-        if(GameConfigManager.WeaponIsMaxLevel(sourceCell.weaponId)){
+        if (GameConfigManager.WeaponIsMaxLevel(sourceCell.weaponId)) {
             console.error("武器已到达最高等级!");
         }
-        let newWeaponId:number=GameConfigManager.GetNextLevelWeaponId(sourceCell.weaponId);
+        let newWeaponId: number = GameConfigManager.GetNextLevelWeaponId(sourceCell.weaponId);
         //删除
-        sourceCell.weaponId=-1;
-        targetCell.weaponId=newWeaponId;
-        targetCell.lastOutputTime=director.getCurrentTime();
+        sourceCell.weaponId = -1;
+        targetCell.weaponId = newWeaponId;
+        targetCell.lastOutputTime = director.getCurrentTime();
 
         //对比新枪和老记录的合成枪
-        let newWeaponConfig=GameConfigManager.GetWeaponConfig(newWeaponId);
-        let synthesisMaxWeaponConfig=GameConfigManager.GetWeaponConfig(this.synthesisMaxWeaponId);
+        let newWeaponConfig = GameConfigManager.GetWeaponConfig(newWeaponId);
+        let synthesisMaxWeaponConfig = GameConfigManager.GetWeaponConfig(this.synthesisMaxWeaponId);
         //新记录
-        if(newWeaponConfig.level>synthesisMaxWeaponConfig.level){
-            this.synthesisMaxWeaponId=newWeaponId;
+        if (newWeaponConfig.level > synthesisMaxWeaponConfig.level) {
+            this.synthesisMaxWeaponId = newWeaponId;
         }
-        //如果比手上的好
-        if(this.__currentWeaponCell.weaponConfig&&newWeaponConfig.level>this.__currentWeaponCell.weaponConfig.level){
-            this.EquipWeapon(targetCellId);
-            return;
+
+        //打点合成最高等级的枪
+        let weChat = PlatformManager.impl as WeChatPlatform;
+        if (weChat instanceof WeChatPlatform) {
+            let level = synthesisMaxWeaponConfig.level;
+            if (newWeaponConfig.level > synthesisMaxWeaponConfig.level) {
+                level = newWeaponConfig.level;
+            }
+            weChat.branchAnalytics(branchIdType.Synthetic, String(level))
+        }
+
+        if(this.currentWeaponCell!=null){
+            if(this.currentWeaponCell==sourceCell){
+                this.currentWeaponCell=null;
+                this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.currentWeaponId);
+            }else if(this.currentWeaponCell==targetCell){
+                this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.currentWeaponId);
+                //如果比手上的好
+                if(this.currentWeaponCell.weaponConfig && newWeaponConfig.level > this.currentWeaponCell.weaponConfig.level){
+                    this.EquipWeapon(targetCell);
+                    return;
+                }
+            }
         }
-        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED,GamePropertys.WeaponCell);
+        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.WeaponCell);
+
     }
 
     /**
@@ -212,13 +231,13 @@ export class GameModel extends DataModel{
      * @param cellId 
      * @param weaponID
      */
-    public AddWeapon(cellId:number,weaponID:number):void{
+    public AddWeapon(cellId: number, weaponID: number): void {
         for (let index = 0; index < this.__weaponCells.length; index++) {
             const element = this.__weaponCells[index];
-            if(element.cellId==cellId){
-                element.weaponId=weaponID;
-                element.lastOutputTime=director.getCurrentTime();
-                this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED,GamePropertys.WeaponCell);
+            if (element.cellId == cellId) {
+                element.weaponId = weaponID;
+                element.lastOutputTime = director.getCurrentTime();
+                this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.WeaponCell);
                 return;
             }
         }
@@ -228,51 +247,43 @@ export class GameModel extends DataModel{
      * 删除武器
      * @param cellId 
      */
-    public RemoveWeapon(cellId:number):void{
-        for (let index = 0; index < this.__weaponCells.length; index++) {
-            const element = this.__weaponCells[index];
-            if(element.cellId==cellId){
-                element.weaponId=-1;
-                this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED,GamePropertys.WeaponCell);
-                return;
-            }
+    public RemoveWeapon(cellId: number): void {
+        let cell:WeaponCell=this.FindCell(cellId);
+        cell.weaponId=-1;
+        if(cell==this.currentWeaponCell){
+            this.currentWeaponCell=null;
+            this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.currentWeaponId);
         }
+        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.WeaponCell);
     }
 
-    /**
-     * 卸下武器
-     */
-    public UnequipWeapon(cellId:number):void{
-        let id:number=this.__currentWeaponCell.weaponId;
-        this.currentWeaponId=-1;
-        this.__currentWeaponCell.lastOutputTime=0;
-        this.AddWeapon(cellId,id);
-    }
+    // /**
+    //  * 卸下武器
+    //  */
+    // public UnequipWeapon(cellId: number): void {
+    //     let id: number = this.__currentWeaponCell.weaponId;
+    //     this.currentWeaponId = -1;
+    //     this.__currentWeaponCell.lastOutputTime = 0;
+    //     this.AddWeapon(cellId, id);
+    // }
 
     /**
      * 装配武器
      * @param weaponId 
      */
-    public EquipWeapon(sourceCellId:number):void{
-        let cell:WeaponCell=this.FindCell(sourceCellId);
-        if(cell==null){
-            throw new Error("找不到武器槽:"+sourceCellId);
-        }
-        let oldWeaponId=this.currentWeaponId;
-        this.currentWeaponId=cell.weaponId;
-        this.__currentWeaponCell.lastOutputTime=cell.lastOutputTime;
-        cell.weaponId=oldWeaponId;
-        cell.lastOutputTime=0;
-        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED,GamePropertys.WeaponCell);
+    public EquipWeapon(sourceCell:WeaponCell): void {
+        this.currentWeaponCell=sourceCell;
+        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.WeaponCell);
+        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.currentWeaponId);
     }
 
     /**
      * 武器空槽位置
      */
-    public get WeaponEmptyCellCount():number{
-        let count:number=0;
+    public get WeaponEmptyCellCount(): number {
+        let count: number = 0;
         this.__weaponCells.forEach(element => {
-            if(element.weaponId<0){
+            if (element.weaponId < 0) {
                 count++;
             }
         });
@@ -282,10 +293,10 @@ export class GameModel extends DataModel{
     /**
      * 寻找武器空槽位
      */
-    public FindWeaponEmptyCell():WeaponCell{
+    public FindWeaponEmptyCell(): WeaponCell {
         for (let index = 0; index < this.__weaponCells.length; index++) {
             const element = this.__weaponCells[index];
-            if(element.weaponId<0){
+            if (element.weaponId < 0) {
                 return element;
             }
         }
@@ -295,7 +306,7 @@ export class GameModel extends DataModel{
     /**
      * 当前快捷可购买的武器
      */
-    public get CurrentQuickBuyWeaponId():number{
+    public get CurrentQuickBuyWeaponId(): number {
         return GameConfigManager.GetQuickBuyWeaponId(this.synthesisMaxWeaponId);
     }
 
@@ -303,7 +314,7 @@ export class GameModel extends DataModel{
      * 查询购买价格
      * @param weapon
      */
-    public GetQuickBuyPrice():number{
+    public GetQuickBuyPrice(): number {
         return this.GetWeaponBuyPrice(this.CurrentQuickBuyWeaponId);
     }
 
@@ -311,28 +322,28 @@ export class GameModel extends DataModel{
      * 查询购买价格
      * @param weaponId 
      */
-    public GetWeaponBuyPrice(weaponId:number):number{
+    public GetWeaponBuyPrice(weaponId: number): number {
         //已购买的次数
-        let buyCount:number=this.GetBuyCount(weaponId);
-        let weaponConfig:any=GameConfigManager.GetWeaponConfig(weaponId);
+        let buyCount: number = this.GetBuyCount(weaponId);
+        let weaponConfig: any = GameConfigManager.GetWeaponConfig(weaponId);
         //价格
-        let price:number=weaponConfig.consumeGold;
+        let price: number = weaponConfig.consumeGold;
         //系数
-        let coefficient:number=weaponConfig.coefficient;
-        if(buyCount<0){
-            buyCount=0;
+        let coefficient: number = weaponConfig.coefficient;
+        if (buyCount < 0) {
+            buyCount = 0;
         }
-        return Math.floor(price*Math.pow(coefficient,buyCount));
+        return Math.floor(price * Math.pow(coefficient, buyCount));
     }
 
     /**
      * 已购买次数
      * @param weaponId 
      */
-    public GetBuyCount(weaponId:number):number{
-        let buyCount:number=0;
-        if(this.__buyHistory.has(weaponId)){
-            buyCount=this.__buyHistory.get(weaponId);
+    public GetBuyCount(weaponId: number): number {
+        let buyCount: number = 0;
+        if (this.__buyHistory.has(weaponId)) {
+            buyCount = this.__buyHistory.get(weaponId);
         }
         return buyCount;
     }
@@ -342,55 +353,55 @@ export class GameModel extends DataModel{
      * @param type 0 金币购买 1钻石购买 2视频购买 
      * @param weaponId 
      */
-    public BuyWeapon(type:number,weaponId:number):boolean{
-        let price:number;
-        let weaponConfig:any
+    public BuyWeapon(type: number, weaponId: number): boolean {
+        let price: number;
+        let weaponConfig: any
 
         //找到空槽位
-        let weaponCell:WeaponCell=this.FindWeaponEmptyCell();
-        if(weaponCell==null){
+        let weaponCell: WeaponCell = this.FindWeaponEmptyCell();
+        if (weaponCell == null) {
             NoticeManager.ShowPrompt("没有空槽位了!");
             return false;
         }
 
-        if(type==0){
-            price=this.GetWeaponBuyPrice(weaponId);
-            if(this.gold<price){
+        if (type == 0) {
+            price = this.GetWeaponBuyPrice(weaponId);
+            if (this.gold < price) {
                 NoticeManager.ShowPrompt("金币不足,不能购买武器!");
                 return false;
             }
             //扣钱
-            let currentGold:number=this.gold;
-            currentGold-=price;
-            if(currentGold<0){
-                currentGold=0;
+            let currentGold: number = this.gold;
+            currentGold -= price;
+            if (currentGold < 0) {
+                currentGold = 0;
             }
-            this.gold=currentGold;
+            this.gold = currentGold;
             //记录购买次数
-            weaponConfig=GameConfigManager.GetWeaponConfig(weaponId);
-            let buyCount:number=this.GetBuyCount(weaponId);
+            weaponConfig = GameConfigManager.GetWeaponConfig(weaponId);
+            let buyCount: number = this.GetBuyCount(weaponId);
             buyCount++;
-            if(buyCount>weaponConfig.frequencyLimit){
-                buyCount=weaponConfig.frequencyLimit;
+            if (buyCount > weaponConfig.frequencyLimit) {
+                buyCount = weaponConfig.frequencyLimit;
             }
-            this.__buyHistory.set(weaponId,buyCount);
-        }else if(type==1){
-            let weaponConfig:any=GameConfigManager.GetWeaponConfig(weaponId);
-            price=weaponConfig.consumeDiamond;
-            if(this.diamond<price){
+            this.__buyHistory.set(weaponId, buyCount);
+        } else if (type == 1) {
+            let weaponConfig: any = GameConfigManager.GetWeaponConfig(weaponId);
+            price = weaponConfig.consumeDiamond;
+            if (this.diamond < price) {
                 NoticeManager.ShowPrompt("宝石不足,不能购买武器!");
                 return false;
             }
             //扣钱
-            let currentDiamond:number=this.gold;
-            currentDiamond-=price;
-            if(currentDiamond<0){
-                currentDiamond=0;
+            let currentDiamond: number = this.gold;
+            currentDiamond -= price;
+            if (currentDiamond < 0) {
+                currentDiamond = 0;
             }
-            this.diamond=currentDiamond;
+            this.diamond = currentDiamond;
         }
         //发货
-        this.AddWeapon(weaponCell.cellId,weaponId);
+        this.AddWeapon(weaponCell.cellId, weaponId);
         return true;
     }
 
@@ -398,10 +409,10 @@ export class GameModel extends DataModel{
      * 通过武器槽ID查找
      * @param id 
      */
-    public FindCell(id:number):WeaponCell{
+    public FindCell(id: number): WeaponCell {
         for (let index = 0; index < this.__weaponCells.length; index++) {
             const element = this.__weaponCells[index];
-            if(element.cellId==id){
+            if (element.cellId == id) {
                 return element;
             }
         }
@@ -411,75 +422,77 @@ export class GameModel extends DataModel{
     /**
      * 武器格子列表
      */
-    public get weaponCells():WeaponCell[]{
+    public get weaponCells(): WeaponCell[] {
         return this.__weaponCells;
     }
 
-    protected OnReadByLocal(data:any):void{
-        let currentTime:number=director.getCurrentTime();
-        //当前武器格
-        this.__currentWeaponCell=new WeaponCell();
-        for (const key in data.currentWeaponCell) {
-            if (Object.prototype.hasOwnProperty.call(data.currentWeaponCell, key)&&Object.prototype.hasOwnProperty.call(this.__currentWeaponCell, key)) {
-                const element = data.currentWeaponCell[key];
-                this.__currentWeaponCell[key]=element;
-            }
-        }
-        this.__currentWeaponCell.lastOutputTime=currentTime;
+    protected OnReadByLocal(data: any): void {
+        let currentTime: number = director.getCurrentTime();
         //武器格子
-        let weaponCells:any[]=data.weaponCells;
-        this.__weaponCells=[];
-        let weaponCell:WeaponCell;
-        if(weaponCells!=null){
+        let weaponCells: any[] = data.weaponCells;
+        this.__weaponCells = [];
+        let weaponCell: WeaponCell;
+        if (weaponCells != null) {
             weaponCells.forEach(element => {
-                weaponCell=new WeaponCell();
+                weaponCell = new WeaponCell();
                 for (const key in element) {
-                    if (Object.prototype.hasOwnProperty.call(element, key)&&Object.prototype.hasOwnProperty.call(weaponCell, key)) {
+                    if (Object.prototype.hasOwnProperty.call(element, key) && Object.prototype.hasOwnProperty.call(weaponCell, key)) {
                         const item = element[key];
-                        weaponCell[key]=item;
+                        weaponCell[key] = item;
                     }
                 }
-                weaponCell.lastOutputTime=currentTime;
+                weaponCell.lastOutputTime = currentTime;
                 this.__weaponCells.push(weaponCell);
             });
         }
+
+        //当前武器格
+        if(data.currentWeaponCellId>0){
+            this.currentWeaponCell=this.FindCell(data.currentWeaponCellId);
+            this.currentWeaponCell.lastOutputTime = currentTime;
+        }
+
         //自动合成Buffer剩余时间
-        if(data.autoSynthesisTime>0){
-            let buffer:AutoSyntheticBuffer=new AutoSyntheticBuffer("AutoSynthesis",data.autoSynthesisTime);
+        if (data.autoSynthesisTime > 0) {
+            let buffer: AutoSyntheticBuffer = new AutoSyntheticBuffer("AutoSynthesis", data.autoSynthesisTime);
             BufferManager.RunBuffer(buffer);
         }
         //加速Buffer
-        if(data.accelerateTime>0){
-            let buffer:AccelerateBuffer=new AccelerateBuffer("Accelerate",data.accelerateTime);
+        if (data.accelerateTime > 0) {
+            let buffer: AccelerateBuffer = new AccelerateBuffer("Accelerate", data.accelerateTime);
             BufferManager.RunBuffer(buffer);
         }
     }
 
-    protected OnSaveToLocal(data:any):void{
-        data.weaponCells=this.__weaponCells;
-        data.currentWeaponCell=this.__currentWeaponCell;
-        //自动合成Buffer剩余时间
-        let buffers:IBuffer[]=BufferManager.GetBufferGroup("AutoSynthesis");
-        if(buffers!=null&&buffers.length>0){
-            let buffer:IBuffer=buffers[0];
-            data.autoSynthesisTime=buffer.GetTimeRemaining();
+    protected OnSaveToLocal(data: any): void {
+        data.weaponCells = this.__weaponCells;
+        if(this.currentWeaponCell!=null){
+            data.currentWeaponCellId = this.currentWeaponCell.cellId;
         }else{
-            data.autoSynthesisTime=0;
+            data.currentWeaponCellId=-1;
+        }
+        //自动合成Buffer剩余时间
+        let buffers: IBuffer[] = BufferManager.GetBufferGroup("AutoSynthesis");
+        if (buffers != null && buffers.length > 0) {
+            let buffer: IBuffer = buffers[0];
+            data.autoSynthesisTime = buffer.GetTimeRemaining();
+        } else {
+            data.autoSynthesisTime = 0;
         }
         //加速Buffer
-        buffers=BufferManager.GetBufferGroup("Accelerate");
-        if(buffers!=null&&buffers.length>0){
-            let accelerateBuffer:AccelerateBuffer=buffers[0] as AccelerateBuffer;
-            data.accelerateTime=accelerateBuffer.GetTimeRemaining();
-        }else{
-            data.accelerateTime=0;
+        buffers = BufferManager.GetBufferGroup("Accelerate");
+        if (buffers != null && buffers.length > 0) {
+            let accelerateBuffer: AccelerateBuffer = buffers[0] as AccelerateBuffer;
+            data.accelerateTime = accelerateBuffer.GetTimeRemaining();
+        } else {
+            data.accelerateTime = 0;
         }
     }
-    
-    private static instance:GameModel;
-    public static get single():GameModel{
-        if(this.instance==null){
-            this.instance=new GameModel();
+
+    private static instance: GameModel;
+    public static get single(): GameModel {
+        if (this.instance == null) {
+            this.instance = new GameModel();
         }
         return this.instance;
     }
@@ -487,49 +500,49 @@ export class GameModel extends DataModel{
     /**
      * 自动合成Buffer剩余时间
      */
-    get autoSynthesisTime():number{
+    get autoSynthesisTime(): number {
         return this.GetProperty(GamePropertys.autoSynthesisTime);
     }
 
     /**
      * 加速Buffer剩余时间
      */
-    get accelerateTime():number{
+    get accelerateTime(): number {
         return this.GetProperty(GamePropertys.accelerateTime);
     }
 
     /**
      * 当前关卡
      */
-    get currentLevel():number{
+    get currentLevel(): number {
         return this.GetProperty(GamePropertys.currentLevel);
     }
 
-    set currentLevel(value:number){
-        this.SetProperty(GamePropertys.currentLevel,value);
+    set currentLevel(value: number) {
+        this.SetProperty(GamePropertys.currentLevel, value);
     }
 
     /**
      * 试用栅栏ID
      */
-    trialFenceId:number=-1;
+    trialFenceId: number = -1;
 
     /**
      * 当前栅栏ID
      */
-    get currentFenceId():number{
+    get currentFenceId(): number {
         return this.GetProperty(GamePropertys.currentFenceId);
     }
 
-    set currentFenceId(value:number){
-        this.SetProperty(GamePropertys.currentFenceId,value);
+    set currentFenceId(value: number) {
+        this.SetProperty(GamePropertys.currentFenceId, value);
     }
 
     /**
      * 栅栏ID (包括试用)
      */
-    get fenceId():number{
-        if(this.trialFenceId>0){
+    get fenceId(): number {
+        if (this.trialFenceId > 0) {
             return this.trialFenceId;
         }
         return this.currentFenceId;
@@ -538,79 +551,79 @@ export class GameModel extends DataModel{
     /**
      * 金币
      */
-    get gold():number{
+    get gold(): number {
         return this.GetProperty(GamePropertys.gold);
     }
 
-    set gold(value:number){
-        this.SetProperty(GamePropertys.gold,value);
+    set gold(value: number) {
+        this.SetProperty(GamePropertys.gold, value);
     }
 
 
-     /**
-     * 积分
-     */
-    get integral():number{
+    /**
+    * 积分
+    */
+    get integral(): number {
         return this._interal
     }
-    private _interal:number;
-    set integral(value:number){
-        this._interal=value;
-        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED,GamePropertys.integral);
+    private _interal: number;
+    set integral(value: number) {
+        this._interal = value;
+        this.DispatchEvent(DataModelEventType.PROPERTY_CHANGED, GamePropertys.integral);
     }
 
     /**
      * 钻石
      */
-    get diamond():number{
+    get diamond(): number {
         return this.GetProperty(GamePropertys.diamond);
     }
 
-    set diamond(value:number){
-        this.SetProperty(GamePropertys.diamond,value);
+    set diamond(value: number) {
+        this.SetProperty(GamePropertys.diamond, value);
     }
 
     /**
      * 击杀数量
      */
-    get killCount():number{
+    get killCount(): number {
         return this.GetProperty(GamePropertys.killCount);
     }
 
-    set killCount(value:number){
-        this.SetProperty(GamePropertys.killCount,value);
+    set killCount(value: number) {
+        this.SetProperty(GamePropertys.killCount, value);
     }
-    
+
     /**
      * 怒气值
      */
-    get angerCount():number{
+    get angerCount(): number {
         return this.GetProperty(GamePropertys.angerCount);
     }
 
-    set angerCount(value:number){
-        this.SetProperty(GamePropertys.angerCount,value);
+    set angerCount(value: number) {
+        this.SetProperty(GamePropertys.angerCount, value);
     }
 
     /**
      * 当前最大合成等级
      */
-    get synthesisMaxWeaponId():number{
+    get synthesisMaxWeaponId(): number {
         return this.GetProperty(GamePropertys.synthesisMaxWeaponId);
     }
 
-    set synthesisMaxWeaponId(value:number){
-        this.SetProperty(GamePropertys.synthesisMaxWeaponId,value);
+    set synthesisMaxWeaponId(value: number) {
+        this.SetProperty(GamePropertys.synthesisMaxWeaponId, value);
     }
 
     /**
      * 上一次领取金币的时间
      */
-    get lastGetGoldTime():number{
+    get lastGetGoldTime(): number {
         return this.GetProperty(GamePropertys.synthesisMaxWeaponId);
     }
 
-    set lastGetGoldTime(value:number){
-        this.SetProperty(GamePropertys.synthesisMaxWeaponId,value);
+    set lastGetGoldTime(value: number) {
+        this.SetProperty(GamePropertys.synthesisMaxWeaponId, value);
     }
 }

+ 9 - 0
assets/scripts/games/scenes/PrepareScene.ts

@@ -7,6 +7,9 @@ import GameConfigManager from '../models/GameConfigManager';
 import { LayerManager } from '../../engines/gui/LayerManager';
 import { NoticeManager } from '../../engines/notices/NoticeManager';
 import BufferManager from '../../engines/buffers/BufferManager';
+import { PlatformManager } from '../../Platform/PlatformManager';
+import { WeChatPlatform } from '../../Platform/WeChat/WeChatPlatform';
+import { branchIdType } from '../../Platform/WeChat/branchIdType';
 const { ccclass, property } = _decorator;
 
 @ccclass('PrepareScene')
@@ -39,6 +42,12 @@ export class PrepareScene extends Component {
         }
         
         GUIManager.single.Show(UIConst.PREPARE_UI);
+
+        let weChat = PlatformManager.impl as WeChatPlatform;
+            if(weChat instanceof WeChatPlatform){
+                weChat.branchAnalytics(branchIdType.EnterHall)
+            }
+
     }
     
     update (deltaTime: number) {

+ 6 - 0
assets/scripts/games/ui/autoSynthesis/AutoSynthesisMediator.ts

@@ -6,6 +6,8 @@ import { GUIMediator } from '../../../engines/gui/GUIMediator';
 import { DataModelEventType } from '../../../engines/models/DataModelEventType';
 import { NoticeManager } from '../../../engines/notices/NoticeManager';
 import { PlatformManager } from '../../../Platform/PlatformManager';
+import { branchIdType } from '../../../Platform/WeChat/branchIdType';
+import { WeChatPlatform } from '../../../Platform/WeChat/WeChatPlatform';
 import AutoSyntheticBuffer from '../../buffers/AutoSyntheticBuffer';
 import GameConfigManager from '../../models/GameConfigManager';
 import { GameModel } from '../../models/GameModel';
@@ -63,6 +65,10 @@ export class AutoSynthesisMediator extends GUIMediator {
     VideoButtonClickHandler():void{
         PlatformManager.showRewardedVideo(()=>{
             this.AddBuffer();
+            let weChat = PlatformManager.impl as WeChatPlatform;
+            if(weChat instanceof WeChatPlatform){
+                weChat.branchAnalytics(branchIdType.AdAutoSynthetic)
+            }
             this.CloseButtonClickHandler();
         },()=>{
             NoticeManager.ShowPrompt("看视频失败");

+ 30 - 23
assets/scripts/games/ui/exchanges/ExchangeItemRenderScript.ts

@@ -1,55 +1,62 @@
 import { _decorator, Component, Node, LabelComponent } from 'cc';
 import { NoticeManager } from '../../../engines/notices/NoticeManager';
 import StringUtils from '../../../engines/utils/StringUtils';
+import { PlatformManager } from '../../../Platform/PlatformManager';
+import { branchIdType } from '../../../Platform/WeChat/branchIdType';
+import { WeChatPlatform } from '../../../Platform/WeChat/WeChatPlatform';
 import { GameModel } from '../../models/GameModel';
 const { ccclass, property } = _decorator;
 
 @ccclass('ExchangeItemRenderScript')
 export class ExchangeItemRenderScript extends Component {
-    
+
     @property({
-        type:LabelComponent
+        type: LabelComponent
     })
-    timeLabel:LabelComponent=null;
+    timeLabel: LabelComponent = null;
 
     @property({
-        type:LabelComponent
+        type: LabelComponent
     })
-    timeLabel1:LabelComponent=null;
+    timeLabel1: LabelComponent = null;
 
     @property({
-        type:LabelComponent
+        type: LabelComponent
     })
-    goldLabel:LabelComponent=null;
+    goldLabel: LabelComponent = null;
 
     @property({
-        type:LabelComponent
+        type: LabelComponent
     })
-    diamondLabel:LabelComponent=null;
+    diamondLabel: LabelComponent = null;
 
-    private data:any;
+    private data: any;
 
-    UpdateItemRender(data:any):void{
-        this.data=data;
-        let time:number=data.time/60/60;
-        this.timeLabel.string=time+"小时枪械收益";
-        this.timeLabel1.string="立即获得"+time+"小时枪械收益!";
-        this.goldLabel.string=StringUtils.numberUtilsEn(GameModel.single.fullEarnings*data.time);
-        this.diamondLabel.string=StringUtils.numberUtilsEn(data.useDiamond,0);
+    UpdateItemRender(data: any): void {
+        this.data = data;
+        let time: number = data.time / 60 / 60;
+        this.timeLabel.string = time + "小时枪械收益";
+        this.timeLabel1.string = "立即获得" + time + "小时枪械收益!";
+        this.goldLabel.string = StringUtils.numberUtilsEn(GameModel.single.fullEarnings * data.time);
+        this.diamondLabel.string = StringUtils.numberUtilsEn(data.useDiamond, 0);
     }
 
     /**
      * 购买
      */
-    BuyButtonClickHandler():void{
-        if(GameModel.single.diamond<this.data.useDiamond){
+    BuyButtonClickHandler(): void {
+        if (GameModel.single.diamond < this.data.useDiamond) {
             NoticeManager.ShowPrompt("钻石不足!");
-        }else{
-            GameModel.single.diamond-=this.data.useDiamond;
+        } else {
+            GameModel.single.diamond -= this.data.useDiamond;
+            let weChat = PlatformManager.impl as WeChatPlatform;
+            if (weChat instanceof WeChatPlatform) {
+                weChat.branchAnalytics(branchIdType.GoldExchange, String(this.data.useDiamond))
+            }
         }
     }
-    
-    start () {
+
+    start() {
         // Your initialization goes here.
     }
 

+ 8 - 1
assets/scripts/games/ui/freeFences/FreeFenceMediator.ts

@@ -6,6 +6,7 @@ import { NoticeManager } from '../../../engines/notices/NoticeManager';
 import { SceneManager } from '../../../engines/scenes/SceneManager';
 import StringUtils from '../../../engines/utils/StringUtils';
 import { PlatformManager } from '../../../Platform/PlatformManager';
+import { branchIdType } from '../../../Platform/WeChat/branchIdType';
 import { WeChatPlatform } from '../../../Platform/WeChat/WeChatPlatform';
 import GameConfigManager from '../../models/GameConfigManager';
 import { GameModel } from '../../models/GameModel';
@@ -81,6 +82,11 @@ export class FreeFenceMediator extends GUIMediator {
     VideoButtonClickHandler():void{
         PlatformManager.showRewardedVideo(()=>{
             GameModel.single.trialFenceId=30301;
+            //看视频获得
+            let weChat = PlatformManager.impl as WeChatPlatform;
+            if(weChat instanceof WeChatPlatform){
+                weChat.branchAnalytics(branchIdType.AdGet, String(GameModel.single.currentLevel))
+            }
             this.startGame();
         },()=>{
             NoticeManager.ShowPrompt("看视频失败");
@@ -99,7 +105,8 @@ export class FreeFenceMediator extends GUIMediator {
          SceneManager.single.Swicth("FightingScene");
          let weChat = PlatformManager.impl as WeChatPlatform
          if(weChat instanceof WeChatPlatform){
-             weChat.startBranchAnalytics(String(GameModel.single.currentLevel));
+            //  weChat.startBranchAnalytics(String(GameModel.single.currentLevel));
+            weChat.branchAnalytics(branchIdType.EnterGame, String(GameModel.single.currentLevel))
          }
     }
 

+ 5 - 2
assets/scripts/games/ui/gameovers/GameOverMediator.ts

@@ -6,6 +6,7 @@ import { SceneManager } from '../../../engines/scenes/SceneManager';
 import StringUtils from '../../../engines/utils/StringUtils';
 import { LiangLiangSDK } from '../../../libs/liangliangSDK';
 import { PlatformManager } from '../../../Platform/PlatformManager';
+import { branchIdType } from '../../../Platform/WeChat/branchIdType';
 import { WeChatPlatform } from '../../../Platform/WeChat/WeChatPlatform';
 import GameConfigManager from '../../models/GameConfigManager';
 import { GameModel } from '../../models/GameModel';
@@ -80,7 +81,8 @@ export class GameOverMediator extends GUIMediator {
             }
             let weChat = PlatformManager.impl as WeChatPlatform;
             if(weChat instanceof WeChatPlatform){
-                weChat.successBranchAnalytics(String(GameModel.single.currentLevel));
+                // weChat.successBranchAnalytics(String(GameModel.single.currentLevel));
+                weChat.branchAnalytics(branchIdType.SuccessGame, String(GameModel.single.currentLevel))
             }
         } else {//失败
             //失败不算奖励
@@ -88,7 +90,8 @@ export class GameOverMediator extends GUIMediator {
             this.DefeatedGroup.active = true;
             let weChat = PlatformManager.impl as WeChatPlatform;
             if(weChat instanceof WeChatPlatform){
-                weChat.failBranchAnalytics(String(GameModel.single.currentLevel));
+                // weChat.failBranchAnalytics(String(GameModel.single.currentLevel));
+                weChat.branchAnalytics(branchIdType.FailGame, String(GameModel.single.currentLevel))
             }
         }
         this.backButtonHandle();

+ 39 - 20
assets/scripts/games/ui/prepares/PrepareMediator.ts

@@ -9,6 +9,7 @@ import { SceneManager } from '../../../engines/scenes/SceneManager';
 import { SoundManager } from '../../../engines/sounds/SoundManager';
 import StringUtils from '../../../engines/utils/StringUtils';
 import { PlatformManager } from '../../../Platform/PlatformManager';
+import { branchIdType } from '../../../Platform/WeChat/branchIdType';
 import { WeChatPlatform } from '../../../Platform/WeChat/WeChatPlatform';
 import AccelerateBuffer from '../../buffers/AccelerateBuffer';
 import AutoSyntheticBuffer from '../../buffers/AutoSyntheticBuffer';
@@ -192,9 +193,7 @@ export class PrepareMediator extends GUIMediator {
             let modelNode: Node = find("ModelView", this.node);
             this.modelView = modelNode.getComponent(ModelComponent);
         }
-        this.modelView.node.active = true;
 
-        let weaponConfig: any = GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
         if (this.modelPrefab) {
             this.modelView.mesh = null;
             let target=this.modelView.materials[0];
@@ -206,26 +205,38 @@ export class PrepareMediator extends GUIMediator {
             loader.release(deps);
             this.modelPrefab=null;
         }
-        loader.loadRes(weaponConfig.prefab, Prefab, (err, prefab) => {
-            if (err) {
-                console.error("加载武器出错");
+
+        //武器为空
+        if(GameModel.single.currentWeaponId<0){
+            this.modelView.node.active = false;
+            this.gunNameLabel.string="";
+            this.weaponInfoLabel.string="";
+            return;
+        }else{
+            this.modelView.node.active = true;
+            let weaponConfig: any = GameConfigManager.GetWeaponConfig(GameModel.single.currentWeaponId);
+            loader.loadRes(weaponConfig.prefab, Prefab, (err, prefab) => {
+                if (err) {
+                    console.error("加载武器出错");
+                }
+                this.modelPrefab = prefab;
+                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;
+            });
+            if (this.gunNameLabel != null) {
+                this.gunNameLabel.string = weaponConfig.name;
             }
-            this.modelPrefab = prefab;
-            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;
-        });
-        if (this.gunNameLabel != null) {
-            this.gunNameLabel.string = weaponConfig.name;
+            //描述
+            this.weaponInfoLabel.string=weaponConfig.desc;
         }
-        //描述
-        this.weaponInfoLabel.string=weaponConfig.desc;
+        
     }
 
     OnHide(): void {
@@ -416,6 +427,10 @@ export class PrepareMediator extends GUIMediator {
     }
 
     StartGame(): void {
+        if(GameModel.single.currentWeaponCell==null||GameModel.single.currentWeaponId<0){
+            NoticeManager.ShowPrompt("请装配武器后再试!");
+            return;
+        }
         GUIManager.single.Show(UIConst.FREE_FENCE_UI);
         // if(GameConfigManager.GetNextFenceID(GameModel.single.currentFenceId)>0){
             // GUIManager.single.Show(UIConst.FREE_FENCE_UI);
@@ -438,6 +453,10 @@ export class PrepareMediator extends GUIMediator {
         PlatformManager.showRewardedVideo(()=>{
             GameModel.single.gold += GameModel.single.fullEarnings * 600;
             NoticeManager.ShowPrompt(`获得${StringUtils.numberUtilsEn(GameModel.single.fullEarnings * 600)}金币`);
+            let weChat = PlatformManager.impl as WeChatPlatform;
+            if(weChat instanceof WeChatPlatform){
+                weChat.branchAnalytics(branchIdType.FreeGold)
+            }
         },()=>{
             NoticeManager.ShowPrompt(`未看完广告,无奖励`);
         })

+ 1 - 1
assets/scripts/games/ui/prepares/WeaponCellListView.ts

@@ -200,7 +200,7 @@ export class WeaponCellListView extends BaseView{
                     GameModel.single.RemoveWeapon(this.currentSelect.cellId);
                 }else if(this.HitNode(this.mediator.equipWeaponNode,this.tempPos))
                 {//装配武器
-                    GameModel.single.EquipWeapon(this.currentSelect.cellId);
+                    GameModel.single.EquipWeapon(this.currentSelect);
                 }
             }else{
                 if(this.startNode!=target){

+ 11 - 0
assets/scripts/games/ui/prepares/WeaponCellScript.ts

@@ -10,6 +10,12 @@ const { ccclass, property } = _decorator;
 @ccclass('WeaponCellScript')
 export class WeaponCellScript extends Component {
     
+
+    @property({
+        type:Node
+    })
+    useing:Node=null;
+
     @property({
         type:LabelComponent
     })
@@ -163,6 +169,11 @@ export class WeaponCellScript extends Component {
             this.imgState3.active=true;
             this.imgState2.active=true;
         }
+        if(GameModel.single.currentWeaponCell==this.weaponCell){
+            this.useing.active=true;
+        }else{
+            this.useing.active=false;
+        }
     }
 
     update (deltaTime: number) {