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

1,修改玩家更新属性消息
2,将定时更新消息放到MainUI里

zouyong 5 лет назад
Родитель
Сommit
40263db33d

+ 12 - 0
tower_sanguo/assets/resources/data/fundes_data.json

@@ -0,0 +1,12 @@
+{
+	"barracks_help": {
+		"id": "barracks_help",
+		"title": "兵营升级",
+		"des": "1.兵营升级需要威望石。\\n\\n2.通关BOSS关卡可以获得\\n威望石\\n\\n3.兵营升级后,可以大大加快\\n武将的升级速度\\n\\n4.武将的训练等级随兵营等级\\n提升而提高。"
+	},
+	"turntable_help": {
+		"id": "turntable_help",
+		"title": "玩法说明",
+		"des": "1.每次转转盘都可100%获得\\n奖励\\n\\n2.每天有10次转转盘机会\\n\\n3.每日12点、18点、0点、将\\n自动重置转盘次数"
+	}
+}

+ 5 - 0
tower_sanguo/assets/resources/data/fundes_data.json.meta

@@ -0,0 +1,5 @@
+{
+  "ver": "1.0.0",
+  "uuid": "dea8365b-bdec-443c-9b6c-97df0b163d82",
+  "subMetas": {}
+}

+ 48 - 0
tower_sanguo/assets/resources/data/openfun_data.json

@@ -0,0 +1,48 @@
+{
+	"1": {
+		"id": 1,
+		"name": "统帅台",
+		"openmission": 3,
+		"btn_src": "btn_marshalstage",
+		"uiID": 1,
+		"ui_src": "marshalStageUI"
+	},
+	"2": {
+		"id": 2,
+		"name": "兵营",
+		"openmission": 5,
+		"btn_src": "btn_barracks",
+		"uiID": 2,
+		"ui_src": "barracksUI"
+	},
+	"3": {
+		"id": 3,
+		"name": "武将",
+		"openmission": 7,
+		"btn_src": "btn_general",
+		"uiID": 3
+	},
+	"4": {
+		"id": 4,
+		"name": "日常任务",
+		"openmission": 9,
+		"btn_src": "btn_task",
+		"uiID": 4,
+		"ui_src": "TaskUI"
+	},
+	"5": {
+		"id": 5,
+		"name": "点将台",
+		"openmission": 7,
+		"btn_src": "btn_getgeneral",
+		"uiID": 5,
+		"ui_src": "GetGeneralUI"
+	},
+	"6": {
+		"id": 6,
+		"name": "转盘",
+		"openmission": 8,
+		"uiID": 6,
+		"ui_src": "GetGeneralUI"
+	}
+}

+ 5 - 0
tower_sanguo/assets/resources/data/openfun_data.json.meta

@@ -0,0 +1,5 @@
+{
+  "ver": "1.0.0",
+  "uuid": "e2e9b129-375e-4943-86f6-5cea71e3e715",
+  "subMetas": {}
+}

+ 50 - 0
tower_sanguo/assets/resources/data/task_data.json

@@ -0,0 +1,50 @@
+{
+	"1": {
+		"id": 1,
+		"description": "武将训练{0}次",
+		"count1": 5,
+		"activevalue1": 5,
+		"count2": 20,
+		"activevalue2": 15
+	},
+	"2": {
+		"id": 2,
+		"description": "投资{0}次",
+		"count1": 2,
+		"activevalue1": 5,
+		"count2": 4,
+		"activevalue2": 10
+	},
+	"3": {
+		"id": 3,
+		"description": "抽取武将{0}次",
+		"count1": 5,
+		"activevalue1": 5,
+		"count2": 10,
+		"activevalue2": 15
+	},
+	"4": {
+		"id": 4,
+		"description": "转盘抽奖{0}次",
+		"count1": 5,
+		"activevalue1": 5,
+		"count2": 10,
+		"activevalue2": 15
+	},
+	"5": {
+		"id": 5,
+		"description": "使用统帅技能{0}次",
+		"count1": 1,
+		"activevalue1": 5,
+		"count2": 3,
+		"activevalue2": 15
+	},
+	"6": {
+		"id": 6,
+		"description": "观看视频广告{0}次",
+		"count1": 15,
+		"activevalue1": 5,
+		"count2": 30,
+		"activevalue2": 20
+	}
+}

