英雄和敌人 全死亡后,判定解决

This commit is contained in:
2025-08-12 20:20:05 +08:00
parent b77f023548
commit d464491172
18 changed files with 1731 additions and 2685 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "51813e85-ae9e-41de-97cd-e51d2b4fcb4b",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "wave_info"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@ import { VM } from "../../../../extensions/oops-plugin-framework/assets/libs/mod
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { Initialize } from "../initialize/Initialize";
import { GameMap } from "../map/GameMap";
import { HeroUI, MissionData, VmInfo } from "./config/Mission";
import { HeroUI, VmInfo } from "./config/Mission";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
@@ -49,13 +49,19 @@ export class SingletonModuleComp extends ecs.Comp {
vmdata: any = {
game_over:false,
game_pause:false,
mission_data:{ },
hero:{ },
boss:{ },
mission_data:{
gold:1000,//金币
score:0,//分数
diamond:0,//钻石
mission:1,//关卡
mon_num:0,//怪物数量
hero_num:0,//英雄数量
wave_time_num:0,//波次时间
in_fight:false,
fight_time:0,//战斗时间
},
};
vmAdd() {
this.vmdata.mission_data=JSON.parse(JSON.stringify(MissionData))
this.vmdata.hero=JSON.parse(JSON.stringify(VmInfo))
VM.add(this.vmdata, "data");
}
reset() {

View File

@@ -71,4 +71,5 @@ export enum GameEvent {
RestOpen = "RestOpen",
HeroLvUp = "HeroLvUp",
MonDead = "MonDead",
HeroDead = "HeroDead",
}

View File

@@ -87,17 +87,7 @@ export enum FightSet {
// AP_UPDATE_RATE=100,
// AP_CHANGE_RATE=0,
}
export const MissionData = {
gold:1000,//金币
score:0,//分数
diamond:0,//钻石
current_wave:1,
mission:1,//关卡
mon_num:0,//怪物数量
wave_time_num:0,//波次时间
in_fight:false,
fight_time:0,//战斗时间
}
export const HeroUI = {
uuid:0,
name:"",

View File

@@ -67,6 +67,7 @@ export class Hero extends ecs.Entity {
if(HeroInfo[uuid].type==HType.mage){
move.targetX = -200; // 右边界'
}
smc.vmdata.mission_data.hero_num++
}
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
var hv = node.getComponent(HeroViewComp)!;

View File

@@ -48,5 +48,8 @@ export default class HeroAnmComp extends Component{
this.anmcon.play("idle")
this.default_anim='idle'
}
buff(){
if(this.anmcon.getState("buff").isPlaying) return
this.anmcon.play("buff")
}
}

View File

@@ -66,7 +66,9 @@ export class HeroSpine extends Component {
break
}
}
do_buff(){
this.anm.buff()
}
move(){
// console.log("change to move",this.status);
if(this.status=="move") return

View File

@@ -122,6 +122,7 @@ export class HeroViewComp extends CCComp {
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.EXPUP,this.exp_up,this)
this.on(GameEvent.HeroLvUp,this.to_update_lv,this)
this.on(GameEvent.FightEnd,this.do_fight_end,this)
const collider = this.node.getComponent(BoxCollider2D);
this.scheduleOnce(()=>{
if (collider) collider.enabled = true; // 先禁用
@@ -142,7 +143,6 @@ export class HeroViewComp extends CCComp {
}
/* 显示角色血量 */
this.node.getChildByName("top").getChildByName("hp").active = true;
}
update(dt: number){
@@ -151,7 +151,6 @@ export class HeroViewComp extends CCComp {
// this.ent.destroy();
// return
// }
if(this.DEBUFF_FROST > 0){
this.DEBUFF_FROST -=dt;
@@ -175,8 +174,10 @@ export class HeroViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar).progress = hp_progress;
// this.node.getChildByName("top").getChildByName("hp").active = (hp == hp_max) ? false : true;
}
do_fight_end(){
this.as.do_buff()
}
get isActive() {
return this.ent.has(HeroViewComp) && this.node?.isValid;
}
@@ -255,14 +256,15 @@ export class HeroViewComp extends CCComp {
do_dead(){
this.do_dead_trigger()
//console.log("[HeroViewComp]:角色死亡",this.hero_uuid)
if(this.is_count_dead) return
this.is_count_dead=true
if(this.fac==FacSet.MON){
if(this.is_count_dead) return
this.is_count_dead=true
this.scheduleOnce(()=>{
oops.message.dispatchEvent(GameEvent.MonDead)
},0.1)
},0.1)
}
if(this.fac==FacSet.HERO){
oops.message.dispatchEvent(GameEvent.HeroDead)
}
if(this.fac==FacSet.HERO){
@@ -479,7 +481,6 @@ export class HeroViewComp extends CCComp {
}
check_dodge(){
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.DODGE_TO_POWER //闪避涨能量
if(this.dod > 0){
let random = Math.random()*100
if(random < this.dod) {
@@ -567,15 +568,7 @@ export class HeroViewComp extends CCComp {
}
exp_up(e:any,data:any){
if(this.fac==FacSet.MON) return
// console.log("[HeroViewComp]:经验提高",data.exp)
smc.vmdata.hero.exp+=data.exp
// smc.vmdata.hero.next_exp=getUpExp(this.lv)
if(smc.vmdata.hero.exp >= smc.vmdata.hero.next_exp){
// console.log("[HeroViewComp]:升级")
this.to_update_lv("seft",data)
oops.message.dispatchEvent(GameEvent.CanUpdateLv)
}
}

View File

@@ -52,6 +52,8 @@ export class Monster extends ecs.Entity {
const move = this.get(BattleMoveComp);
move.direction = -1; // 向左移动
move.targetX = -800; // 左边界
smc.vmdata.mission_data.mon_num++
console.log("[Mon] mission_data.mon_num:",smc.vmdata.mission_data.mon_num)
}
brith_light(pos:Vec3,scene:any){
var path = "game/skills/map_birth";

View File

@@ -78,21 +78,7 @@ export class EquipSkillComp extends CCComp {
}
update(dt: number): void {
if(!smc.mission.play||smc.mission.pause) return
if(this.skill1.uuid!=0){
let cd=this.skill1.cd/((smc.vmdata.hero.skill_cd_buff)/100+1)
if(this.skill1.cd_time < cd){
this.skill1.cd_time+=dt
}else{
if(this.skill1.type==1){
this.do_skill1()
}
}
this.skill1_cd_bar_progress.progress=(1-this.skill1.cd_time/cd)
}
if(this.skill2.uuid!=0&&smc.vmdata.hero.power>=smc.vmdata.hero.power_max&&!this.max_show){
this.show_max()
this.max_show=true
}
}
show_max(){
@@ -116,13 +102,10 @@ export class EquipSkillComp extends CCComp {
}
do_skill2(){
if(smc.vmdata.hero.power<smc.vmdata.hero.power_max) return
console.log("do_skill2")
tween(this.boxs.getChildByName("skill2")).to(0.1, {scale:v3(1.5,1.5,1)},{onComplete:()=>{
tween(this.boxs.getChildByName("skill2")).to(0.2, {scale:v3(1,1,1)}).start()
}}).start()
this.do_skill(this.skill2.uuid)
smc.vmdata.hero.power=0
this.hide_max()
}

View File

@@ -57,18 +57,6 @@ export class MSkillComp extends CCComp {
}
update(dt: number): void {
if(!smc.mission.play||smc.mission.pause) return
if(this.skill.uuid!=0){
let cd=this.skill.cd/((smc.vmdata.hero.skill_cd_buff)/100+1)
if(this.skill.cd_time < cd){
this.skill.cd_time+=dt
}else{
if(this.skill.type==1){
this.spell_skill()
}
}
let progress=(1-this.skill.cd_time/cd)
this.node.getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=progress
}
}
show_max(){

View File

@@ -3,10 +3,12 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { FightSet, HeroUI, MissionData, VmInfo} from "../common/config/Mission";
import { FightSet} from "../common/config/Mission";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { GameEvent } from "../common/config/GameEvent";
import { HeroViewComp } from "../hero/HeroViewComp";
import { MonModelComp } from "../hero/MonModelComp";
import { SkillCom } from "../skills/SkillCom";
const { ccclass, property } = _decorator;
@@ -24,7 +26,7 @@ export class MissionComp extends CCComp {
onLoad(){
this.on(GameEvent.MissionStart,this.mission_start,this)
this.on(GameEvent.MonDead,this.do_mon_dead,this)
this.on(GameEvent.HeroDead,this.do_hero_dead,this)
this.on(GameEvent.FightEnd,this.fight_end,this)
this.on(GameEvent.MissionEnd,this.mission_end,this)
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
@@ -44,22 +46,21 @@ export class MissionComp extends CCComp {
}
do_mon_dead(){
this.do_mon_dead_thing()
smc.addGold(1)
smc.vmdata.mission_data.mon_num--
console.log("[MissionComp] do_mon_dead",smc.vmdata.mission_data.mon_num)
if(smc.vmdata.mission_data.mon_num<=0) {
// if(smc.vmdata.mission_data.current_wave == RogueTalWave[this.count_tal()].wave){
// console.log("[MissionComp] current_wave:"+smc.vmdata.mission_data.current_wave+" tal wave:"+RogueTalWave[this.count_tal()].wave)
// oops.message.dispatchEvent(GameEvent.TalentSelect,{slot:TalentSlot[this.count_tal()]})
// this.tals[this.count_tal()]=true
// }
smc.setGameProperty("mission",smc.data.mission+1,true)
oops.message.dispatchEvent(GameEvent.FightEnd,{victory:true})
}
}
do_mon_dead_thing(){
smc.addGold(1)
do_hero_dead(){
smc.vmdata.mission_data.hero_num--
console.log("[MissionComp] do_hero_dead",smc.vmdata.mission_data.hero_num)
if(smc.vmdata.mission_data.hero_num<=0) {
oops.message.dispatchEvent(GameEvent.FightEnd,{victory:false})
}
}
do_ad(){
if(this.ad_back()){
oops.message.dispatchEvent(GameEvent.AD_BACK_TRUE)
@@ -87,14 +88,14 @@ export class MissionComp extends CCComp {
loading.active=true
this.scheduleOnce(()=>{
loading.active=false
this.node.getChildByName("ending").active=false
},1)
this.to_fight()
},0.5)
this.scheduleOnce(()=>{
this.to_fight()
},0.1)
}
to_fight(){
console.log("[MissionComp] ** 3 ** to_fight")
smc.mission.in_fight=true
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
}
@@ -107,8 +108,6 @@ export class MissionComp extends CCComp {
fight_end(){
console.log("任务结束")
this.node.getChildByName("ending").active=true
this.node.getChildByName("ending").getComponent(Animation).play("endFight")
// 延迟0.5秒后执行任务结束逻辑
this.scheduleOnce(() => {
smc.mission.play=false
@@ -125,12 +124,14 @@ export class MissionComp extends CCComp {
data_init(){
//局内数据初始化 smc 数据初始化
smc.mission.play = true;
smc.vmdata.mission_data = JSON.parse(JSON.stringify(MissionData));
console.log("局内数据初始化")
smc.vmdata.mission_data.in_fight=false
smc.vmdata.mission_data.fight_time=0
console.log("[MissionComp]局内数据初始化",smc.vmdata.mission_data)
}
private cleanComponents() {
ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});
ecs.query(ecs.allOf(SkillCom)).forEach(entity => {entity.remove(SkillCom);entity.destroy()});
}

View File

@@ -46,6 +46,7 @@ export class MissionHeroCompComp extends CCComp {
// }
// this.current_hero_num=-1
// this.current_hero_uuid=0
smc.vmdata.mission_data.hero_num=0
console.log("[MissionHeroComp]:fight_ready",smc.fight_heros,Object.keys(smc.fight_heros).length)
let heros:any = smc.fight_heros
for(let i=0;i<Object.keys(heros).length;i++){

View File

@@ -55,6 +55,7 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 使
fight_ready(){
// console.log("[MissionMonComp]:fight_ready")
smc.vmdata.mission_data.mon_num=0
this.do_mon_wave()
}
@@ -95,7 +96,6 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 使
do_mon_wave(){
// console.log("[MissionMonComp]:怪物登场,当前关卡 :",smc.vmdata.mission_data.current_wave)
// 重置召唤相关状态
this.spawnCount = 0;
this.isPausing = false;
@@ -112,11 +112,10 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 使
// 根据新的关卡配置生成怪物
private generateMonstersFromStageConfig(monsterConfigs: any[]) {
const currentStage = smc.vmdata.mission_data.current_wave;
const currentStage = smc.vmdata.mission_data.mission;
// 设置怪物总数
smc.vmdata.mission_data.mon_num = monsterConfigs.length;
console.log("[MissionMonComp] generateMonstersFromStageConfig",monsterConfigs)
if (!monsterConfigs || monsterConfigs.length === 0) {
console.warn(`[MissionMonComp]:关卡${currentStage}配置中没有怪物信息`);
return;

View File

@@ -26,7 +26,7 @@ export class VictoryComp extends CCComp {
this.hide()
}
fight_end(e:any,val:any){
console.log("[VictoryComp] fight_end",val)
this.open()
}
victory_end(){

View File

@@ -62,6 +62,7 @@ export class SkillCom extends CCComp {
protected onLoad(): void {
}
private initializeSkillConfig() {
if (this.isInitialized) return;