//#region 文件引入
import { _decorator, Button, Component, Label, Node, sp, Animation, RichText, ProgressBar, Prefab, instantiate, Color, tween, UIOpacity, Vec3, v2, v3, Tween, SpriteFrame, Widget, Sprite } from "cc";
import BaseUIForm from "../../Mgr_UI/BaseUIForm";
import { MainBtnPoxy } from "./MainBtnPoxy";
import UIMgr from "../../Mgr_UI/UIMgr";
import { EUIForms } from "../../const/UIFormCnf";
import MathUtils from "../../ExUtils/MathUtils";
import RoleDataMgr from "../../Mgr_LocalData/RoleDataMgr";
import SceneDataMgr from "../../Mgr_LocalData/SceneDataMgr";
import { BOUNTY_PARAMS, EBundleName, EGongFaType, ESKINANIMMAPPING, ESKINMAPPING, EVideoType, FIGHTING_TYPE, GameTotalType, PropType, TRIGGER_TYPE, TXVideoMapping } from "../../const/GameEnum";
import { EGlobalEvent } from "../../MesEvent/EGlobalEvent";
import MesMgr from "../../MesEvent/MesMgr";
import SoulDataMgr from "../../Mgr_LocalData/SoulDataMgr";
import { UINodeEffect } from "../../CComEx/UINodeEffect";
import { TaskDataProxy } from "../../Mgr_LocalData/DataTypeProxy/TaskDataProxy";
import Damage_Proxy from "./Damage_Proxy";
import EnemyCoin_Proxy from "./EnemyCoin_Proxy";
import { GameDataProxy } from "../../Mgr_LocalData/DataTypeProxy/GameDataProxy";
import Language from "../../Language";
import { Utils } from "../../ExUtils/Utils";
import { LocalDataMgr } from "../../Mgr_LocalData/LocalDataMgr";
import { IData } from "../../const/GameInterface";
import PlatformManager from "../../Platform/PlatformManager";
import { ESounds } from "../../MesEvent/ESounds";
import { Global } from "../../Global";
import GuideDataMgr from "../../Mgr_Guide/GuideDataMgr";
import { GuideConfigType } from "../../Mgr_Guide/GuideConfig";
import AudioUtils from "../../Mgr_Audio/AudioUtils";
import { RedNotice } from "../../Mgr_RedPoint/RedNotice";
import { MainRedEnum, HomeUIRedEnum } from "../../Mgr_RedPoint/RedEnumType";
import StringUtils from "../../ExUtils/StringUtils";
import { executionAsyncId } from "async_hooks";
import { MainConfig } from "db://assets/Launch/_MainConfig";
import EnemyTJCoin_Proxy from "./EnemyTJCoin_Proxy";
import { COLOR_PARAMS, MUTATE_PARAMS } from "../../const/GGameData";
import { TXSDKMgr } from "../../Mgr_Ge/TXSDKMgr";
import CySDK from "../../Mgr_Ge/CySDK";
import GDUtils from "../../ExCUtils/GDUtils";
import { ISuitEffect } from "../../Mgr_CSV/CsvEnum";
//#endregion 文件引入
enum PlayerState{
NUll,
idle,
Attack,
Entry, // 出生
Hurt, // 受击
Dead, // 死亡
Show, // 出生show
}
enum PlayerAnimation{
/**刀 */
knife = "d/22011",
/**棍 */
stick = "cq/23011",
/**剑 */
sword = "j/21011",
}
const { ccclass, property, menu } = _decorator;
@ccclass("MainUI_Proxy")
export default class MainUI_Proxy extends BaseUIForm {
//#region 节点自动生成
@property(Node)
n_Scene: Node = null;
@property(Sprite)
spr_levelbg: Sprite = null;
@property(Sprite)
spr_mutatebg: Sprite = null;
@property(Node)
n_effect: Node = null;
@property(Node)
n_spines: Node = null;
@property(sp.Skeleton)
spi_enemy: sp.Skeleton = null;
@property(sp.Skeleton)
spi_hit: sp.Skeleton = null;
@property(Node)
n_minfo: Node = null;
@property(ProgressBar)
pro_EnemyHp: ProgressBar = null;
@property(Sprite)
spr_mHeadIcon: Sprite = null;
@property(Label)
lab_enemyHp: Label = null;
@property(Label)
lab_enemyName: Label = null;
@property(sp.Skeleton)
spi_hero: sp.Skeleton = null;
@property(sp.Skeleton)
spi_smoke1: sp.Skeleton = null;
@property(sp.Skeleton)
spi_smoke2: sp.Skeleton = null;
@property(Node)
n_DamagePoint: Node = null;
@property(Node)
n_binfo: Node = null;
@property(ProgressBar)
pro_BossHp: ProgressBar = null;
@property(Sprite)
spr_bHeadIcon: Sprite = null;
@property(Label)
lab_bossName: Label = null;
@property(Label)
lab_bossHp: Label = null;
@property(Label)
lab_bossCD: Label = null;
@property(sp.Skeleton)
spi_victory: sp.Skeleton = null;
@property(Node)
n_AddTJPoint: Node = null;
@property(Node)
n_dialogue: Node = null;
@property(Label)
lab_dialogue: Label = null;
@property(Button)
btn_ClickTounch: Button = null;
@property(Node)
n_LevelInfo: Node = null;
@property(Label)
lab_levelTitle: Label = null;
@property(Label)
lab_LevelDes: Label = null;
@property(Node)
n_targetNode: Node = null;
@property(Label)
lab_LevelTarget: Label = null;
@property(Label)
lab_LevelEnemyCoin: Label = null;
@property(Button)
btn_Setting: Button = null;
@property(Button)
btn_Notice: Button = null;
@property(Node)
n_left_layout: Node = null;
@property(Button)
btn_AddShortcut: Button = null;
@property(Button)
btn_SideBar: Button = null;
@property(Button)
btn_singin: Button = null;
@property(Button)
btn_rank: Button = null;
@property(Button)
btn_outline: Button = null;
@property(Node)
n_right_layout: Node = null;
@property(Button)
btn_Share: Button = null;
@property(Button)
btn_JingLuo: Button = null;
@property(Button)
btn_XuanWu: Button = null;
@property(Node)
n_xwd_unlock: Node = null;
@property(Button)
btn_PassTip: Button = null;
@property(Button)
btn_Redeem: Button = null;
@property(Button)
btn_FeedSubscribe: Button = null;
@property(Node)
n_bottom: Node = null;
@property(Button)
btn_Task: Button = null;
@property(Sprite)
spr_taskIcon: Sprite = null;
@property(Label)
lab_taskReward: Label = null;
@property(Label)
lab_taskTitle: Label = null;
@property(Label)
lab_taskProgress: Label = null;
@property(Node)
n_patkinfo: Node = null;
@property(Sprite)
spr_wpicon: Sprite = null;
@property(Label)
lab_gongfaName: Label = null;
@property(Label)
lab_attackSpeed: Label = null;
@property(Label)
lab_crit: Label = null;
@property(Button)
btn_Auto: Button = null;
@property(Node)
n_auto_hide: Node = null;
@property(Node)
n_auto_show: Node = null;
@property(Node)
n_boss_AdCrit: Node = null;
@property(Node)
n_boss_Ad: Node = null;
@property(Node)
n_autoAdTips: Node = null;
@property(Node)
n_auto_Des: Node = null;
@property(Node)
n_autoLevel_unlock: Node = null;
@property(Button)
btn_Skill: Button = null;
@property(Sprite)
spr_skillbg: Sprite = null;
@property(Sprite)
spr_skillicon: Sprite = null;
@property(Label)
lab_skillcd: Label = null;
@property(Label)
lab_skillname: Label = null;
@property(Node)
n_BossBtns: Node = null;
@property(Button)
btn_TrialBoos: Button = null;
@property(Sprite)
spr_trialbossicon: Sprite = null;
@property(Label)
lab_trialbossname: Label = null;
@property(Button)
btn_Boos: Button = null;
@property(Sprite)
spr_bossIcon: Sprite = null;
@property(Label)
lab_bossTitle: Label = null;
@property(Label)
lab_bosstf: Label = null;
@property(Button)
btn_Retreat: Button = null;
@property(Node)
n_PassNotice: Node = null;
@property(RichText)
ric_suitinfo: RichText = null;
@property(Button)
btn_Mutate: Button = null;
@property(Sprite)
spr_mutateIcon: Sprite = null;
@property(RichText)
ric_mutateTitle: RichText = null;
@property(RichText)
ric_mutateaddpre: RichText = null;
@property(Node)
n_addCoinPoint: Node = null;
@property(Node)
n_addCoinPoint2: Node = null;
//#endregion 节点自动生成
@property(Prefab)
mDamageText:Prefab = null;
@property(Prefab)
mEnemyCoin:Prefab = null;
@property(Prefab)
mEnemyTJCoin:Prefab = null;
@property({type:[SpriteFrame]})
protected mWPIcon: SpriteFrame[] = [];
@property({type:[sp.Skeleton]})
protected spiBossFinish: sp.Skeleton[] = [];
private animationIdx:number = 1;
private hitIdx:number =1;
private isshowBossCD:boolean = false;
private pro_showHp: ProgressBar = null;
private lab_showName:Label = null;
private lab_showHp: Label = null;
private spr_showIcon: Sprite = null;
private isshowPlayerAttInfo:boolean = false;
private lastAttackTime: number = 0; // 记录上次攻击的时间戳
private pInfoOpacity: UIOpacity = null;
private tempN_Pos: Vec3 = new Vec3();
private tempS_Pos: Vec3 = new Vec3();
private tempB_Pos: Vec3 = new Vec3();
private n_endPosY = 0;
private s_endPosY = 0;
private b_endPosY = 0;
private cur_skin: string = "";
private eOpacity:UIOpacity = null;
private mBottomWidget:Widget = null;
// boss挑战按钮是否解锁
private mBossUnlock:boolean = false;
private trialskillani = ["sword_skill","knife_skill","stick_skill"]
private trialendsounds = [ESounds.So_boss_sword_skill_word,ESounds.So_boss_knife_skill_sword,ESounds.So_boss_stick_skill_boss]
private trialskillsounds = [ESounds.So_boss_sword_skill_effect,ESounds.So_boss_knife_skill_effect,ESounds.So_boss_stick_skill_effect]
// 当前已激活技能的套装
// private skillSuitCfg:ISuitEffect = null;
onButtonClick(button: Button) {
switch (button) {
case this.btn_ClickTounch:
!RoleDataMgr.Ins.skillplaying && SceneDataMgr.Ins.onAttackOnce(TRIGGER_TYPE.MANUALLY);
break;
case this.btn_Setting:
UIMgr.Ins.ShowUI(EUIForms.SettingUI)
break;
case this.btn_Notice:
UIMgr.Ins.ShowUI(EUIForms.PopNoticeUI)
break;
case this.btn_Boos:
if(this.mBossUnlock){
UIMgr.Ins.ShowUI(EUIForms.WantedNoticeUI);
}else{
UIMgr.Ins.ShowTipsUI("完成第一个任务后解锁");
}
break;
case this.btn_TrialBoos:
MainConfig.isTrialOpen && UIMgr.Ins.ShowUI(EUIForms.FinalTrialUI);
break;
case this.btn_Mutate:
this.mDataMgr.Mutate.unlock && UIMgr.Ins.ShowUI(EUIForms.WantedNoticeUI, {param:{fighttype:FIGHTING_TYPE.MUTATEBOSS}});
break;
case this.btn_outline:
UIMgr.Ins.ShowUI(EUIForms.OfflineRewardUI)
break;
case this.btn_rank:
UIMgr.Ins.ShowUI(EUIForms.RankUI)
break;
case this.btn_Redeem:
UIMgr.Ins.ShowUI(EUIForms.RedemptionUI)
break;
case this.btn_singin:
UIMgr.Ins.ShowUI(EUIForms.SigninUI)
break;
case this.btn_Auto:
if(!SoulDataMgr.Ins.unlock){
SceneDataMgr.Ins.onUnlockSoul(true);
}else{
UIMgr.Ins.ShowUI(EUIForms.ImperialWeaponsUI)
}
break;
case this.btn_Task:
UIMgr.Ins.ShowUI(EUIForms.TaskInfoUI)
break;
case this.btn_Retreat:
// 撤退,弹出框
const fighttype = this.mDataMgr.Scene.fighting_type;
let desc = "";
switch(fighttype){
case FIGHTING_TYPE.PVE:
case FIGHTING_TYPE.MUTATEBOSS:
desc = "撤退将直接失败,确定吗?";
break;
case FIGHTING_TYPE.TRIALBOSS:
desc = "撤退仍会记录当前的挑战成果,确定吗?";
}
// const desc = this.mDataMgr.Scene.fighting_type === FIGHTING_TYPE.PVE?"撤退将直接失败,确定吗?":"撤退仍会记录当前的挑战成果,确定吗?";
UIMgr.Ins.ShowUI(EUIForms.MsgBoxUI,{param:{title:"撤退",content:desc, okcallback:()=>{
if(fighttype === FIGHTING_TYPE.PVE || fighttype === FIGHTING_TYPE.MUTATEBOSS){
// 弹出失败界面
UIMgr.Ins.ShowUI(EUIForms.DefeatUI);
// 挑战中途退出
if(fighttype === FIGHTING_TYPE.PVE){
const currreallv = this.mDataMgr.Scene.getRealLevel();
TXSDKMgr.ins.onLevel_Exit(
{
ad_cnt: this.mDataMgr.Scene.level.ad_cnt,
level_id: currreallv,
duration: this.mDataMgr.Scene.level.duration,
coin_amount: LocalDataMgr.Token.getTokenCount(PropType.eGold)
}
);
CySDK.onLevelFail("normal", `真实关卡:${currreallv}`, this.mDataMgr.Scene.level.id);
}
}else{
this.mDataMgr.Scene.fightBossFail();
}
}}})
break;
case this.btn_SideBar:
UIMgr.Ins.ShowUI(EUIForms.PopSideBarUI);
break;
case this.btn_AddShortcut:
UIMgr.Ins.ShowUI(EUIForms.AddShortCutUI);
break;
case this.btn_XuanWu:
if(SceneDataMgr.Ins.getRealLevel() < 21){
UIMgr.Ins.ShowTipsUI("通关21关后解锁");
}else{
UIMgr.Ins.ShowUI(EUIForms.TreasureUI);
}
break;
case this.btn_PassTip:
UIMgr.Ins.ShowUI(EUIForms.PopPassUI);
break;
case this.btn_Share:
UIMgr.Ins.ShowUI(EUIForms.ShareUI);
break;
case this.btn_JingLuo:
UIMgr.Ins.ShowUI(EUIForms.MeridianUI);
break;
case this.btn_FeedSubscribe:
PlatformManager.PlatformInstance.requestFeedSubscribe((isOK:boolean)=>{
MainConfig.isFeedSubscribe = isOK;
CNodeUtils.setActive(this.btn_FeedSubscribe, Global.CsvMgr.openSubscribe() && !MainConfig.isFeedSubscribe);
});
break;
case this.btn_Skill:
if(RoleDataMgr.Ins.skillSuitCfg){
if(RoleDataMgr.Ins.getCurrSuitSkillCD() > 0){
UIMgr.Ins.ShowTipsUI("技能冷却中!");
}else{
this.playSuitSkill();
}
}
break;
default:
break;
}
}
// 套装技能播放
playSuitSkill(){
const skillcfg = RoleDataMgr.Ins.skillSuitCfg;
const skillname = GDUtils.GetHEXBySuitTypeForStr(skillcfg.skill_name, skillcfg.suit_type);
UIMgr.Ins.ShowTipsUI(`释放技能:${skillname}`);
RoleDataMgr.Ins.skillplaying = true;
RoleDataMgr.Ins.suitSkillCD[skillcfg.suit_type] = skillcfg.prop2;
ConsoleEx.Warn(`开始播放技能id:${skillcfg.id},name:${skillcfg.skill_name},cd:${skillcfg.prop2}`);
// 播放主角技能动画,到关键帧再触发攻击计算
this.isPlayerAttacking = true;
this.playerAttackQueue.length = 0; // 清空攻击动画队列中剩余的旧请求
this.spi_hero.timeScale = 1;
this.spi_hero.setSkin("default");
const trackEntry = this.spi_hero.setAnimation(0, skillcfg.skill_sp, false);
Global.Audio.playEffect({ bundle: "Sound", url: skillcfg.skill_audio1 });
this.playerAttackEndTime = Date.now() + trackEntry.animation.duration * 1000;
this.spi_hero.setTrackEventListener(trackEntry, (track, event:sp.spine.Event) => {
switch (event.data.name) {
case 'hit_1':
RoleDataMgr.Ins.skillplaying && this.enemy_play_animation(false, false, 1);
Global.Vibrate.startVibrate();
Global.Audio.playEffect({ bundle: "Sound", url: skillcfg.skill_audio2 });
break;
case 'hit_2':
if(RoleDataMgr.Ins.skillplaying){
SceneDataMgr.Ins.onAttack(TRIGGER_TYPE.SKILL, 1, 2);
Global.Vibrate.startVibrate();
// RoleDataMgr.Ins.skillplaying = false;
}
break;
case 'end':
if(RoleDataMgr.Ins.skillplaying){
const skin = RoleDataMgr.Ins.weapon? ESKINMAPPING[RoleDataMgr.Ins.attack_type] + RoleDataMgr.Ins.weapon.id : PlayerAnimation.sword;
this.spi_hero.setSkin(skin);
this.playHeroAnimation(PlayerState.idle);
RoleDataMgr.Ins.skillplaying = false;
this.n_spines.setParent(this.n_effect);
}
break;
}
});
this.scheduleOnce(()=>{
// 保险处理
if(RoleDataMgr.Ins.skillplaying){
ConsoleEx.Warn("技能播放异常,补救处理");
const skin = RoleDataMgr.Ins.weapon? ESKINMAPPING[RoleDataMgr.Ins.attack_type] + RoleDataMgr.Ins.weapon.id : PlayerAnimation.sword;
this.spi_hero.setSkin(skin);
RoleDataMgr.Ins.skillplaying = false;
this.n_spines.setParent(this.n_effect);
}
}, trackEntry.animation.duration + 0.05);
MesMgr.event(EGlobalEvent.PLAY_SUIT_SKILL, this.n_spines, trackEntry.animation.duration);
}
addEvent(): void {
this.spi_hero.setStartListener(this.AnimationCallBack.bind(this));
this.spi_enemy.setStartListener(this.enemyAniCallBack.bind(this));
MesMgr.on(EGlobalEvent.REFRESH_SPEED, this.refreshAttackSpeed, this)
MesMgr.on(EGlobalEvent.ATTACK_ONCE, this.onATTACK_ONCE, this)
MesMgr.on(EGlobalEvent.REFRESH_XIAOGUAI, this.refreshEnemyTaskInfo, this)
MesMgr.on(EGlobalEvent.ROLE_PLAY_ANIMATION,this.role_play_animation,this)
MesMgr.on(EGlobalEvent.ROLE_ENEMY_HIT_ANI,this.enemy_play_animation,this)
MesMgr.on(EGlobalEvent.ENEMY_DEATH_COIN,this.enemy_death_coin,this);
MesMgr.on(EGlobalEvent.ENEMY_TJ_COIN,this.enemy_tj_coin,this);
MesMgr.on(EGlobalEvent.REFRESH_FIGHT,this.refreshShowNode,this);
MesMgr.on(EGlobalEvent.UP_GONGFA,this.refreshCrit,this);
MesMgr.on(EGlobalEvent.UNLOCK_SOUL,this.refreshAutoAttack,this);
MesMgr.on(EGlobalEvent.REFRESH_TASK,this.refreshTaskInfo,this);
MesMgr.on(EGlobalEvent.EXCHANGE_WEAPON,this.refreshhHero,this);
MesMgr.on(EGlobalEvent.BOSS_SUCCESS,this.onLevelVictory,this)
MesMgr.on(EGlobalEvent.SIGNIN_DONE,this.refreshSignInInfo,this)
MesMgr.on(EGlobalEvent.OUTLINE_UPDATE,this.refreshOutLineInfo,this);
MesMgr.on(EGlobalEvent.CHANGE_SOUL, this.refreshSoulState, this);
MesMgr.on(EGlobalEvent.FINISH_TASK,this.refreshAutoAttack,this);
MesMgr.on(EGlobalEvent.RESTART_NEWGAME, this.start, this);
MesMgr.on(EGlobalEvent.ENTER_NEW_SCENE, this.refreshSceneBg, this);
MesMgr.on(EGlobalEvent.CHANGE_FIGHTING_TYPE,this.refreshFightingType,this);
MesMgr.on(EGlobalEvent.BOSS_FAIL,this.fightBossFinish,this);
MesMgr.on(EGlobalEvent.ADD_SHORTCUR,this.addShortCut,this);
MesMgr.on(EGlobalEvent.E_FEED_ENTER_GAME,this.feedEnterGame,this);
MesMgr.on(EGlobalEvent.REFRESH_MUTATE,this.refreshMutateInfo,this);
MesMgr.on(EGlobalEvent.WATCH_AD_SUCCESS,this.refreshMutateRewardEx,this);
// MesMgr.on(EGlobalEvent.REFRESH_SUIT,this.refreshSuitInfo,this);
}
protected start(): void {
this.unscheduleAllCallbacks();
this.mBottomWidget = this.n_bottom.getComponent(Widget);
// this.pInfoOpacity = CNodeUtils.getOrAddComponent(this.n_patkinfo, UIOpacity);
this.eOpacity = this.spi_enemy.getComponent(UIOpacity);
this.tempN_Pos.x = this.n_LevelInfo.position.x;
this.n_endPosY = this.tempN_Pos.y = this.n_LevelInfo.position.y;
this.tempS_Pos.x = this.n_Scene.position.x;
this.s_endPosY = this.tempS_Pos.y = this.n_Scene.position.y;
this.tempB_Pos.x = this.btn_Auto.node.position.x;
this.b_endPosY = this.tempB_Pos.y = this.btn_Auto.node.position.y;
this.refreshSceneBg();
this.refreshAutoAttack();
this.refreshhHero();
this.refreshAttackSpeed();
this.refreshCrit();
this.playHeroAnimation(PlayerState.idle,1);
SceneDataMgr.Ins.start();
this.refreshShowNode();
this.refreshTaskInfo();
this.refreshSignInInfo();
this.refreshOutLineInfo();
this.refreshRedInfo();
this.refreshSuitInfo();
// this.feedEnterGame();
this.schedule(this.scheduleUpdate, 0.5);
GuideDataMgr.ins.setExecuteGuide(GuideConfigType.第一次查看任务);
}
refreshSceneBg(){
const Level = this.mDataMgr.Scene.level;
let data:IData = {
type: GameTotalType.SCENEBG,
id: Level.config.id,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_levelbg,data,0,()=>{
// this.spr_levelbg["MY_ADD"] = 0;
MesMgr.event(EGlobalEvent.MAINUI_READY);
});
}
// 刷新红点
refreshRedInfo(){
/**通知 这个类的红点逻辑 */
RedNotice.emit(EGlobalEvent.E_RED_UPDATE,[MainRedEnum.游历]);
// RedNotice.emit(EGlobalEvent.E_RED_UPDATE,[MainRedEnum.游历, HomeUIRedEnum.离线奖励]);
// RedNotice.emit(EGlobalEvent.E_RED_UPDATE,[MainRedEnum.游历, HomeUIRedEnum.签到]);
// RedNotice.emit(EGlobalEvent.E_RED_UPDATE,[MainRedEnum.游历, HomeUIRedEnum.任务完成]);
}
// 签到
refreshSignInInfo(){
CNodeUtils.setActive(this.btn_singin, !this.mDataMgr.Signin.isAllSignDone());
}
// 离线
refreshOutLineInfo(){
if(MainConfig.isAutoOpenOffline){
const feed_game_scene = PlatformManager.PlatformInstance.GetFeedType();
// 不是推荐流直出,才自动打开离线界面
if(feed_game_scene === -1){
UIMgr.Ins.ShowUI(EUIForms.OfflineRewardUI);
}
MainConfig.isAutoOpenOffline = false;
}
CNodeUtils.setActive(this.btn_outline, this.mDataMgr.Date.getRedShow());
}
// 任务
refreshTaskInfo(){
if(LocalDataMgr.Task.isCompleteAllTask()){
CNodeUtils.setActive(this.btn_Task, false);
return;
}
const taskConfig = this.mDataMgr.Task.task.config;
let cur = this.mDataMgr.Task.task.progress;
let max = taskConfig.conditionValue;
let reward = {
type:taskConfig.rewardType,
id:taskConfig.rewardId,
num:taskConfig.rewardValue
}
CNodeUtils.SwitchTextureByData(this.spr_taskIcon, reward, 72)
CNodeUtils.switchText(this.lab_taskReward, taskConfig.desc);
CNodeUtils.switchText(this.lab_taskTitle, taskConfig.conditionDesc);
this.lab_taskProgress.color = this.lab_taskProgress.color.fromHEX( cur >= max ? "#B9EFA0" : "#EF0C08");
CNodeUtils.switchText(this.lab_taskProgress, `${cur}/${max}`);
if(!this.mBossUnlock){
this.mBossUnlock = (this.mDataMgr.Task.task.index > 0 && !SceneDataMgr.Ins.level.passed);
if(this.mBossUnlock){
this.refreshBossBtn();
}
}
// !this.btn_Boos.node.active && CNodeUtils.setActive(this.btn_Boos, (SceneDataMgr.Ins.level.monster.fighting && this.mDataMgr.Task.task.index > 0 && !SceneDataMgr.Ins.level.passed));
}
private refreshBossBtn(){
let sprite = this.btn_Boos.node.getComponent(Sprite);
sprite && (sprite.grayscale = !this.mBossUnlock);
let children = this.btn_Boos.node.children;
for(let i = 0; i < children.length; i++){
let child = children[i];
sprite = child.getComponent(Sprite);
sprite && (sprite.grayscale = !this.mBossUnlock);
}
this.lab_bosstf.color = this.mBossUnlock ? new Color(185,0,0) : new Color(124,124,124);
this.lab_bossTitle.color = this.mBossUnlock ? new Color(255,255,255) : new Color(124,124,124);
}
enemy_death_coin(money:number,type:number = 0){
let EnemyCoin = EnemyCoin_Proxy.CreateCoin(this.mEnemyCoin);
switch(type){
case 0:
EnemyCoin.setParent(this.n_addCoinPoint);
break;
case 1:
EnemyCoin.setParent(this.n_addCoinPoint2);
break;
}
EnemyCoin.setPosition(0, 0);
EnemyCoin.getComponent(EnemyCoin_Proxy).PlayText("+" + StringUtils.formatLargeNumber(money));
}
enemy_tj_coin(money:number){
let EnemyTJCoin = EnemyTJCoin_Proxy.CreateCoin(this.mEnemyTJCoin);
EnemyTJCoin.setParent(this.n_AddTJPoint);
EnemyTJCoin.setPosition(0, 0);
EnemyTJCoin.getComponent(EnemyTJCoin_Proxy).PlayText("+" + StringUtils.formatLargeNumber(money));
}
onATTACK_ONCE(triggerType:TRIGGER_TYPE,finalDamage:number,isCritical:boolean){
let damage = Damage_Proxy.CreateDamageText(this.mDamageText);
damage.setParent(this.n_DamagePoint);
damage.setPosition(0,0)
damage.getComponent(Damage_Proxy).PlayText("" + -finalDamage,isCritical, triggerType);
//ConsoleEx.Log(`${triggerType == TRIGGER_TYPE.AUTO ? "自动攻击" : "手动攻击"}`, `伤害:${finalDamage}`, `暴击:${isCritical ? "是" : "否"}`);
this.refreshEnemyHp();
// if(!SoulDataMgr.Ins.unlock){
// this.lastAttackTime = Date.now();
// if(!this.isshowPlayerAttInfo){
// Tween.stopAllByTarget(this.pInfoOpacity);
// this.pInfoOpacity.opacity = 255;
// this.isshowPlayerAttInfo = true;
// }
// }else if(!this.isshowPlayerAttInfo || this.pInfoOpacity.opacity !== 255){
// Tween.stopAllByTarget(this.pInfoOpacity);
// this.pInfoOpacity.opacity = 255;
// this.isshowPlayerAttInfo = true;
// }
// 手动攻击,直接播放震动
if(triggerType === TRIGGER_TYPE.MANUALLY || triggerType === TRIGGER_TYPE.SKILL){
Global.Vibrate.startVibrate();
}
}
// // 淡出元素
// private fadeOutElement() {
// tween(this.pInfoOpacity).to(0.2, {opacity:0}).call(() => {
// this.isshowPlayerAttInfo = false;
// }).start();
// }
refreshEnemyTaskInfo(){
const Level = SceneDataMgr.Ins.level;
const conditionDesc:string = Level.target.displayName;//TaskDataProxy.Ins.task.config.conditionDesc;
CNodeUtils.switchText(this.lab_LevelTarget, `抓捕${conditionDesc} ${Level.task_count}/${BOUNTY_PARAMS.TARGET}`);
CNodeUtils.switchText(this.lab_LevelEnemyCoin,"赏金:" + StringUtils.formatLargeNumber(Level.task_money));
this.refreshEnemyHp();
}
refreshMutateInfo(){
const Level = SceneDataMgr.Ins.level;
const Mutate = this.mDataMgr.Mutate;
let isshow = (Level.monster.fighting && Mutate.unlock && Mutate.isAlive());
CNodeUtils.setActive(this.btn_Mutate, isshow);
if(isshow){
const mutateBoss = Mutate.getMutateBoss();
const displayname = mutateBoss.tgbyboss? `${mutateBoss.displayName}(精英)` : mutateBoss.displayName;
CNodeUtils.switchRichText(this.ric_mutateTitle, displayname);
let data:IData = {
type: GameTotalType.MUTATEICON,
id: mutateBoss.config.id,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_mutateIcon, data);
this.refreshMutateRewardEx();
}
}
refreshMutateRewardEx(){
// const addpre = this.mDataMgr.Mutate.getRewardAddPre() * 100;
// CNodeUtils.switchRichText(this.ric_mutateaddpre, `奖励加成:${addpre}%`);
const lefttimes = this.mDataMgr.Game.FreeChallengeTimes;
const text = lefttimes > 0 ? `(${lefttimes}/${MUTATE_PARAMS.MAXFREETIMES})`: `(0/${MUTATE_PARAMS.MAXFREETIMES})`;
CNodeUtils.switchRichText(this.ric_mutateaddpre, `今日免费次数${text}`);
}
// 根据关卡目标刷新显示组件
refreshShowNode(){
this.feedEnterGame();
SceneDataMgr.Ins.onGamePause();
const isUnLock = SoulDataMgr.Ins.unlock;
const Level = SceneDataMgr.Ins.level;
CNodeUtils.setActive(this.n_minfo, Level.monster.fighting);
CNodeUtils.setActive(this.n_targetNode, Level.monster.fighting);
// CNodeUtils.setActive(this.n_left_layout, Level.monster.fighting);
// CNodeUtils.setActive(this.n_right_layout, Level.monster.fighting);
CNodeUtils.setActive(this.btn_rank, Level.id > 1);
CNodeUtils.setActive(this.btn_Redeem, Level.id > 1);
CNodeUtils.setActive(this.btn_SideBar, Global.CsvMgr.openSideBar() && Level.monster.fighting);
CNodeUtils.setActive(this.btn_FeedSubscribe, Global.CsvMgr.openSubscribe() && !MainConfig.isFeedSubscribe && Level.monster.fighting);
// CNodeUtils.setActive(this.btn_AddShortcut, !PlatformManager.PlatformInstance.isAddShortcut && Level.monster.fighting);
CNodeUtils.setActive(this.n_binfo, Level.boss.fighting);
CNodeUtils.setActive(this.btn_Retreat, Level.boss.fighting);
CNodeUtils.setActive(this.btn_PassTip, (Level.monster.fighting && Level.passed));
CNodeUtils.setActive(this.btn_XuanWu, Level.monster.fighting && Level.id > 1);
CNodeUtils.setActive(this.n_xwd_unlock, (Level.monster.fighting && SceneDataMgr.Ins.getRealLevel() < 21));
// -----------------备案包临时屏蔽----------------//
CNodeUtils.setActive(this.btn_Setting, Level.monster.fighting);
CNodeUtils.setActive(this.btn_Notice, Level.monster.fighting && Global.CsvMgr.GetNoticeData() != null);
CNodeUtils.setActive(this.btn_Task, Level.monster.fighting && !LocalDataMgr.Task.isCompleteAllTask());
CNodeUtils.setActive(this.btn_Boos, Level.monster.fighting && !LocalDataMgr.Task.isCompleteAllTask() && !Level.passed);
// 第一次通关,且没重生,则显示通关提示
CNodeUtils.setActive(this.n_PassNotice, Level.monster.fighting && LocalDataMgr.Pass.restart_times === 0 && LocalDataMgr.Pass.passed_times === 1);
CNodeUtils.setActive(this.btn_TrialBoos, MainConfig.isTrialOpen && Level.monster.fighting && LocalDataMgr.Pass.restart_times > 0);
CNodeUtils.setScale(this.n_BossBtns, (MainConfig.isTrialOpen && LocalDataMgr.Pass.restart_times > 0)? 0.8 : 1);
// CNodeUtils.setActive(this.btn_Mutate, Level.monster.fighting && this.mDataMgr.Mutate.unlock && this.mDataMgr.Mutate.getMutateBoss() !== null);
this.refreshMutateInfo();
this.addShortCut();
CNodeUtils.setActive(this.spr_levelbg, true);
CNodeUtils.setActive(this.spr_mutatebg, false);
// CNodeUtils.setActive(this.btn_Setting, false);
// CNodeUtils.setActive(this.btn_Task, false);
// CNodeUtils.setActive(this.btn_Boos, Level.monster.fighting);
// -------------------------------------//
// this.pInfoOpacity.opacity = isUnLock ? 255 : 0;
this.mBottomWidget.bottom = Level.monster.fighting ? 0 : -165;
this.isshowPlayerAttInfo = false;
let data:IData = {
type: GameTotalType.ENEMYICON,
id: SceneDataMgr.Ins.level.bossConfig.id,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_bossIcon, data);
CNodeUtils.switchText(this.lab_bossTitle, Level.bossConfig.name);
// 普通关卡
if (Level.monster.fighting){
this.pro_showHp = this.pro_EnemyHp;
this.lab_showName = this.lab_enemyName;
this.lab_showHp = this.lab_enemyHp;
this.spr_showIcon = this.spr_mHeadIcon;
this.isshowBossCD = false;
this.tempN_Pos.y = this.n_endPosY;
this.tempS_Pos.y = this.s_endPosY;
this.tempB_Pos.y = this.b_endPosY;
this.refreshEnemyTaskInfo();
this.refreshLevelInfo();
this.refreshTrialBossInfo();
}else{
this.pro_showHp = this.pro_BossHp;
this.lab_showName = this.lab_bossName;
this.lab_showHp = this.lab_bossHp;
this.spr_showIcon = this.spr_bHeadIcon;
this.isshowBossCD = true;
this.tempN_Pos.y = this.n_endPosY + 100;
this.tempS_Pos.y = this.s_endPosY - 100;
this.tempB_Pos.y = this.b_endPosY - 50;
}
this.refreshAutoAttack();
// this.refreshEnemyInfo();
this.refreshEnemyHp();
this.refreshEnemyInfo(["entry","idle"], true);
this.playEnemyAnimation(PlayerState.Entry);
this.scheduleOnce(() => {
SceneDataMgr.Ins.onGameResume();
}, 0.4);
// 通关弹窗
if(this.mDataMgr.Scene.isPassedState){
this.mDataMgr.Scene.isPassedState = false;
UIMgr.Ins.ShowUI(EUIForms.PopPassInfoUI);
}
// 未解锁广告曝光上报
isUnLock || TXSDKMgr.ins.AD_UI_SHOW(TXVideoMapping[EVideoType.UnlockSoul]);
// tween(this.n_Scene).to(0.2, {position : this.tempS_Pos}).call(() => {
// }).start();
// tween(this.btn_Auto.node).to(0.1, { position: this.tempB_Pos }).start();
// tween(this.n_LevelInfo).to(0.1, { position: this.tempN_Pos }).start();
}
refreshEnemyInfo(anims?:string|string[],loop?:boolean) {
const fighttype = SceneDataMgr.Ins.fighting_type;
// const target = (fighttype === FIGHTING_TYPE.PVE) ? SceneDataMgr.Ins.level.target : this.mDataMgr.Trial.getTrialBoss();
let target = null;
let nameex = "";
switch (fighttype) {
case FIGHTING_TYPE.PVE:
target = this.mDataMgr.Scene.level.target;
break;
case FIGHTING_TYPE.TRIALBOSS:
target = this.mDataMgr.Trial.getTrialBoss();
break;
case FIGHTING_TYPE.MUTATEBOSS:
target = this.mDataMgr.Mutate.getMutateBoss();
nameex = target.tgbyboss? "(精英)" : "";
break;
}
if(!target){
ConsoleEx.Log("attack target is null");
return;
}
CNodeUtils.switchText(this.lab_showName,target.displayName + nameex);
let data:IData = {
type: GameTotalType.ENEMYICON,
id: target.config.id,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_showIcon, data);
ConsoleEx.Warn("刷新EnemyInfo,当前皮肤:",this.spi_enemy.skeletonData?.name)
if(this.spi_enemy.skeletonData?.name !== target.config.sp){
ConsoleEx.Warn("目标皮肤:",target.config.sp)
CNodeUtils.SwitchSpine(this.spi_enemy, target.skin, EBundleName.Spine, anims, loop);
CNodeUtils.setScale(this.spi_enemy, target.config.scale)
}
}
refreshTrialBossInfo(){
if(this.mDataMgr.Trial.isActive && this.mDataMgr.Pass.restart_times > 0){
const type = this.mDataMgr.Trial.getCurrTrialBossIdx();
const bossid = this.mDataMgr.Trial.getTrialConfig(type).bossid;
let data:IData = {
type: GameTotalType.ENEMYICON,
id: bossid,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_trialbossicon, data);
const bossConfig = Global.CsvMgr.Enemy_csv[bossid];
CNodeUtils.switchText(this.lab_trialbossname, bossConfig.name);
}
}
refreshEnemyHp(){
const fighttype = SceneDataMgr.Ins.fighting_type;
// const target = (fighttype === FIGHTING_TYPE.PVE) ? SceneDataMgr.Ins.level.target : this.mDataMgr.Trial.getTrialBoss();
let target = null;
switch (fighttype) {
case FIGHTING_TYPE.PVE:
target = this.mDataMgr.Scene.level.target;
break;
case FIGHTING_TYPE.TRIALBOSS:
target = this.mDataMgr.Trial.getTrialBoss();
break;
case FIGHTING_TYPE.MUTATEBOSS:
target = this.mDataMgr.Mutate.getMutateBoss();
break;
}
if(!target){
ConsoleEx.Log("attack target is null");
return false;
}
let pro = target.hp / target.totalHP;
CNodeUtils.switchText(this.lab_showHp, MathUtils.fixedDecimal(pro * 100, 2) + "%");
this.pro_showHp.progress = pro;
}
refreshAutoAttack(){
let isUnLock = SoulDataMgr.Ins.unlock;
const mFighting = SceneDataMgr.Ins.level.monster.fighting;
const cTaskId = Number(this.mDataMgr.Task.task.id);
// -----------------备案包临时屏蔽----------------//
CNodeUtils.setActive(this.btn_Auto, (isUnLock || mFighting) && cTaskId > 1);
// CNodeUtils.setActive(this.btn_Auto, false);
// -------------------------------------//
CNodeUtils.setActive(this.n_auto_show, isUnLock && mFighting);
CNodeUtils.setActive(this.n_auto_hide, !isUnLock && mFighting);
CNodeUtils.setActive(this.n_autoLevel_unlock, !isUnLock && mFighting);
CNodeUtils.setActive(this.n_autoAdTips, !isUnLock && mFighting);
CNodeUtils.setActive(this.n_boss_AdCrit, isUnLock && !mFighting);
CNodeUtils.switchText(this.n_auto_Des.getChildByName("Label"), isUnLock? "攻速爆发" : "自动攻击");
isUnLock && mFighting && this.n_auto_Des.getComponent(UINodeEffect)?.StartEffect();
this.refreshSoulState();
}
refreshSoulState(){
CNodeUtils.setActive(this.n_boss_Ad, !SoulDataMgr.Ins.crit);
}
refreshhHero(){
const wugong = RoleDataMgr.Ins.attackWuGong;
CNodeUtils.switchText(this.lab_gongfaName, wugong? wugong.config.name : "无");
const skin = RoleDataMgr.Ins.weapon? ESKINMAPPING[RoleDataMgr.Ins.attack_type] + RoleDataMgr.Ins.weapon.id : PlayerAnimation.sword;
this.cur_skin = ESKINANIMMAPPING[RoleDataMgr.Ins.attack_type] || ESKINANIMMAPPING[EGongFaType.剑法];
this.spi_hero.setSkin(skin);
this.spr_wpicon.spriteFrame = this.mWPIcon[RoleDataMgr.Ins.attack_type - 1];
}
refreshCrit(){
CNodeUtils.switchText(this.lab_crit, "暴击 " + MathUtils.fixedDecimal(RoleDataMgr.Ins.crit, 1) + "%");
}
refreshAttackSpeed(){
CNodeUtils.switchText(this.lab_attackSpeed, "" + MathUtils.fixedDecimal(SceneDataMgr.Ins.realSpeed, 1) + "次/秒");
}
refreshLevelInfo(){
const levelid = Math.min(this.mDataMgr.Scene.level.id, 21);
this.lab_levelTitle.string = "第" + Utils.StringUtils.ChineseNumConvert(levelid) + "关 " + Language.getValue(SceneDataMgr.Ins.level.displayName);
CNodeUtils.switchText(this.lab_LevelDes, SceneDataMgr.Ins.level.displayDesc);
}
//#region 战斗动画
// 玩家攻击状态管理
private isPlayerAttacking: boolean = false; // 玩家是否正在攻击
private playerAttackQueue: number[] = []; // 玩家攻击队列
private playerAttackEndTime: number = 0; // 玩家攻击结束时间
// 在类中添加以下属性
private isEnemyHurtAnimating: boolean = false; // 敌人是否正在播放受击动画
private enemyHurtQueue: number[] = []; // 受击动画队列
private enemyHurtEndTime: number = 0; // 敌人受击动画结束时间
// 在update方法中添加以下代码(取消注释并修改)
protected update(dt: number): void {
// 检查玩家攻击动画是否结束
if (this.isPlayerAttacking && Date.now() >= this.playerAttackEndTime) {
this.isPlayerAttacking = false;
this.processPlayerAttackQueue();
}
// 检查敌人受击动画是否结束
if (this.isEnemyHurtAnimating && Date.now() >= this.enemyHurtEndTime) {
this.isEnemyHurtAnimating = false;
this.processEnemyHurtQueue();
}
}
// 玩家攻击动画触发
role_play_animation(speed:number){
// 优化队列处理:限制队列长度,保留最新的攻击请求
if (this.playerAttackQueue.length >= 3) {
// 如果队列过长,移除旧的请求,只保留最近的几次攻击
this.playerAttackQueue.splice(0, this.playerAttackQueue.length - 2);
}
this.playerAttackQueue.push(speed); // 加入队列
this.processPlayerAttackQueue(); // 处理队列
}
// 处理玩家攻击队列
private processPlayerAttackQueue() {
// 如果正在攻击或者队列为空,则不处理
if (this.isPlayerAttacking || this.playerAttackQueue.length === 0) {
return;
}
// 取出队列中最后一个(最新的)攻击速度参数,而不是第一个
// 这样可以确保动画与当前攻击速度匹配
const speed = this.playerAttackQueue.pop();
this.playerAttackQueue.length = 0; // 清空队列中剩余的旧请求
// 播放攻击动画
this.playHeroAnimation(PlayerState.Attack, speed);
}
// 修改 enemy_play_animation 方法
enemy_play_animation(dead:boolean = false, isboss:boolean = false, speed:number = 1){
if (dead) {
// 死亡动画具有最高优先级,直接播放
this.isEnemyHurtAnimating = false; // 清空受击动画队列
this.enemyHurtQueue.length = 0; // 清空队列
this.enemyHurtEndTime = 0;
this.playEnemyAnimation(PlayerState.Dead, isboss, speed);
} else {
// 受击动画需要排队播放,但也需要限制队列长度
if (this.enemyHurtQueue.length >= 5) {
// 限制敌人受击动画队列长度
this.enemyHurtQueue.splice(0, this.enemyHurtQueue.length - 3);
}
// 受击动画需要排队播放
this.enemyHurtQueue.push(speed);
this.processEnemyHurtQueue();
}
}
// 新增处理受击动画队列的方法
private processEnemyHurtQueue() {
// 如果敌人正在播放受击动画或队列为空,则不处理
if (this.isEnemyHurtAnimating || this.enemyHurtQueue.length === 0) {
return;
}
// 对于敌人受击动画,采用不同的策略:
// 1. 如果队列很长,说明攻击很快,只播放最新的几次
// 2. 如果队列较短,按顺序播放
let speed;
if (this.enemyHurtQueue.length > 3) {
// 队列较长时,跳过一些动画以跟上攻击节奏
speed = this.enemyHurtQueue[this.enemyHurtQueue.length - 1]; // 取最新的
this.enemyHurtQueue.length = 0; // 清空队列
} else {
// 队列较短时,按顺序处理
speed = this.enemyHurtQueue.shift();
}
this.playEnemyAnimation(PlayerState.Hurt, false, speed);
}
// 修改 playHeroAnimation 方法
playHeroAnimation(State:PlayerState,speed:number = 1) {
switch (State) {
case PlayerState.idle:
this.spi_hero.setAnimation(0,"idle", true);
break;
case PlayerState.Attack:
if(SceneDataMgr.Ins.realSpeed < 6){
tween(this.lab_attackSpeed.node).stop();
}
// const actualSpeed = Math.min(speed, 2.5);
this.spi_hero.timeScale = speed;
const attackDuration = 0.5 / speed * 1000; // 转换为毫秒
this.playerAttackEndTime = Date.now() + attackDuration;
this.isPlayerAttacking = true;
this.spi_hero.setAnimation(0, `attack_${this.cur_skin}_${this.animationIdx}`, false)
this.animationIdx++
if (this.animationIdx > 3) {
this.animationIdx = 1;
}
// 自动攻击才在这里播震动
SceneDataMgr.Ins.currTriggerType === TRIGGER_TYPE.AUTO && Global.Vibrate.startVibrate();
// if(this.animationIdx==2){
// }
const speedAni = tween(this.lab_attackSpeed.node).to(0.1,{scale:v3(1.2,1.2)}).to(0.1,{scale:v3(1,1)}).union().start();
this.spi_smoke1.node.active = true;
this.spi_smoke2.node.active = true;
this.spi_smoke1.setAnimation(0,"smoke",false);
this.spi_smoke1.setCompleteListener(() =>{
this.spi_smoke1.node.active = false;
})
this.spi_smoke2.setAnimation(0,"smoke",false);
this.spi_smoke1.setCompleteListener(() =>{
this.spi_smoke1.node.active = false;
})
if(this.playerAttackQueue.length == 0){
this.spi_hero.addAnimation(0, "idle", true);
}
if(RoleDataMgr.Ins.attack_type == EGongFaType.剑法){
AudioUtils.ins.playEffect(ESounds.So_attack1_sword);
Global.Audio.playEffect(ESounds.So_hit);
}else if(RoleDataMgr.Ins.attack_type == EGongFaType.刀法){
AudioUtils.ins.playEffect(ESounds.So_attack2_knife);
Global.Audio.playEffect(ESounds.So_hit);
}else{
AudioUtils.ins.playEffect(ESounds.So_attack3_stick);
Global.Audio.playEffect(ESounds.So_hit);
}
break;
}
}
// 修改 playEnemyAnimation 方法中的 Hurt 状态处理
playEnemyAnimation(State:PlayerState, isboss:boolean = false, speed:number = 1) {
CNodeUtils.setOpacity(this.spi_enemy.node, 255);
switch (State) {
case PlayerState.Entry:
case PlayerState.Show:
this.spi_enemy.timeScale = 1; // 死亡动画固定最高速度
this.isEnemyHurtAnimating = false; // 清空受击动画队列
this.enemyHurtQueue.length = 0; // 清空队列
this.enemyHurtEndTime = 0;
// this.spi_enemy.setAnimation(0, "entry", false);
// this.spi_enemy.setAnimation(0, "show", false);
// this.spi_enemy.addAnimation(0, "idle", true);
break;
case PlayerState.idle:
this.spi_enemy.setAnimation(0,"idle", true);
break;
case PlayerState.Dead:
this.spi_enemy.setAnimation(0,"death", false);
if(!isboss){
// 非boss死亡后重新入场
tween(this.eOpacity).to(0.4, { opacity: 0 }).start();
this.spi_enemy.timeScale = 2.5; // 死亡动画固定最高速度
this.spi_enemy.addAnimation(0, "entry", false);
this.spi_enemy.addAnimation(0,"idle", true);
}else{
tween(this.eOpacity).to(1.5, { opacity: 0 }).start();
this.spi_enemy.timeScale = 0.5; // boss死亡动画慢放
}
break;
case PlayerState.Hurt:
// 受击动画
this.spi_enemy.setAnimation(0, "hit", false);
// 非审核版才播放受击特效
if(!MainConfig.isReviewVer){
this.spi_hit.node.active = true;
this.spi_hit.setAnimation(0,`texiao${this.hitIdx}`,false);
this.spi_hit.setCompleteListener(()=>{
this.spi_hit.node.active = false;
})
}
this.hitIdx++
if (this.hitIdx > 2) {
this.hitIdx = 1;
}
// 计算动画结束时间(假设受击动画时长约为0.3秒)
this.spi_enemy.timeScale = speed;
const hurtDuration = 0.5 / speed * 1000; // 转换为毫秒
this.enemyHurtEndTime = Date.now() + hurtDuration;
this.isEnemyHurtAnimating = true;
// 受击后回到待机动画
this.spi_enemy.addAnimation(0, "idle", true);
break;
}
}
// 玩家动画完成回调
AnimationCallBack(track:sp.spine.TrackEntry){
if (track.animation.name == "idle") {
this.spi_hero.timeScale = 1;
}
}
// 修改 enemyAniCallBack 方法
enemyAniCallBack(track:sp.spine.TrackEntry){
if(track.animation.name == "entry"){
CNodeUtils.setOpacity(this.spi_enemy.node, 255);
} else if(track.animation.name == "death"){
Tween.stopAllByTarget(this.eOpacity);
}
}
//#endregion 战斗动画
// 定时更新0.5秒
private scheduleUpdate(){
SceneDataMgr.Ins.updateOnce();
if (this.isshowBossCD){
CNodeUtils.switchText(this.lab_bossCD, '倒计时:' + Math.floor(SceneDataMgr.Ins.bossCD) + '秒');
}
const skillcfg = RoleDataMgr.Ins.skillSuitCfg;
if (skillcfg){
const cdtimes = RoleDataMgr.Ins.suitSkillCD[skillcfg.suit_type];
if (cdtimes > 0){
CNodeUtils.switchText(this.lab_skillcd, Math.floor(cdtimes) + '秒');
this.spr_skillicon.fillRange = cdtimes / skillcfg.prop2;
}else{
CNodeUtils.switchText(this.lab_skillcd, "");
this.spr_skillicon.fillRange = 0
}
}
}
private onLevelVictory(){
CNodeUtils.setActive(this.btn_Retreat, false);
CNodeUtils.setActive(this.btn_Auto, false);
if(this.spi_victory){
this.spi_victory.node.active = true;
this.spi_victory.setAnimation(0,"victory",false)
this.spi_victory.setCompleteListener(()=>{
this.spi_victory.clearTracks();
this.spi_victory.node.active = false;
})
}
}
private fightBossFinish(){
if(this.mDataMgr.Scene.fighting_type === FIGHTING_TYPE.TRIALBOSS){
CNodeUtils.setActive(this.btn_Retreat, false);
const currbossidx = this.mDataMgr.Trial.getCurrTrialBossIdx();
const trialboss = this.mDataMgr.Trial.getTrialBoss();
if(this.spi_enemy && trialboss){
if (trialboss.hp > 0){
Global.Vibrate.startVibrate();
const trialcfg = this.mDataMgr.Trial.getTrialConfig(currbossidx);
CNodeUtils.setActive(this.n_dialogue, true);
CNodeUtils.switchText(this.lab_dialogue, trialcfg.dialog);
AudioUtils.ins.playEffect(this.trialendsounds[currbossidx]);
this.scheduleOnce(()=>{
this.spi_enemy.setAnimation(0, "skill", false);
CNodeUtils.setActive(this.n_dialogue, false);
this.scheduleOnce(()=>{
AudioUtils.ins.playEffect(this.trialskillsounds[currbossidx]);
const spine = this.spiBossFinish[currbossidx];
if(spine){
spine.node.active = true;
spine.setAnimation(0,this.trialskillani[currbossidx],false);
spine.setCompleteListener(()=>{
Global.Vibrate.startVibrate();
spine.clearTracks();
spine.node.active = false;
this.mDataMgr.Trial.endTrial();
UIMgr.Ins.ShowUI(EUIForms.FinalTrialFinishUI);
})
}
},1);
}, 1)
}else{
this.spi_enemy.setAnimation(0, "death", false);
this.scheduleOnce(()=>{
this.mDataMgr.Trial.endTrial();
UIMgr.Ins.ShowUI(EUIForms.FinalTrialFinishUI);
}, 2)
}
}
}
}
// 推荐流直出
private feedEnterGame(){
const feed_game_scene = PlatformManager.PlatformInstance.GetFeedType();
// 获客广告,还未正式进入游戏,隐藏底部功能栏
ConsoleEx.Warn('!!!!!!!!!!!!!feedEnterGame,feed_game_scene = ', feed_game_scene, " || isEnterGame = " + MainConfig.isEnterGame, " || isFeedEnter = " + MainConfig.isFeedEnter)
if((feed_game_scene == 0 || feed_game_scene == 3) && !MainConfig.isFeedEnter){
CNodeUtils.setActive(this.n_left_layout, false);
CNodeUtils.setActive(this.n_right_layout, false);
}else{
const isshow = this.mDataMgr.Scene.level.monster.fighting && this.mDataMgr.Scene.fighting_type === FIGHTING_TYPE.PVE;
ConsoleEx.Warn('===========feedEnterGame,feed_game_scene = ', feed_game_scene, " || isFeedEnter = " + MainConfig.isFeedEnter," || isshow = ", isshow)
CNodeUtils.setActive(this.n_left_layout, isshow);
CNodeUtils.setActive(this.n_right_layout, isshow);
}
}
private refreshFightingType() {
SceneDataMgr.Ins.onGamePause();
CNodeUtils.setActive(this.n_minfo, false);
CNodeUtils.setActive(this.n_targetNode, false);
CNodeUtils.setActive(this.n_left_layout, false);
CNodeUtils.setActive(this.n_right_layout, false);
CNodeUtils.setActive(this.btn_Setting, false);
CNodeUtils.setActive(this.btn_Notice, false);
CNodeUtils.setActive(this.btn_Task, false);
CNodeUtils.setActive(this.btn_Boos, false);
CNodeUtils.setActive(this.btn_TrialBoos, false);
CNodeUtils.setActive(this.btn_Mutate, false);
CNodeUtils.setActive(this.n_binfo, true);
CNodeUtils.setActive(this.btn_Retreat, true);
this.mBottomWidget.bottom = -165;
this.isshowBossCD = true;
this.pro_showHp = this.pro_BossHp;
this.lab_showName = this.lab_bossName;
this.lab_showHp = this.lab_bossHp;
this.spr_showIcon = this.spr_bHeadIcon;
let delay = 0.5
let animState = PlayerState.Entry;
if(this.mDataMgr.Scene.fighting_type === FIGHTING_TYPE.TRIALBOSS){
CNodeUtils.setActive(this.btn_Auto, false);
this.lab_levelTitle.string = "终极试炼";
this.lab_LevelDes.string = "";
this.refreshEnemyInfo(["entry","idle"], true);
}else if(this.mDataMgr.Scene.fighting_type === FIGHTING_TYPE.MUTATEBOSS){
// this.lab_levelTitle.string = Language.getValue(SceneDataMgr.Ins.level.displayName);
// CNodeUtils.switchText(this.lab_LevelDes, SceneDataMgr.Ins.level.displayDesc);
CNodeUtils.setActive(this.btn_Auto, true);
const mutateBoss = this.mDataMgr.Mutate.getMutateBoss();
this.lab_levelTitle.string = "异兽挑战";
CNodeUtils.switchText(this.lab_LevelDes, mutateBoss.config.desc);
this.refreshEnemyInfo(["show","idle"], true);
animState = PlayerState.Show;
CNodeUtils.setActive(this.spr_levelbg, false);
CNodeUtils.setActive(this.spr_mutatebg, true);
delay = 2;
}
this.refreshEnemyHp();
this.playEnemyAnimation(animState);
this.scheduleOnce(() => {
SceneDataMgr.Ins.onGameResume();
}, delay);
}
private addShortCut(){
const level = this.mDataMgr.Scene.level;
const getnum = this.mDataMgr.Game.getAddShortCutNum();
CNodeUtils.setActive(this.btn_AddShortcut, !PlatformManager.PlatformInstance.isAddShortcut && level.id > 1 && getnum === 0 && level.monster.fighting);
}
/**套装刷新 */
private refreshSuitInfo(){
CNodeUtils.switchRichText(this.ric_suitinfo, RoleDataMgr.Ins.skillSuitDesc);
const cfg: ISuitEffect = RoleDataMgr.Ins.skillSuitCfg;
if(!cfg){
CNodeUtils.setActive(this.btn_Skill, false);
}else{
CNodeUtils.setActive(this.btn_Skill, true);
CNodeUtils.switchText(this.lab_skillname, cfg.skill_name);
let data:IData = {
type: GameTotalType.SUITSKILL,
id: cfg.id,
num:0
}
CNodeUtils.SwitchTextureByData(this.spr_skillbg,data);
CNodeUtils.SwitchTextureByData(this.spr_skillicon,data);
}
}
}