2025-04-24 17:03:28 +08:00

1107 lines
27 KiB
JavaScript

import LocalUtil from "../../ts/core/LocalUtil";
import GameModel from "../../ts/core/GameModel";
import { ELivingType, EAttrTypeL1 } from "../../ts/core/EEnum";
import SKTimeUtil from "../../ts/gear_2.3.4/util/SKTimeUtil";
import SKUIUtil from "../../ts/gear_2.3.4/util/SKUIUtil";
import SKDataUtil from "../../ts/gear_2.3.4/util/SKDataUtil";
import SkillUtil from "../../ts/game/skill/core/SkillUtil";
import { ESkillType, ActionType } from "../../ts/game/skill/core/SkillBase";
import { EActType } from "../../ts/game/battle/Battle";
import Report from "../../ts/gear_2.3.4/net/Report";
import MsgAlert from "../../ts/game/msg/MsgAlert";
import BtlInfo from "../../ts/btlInfo/BtlInfo";
cc.Class({
extends: cc.Component,
properties: {
timeLabel: cc.Label,
RoundTime: cc.Node,
AutoBtn: [cc.Node],
lzBtn: cc.Node,
lzCd: 0,
longChangRound: 0,
lzIcon: [cc.SpriteFrame],
btmBtl: cc.Node,
upBtl: cc.Node,
petBtns: cc.Node,
btnLayer: cc.Node,
btlTimerLable: cc.Label,
roundLable: cc.Label,
round: {
get() {
return this.roundLable.string;
},
set(n) {
this.roundLable.string = n;
}
},
skillPanel: cc.Node,
autoSkillPanel: cc.Node,
autoPetSkillPanel: cc.Node,
petSkillPanel: cc.Node,
petSkillNode: cc.Node,
backSkillBtn: cc.Node,
autoIcons: [cc.Sprite],
autoLayer: cc.Node,
typeNodes: [cc.Sprite],
typeTxtAtlas: cc.SpriteAtlas,
skillNodes: [cc.Node],
autoSkillNodes: [cc.Node],
autoPetSkillNodes: [cc.Node],
catchBtn: cc.Node,
mpLabel: cc.Label,
petPanel: cc.Node,
petContent: cc.Node,
petItem: cc.Node,
itemPanel: cc.Node,
scaleSmallNode: cc.Node,
scaleBigNode: cc.Node,
scaleNum: 0.8,
_test: 0,
test: {
get() {
return this._test;
},
set(n) {
this._test = n;
n == 0 ? this.setPetSkill([]) : this.setPetSkill([1011]);
}
}
},
ctor() {
this.stageLogic = null;
this.MainUILogic = null;
this.lastSkill = 0;
this.petLastSkill = 0;
this.backType = 0; // 1 skill 2 btnlayer
this.updateTimer = 0;
this.battleTimer = 0;
this.petId = 0;
this.petItems = [];
this.petSkillNodes = [];
this.petAutoSkillNodes = [];
this.isAuto = null;
},
onLoad() {
this.updateTime();
this.updateTimer = SKTimeUtil.loop(this.updateTime.bind(this), 30000);
this.lzCd = 5;
this.dontShowMoreBtlInfo()
if (this.scaleNum == 0.8) {
this.scaleSmallNode.active = true
this.scaleBigNode.active = false
} else {
this.scaleSmallNode.active = false
this.scaleBigNode.active = true
}
},
start() {
this.initSkillPanel();
this.finishState();
if (this.MainUILogic == null) {
let MainUI = cc.find('Canvas/MainUI');
let MainUILogic = MainUI.getComponent('MainUI');
this.MainUILogic = MainUILogic;
}
if (this.isAuto == null) {
let isauto = LocalUtil.get('battle_isauto');
if (isauto == '' || isauto == null || isNaN(isauto)) {
isauto = 0;
}
this.isAuto = isauto != 0;
}
let skill = LocalUtil.get('battle_r_skill');
if (skill == null || skill == 0) {
skill = ESkillType.NormalAtkSkill;
}
this.setLastAction({
acttype: EActType.SKILL,
actid: skill,
});
let pskill = LocalUtil.get('battle_p_skill');
if (pskill == null || pskill == 0) {
pskill = ESkillType.NormalAtkSkill;
}
this.setPetLastAction({
acttype: EActType.SKILL,
actid: pskill,
});
},
updateTime() {
let time = new Date();
let h = time.getHours();
if (h < 10) {
h = '0' + h;
}
let m = time.getMinutes();
if (m < 10) {
m = '0' + m;
}
let t = `${h}:${m}`;
this.timeLabel.string = t;
},
onDestroy() {
this.updateTimer = SKTimeUtil.cancelLoop(this.updateTimer);
this.battleTimer = SKTimeUtil.cancelLoop(this.battleTimer);
this.autoTimer = SKTimeUtil.cancelDelay(this.autoTimer);
},
onEnable() {
this.onBattle();
this.round = 1;
this.hideBtlTimer();
this.finishState();
let SLDHMgr = require('../Activity/ShuiLuDaHui/sldh_mgr');
SLDHMgr.getInstance().hideShuiLuIcon();
for (let node of this.petSkillNodes) {
node.destroy();
}
this.petSkillNodes = [];
},
showBtlInfo() {
BtlInfo.Instance.openBtlInfoPanel();
},
dontShowMoreBtlInfo() {
var iconSee = cc.find("infolayer/btlInfoBtn/see", this.node)
var iconNoSee = cc.find("infolayer/btlInfoBtn/nosee", this.node)
iconSee.active = BtlInfo.Instance.showMoreInfo ? true : false
iconNoSee.active = BtlInfo.Instance.showMoreInfo ? false : true
},
setMp(mp, maxmp = null) {
if (!maxmp) {
let temp = GameModel.player;
if (temp) {
temp = temp.gameData;
if (temp) {
temp = temp.attr1;
if (temp) {
if (SKDataUtil.getLength(temp) >= EAttrTypeL1.MP_MAX) {
maxmp = temp[EAttrTypeL1.MP_MAX];
} else {
cc.warn(`$警告:無此屬性值[${EAttrTypeL1.MP_MAX}]`);
}
} else {
cc.warn(`$警告:無屬性列表`);
}
} else {
cc.warn(`$警告:無遊戲數據`);
}
} else {
cc.warn(`$警告:無玩家數據`);
}
}
this.mpLabel.string = '當前法力:' + mp + '/' + maxmp;
let roleindex = (GameModel.player.race - 1) * 2 + GameModel.player.sex - 1;
let curids = JSON.parse(JSON.stringify(SkillUtil.getRoleSkillIds(roleindex)));
this.isLong = curids.length == 7;
if (this.isLong)
curids.shift()
if (curids) {
for (let index = 0; index < curids.length; index++) {
let skillId = curids[index];
let skill = SkillUtil.getSkill(skillId);
if (!skill) {
cc.warn(`找不到技能:${skillId}`);
continue;
}
let skillnode = this.skillNodes[index];
if (SKUIUtil.isValid(skillnode)) {
let xhNode = cc.find('expLab', skillnode);
let xhLabel = xhNode.getComponent(cc.Label)
let xhNum = Math.ceil(skill.maxExp * (index % 2 == 0 ? 0.1 : 0.3));
if (xhLabel)
xhLabel.string = `法力:${xhNum}`
if (xhNum > mp) {
xhLabel.node.color = new cc.color(230, 54, 44)
} else {
xhLabel.node.color = new cc.color(90, 52, 52)
}
}
}
}
},
setPetId(petid) {
this.petId = petid;
},
onBattle() {
this.lzCd = 5;
this.lzBtn.getComponent(cc.Sprite).spriteFrame = this.lzIcon[0];
let stage = cc.find('Canvas/BattleLayer/BattleStage');
if (stage) {
this.stageLogic = stage.getComponent('BattleStage');
}
if (this.isAuto) {
this.setAutoTimer(3);
}
},
scaleSmallObj() {
var objPNode = cc.find("Canvas/BattleLayer/BattleStage/objLayer")
this.scaleNum = 0.6
if (objPNode) {
var childs = objPNode.children;
for (let i = 0; i < childs.length; i++) {
childs[i].scale = 0.6;
if(childs[i].name == "baby") continue
childs[i].getChildByName("nameRT").scale = 1.33;
}
}
this.scaleSmallNode.active = false;
this.scaleBigNode.active = true;
},
scaleBigObj() {
var objPNode = cc.find("Canvas/BattleLayer/BattleStage/objLayer")
this.scaleNum = 0.8
if (objPNode) {
var childs = objPNode.children;
for (let i = 0; i < childs.length; i++) {
childs[i].scale = 0.8;
if(childs[i].name == "baby") continue
childs[i].getChildByName("nameRT").scale = 1;
}
}
this.scaleSmallNode.active = true;
this.scaleBigNode.active = false;
},
normalState() {
this.isAuto = false;
if (this.canOperation == false) {
return;
}
this.backSkillBtn.active = false;
this.petBtns.active = false;
this.AutoBtn[0].active = true;
this.AutoBtn[1].active = false;
this.MainUILogic && (this.MainUILogic.btmOper.active = false);
this.MainUILogic && (this.MainUILogic.btmOper.x = 0);
this.skillPanel.active = false;
this.autoLayer.active = false;
this.scheduleOnce(() => {
this.runStartAction();
}, 0);
},
autoState() {
this.isAuto = true;
this.backSkillBtn.active = false;
this.AutoBtn[1].active = true;
this.AutoBtn[0].active = false;
this.btmBtl.active = false;
this.upBtl.active = false;
this.MainUILogic && (this.MainUILogic.btmOper.active = true);
this.MainUILogic && (this.MainUILogic.btmOper.x = -100);
this.skillPanel.active = false;
this.petBtns.active = false;
this.autoLayer.active = true;
},
petState() {
this.isAuto = false;
if (this.canOperation == false) {
return;
}
this.backSkillBtn.active = false;
this.petBtns.active = true;
},
setAutoTimer(time = 3) {
this.isAuto = true;
let self = this;
this.autoTimer = SKTimeUtil.delay(() => {
let acttype = self.lastAction.acttype;
let actid = self.lastAction.actid;
GameModel.send('c2s_btl_act', {
action: acttype,
actionid: actid,
targetid: 0,
onlyid: GameModel.player.onlyid,
});
acttype = self.petLastAction.acttype;
actid = self.petLastAction.actid;
GameModel.send('c2s_btl_act', {
action: acttype,
actionid: actid,
targetid: 0,
onlyid: self.petId,
});
}, time);
},
finishState() {
this.btnLayer.active = true;
this.lzBtn.active = false;
this.backSkillBtn.active = false;
this.AutoBtn[0].active = !this.isAuto;
this.AutoBtn[1].active = this.isAuto;
this.petBtns.active = false;
this.btmBtl.active = false;
this.upBtl.active = false;
this.MainUILogic && (this.MainUILogic.btmOper.active = true);
this.MainUILogic && (this.MainUILogic.btmOper.x = -100);
this.skillPanel.active = false;
this.autoLayer.active = this.isAuto;
this.canOperation = false;
this.hideSkillPanel();
this.hidePetSkillPanel();
this.closeAutoSkillPanel();
this.closePetAutoSkillPanel();
},
startRound() {
if (!SKUIUtil.isActive(this.node)) {
return;
}
//龍族變身部分start
if (this.lzCd > 0)
this.lzCd--;
if (this.longChangRound > 0)
this.longChangRound--;
if (this.isLong) {
this.lzBtn.children[0].getComponent(cc.Label).string = this.lzCd;
if (this.lzCd == 0) {
this.lzBtn.getComponent(cc.Sprite).spriteFrame = this.lzIcon[1];
this.lzBtn.children[0].getComponent(cc.Label).string = "";
}
}
//龍族變身部分end
this.reSetBtlTimer();
this.catchBtn.active = this.stageLogic.hasBB();
this.canOperation = true;
this.btnLayer.active = true;
if (this.isAuto) {
this.autoState();
this.setAutoTimer();
} else {
// let rolelogic = this.stageLogic.getRoleLogicByOnlyId(GameModel.player.onlyid);
// if (rolelogic == null || rolelogic.isdead) {
// let petlogic = this.stageLogic.getRoleLogicByOnlyId(this.petId);
// if (petlogic == null || petlogic.isdead) {
// this.finishState();
// return;
// }
// this.petOperation();
// return;
// }
this.normalState();
}
},
finishOper() {
this.finishState();
},
hideBtlTimer() {
this.btlTimerLable.node.active = false;
},
reSetBtlTimer() {
this.btlTimerNum = 30;
this.btlTimerLable.node.active = true;
this.btlTimerLable.string = this.btlTimerNum;
if (!SKTimeUtil.hasRun(this.battleTimer)) {
let self = this;
this.battleTimer = SKTimeUtil.loop(() => {
self.btlTimerNum--;
if (self.btlTimerNum <= 0) {
self.btlTimerNum = 0;
}
self.btlTimerLable.string = this.btlTimerNum;
}, 1000);
}
},
setRound(round) {
this.roundLable.string = round;
},
openPetPanel() {
this.petPanel.active = true;
this.petPanel.runAction(
cc.moveTo(0.2, 419, -80)
);
this.btnLayer.active = false;
},
closePetPanel() {
this.petPanel.x = 1064;
this.petPanel.active = false;
this.btnLayer.active = true;
},
openItemPanel(e, d) {
this.backType = 6;
this.itemPanel.active = true;
this.itemPanel.x = 1064;
this.itemPanel.y = -80;
let logic = this.itemPanel.getComponent('BattleUIItemPanel');
let operid = GameModel.player.onlyid;
if (d == 'pet') {
operid = this.petId;
}
logic.updateItemList(operid);
this.itemPanel.runAction(
cc.moveTo(0.2, 419, -80)
);
this.btnLayer.active = false;
},
closeItemPanel() {
this.itemPanel.x = 1064;
this.itemPanel.active = false;
this.btnLayer.active = true;
},
closeSkillPanel() {
this.skillPanel.x = 1064;
this.skillPanel.active = false;
this.btnLayer.active = true;
},
openSkillPanel() {
this.skillPanel.active = true;
this.skillPanel.runAction(
cc.moveTo(0.2, 419, -80)
);
this.btnLayer.active = false;
},
hideSkillPanel() {
this.skillPanel.active = false;
},
showSkillPanel() {
this.skillPanel.active = true;
this.skillPanel.x = 364;
},
skillBtnClicked(e, d) {
if (this.skillPanel.active) {
this.closeSkillPanel();
} else {
this.openSkillPanel();
}
},
initSkillPanel() {
let roleindex = (GameModel.player.race - 1) * 2 + GameModel.player.sex - 1;
let curids = JSON.parse(JSON.stringify(SkillUtil.getRoleSkillIds(roleindex)));
let curtypes = SkillUtil.getRoleESkillTypes(roleindex);
this.isLong = curids.length == 7;
var autoWordType = [
[
["單混", "群混", "單睡", "群睡", "單冰", "群冰"],
["單毒", "群毒", "單睡", "群睡", "單冰", "群冰"]
],
[
["單風", "群風", "單雷", "群雷", "單水", "群水"],
["單火", "群火", "單雷", "群雷", "單水", "群水"]
],
[
["單速", "群速", "單攻", "群攻", "單抽", "群抽"],
["單防", "群防", "單攻", "群攻", "單抽", "群抽"]
],
[
["單回", "群回", "單秒", "群秒", "單忘", "群忘"],
["單魅", "群魅", "單秒", "群秒", "單忘", "群忘"]
],
[
["單破", "群破", "單愈", "群愈", "單掃", "群掃"],
["單擊", "群擊", "單愈", "群愈", "單掃", "群掃"]
]
]
if (this.isLong)
curids.shift()
if (curids && curtypes) {
for (let index = 0; index < curtypes.length; index++) {
this.typeNodes[index].spriteFrame = this.typeTxtAtlas.getSpriteFrame(`skill_type_${curtypes[index]}`);
}
for (let index = 0; index < curids.length; index++) {
let skillId = curids[index];
let skill = SkillUtil.getSkill(skillId);
if (!skill) {
cc.warn(`找不到技能:${skillId}`);
continue;
}
let skillnode = this.skillNodes[index];
if (SKUIUtil.isValid(skillnode)) {
skillnode.skillid = skillId;
let skillframenode = cc.find('icon', skillnode);
let spr = skillframenode.getComponent(cc.Sprite);
spr.spriteFrame = SkillUtil.getSkillIcon(skill.icon);
} else {
cc.warn(`${skillId}無法放入`);
}
let autoNode = this.autoSkillNodes[index];
if (SKUIUtil.isValid(autoNode)) {
autoNode.skillid = skillId;
let skillFrame = cc.find('icon', autoNode);
if (skillFrame) {
let autoSprite = skillFrame.getComponent(cc.Sprite);
autoSprite.spriteFrame = SkillUtil.getSkillIcon(skill.icon);
}
let skillClass = cc.find('class', autoNode);
if (skillClass) {
let autoClass = skillClass.getComponent(cc.Label);
autoClass.string = autoWordType[GameModel.player.race - 1][GameModel.player.sex - 1][index];
}
} else {
cc.warn(`${skillId}無法放入`);
}
}
} else {
Report.report(`戰鬥界面:技能面板找不到定義${roleindex}}`);
}
let autonode = this.autoSkillNodes[6];
autonode.skillid = ESkillType.NormalAtkSkill;
autonode = this.autoSkillNodes[7];
autonode.skillid = ESkillType.NormalDefSkill;
let attr = GameModel.player.gameData.attr1;
let mpValue = SKDataUtil.valueForKey(attr, EAttrTypeL1.MP);
if (!mpValue) {
cc.warn(`$警告:戰鬥界面技能MP屬性無效!`);
return;
}
let maxMpValue = SKDataUtil.valueForKey(attr, EAttrTypeL1.MP_MAX);
if (!maxMpValue) {
cc.warn(`$警告:戰鬥界面技能MP_MAX屬性無效!`);
return;
}
this.setMp(mpValue, maxMpValue);
},
initPetPanel(pets) {
this.petContent.removeAllChildren();
if (typeof pets != 'object') {
return;
}
let n = 1;
let self = this;
for (let pet of pets) {
if (pet.type != ELivingType.PET) {
continue;
}
if (pet.ownonlyid != GameModel.player.onlyid) {
continue;
}
let petitem = cc.instantiate(this.petItem);
let logic = petitem.getComponent('BattleUIPetItem');
logic.setName(pet.name);
logic.setLevel(pet.relive, pet.level);
logic.setHeadIcon(pet.resid);
logic.isFight = pet.isfight == 1;
logic.isDead = false;
logic.selectCallback = () => {
self.closePetPanel();
GameModel.send('c2s_btl_act', {
action: EActType.SUMMON,
actionid: pet.onlyid,
targetid: 0,
onlyid: GameModel.player.onlyid,
});
};
petitem.onlyid = pet.onlyid;
petitem.active = true;
petitem.parent = this.petContent;
petitem.y = this.petItem.y - (this.petItem.height + 10) * n;
petitem.x = 0;
n++;
this.petItems.push(petitem);
}
this.petContent.height = (n + 1) * (this.petItem.height + 10);
},
changePkTitle(n) {
let pktitle = cc.find('pkTitle', this.node);
if (pktitle) {
if (n == '') {
pktitle.active = false;
} else {
pktitle.active = true;
cc.find('pkTitle/Label', this.node).getComponent(cc.Label).string = n;
}
}
},
hidePkTitle() {
let pktitle = cc.find('pkTitle', this.node);
if (pktitle.active) {
pktitle.active = false;
}
},
uiPetDead(onlyid) {
for (const petitem of this.petItems) {
if (petitem.onlyid == onlyid) {
let logic = petitem.getComponent('BattleUIPetItem');
logic.isDead = true;
}
}
},
// 設置召喚獸技能
setPetSkill(skilllist) {
if (!SKDataUtil.isArray(skilllist)) {
console.warn(`召喚獸[${this.petId}]技能列表無效!`);
}
SKUIUtil.destroyList(this.petSkillNodes);
SKUIUtil.destroyList(this.petAutoSkillNodes);
let autonode = this.autoPetSkillNodes[0];
autonode.skillid = ESkillType.NormalAtkSkill;
autonode = this.autoPetSkillNodes[1];
autonode.skillid = ESkillType.NormalDefSkill;
let n = 0;
for (let skillid of skilllist) {
if (skillid == 0) {
continue;
}
let skill = SkillUtil.getSkill(skillid);
if (skill == null) {
continue;
}
if (skill.action_type == ActionType.PASSIVE) {
continue;
}
let autoskillnode = cc.instantiate(autonode);
autoskillnode.skillid = skillid;
let skillframe = cc.find('skillicon', autoskillnode);
let autospr = skillframe.getComponent(cc.Sprite);
autospr.spriteFrame = SkillUtil.getSkillIcon(skill.icon);
autoskillnode.parent = autonode.parent;
autoskillnode.x = 80 + (Math.floor(n / 2) + 1) * 100;
autoskillnode.y = n % 2 == 0 ? -57 : 57;
this.petAutoSkillNodes.push(autoskillnode);
let psnode = cc.instantiate(this.petSkillNode);
psnode.active = true;
psnode.parent = this.petSkillNode.parent;
psnode.skillid = skillid;
psnode.y = -50 - 115 * n;
let pnamelabel = cc.find('RoleSkillItem1/nameLab', psnode);
let pnamel = pnamelabel.getComponent(cc.Label);
pnamel.string = skill.getName();
let sprnode = cc.find('RoleSkillItem1/icon', psnode);
let spr = sprnode.getComponent(cc.Sprite);
spr.spriteFrame = SkillUtil.getSkillIcon(skill.icon);
this.petSkillNodes.push(psnode);
n++;
}
this.autoPetSkillPanel.width = Math.ceil(n / 2) * 100 + 160;
this.petSkillNode.parent.height = 115 * n + 50;
let scroll = SKUIUtil.getParentScroll(this.petSkillNode);
SKUIUtil.scrollToTop(scroll);
},
onAutoBtnClick(e, d) {
this.setAutoTimer(3);
this.autoState();
LocalUtil.set('battle_isauto', 1);
},
onUnAutoBtnClick(e, d) {
SKTimeUtil.cancelDelay(this.autoTimer);
this.autoTimer = 0;
this.normalState();
this.AutoBtn[1].active = false;
this.AutoBtn[0].active = true;
this.autoLayer.active = false;
LocalUtil.set('battle_isauto', 0);
},
setLastSkill(skillid) {
this.lastSkill = skillid;
this.setPlayerAutoSkill(skillid);
},
setPetLastSkill(skillid) {
this.petLastSkill = skillid;
this.petLastAction.acttype = EActType.SKILL;
this.petLastAction.actid = skillid;
this.setPetAutoSkill(skillid);
},
setLastAction(act) {
this.lastAction = act;
if (act.acttype == EActType.SKILL) {
this.setLastSkill(act.actid);
}
},
setPetLastAction(act) {
this.petLastAction = act;
if (act.acttype == EActType.SKILL) {
this.setPetLastSkill(act.actid);
}
},
onSelectSkill(e, d) {
let node = e.target;
this.setLastAction({
acttype: EActType.SKILL,
actid: node.skillid,
});
this.stageLogic.selectSkill(GameModel.player.onlyid, node.skillid);
this.hideSkillPanel();
this.backType = 1;
this.backSkillBtn.active = true;
},
onSelectLzSkill(e, d) {
if (this.lzCd > 0) {
MsgAlert.addMsg("變身技能冷卻中");
return
}
GameModel.send('c2s_btl_act', {
action: EActType.SKILL,
actionid: 1045,
targetid: 0,
onlyid: GameModel.player.onlyid,
});
this.lzBtn.getComponent(cc.Sprite).spriteFrame = this.lzIcon[0];
this.lzBtn.active = false;
this.longChangRound = 2;
this.lzCd = 6;
},
onPetSelectSkill(e, d) {
let node = e.target;
this.setPetLastAction({
acttype: EActType.SKILL,
actid: node.skillid,
});
this.stageLogic.selectSkill(this.petId, node.skillid);
this.hidePetSkillPanel();
this.backType = 4;
this.backSkillBtn.active = true;
},
onBackSelectSkill(e, d) {
this.stageLogic.cleanAllRoleSelectFlag();
if (this.backType == 1) {
this.showSkillPanel();
}
if (this.backType == 2) {
this.btnLayer.active = true;
}
if (this.backType == 3) {
this.btnLayer.active = true;
}
if (this.backType == 4) {
this.showPetSkillPanel();
}
if (this.backType == 5) {
this.petOperation();
}
if (this.backType == 6) {
this.openItemPanel();
}
this.backSkillBtn.active = false;
},
onButtonClick(e, d) {
this.lzBtn.active = false;
if (d == 'atk') {
this.setLastAction({
acttype: EActType.SKILL,
actid: ESkillType.NormalAtkSkill,
});
this.stageLogic.selectSkill(GameModel.player.onlyid, ESkillType.NormalAtkSkill);
this.backType = 2;
this.btnLayer.active = false;
this.backSkillBtn.active = true;
} else if (d == 'last') {
this.stageLogic.selectSkill(GameModel.player.onlyid, this.lastSkill);
this.backType = 2;
this.btnLayer.active = false;
this.backSkillBtn.active = true;
} else if (d == 'run') {
// 逃跑
GameModel.send('c2s_btl_act', {
action: EActType.RUN_AWAY,
actionid: 0,
targetid: 0,
onlyid: GameModel.player.onlyid,
});
// this.stageLogic.showLianji(11);
} else if (d == 'def') {
// 防禦
this.setLastAction({
acttype: EActType.SKILL,
actid: ESkillType.NormalDefSkill,
});
GameModel.send('c2s_btl_act', {
action: EActType.SKILL,
actionid: ESkillType.NormalDefSkill,
targetid: 0,
onlyid: GameModel.player.onlyid,
});
} else if (d == 'catch') {
// 捕捉
// let camp = this.stageLogic.getObjCamp(GameModel.player.onlyid);
this.stageLogic.selectTarget(2, (targetid) => {
GameModel.send('c2s_btl_act', {
action: EActType.CATCH,
actionid: 0,
targetid: targetid,
onlyid: GameModel.player.onlyid,
});
});
this.backType = 2;
this.btnLayer.active = false;
this.backSkillBtn.active = true;
} else if (d == 'sum') {
// 召喚
this.openPetPanel();
} else if (d == 'sumback') {
// 召喚
GameModel.send('c2s_btl_act', {
action: EActType.SUMMON_BACK,
actionid: 0,
targetid: 0,
onlyid: GameModel.player.onlyid,
});
} else if (d == 'protect') {
// 保護
let camp = this.stageLogic.getObjCamp(GameModel.player.onlyid);
this.stageLogic.selectTarget(camp, (targetid) => {
GameModel.send('c2s_btl_act', {
action: EActType.PROTECT,
actionid: 0,
targetid: targetid,
onlyid: GameModel.player.onlyid,
});
});
this.backType = 2;
this.btnLayer.active = false;
this.backSkillBtn.active = true;
} else if (d == 'autoskill') {
// 自動戰鬥技能
this.showAutoSkillPanel();
} else if (d == 'autopetskill') {
// 自動戰鬥技能
this.showPetAutoSkillPanel();
}
},
runStartAction() {
this.upBtl.active = true;
this.btmBtl.active = true;
this.upBtl.stopAllActions();
this.btmBtl.stopAllActions();
this.petBtns.active = false;
let uppos = {
x: -52,
y: 113
};
let btmpos = {
x: -105,
y: 60
};
this.upBtl.y = -500;
this.btmBtl.x = 700;
this.upBtl.runAction(cc.moveTo(0.3, uppos).easing(cc.easeBackOut()));
this.btmBtl.runAction(cc.moveTo(0.3, btmpos).easing(cc.easeBackOut()));
this.scheduleOnce(() => {
if (this.isLong && this.longChangRound <= 0)
this.lzBtn.active = true;
}, 0.2);
},
setPlayerAutoSkill(skillid) {
this.lastSkill = skillid;
this.lastAction.acttype = EActType.SKILL;
this.lastAction.actid = skillid;
let skillinfo = SkillUtil.getSkill(skillid);
if (skillinfo) {
this.autoIcons[0].spriteFrame = SkillUtil.getSkillIcon(skillinfo.icon);
}
LocalUtil.set('battle_r_skill', skillid);
},
setPetAutoSkill(skillid) {
this.petLastSkill = skillid;
this.petLastAction.acttype = EActType.SKILL;
this.petLastAction.actid = skillid;
let skill = SkillUtil.getSkill(skillid);
if (skill) {
this.autoIcons[1].spriteFrame = SkillUtil.getSkillIcon(skill.icon);
}
LocalUtil.set('battle_p_skill', skillid);
},
ontestAtk(e, d) {
if (d == 1) {
// this.stageLogic.playEffectOnStage(1007, false);
// this.stageLogic.onTestAttack2();
} else {
// this.stageLogic.playEffectOnStage(1007, true);
// this.stageLogic.onTestAttack();
}
this.stageLogic.testObjEffect();
},
onSelectAutoSkill(e, d) {
let node = e.target;
this.setPlayerAutoSkill(node.skillid);
this.closeAutoSkillPanel();
},
showAutoSkillPanel() {
if (this.autoSkillPanel.x <= 600) {
this.closeAutoSkillPanel();
} else {
this.autoSkillPanel.x = 1052;
this.closePetAutoSkillPanel();
this.autoSkillPanel.runAction(cc.moveTo(0.2, {
x: 256,
y: -128
}));
}
},
closeAutoSkillPanel() {
this.autoSkillPanel.x = 1052;
},
onSelectPetAutoSkill(e, d) {
let node = e.target;
this.setPetAutoSkill(node.skillid);
this.closePetAutoSkillPanel();
},
showPetAutoSkillPanel() {
if (this.autoPetSkillPanel.x <= 600) {
this.closePetAutoSkillPanel();
} else {
this.autoPetSkillPanel.x = 1000;
this.closeAutoSkillPanel();
let w = this.autoPetSkillPanel.width;
let x = 360 - (w - 160);
this.autoPetSkillPanel.runAction(cc.moveTo(0.2, {
x: x,
y: -128
}));
}
},
closePetAutoSkillPanel() {
this.autoPetSkillPanel.x = 1000;
},
petOperation() {
if (this.petId == 0) {
this.finishOper();
return;
}
this.backType = 3;
this.btmBtl.active = false;
this.upBtl.active = false;
this.MainUILogic && (this.MainUILogic.btmOper.active = false);
this.MainUILogic && (this.MainUILogic.btmOper.x = 0);
this.backSkillBtn.active = false;
this.petBtns.active = true;
},
closePetSkillPanel() {
this.petSkillPanel.x = 1164;
this.petSkillPanel.active = false;
this.petBtns.active = true;
},
openPetSkillPanel() {
this.petSkillPanel.active = true;
this.petSkillPanel.runAction(
cc.moveTo(0.2, 420, -80)
);
this.petBtns.active = false;
},
hidePetSkillPanel() {
this.petSkillPanel.active = false;
},
showPetSkillPanel() {
this.petSkillPanel.active = true;
this.petSkillPanel.x = 420;
},
onPetBtnClick(e, d) {
if (d == 'atk') {
this.setPetLastAction({
acttype: EActType.SKILL,
actid: ESkillType.NormalAtkSkill,
});
this.stageLogic.selectSkill(this.petId, ESkillType.NormalAtkSkill);
} else if (d == 'def') {
this.setPetLastAction({
acttype: EActType.SKILL,
actid: ESkillType.NormalDefSkill,
});
GameModel.send('c2s_btl_act', {
action: EActType.SKILL,
actionid: ESkillType.NormalDefSkill,
targetid: 0,
onlyid: this.petId,
});
} else if (d == 'showskill') {
this.openPetSkillPanel();
} else if (d == 'closeskill') {
this.closePetSkillPanel();
} else if (d == 'protect') {
// 保護
let camp = this.stageLogic.getObjCamp(this.petId);
this.stageLogic.selectTarget(camp, (targetid) => {
GameModel.send('c2s_btl_act', {
action: EActType.PROTECT,
actionid: 0,
targetid: targetid,
onlyid: this.petId,
});
});
this.backType = 5;
this.petBtns.active = false;
this.backSkillBtn.active = true;
}
},
});