chenwb10023 vor 4 Tagen
Ursprung
Commit
6c8c7b368b

+ 335 - 0
assets/bundle/battle/UEBattleCell.prefab

@@ -0,0 +1,335 @@
+[
+  {
+    "__type__": "cc.Prefab",
+    "_name": "",
+    "_objFlags": 0,
+    "_native": "",
+    "data": {
+      "__id__": 1
+    },
+    "optimizationPolicy": 0,
+    "asyncLoadAssets": false,
+    "readonly": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "UEBattleCell",
+    "_objFlags": 0,
+    "_parent": null,
+    "_children": [
+      {
+        "__id__": 2
+      },
+      {
+        "__id__": 6
+      }
+    ],
+    "_active": true,
+    "_components": [],
+    "_prefab": {
+      "__id__": 9
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "New Sprite(Splash)",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 3
+      },
+      {
+        "__id__": 4
+      }
+    ],
+    "_prefab": {
+      "__id__": 5
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 104,
+      "height": 104
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_spriteFrame": {
+      "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
+    },
+    "_type": 0,
+    "_sizeMode": 0,
+    "_fillType": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Widget",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "alignMode": 1,
+    "_target": null,
+    "_alignFlags": 45,
+    "_left": -2,
+    "_right": -2,
+    "_top": -2,
+    "_bottom": -2,
+    "_verticalCenter": 0,
+    "_horizontalCenter": 0,
+    "_isAbsLeft": true,
+    "_isAbsRight": true,
+    "_isAbsTop": true,
+    "_isAbsBottom": true,
+    "_isAbsHorizontalCenter": true,
+    "_isAbsVerticalCenter": true,
+    "_originalWidth": 100,
+    "_originalHeight": 100,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "99nPYwUvBBwoKu0IYaPhWo",
+    "sync": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "txtIndex",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 7
+      }
+    ],
+    "_prefab": {
+      "__id__": 8
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 97.87,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 6
+    },
+    "_enabled": true,
+    "_materials": [
+      {
+        "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
+      }
+    ],
+    "_srcBlendFactor": 770,
+    "_dstBlendFactor": 771,
+    "_string": "",
+    "_N$string": "",
+    "_fontSize": 40,
+    "_lineHeight": 40,
+    "_enableWrapText": true,
+    "_N$file": null,
+    "_isSystemFontUsed": true,
+    "_spacingX": 0,
+    "_batchAsBitmap": false,
+    "_styleFlags": 0,
+    "_underlineHeight": 0,
+    "_N$horizontalAlign": 1,
+    "_N$verticalAlign": 1,
+    "_N$fontFamily": "Arial",
+    "_N$overflow": 0,
+    "_N$cacheMode": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "29oW0eQLNB4aHMrjyQnGRz",
+    "sync": false
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "",
+    "sync": false
+  }
+]

+ 9 - 0
assets/bundle/battle/UEBattleCell.prefab.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.3.2",
+  "uuid": "b323d351-30fe-44d1-86fb-4ae6da1747ba",
+  "importer": "prefab",
+  "optimizationPolicy": "AUTO",
+  "asyncLoadAssets": false,
+  "readonly": false,
+  "subMetas": {}
+}

+ 95 - 15
assets/bundle/battle/UEBattleView.prefab