+ 5 - 0
tower_sanguo/assets/resources/data/task_data.json.meta

@@ -0,0 +1,5 @@
+{
+  "ver": "1.0.0",
+  "uuid": "543979fd-7402-4c02-804c-391cd0848831",
+  "subMetas": {}
+}

+ 0 - 15
tower_sanguo/assets/scripts/data/GameData.ts

@@ -425,8 +425,6 @@ export default class GameData {
             }
         }
 
-        this.initScheduler();
-
         GameController.loadMain();
     }
 
@@ -510,19 +508,6 @@ export default class GameData {
         }
     }
 
-    private initScheduler() {
-        let self = this;
-        let count = 0;
-        cc.director.getScheduler().schedule(() => {
-            count++;
-            if (count % 5 == 0) {
-                count = 1;
-                let vo: MissionVO = self.getMissionByID(self.player.current_mission);
-                self.updateProp(PLAYERPROP.FOOD, Math.floor(vo.foodRecover * 5), true);
-            }
-        }, this, 1);
-    }
-
     /**
      * 兵营等级更新后,更新开放武将及下个开放武将
      * @param barrackLv 

+ 0 - 9
tower_sanguo/assets/scripts/data/GameDefinition.ts

@@ -73,15 +73,6 @@ export enum VIDEO_TYPE {
     adRbProgressAd,
 }
 
-/**带消耗确认框界面参数 */
-export interface CustomDialogParams {
-    content: string,
-    count: number;
-    certainCb?: Function,
-    cancelCb?: Function,
-    closeUIOnCancle?: boolean,
-    thisObj?: any,
-}
 /** 奖励状态 */
 export enum RewardState {
     /** 未解锁 */

+ 14 - 0
tower_sanguo/assets/scripts/module/main/MainUI.ts

@@ -86,6 +86,20 @@ export default class MainUI extends BaseUI {
 
         this.barracks_red.active = barracksModel.getInstance().checkRed();
         turntableModel.Instance.updateResetTurntable();
+
+        this.initScheduler();
+    }
+
+    private initScheduler() {
+        let count = 0;
+        this.schedule(() => {
+            count++;
+            if (count % 5 == 0) {
+                count = 1;
+                let vo: MissionVO = GameController.gameData.getMissionByID(GameController.gameData.player.current_mission);
+                GameController.gameData.updateProp(PLAYERPROP.FOOD, Math.floor(vo.foodRecover * 5), true);
+            }
+        }, 1);
     }
 
     updateProp(type: PLAYERPROP, value: number) {

+ 17 - 3
tower_sanguo/assets/scripts/net/HttpCommand.ts

@@ -175,10 +175,16 @@ export default class HttpCommand {
 
     /** 更新货币 */
     updateProp(callback, type: PLAYERPROP, value, add: boolean = false) {
+        let prop = {} as UpdatePlayerProps;
+        prop.add = add ? 1 : 0;
+        prop.proptype = type;
+        prop.propvalue = value;
+        this.updateProps(callback,[prop]);
+    }
+    /** 更新货币 */
+    updateProps(callback, arr:UpdatePlayerProps[]) {
         let msg: PlayerUpdateRequest = new PlayerUpdateRequest();
-        msg.proptype = type;
-        msg.propvalue = value;
-        msg.add = add ? 1 : 0;
+        msg.arr = arr;
         let str = JSON.stringify(msg);
         this.httpM.sendRequest(HTTPTYPE.updateProp, 'POST', str, callback);
     }
@@ -290,3 +296,11 @@ export enum HTTPTYPE {
 
     updateADLog = 'updateADLog',
 }
+
+
+/** 更新玩家属性 */
+export interface UpdatePlayerProps {
+    add:number,         //0覆盖 1增加
+    proptype:number,    //需要更新的属性
+    propvalue:number,   //更新后的属性
+}

+ 7 - 10
tower_sanguo/assets/scripts/net/msg/PlayerUpdateRequest.ts

@@ -8,14 +8,11 @@ const { ccclass } = cc._decorator;
 export default class PlayerUpdateRequest {
     constructor() {
     }
-
-    /** 0覆盖 1增加 */
-    add:number = 0;
-
-    /** 需要更新的属性  */
-    proptype:number;
-
-    /** 更新后的属性 */
-    propvalue:number;
-
+    
+    /**
+     * add 0覆盖 1增加
+     * proptype 需要更新的属性
+     * propvalue 更新后的属性
+     */
+    arr:{add:number,proptype:number,propvalue:number}[] = [];
 }

+ 2 - 4
tower_sanguo/assets/scripts/net/msg/PlayerUpdateResponse.ts

@@ -1,3 +1,4 @@
+import { UpdatePlayerProps } from "../HttpCommand";
 import BaseResponse from "./BaseResponse";
 
 /**
@@ -11,8 +12,5 @@ export default class PlayerUpdateResponse extends BaseResponse{
         super();
     }
 
-    proptype:number;
-    propvalue:number;
-    addvalue:number;
-
+    arr:UpdatePlayerProps[] = [];
 }

+ 22 - 16
tower_sanguo/assets/scripts/net/servertest/ServerManager.ts

@@ -1,7 +1,7 @@
 import { GENERALPROP, GENERALSTATUS, ITEMTYPE, PLAYERPROP } from "../../data/GameDefinition";
 import GameController from "../../GameController";
 import barracksModel from "../../module/barracks/barracksModel";
-import { HTTPTYPE } from "../HttpCommand";
+import { HTTPTYPE, UpdatePlayerProps } from "../HttpCommand";
 import AddItemRequest from "../msg/AddItemRequest";
 import AddItemResponse from "../msg/AddItemResponse";
 import BarracksLvUpResponse from "../msg/BarracksLvUpResponse";
@@ -268,22 +268,28 @@ export default class ServerManager {
     private updateProp(url, data: string, callback) {
         let jsondata = JSON.parse(data);
         let msg = new PlayerUpdateResponse();
-        switch (jsondata.proptype) {
-            case PLAYERPROP.FOOD:
-                this.player.food = jsondata.add == 1 ? this.player.food + jsondata.propvalue : jsondata.propvalue;
-                msg.propvalue = this.player.food;
-                break;
-            case PLAYERPROP.YB:
-                this.player.yb = jsondata.add == 1 ? this.player.yb + jsondata.propvalue : jsondata.propvalue;
-                msg.propvalue = this.player.food;
-                break;
-            case PLAYERPROP.REDBAG:
-                this.player.redbag = jsondata.add == 1 ? this.player.redbag + jsondata.propvalue : jsondata.propvalue;
-                msg.propvalue = this.player.food;
-                break;
+        let arr = msg.arr;
+        let brr = [];
+        for (let i = 0; i < arr.length; i++) {
+            let prop: UpdatePlayerProps = arr[i];
+            let propresponse = {} as UpdatePlayerProps;
+            switch (prop.proptype) {
+                case PLAYERPROP.FOOD:
+                    this.player.food = jsondata.add == 1 ? this.player.food + jsondata.propvalue : jsondata.propvalue;
+                    propresponse.propvalue = this.player.food;
+                    break;
+                case PLAYERPROP.YB:
+                    this.player.yb = jsondata.add == 1 ? this.player.yb + jsondata.propvalue : jsondata.propvalue;
+                    propresponse.propvalue = this.player.food;
+                    break;
+                case PLAYERPROP.REDBAG:
+                    this.player.redbag = jsondata.add == 1 ? this.player.redbag + jsondata.propvalue : jsondata.propvalue;
+                    propresponse.propvalue = this.player.food;
+                    break;
+            }
+            propresponse.proptype = jsondata.type;
         }
-        msg.proptype = jsondata.type;
-        msg.addvalue = jsondata.propvalue;
+        msg.arr = brr;
 
         this.respone(url, msg, callback);
     }