فهرست منبع

1,修改武将背包数据格式 arr->Map
2,添加获取武将

zouyong 5 سال پیش
والد
کامیت
2a68156157

+ 7 - 0
tower_sanguo/assets/resources/animation.meta

@@ -0,0 +1,7 @@
+{
+  "ver": "1.0.1",
+  "uuid": "68823adf-0f92-40c0-aff8-6c8e1296e083",
+  "isSubpackage": false,
+  "subpackageName": "",
+  "subMetas": {}
+}

+ 9 - 0
tower_sanguo/assets/resources/animation/bossover.anim

@@ -0,0 +1,9 @@
+{
+  "__type__": "cc.AnimationClip",
+  "_name": "",
+  "_objFlags": 0,
+  "_duration": 0,
+  "sample": 60,
+  "curveData": {},
+  "events": []
+}

+ 5 - 0
tower_sanguo/assets/resources/animation/bossover.anim.meta

@@ -0,0 +1,5 @@
+{
+  "ver": "2.1.0",
+  "uuid": "e3ae627a-e510-4e54-b9ec-352757d58cac",
+  "subMetas": {}
+}

+ 3 - 3
tower_sanguo/assets/resources/module/main/main.prefab

@@ -145,7 +145,7 @@
       "array": [
         0,
         0,
-        536.0573890229031,
+        252.985097453772,
         0,
         0,
         0,
@@ -2248,7 +2248,7 @@
     "asset": {
       "__uuid__": "12e4eb4b-bc7d-4f5e-8a52-dbe046a0531a"
     },
-    "fileId": "60069SXHxA4oiXk+/LEnTs",
+    "fileId": "e7MeKn4TJJrL+O0noKnMaf",
     "sync": false
   },
   {
@@ -2378,7 +2378,7 @@
     "asset": {
       "__uuid__": "12e4eb4b-bc7d-4f5e-8a52-dbe046a0531a"
     },
-    "fileId": "bfPWnF4RxDn5XTcMVW72Z3",
+    "fileId": "b4U4OtPoRPiLSqo7hCQpE+",
     "sync": false
   },
   {

+ 95 - 35
tower_sanguo/assets/scripts/data/GameData.ts

@@ -275,6 +275,10 @@ export default class GameData {
     getGeneralByID(id): GeneralVO {
         return this.general_data[id];
     }
+    getGeneralByIDInPack(id): GeneralVO {
+        
+        return this.general_data[id];
+    }
 
     getSkillByID(id): SkillVO {
         return this.skill_data[id];
@@ -372,7 +376,7 @@ export default class GameData {
         this.player.max_mission = data.mission_arrive;
         this.player.current_mission = data.mission_arrive;
         this.player.generals = [];
-        this.player.generals_bag = [];
+        this.player.generals_bag = new Map<number,GeneralVO>();
 
         this.updateBarrack(data.barrack);
 
@@ -380,42 +384,12 @@ export default class GameData {
         for (let i = 0; i < arr.length; i++) {
             let brr = arr[i].split(",");
             let id = parseInt(brr[GENERALPROP.ID - GENERALPROP.PROP_START]);
-            let config = this.getGeneralByID(id);
-            let vo = new GeneralVO();
-            //配置
-            vo.id = config.id;
-            vo.camp = config.camp;
-            vo.cri = config.cri;
-            vo.attack = config.attack;
-            vo.acc = config.acc;
-            vo.attSpeed = config.attSpeed;
-            vo.atk_res = config.atk_res;
-            vo.hit_res = config.hit_res;
-            vo.color = config.color;
-            vo.commander = config.commander;
-            vo.intStar = config.intStar;
-            vo.name = config.name;
-            vo.resource = config.resource;
-            vo.skillID = config.skillID;
-            vo.upRatio = config.upRatio;
-            vo.fragment_compose = config.fragment_compose;
-            //服务器数据
-            vo.lv = parseInt(brr[GENERALPROP.LV - GENERALPROP.PROP_START]);
-            vo.pos = parseInt(brr[GENERALPROP.POS - GENERALPROP.PROP_START]);
-            vo.star = parseInt(brr[GENERALPROP.STAR - GENERALPROP.PROP_START]);
-            vo.fragment = parseInt(brr[GENERALPROP.FRAGMENT - GENERALPROP.PROP_START]);
-            if (brr[GENERALPROP.FRAGMENT - GENERALPROP.PROP_START] == '1') {
-                vo.status == GENERALSTATUS.GET;
-            }
-            else{
-                vo.status = GENERALSTATUS.HAVE;
-            }
-            vo.exp = parseInt(brr[GENERALPROP.EXP - GENERALPROP.PROP_START]);
+            let vo: GeneralVO = this.createGeneralVO(id, 0, brr);
 
             if (vo.pos >= 0 && vo.pos < 5) {
                 this.player.generals[vo.pos] = vo;
             }
-            this.player.generals_bag.push(vo);
+            this.player.generals_bag[vo.id] = vo;
 
             if (this.player.max_mission < this.player.mission_open[i]) {
                 this.general_data[i] = -1;
@@ -428,6 +402,86 @@ export default class GameData {
         GameController.loadMain();
     }
 
+    /**
+     * 
+     * @param id 
+     * @param type 0服务器数据  1整卡(只有整卡可以无视兵营) 2碎片
+     * @param arg type=0表示服务器数据 type=2表示碎片数量
+     * @returns 
+     */
+    private createGeneralVO(id, type: number, arg = null): GeneralVO {
+        let vo = new GeneralVO();
+        let config = this.getGeneralByID(id);
+        //配置
+        vo.id = config.id;
+        vo.camp = config.camp;
+        vo.cri = config.cri;
+        vo.attack = config.attack;
+        vo.acc = config.acc;
+        vo.attSpeed = config.attSpeed;
+        vo.atk_res = config.atk_res;
+        vo.hit_res = config.hit_res;
+        vo.color = config.color;
+        vo.commander = config.commander;
+        vo.intStar = config.intStar;
+        vo.name = config.name;
+        vo.resource = config.resource;
+        vo.skillID = config.skillID;
+        vo.upRatio = config.upRatio;
+        vo.fragment_compose = config.fragment_compose;
+        if (type == 0) {
+            //服务器数据
+            vo.lv = parseInt(arg[GENERALPROP.LV - GENERALPROP.PROP_START]);
+            vo.pos = parseInt(arg[GENERALPROP.POS - GENERALPROP.PROP_START]);
+            vo.star = parseInt(arg[GENERALPROP.STAR - GENERALPROP.PROP_START]);
+            vo.fragment = parseInt(arg[GENERALPROP.FRAGMENT - GENERALPROP.PROP_START]);
+            if (arg[GENERALPROP.FRAGMENT - GENERALPROP.PROP_START] == '1') {
+                vo.status == GENERALSTATUS.GET;
+            }
+            else {
+                vo.status = this.updateGeneralStatus(vo);
+            }
+            vo.exp = parseInt(arg[GENERALPROP.EXP - GENERALPROP.PROP_START]);
+        }
+        else if (type == 1) {
+            vo.lv = 1;
+            vo.pos = -1;
+            vo.star = vo.intStar;
+            vo.fragment = 0;
+            vo.status = GENERALSTATUS.GET;
+        }
+        else {
+            vo.lv = 1;
+            vo.pos = -1;
+            vo.star = vo.intStar;
+            vo.fragment = arg;
+            vo.status = this.updateGeneralStatus(vo);
+        }
+        return vo;
+    }
+    private updateGeneralsStatus() {
+        for (let i in this.player.generals_bag) {
+            let vo = this.player.generals_bag[i];
+            vo.status = this.updateGeneralStatus(vo);
+        }
+    }
+    private updateGeneralStatus(vo: GeneralVO): number {
+        if (vo.status == GENERALSTATUS.GET) {
+            return GENERALSTATUS.GET;
+        }
+        else {
+            if (this.player.open_generals_inbarracks.indexOf(vo.id) != -1) {
+                return GENERALSTATUS.HAVE;
+            }
+            else if (this.player.nextgenerals_inbarracks.indexOf(vo.id) != -1) {
+                return GENERALSTATUS.UNLOCK;
+            }
+            else {
+                return GENERALSTATUS.LOCK;
+            }
+        }
+    }
+
     private initScheduler() {
         let self = this;
         let count = 0;
@@ -460,6 +514,7 @@ export default class GameData {
                 break;
             }
         }
+        this.updateGeneralsStatus();
     }
 
     /** 更新武将阵位 */
@@ -467,8 +522,7 @@ export default class GameData {
         const count = arr_embattle.length;
         if (!count) return;
         // 
-        const bag_count = this.player.generals_bag.length;
-        for (let i = 0; i < bag_count; i++) {
+        for(let i in this.player.generals_bag){
             let a_general = this.player.generals_bag[i];
             let index = arr_embattle.indexOf(a_general);
             if (index >= 0) {
@@ -483,6 +537,12 @@ export default class GameData {
         XXEvent.emit(XXConst.UpdateGenerals, this.player.generals);
         console.table(this.player.generals)
     }
+    addGeneral(id) {
+        let v = this.getGeneralByID(id);
+        if (v) {
+            this.player.generals_bag[id] = this.createGeneralVO(id, 1);
+        }
+    }
     // 更新武将属性
     updateGeneral(arr_embattle: Array<GeneralVO> = []) {
         const count = arr_embattle.length;

+ 1 - 2
tower_sanguo/assets/scripts/data/GameDefinition.ts

@@ -13,7 +13,6 @@ export enum PLAYERPROP {
 
     MISSION_ARRIVE = 20,//当前到达的最大关卡
     MISSION_PASSED = 21,//当前通过的最大关卡
-
 }
 
 export enum ITEMTYPE {
@@ -46,5 +45,5 @@ export enum GENERALSTATUS {
     LOCK = 0,//下级兵营之后扔不开放的
     UNLOCK = 1,//下个兵营开放的
     HAVE = 2,//已经兵营解锁的,但是还未拥有的(哪怕碎片是0个)
-    GET = 3,//已拥有(在武将背包内的)
+    GET = 3,//已拥有(在武将背包内的),其他状态表示未拥有,其他状态仅用于武将图鉴
 }

+ 3 - 2
tower_sanguo/assets/scripts/module/general/GeneralInfoUI.ts

@@ -177,8 +177,9 @@ export default class GeneralInfoUI extends BaseUI {
         const success_general: GeneralVO = data.general_data;
         // 更新背包数据
         let generals_bag = GameController.gameData.player.generals_bag
-        const g_b_count = generals_bag.length;
-        for (let i = 0; i < g_b_count; i++) {
+        // const g_b_count = generals_bag.length;
+        // for (let i = 0; i < g_b_count; i++) {
+        for(let i in generals_bag){
             let general_data = generals_bag[i];
             if (general_data.id === success_general.id) {
                 generals_bag[i].star = success_general.star;

+ 42 - 16
tower_sanguo/assets/scripts/module/general/GeneralTuJianUI.ts

@@ -56,32 +56,58 @@ export default class GeneralTuJianUI extends BaseUI {
         let unlock_have = [];// 已解锁无碎片
         let unowned_data: Array<any> = [];// 未解锁
         // 找出 已拥有已合成 和 已拥有未合成 的武将 by 当前选择的阵营
-        let my_count = GameController.gameData.player.generals_bag.length
-        for (let i = 0; i < my_count; i++) {
-            const general_data = GameController.gameData.player.generals_bag[i];
+        // let my_count = GameController.gameData.player.generals_bag.length
+        // for (let i = 0; i < my_count; i++) {
+        let generals = GameController.gameData.player.generals_bag;
+        for(let i in generals){
+            const general_data = generals[i];
             if (camp_type && general_data.camp != camp_type) continue;
-            if (general_data.status === GENERALSTATUS.HAVE) {
-                unlock_unget.push(general_data);
-            } else {
+            if (general_data.status === GENERALSTATUS.GET) {
                 owned_data.push(general_data);
-            }
+            } 
+            // else {
+            //     unlock_unget.push(general_data);//是否显示已解锁只和兵营等级有关,和是否有碎片无关
+            // }
         }
         const camplv = 1;// 假设兵营等级是1级
         const next_camplv = 2;// 假设这是下级解锁等级
         let obj = GameController.gameData.getAllGeneral();
         // 未拥有 已解锁 无碎片
         // 找出未拥有的武将 by 武将列表 && 选中的阵营
-        for (const key in obj) {
-            if (Object.prototype.hasOwnProperty.call(obj, key)) {
-                const general_data: GeneralVO = obj[key];
-                if (camp_type && general_data.camp != camp_type) continue;
-                if (owned_data.includes(general_data)) continue;
-                if (unlock_unget.includes(general_data)) continue;
-                if (general_data.unlockLevel <= next_camplv) {
-                    unowned_data.push(general_data);
-                }
+        // for (const key in obj) {
+        //     if (Object.prototype.hasOwnProperty.call(obj, key)) {
+        //         const general_data: GeneralVO = obj[key];
+        //         if (camp_type && general_data.camp != camp_type) continue;
+        //         if (owned_data.includes(general_data)) continue;
+        //         if (unlock_unget.includes(general_data)) continue;
+        //         if (general_data.unlockLevel <= next_camplv) {
+        //             unowned_data.push(general_data);
+        //         }
+        //     }
+        // }
+        let openIds = GameController.gameData.player.open_generals_inbarracks;
+        let nextIds = GameController.gameData.player.nextgenerals_inbarracks;
+        for(let i=0;i<openIds.length;i++){
+            let vo = GameController.gameData.getGeneralByIDInPack(openIds[i]);
+            if(vo){
+                unlock_unget.push(vo);
+            }
+            else{
+                vo = GameController.gameData.getGeneralByID(openIds[i]);
+            }
+            owned_data.push(vo);
+        }
+        for(let i=0;i<nextIds.length;i++){
+            let vo = GameController.gameData.getGeneralByIDInPack(nextIds[i]);
+            if(vo){
+                unlock_unget.push(vo);
+            }
+            else{
+                vo = GameController.gameData.getGeneralByID(nextIds[i]);
             }
+            unowned_data.push(vo);
         }
+
         // 已拥有
         let sortProperty1 = ['pos', 'color', 'star', 'lv', 'id'];
         owned_data.sort(XXMath.compare2(sortProperty1, false));

+ 8 - 5
tower_sanguo/assets/scripts/module/general/GeneralZhenWeiUI.ts

@@ -93,7 +93,7 @@ export default class GeneralZhenWeiUI extends BaseUI {
     private initStyle() {
         // 羁绊数据
         let fetter_data = this.getFetterData();
-        if(!fetter_data){
+        if (!fetter_data) {
             return;
         }
         this.fetter_data = GameController.gameData.getFetterByID(fetter_data.id);
@@ -167,8 +167,9 @@ export default class GeneralZhenWeiUI extends BaseUI {
     private GetData(camp_type = 0): Array<any> {
         let owned_data: Array<any> = []
         // 找出已拥有的武将 by 当前选择的阵营
-        const my_count = GameController.gameData.player.generals_bag.length
-        for (let i = 0; i < my_count; i++) {
+        // const my_count = GameController.gameData.player.generals_bag.length
+        // for (let i = 0; i < my_count; i++) {
+        for (let i in GameController.gameData.player.generals_bag) {
             const general_data = GameController.gameData.player.generals_bag[i];
             if (camp_type && general_data.camp != camp_type) continue;
             if (general_data.status != GENERALSTATUS.GET) continue;
@@ -282,7 +283,8 @@ export default class GeneralZhenWeiUI extends BaseUI {
         if (general_data.pos === -1) {
             // 上阵
             let my_generals = GameController.gameData.player.generals_bag;
-            for (let i = 0; i < my_generals.length; i++) {
+            // for (let i = 0; i < my_generals.length; i++) {
+            for(let i in my_generals){
                 if (my_generals[i].id === this.beChangeGeneral.id) continue;
                 if (my_generals[i].pos >= 0 || my_generals[i].id === general_data.id) {
                     if (my_generals[i].id === general_data.id) {
@@ -296,7 +298,8 @@ export default class GeneralZhenWeiUI extends BaseUI {
             let temp_pos_1 = this.beChangeGeneral.pos + 0;
             let temp_pos_2 = general_data.pos + 0;
             let my_generals = GameController.gameData.player.generals_bag;
-            for (let i = 0; i < my_generals.length; i++) {
+            // for (let i = 0; i < my_generals.length; i++) {
+            for(let i in my_generals){
                 if (my_generals[i].pos >= 0) {
                     if (my_generals[i].id === general_data.id) {
                         my_generals[i].pos = temp_pos_1;

+ 3 - 2
tower_sanguo/assets/scripts/module/general/general_card_info.ts

@@ -165,8 +165,9 @@ export default class general_card_info extends cc.Component {
         const success_general: GeneralVO = data.general_data;
         // 更新背包数据
         let generals_bag = GameController.gameData.player.generals_bag
-        const g_b_count = generals_bag.length;
-        for (let i = 0; i < g_b_count; i++) {
+        // const g_b_count = generals_bag.length;
+        // for (let i = 0; i < g_b_count; i++) {
+        for(let i in generals_bag){
             let general_data = generals_bag[i];
             if (general_data.id === success_general.id) {
                 generals_bag[i].star = success_general.star;

+ 3 - 2
tower_sanguo/assets/scripts/module/general/general_mingrentang_item.ts

@@ -50,7 +50,7 @@ export default class general_tujian_item extends cc.Component {
     /** 处理武将位置 */
     private initBodyInfo() {
         let my_generals = GameController.gameData.player.generals_bag;
-        let my_general_countt = my_generals.length;
+        // let my_general_countt = my_generals.length;
         let count = this.arr_spr_general.length;
         for (let i = 0; i < count; i++) {
             let general_id = this.item_data[i];
@@ -66,7 +66,8 @@ export default class general_tujian_item extends cc.Component {
             }
             // 自己是否拥有这个武将
             let ishav = false;
-            for (let i = 0; i < my_general_countt; i++) {
+            // for (let i = 0; i < my_general_countt; i++) {
+            for(let i in my_generals){
                 const my_general = my_generals[i];
                 if (my_general.id === general_data.id && my_general.status === GENERALSTATUS.GET) {
                     spr_item.getComponent(cc.RenderComponent).setMaterial(0, this.met_sprite);

+ 2 - 1
tower_sanguo/assets/scripts/module/main/MainUI.ts

@@ -146,7 +146,8 @@ export default class MainUI extends BaseUI {
     }
 
     clickCashOut() {
-
+        let id = parseInt(this.ui.lbl_input.getComponent(cc.EditBox).string);
+        GameController.gameData.addGeneral(id);
     }
 
     clickAddFood() {

+ 3 - 0
tower_sanguo/assets/scripts/net/servertest/ServerManager.ts

@@ -31,6 +31,9 @@ export default class ServerManager {
             if (g && g.pos != -1) {
                 this.embattle[g.pos] = g.id;
             }
+            if(g.status == 1){
+                g.status = GENERALSTATUS.GET;
+            }
             this.generals[g.id] = g;
         }
     }

+ 1 - 1
tower_sanguo/assets/scripts/vo/PlayerVO.ts

@@ -47,7 +47,7 @@ export default class PlayerVO {
      */
     generals: GeneralVO[];
 
-    generals_bag: GeneralVO[];
+    generals_bag: Map<number,GeneralVO>;
 
     /** 根据当前兵营等级得出已经开放的武将id */
     open_generals_inbarracks:number[];