@@ -21,23 +21,23 @@
         "__id__": 2
       },
       {
-        "__id__": 8
+        "__id__": 10
       },
       {
-        "__id__": 10
+        "__id__": 12
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 12
+        "__id__": 14
       },
       {
-        "__id__": 13
+        "__id__": 15
       }
     ],
     "_prefab": {
-      "__id__": 14
+      "__id__": 16
     },
     "_opacity": 255,
     "_color": {
@@ -96,16 +96,19 @@
     "_children": [
       {
         "__id__": 3
+      },
+      {
+        "__id__": 5
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 6
+        "__id__": 8
       }
     ],
     "_prefab": {
-      "__id__": 7
+      "__id__": 9
     },
     "_opacity": 255,
     "_color": {
@@ -156,6 +159,77 @@
   },
   {
     "__type__": "cc.Node",
+    "_name": "cellLayer",
+    "_objFlags": 0,
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [],
+    "_prefab": {
+      "__id__": 4
+    },
+    "_opacity": 255,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 0,
+      "height": 0
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_trs": {
+      "__type__": "TypedArray",
+      "ctor": "Float64Array",
+      "array": [
+        0,
+        -141.21,
+        0,
+        0,
+        0,
+        0,
+        1,
+        1,
+        1,
+        1
+      ]
+    },
+    "_eulerAngles": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_skewX": 0,
+    "_skewY": 0,
+    "_is3DNode": false,
+    "_groupIndex": 0,
+    "groupIndex": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "71qOnWGhpOQKIjKbPiBSP1",
+    "sync": false
+  },
+  {
+    "__type__": "cc.Node",
     "_name": "TxtRound",
     "_objFlags": 0,
     "_parent": {
@@ -165,11 +239,11 @@
     "_active": true,
     "_components": [
       {
-        "__id__": 4
+        "__id__": 6
       }
     ],
     "_prefab": {
-      "__id__": 5
+      "__id__": 7
     },
     "_opacity": 255,
     "_color": {
@@ -181,7 +255,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 136.68,
+      "width": 0,
       "height": 50.4
     },
     "_anchorPoint": {
@@ -223,7 +297,7 @@
     "_name": "",
     "_objFlags": 0,
     "node": {
-      "__id__": 3
+      "__id__": 5
     },
     "_enabled": true,
     "_materials": [
@@ -316,7 +390,7 @@
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 9
+      "__id__": 11
     },
     "_opacity": 255,
     "_color": {
@@ -387,7 +461,7 @@
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 11
+      "__id__": 13
     },
     "_opacity": 255,
     "_color": {
@@ -488,11 +562,17 @@
     "subHpPrefab": {
       "__uuid__": "055d3d34-845e-45f0-9da4-2d75e5ff7085"
     },
+    "cellPrefab": {
+      "__uuid__": "b323d351-30fe-44d1-86fb-4ae6da1747ba"
+    },
     "roleContent": {
-      "__id__": 8
+      "__id__": 10
     },
     "hpLayer": {
-      "__id__": 10
+      "__id__": 12
+    },
+    "cellLayer": {
+      "__id__": 3
     },
     "_id": ""
   },

+ 9 - 0
assets/script/logic/battle/BattleGridConstant.ts

@@ -0,0 +1,9 @@
+/** 地图格子参数配置 */
+
+export class BattleGridConstant {
+    static readonly ROW = 6;
+    static readonly COL = 10;
+    static readonly CELL_WIDTH = 125;
+    static readonly CELL_HEIGHT = 125;
+    static readonly CELL_SIZE = cc.size(BattleGridConstant.CELL_WIDTH, BattleGridConstant.CELL_HEIGHT);
+}

+ 10 - 0
assets/script/logic/battle/BattleGridConstant.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "e63e5fff-6b33-40f8-8f99-79486da0a1cc",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 6 - 3
assets/script/logic/battle/UEBattleRole.ts

@@ -17,6 +17,7 @@ export default class UEBattleRole extends UERole {
     team: FightTeam;
     type: FightType;
     posX: number;
+    posY: number;
 
     onLoad() {
         this.m_ResSpine = this.node.getChildByName("spine").getComponent(ResSpine);
@@ -26,11 +27,13 @@ export default class UEBattleRole extends UERole {
 
     }
 
-    setRole(posX: number, team: FightTeam, type: FightType) {
+    setRole(pos: cc.Vec3, team: FightTeam, type: FightType) {
         this.team = team;
         this.type = type;
-        this.node.x = posX;
-        this.posX = posX;
+        this.node.x = pos.x;
+        this.node.y = pos.y;
+        this.posX = pos.x;
+        this.posY = pos.y;
         this.LoadRoleRes();
     }
 

+ 54 - 19
assets/script/logic/battle/UEBattleView.ts

@@ -4,6 +4,7 @@ import GameDataCenter from "../../data/GameDataCenter";
 import UEBase from "../../frameWork/compment/UEBase";
 import { eg } from "../../frameWork/eg";
 import AssetMgr from "../../utils/AssetMgr";
+import { BattleGridConstant } from "./BattleGridConstant";
 import UEBattleRole from "./UEBattleRole";
 
 const { ccclass, property } = cc._decorator;
@@ -14,10 +15,14 @@ export default class UEBattleView extends UEBase {
     rolePrefab: cc.Prefab = null;
     @property(cc.Prefab)
     subHpPrefab: cc.Prefab = null;
+    @property(cc.Prefab)
+    cellPrefab: cc.Prefab = null!;
     @property(cc.Node)
     roleContent: cc.Node = null;
-	@property(cc.Node)
+    @property(cc.Node)
     hpLayer: cc.Node = null
+    @property(cc.Node)
+    cellLayer: cc.Node = null;
 
     fightStart: ActFightStart;
     fightLogList: fightLogList;
@@ -32,11 +37,11 @@ export default class UEBattleView extends UEBase {
     TxtRound: cc.Label;
 
     static getInstance() {
-		return this.s_ins
-	}
+        return this.s_ins
+    }
 
     Init() {
-		UEBattleView.s_ins = this;
+        UEBattleView.s_ins = this;
         this.fightStart = {
             "from": "pve",
             "seed": 29576,
@@ -963,6 +968,7 @@ export default class UEBattleView extends UEBase {
         }
         this.TxtRound = this.node.getChildByName("ImgDi").getChildByName("TxtRound").getComponent(cc.Label);
         this.initEvent();
+        this.LoadCell();
     }
     initEvent(): void {
 
@@ -971,14 +977,43 @@ export default class UEBattleView extends UEBase {
     onDisable(): void {
         this.node.destroy();
     }
+    /** 加载地图数据 */
+    private LoadCell() {
+        for (let i = 0; i < BattleGridConstant.COL; i++) {
+            for (let j = 0; j < BattleGridConstant.ROW; j++) {
+                this.CreateCell(i, j);
+            }
+        }
+    }
+    /** 创建格子 */
+    private CreateCell(i: number, j: number) {
+        let cell = cc.instantiate(this.cellPrefab);
+        this.cellLayer.addChild(cell);
+        cell.width = BattleGridConstant.CELL_WIDTH;
+        cell.height = BattleGridConstant.CELL_HEIGHT;
+        let pos = this.GetPosByIdx(i, j);
+        cell.setPosition(pos);
+        cell.name = `${(i + 1) * 10 + (j + 1)}`;
+        cell.getChildByName("txtIndex").getComponent(cc.Label).string = `${(i + 1) * 10 + (j + 1)}`;
+        return cell;
+    }
+    /** 根据索引获取实际像素坐标 */
+    private GetPosByIdx(i: number, j: number): cc.Vec3 {
+        const startX = -(BattleGridConstant.ROW * BattleGridConstant.CELL_WIDTH) / 2;
+        const startY = (BattleGridConstant.COL * BattleGridConstant.CELL_HEIGHT) / 2;
+        return cc.v3(
+            startX + j * BattleGridConstant.CELL_WIDTH + BattleGridConstant.CELL_WIDTH / 2,
+            startY - i * BattleGridConstant.CELL_HEIGHT - BattleGridConstant.CELL_HEIGHT / 2
+        )
+    }
     /** 获取扣血飘字表现层 */
-	GetHpLayer() {
-		return this.hpLayer;
-	}
+    GetHpLayer() {
+        return this.hpLayer;
+    }
     /** 获取扣血飘字预制体 */
-	GetSubHpPrefab() {
-		return this.subHpPrefab;
-	}
+    GetSubHpPrefab() {
+        return this.subHpPrefab;
+    }
     //开始战斗
     async onStartFight() {
         eg.poolManager.GetPool("subHPPool").clear();
@@ -990,17 +1025,17 @@ export default class UEBattleView extends UEBase {
     async produceRole() {
         let role1 = this.fightStart.teams[BattleTeamId.role1]
         let role2 = this.fightStart.teams[BattleTeamId.role2]
-        let roleZhanwei1: number = 2
-        let roleZhanwei2: number = 2
+        let roleZhanwei1: string = "61"
+        let roleZhanwei2: string = "66"
 
         let fightType: FightType = this.type;
-        let roleNode1 = AssetMgr.instantiate(this.roleContent, this.rolePrefab);
-        roleNode1.getComponent(UEBattleRole).setRole(roleZhanwei1 == 1 ? -118 : -265, role1, fightType);
+        let roleNode1 = AssetMgr.instantiate(this.cellLayer, this.rolePrefab);
+        roleNode1.getComponent(UEBattleRole).setRole(this.cellLayer.getChildByName(roleZhanwei1).position, role1, fightType);
         roleNode1.scaleX = 1;
         GameDataCenter.battle.addRole(role1?.fid, roleNode1.getComponent(UEBattleRole));
 
-        let roleNode2 = AssetMgr.instantiate(this.roleContent, this.rolePrefab);
-        roleNode2.getComponent(UEBattleRole).setRole(roleZhanwei2 == 1 ? 118 : 265, role2, fightType);
+        let roleNode2 = AssetMgr.instantiate(this.cellLayer, this.rolePrefab);
+        roleNode2.getComponent(UEBattleRole).setRole(this.cellLayer.getChildByName(roleZhanwei2).position, role2, fightType);
         roleNode2.scaleX = -1;
         GameDataCenter.battle.addRole(role2?.fid, roleNode2.getComponent(UEBattleRole));
 
@@ -1051,12 +1086,12 @@ export default class UEBattleView extends UEBase {
     playAtk(curLog: fightLogOne) {
         let atker = GameDataCenter.battle.battleRoleList[curLog.atker.fid];
         let target0 = curLog.target.length > 0 ? GameDataCenter.battle.battleRoleList[curLog.target[0].fid]
-                : Object.values(GameDataCenter.battle.battleRoleList)[0] //没有target 默认取一个防错
+            : Object.values(GameDataCenter.battle.battleRoleList)[0] //没有target 默认取一个防错
         let delay = 0.5;
         let hitX = 150; //近战偏移量
         cc.tween(atker.node)
             .delay(0.15 / GameDataCenter.battle.realBattleSpeed)
-            .to(delay / GameDataCenter.battle.realBattleSpeed, { x : atker.posX < 0 ? target0.node.x - hitX : target0.node.x + hitX })
+            .to(delay / GameDataCenter.battle.realBattleSpeed, { x: atker.posX < 0 ? target0.node.x - hitX : target0.node.x + hitX })
             .call(() => {
                 if (curLog.atker.fid == "1022") {
                     atker.playAni("atk", false);
@@ -1086,7 +1121,7 @@ export default class UEBattleView extends UEBase {
                 }
                 // GameDataCenter.audio.playEffect(atker.atkAudio);
             })
-            .to(delay / GameDataCenter.battle.realBattleSpeed, { x : atker.posX })//回到初始位置
+            .to(delay / GameDataCenter.battle.realBattleSpeed, { x: atker.posX })//回到初始位置
             .call(() => {
                 if (curLog.atker.fid != "1022") {
                     atker.playAni("stand", true);