|
@@ -4,6 +4,7 @@ import GameDataCenter from "../../data/GameDataCenter";
|
|
import UEBase from "../../frameWork/compment/UEBase";
|
|
import UEBase from "../../frameWork/compment/UEBase";
|
|
import { eg } from "../../frameWork/eg";
|
|
import { eg } from "../../frameWork/eg";
|
|
import AssetMgr from "../../utils/AssetMgr";
|
|
import AssetMgr from "../../utils/AssetMgr";
|
|
|
|
+import { BattleGridConstant } from "./BattleGridConstant";
|
|
import UEBattleRole from "./UEBattleRole";
|
|
import UEBattleRole from "./UEBattleRole";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
const { ccclass, property } = cc._decorator;
|
|
@@ -14,10 +15,14 @@ export default class UEBattleView extends UEBase {
|
|
rolePrefab: cc.Prefab = null;
|
|
rolePrefab: cc.Prefab = null;
|
|
@property(cc.Prefab)
|
|
@property(cc.Prefab)
|
|
subHpPrefab: cc.Prefab = null;
|
|
subHpPrefab: cc.Prefab = null;
|
|
|
|
+ @property(cc.Prefab)
|
|
|
|
+ cellPrefab: cc.Prefab = null!;
|
|
@property(cc.Node)
|
|
@property(cc.Node)
|
|
roleContent: cc.Node = null;
|
|
roleContent: cc.Node = null;
|
|
- @property(cc.Node)
|
|
|
|
|
|
+ @property(cc.Node)
|
|
hpLayer: cc.Node = null
|
|
hpLayer: cc.Node = null
|
|
|
|
+ @property(cc.Node)
|
|
|
|
+ cellLayer: cc.Node = null;
|
|
|
|
|
|
fightStart: ActFightStart;
|
|
fightStart: ActFightStart;
|
|
fightLogList: fightLogList;
|
|
fightLogList: fightLogList;
|
|
@@ -32,11 +37,11 @@ export default class UEBattleView extends UEBase {
|
|
TxtRound: cc.Label;
|
|
TxtRound: cc.Label;
|
|
|
|
|
|
static getInstance() {
|
|
static getInstance() {
|
|
- return this.s_ins
|
|
|
|
- }
|
|
|
|
|
|
+ return this.s_ins
|
|
|
|
+ }
|
|
|
|
|
|
Init() {
|
|
Init() {
|
|
- UEBattleView.s_ins = this;
|
|
|
|
|
|
+ UEBattleView.s_ins = this;
|
|
this.fightStart = {
|
|
this.fightStart = {
|
|
"from": "pve",
|
|
"from": "pve",
|
|
"seed": 29576,
|
|
"seed": 29576,
|
|
@@ -963,6 +968,7 @@ export default class UEBattleView extends UEBase {
|
|
}
|
|
}
|
|
this.TxtRound = this.node.getChildByName("ImgDi").getChildByName("TxtRound").getComponent(cc.Label);
|
|
this.TxtRound = this.node.getChildByName("ImgDi").getChildByName("TxtRound").getComponent(cc.Label);
|
|
this.initEvent();
|
|
this.initEvent();
|
|
|
|
+ this.LoadCell();
|
|
}
|
|
}
|
|
initEvent(): void {
|
|
initEvent(): void {
|
|
|
|
|
|
@@ -971,14 +977,43 @@ export default class UEBattleView extends UEBase {
|
|
onDisable(): void {
|
|
onDisable(): void {
|
|
this.node.destroy();
|
|
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() {
|
|
async onStartFight() {
|
|
eg.poolManager.GetPool("subHPPool").clear();
|
|
eg.poolManager.GetPool("subHPPool").clear();
|
|
@@ -990,17 +1025,17 @@ export default class UEBattleView extends UEBase {
|
|
async produceRole() {
|
|
async produceRole() {
|
|
let role1 = this.fightStart.teams[BattleTeamId.role1]
|
|
let role1 = this.fightStart.teams[BattleTeamId.role1]
|
|
let role2 = this.fightStart.teams[BattleTeamId.role2]
|
|
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 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;
|
|
roleNode1.scaleX = 1;
|
|
GameDataCenter.battle.addRole(role1?.fid, roleNode1.getComponent(UEBattleRole));
|
|
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;
|
|
roleNode2.scaleX = -1;
|
|
GameDataCenter.battle.addRole(role2?.fid, roleNode2.getComponent(UEBattleRole));
|
|
GameDataCenter.battle.addRole(role2?.fid, roleNode2.getComponent(UEBattleRole));
|
|
|
|
|
|
@@ -1051,12 +1086,12 @@ export default class UEBattleView extends UEBase {
|
|
playAtk(curLog: fightLogOne) {
|
|
playAtk(curLog: fightLogOne) {
|
|
let atker = GameDataCenter.battle.battleRoleList[curLog.atker.fid];
|
|
let atker = GameDataCenter.battle.battleRoleList[curLog.atker.fid];
|
|
let target0 = curLog.target.length > 0 ? GameDataCenter.battle.battleRoleList[curLog.target[0].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 delay = 0.5;
|
|
let hitX = 150; //近战偏移量
|
|
let hitX = 150; //近战偏移量
|
|
cc.tween(atker.node)
|
|
cc.tween(atker.node)
|
|
.delay(0.15 / GameDataCenter.battle.realBattleSpeed)
|
|
.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(() => {
|
|
.call(() => {
|
|
if (curLog.atker.fid == "1022") {
|
|
if (curLog.atker.fid == "1022") {
|
|
atker.playAni("atk", false);
|
|
atker.playAni("atk", false);
|
|
@@ -1086,7 +1121,7 @@ export default class UEBattleView extends UEBase {
|
|
}
|
|
}
|
|
// GameDataCenter.audio.playEffect(atker.atkAudio);
|
|
// GameDataCenter.audio.playEffect(atker.atkAudio);
|
|
})
|
|
})
|
|
- .to(delay / GameDataCenter.battle.realBattleSpeed, { x : atker.posX })//回到初始位置
|
|
|
|
|
|
+ .to(delay / GameDataCenter.battle.realBattleSpeed, { x: atker.posX })//回到初始位置
|
|
.call(() => {
|
|
.call(() => {
|
|
if (curLog.atker.fid != "1022") {
|
|
if (curLog.atker.fid != "1022") {
|
|
atker.playAni("stand", true);
|
|
atker.playAni("stand", true);
|