This commit is contained in:
2024-09-30 08:39:10 +08:00
parent 45e1265e51
commit 5d79ad7d4f
28 changed files with 6057 additions and 10195 deletions

View File

@@ -384,6 +384,10 @@ export class RoleViewComp extends CCComp {
this.heathed();
this.tooltip(2,hp.toString());
let hp_progress= this.hp/this.hp_max;
this.hp += hp;
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
add_atk(atk: number,time:number=0){
@@ -520,7 +524,6 @@ export class RoleViewComp extends CCComp {
}
dead(){
oops.message.dispatchEvent("minssion_defeat");
var path = "game/skills/dead";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);

View File

@@ -79,7 +79,10 @@ export class SingletonModuleComp extends ecs.Comp {
mission:{
play:false,
pause:false,
refresh_timer:4,
refresh_timer:3,
mission_lv:1,
boss_cd:10,
bboss_cd:10,
victory:0,
once:6, //每波刷新怪物数量
total:120, //总怪物数
@@ -115,8 +118,13 @@ export class SingletonModuleComp extends ecs.Comp {
}
},
role:{
hp:3000,
hp_max:3000,
mission:1,
mission_finish:false,
mission_num:0,
mission_num_max:5,
hero_num:12,
hp:300,
hp_max:300,
speed:60,
atk:10,
atk_dis:100,

View File

@@ -49,3 +49,4 @@ export const MissionSet = {
lv5_skill_num:10,
}
}
export const MissionReward = []

View File

@@ -44,8 +44,8 @@ export class CardControllerComp extends CCComp {
protected onLoad(): void {
// oops.message.on("do_reward", this.do_reward, this)
oops.message.on("minssion_victory", this.do_minssion_victory, this)
oops.message.on("minssion_defeat", this.do_minssion_defeat, this)
oops.message.on("to_mission", this.to_mission, this)
}
start() {
@@ -72,39 +72,6 @@ export class CardControllerComp extends CCComp {
}
}
do_minssion_victory(){
this.node.getChildByName("victory").active=true
this.to_mission()
}
do_minssion_defeat(){
this.node.getChildByName("defeat").active=true
this.to_mission()
}
end_mission(){
this.node.getChildByName("victory").active=false
this.node.getChildByName("defeat").active=false
console.log("end_mission")
}
empty_mission(){
let monsters:any= ecs.query(ecs.allOf(MonViewComp));
let heros:any= ecs.query(ecs.allOf(HeroViewComp));
let roles:any= ecs.query(ecs.allOf(RoleViewComp));
let boss:any= ecs.query(ecs.allOf(BossViewComp));
for(let i=0;i<monsters.length;i++){
monsters[i].MonView.ent.destroy()
}
for(let i=0;i<heros.length;i++){
heros[i].HeroView.ent.destroy()
}
for(let i=0;i<roles.length;i++){
roles[i].RoleView.ent.destroy()
}
for(let i=0;i<boss.length;i++){
boss[i].BossView.ent.destroy()
}
}
normal_call(){
if(smc.vm_data.mission.coin >= smc.vm_data.mission.normal_cost){
smc.vm_data.mission.coin -= smc.vm_data.mission.normal_cost

View File

@@ -32,21 +32,24 @@ export class MapMonsterComp extends CCComp {
refresh_timer: Timer = new Timer(5); // 刷新怪物定时器
refresh_cd: Timer = new Timer(0.5);
mission_up_timer: Timer = new Timer(30); //波次增加
boss_timer: Timer = new Timer(10);
boss_num:number = 1;
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
boss_list:any = []
setp_timer: Timer = new Timer(0.2);
setp_timer: Timer = new Timer(0.3);
call_hero_timer: Timer = new Timer(0.3);
target_timer: Timer = new Timer(0.1);
setp_num:number = smc.vm_data.mission.once;
total:number = smc.vm_data.mission.total;
total:number = 0;
hero_total:number = 0;
reward:number = 0;
reward_num:number = 0;
game_over:boolean = false;
start_ys:any[] = [70,0,-70];
hero_start_ys:any[] = [35,-35];
start_ys:any[] = [0,70,-70];
mon_index:number = 0
hero_index:number = 0
hero_x:number = 0;
@property(Node)
start_p: Node = null;
@@ -66,13 +69,8 @@ export class MapMonsterComp extends CCComp {
var scene = smc.map.MapView.scene;
this.start_p.parent=scene.mapLayer!.node!
this.set_start_point()
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
this.cur_mission = num[0]
this.mission_list = MonsetList[this.cur_mission]
this.boss_list = BossList[this.cur_mission]
// console.log("当前关卡方案",this.cur_mission,this.mission_list)
this.refresh_timer= new Timer(smc.vm_data.mission.refresh_timer);
smc.vm_data.mission.m_less=smc.vm_data.mission.m_alive=JSON.parse(JSON.stringify(this.total));
}
protected update(dt: number): void {
@@ -83,6 +81,14 @@ export class MapMonsterComp extends CCComp {
if(this.total<=0) return
this.monster_refresh()
}
if(this.call_hero_timer.update(dt)){
if(this.hero_total <= 0) return
this.on_normal_call()
}
if(this.boss_timer.update(dt)){
if(this.boss_num <=0 ) return
this.load_boss()
}
this.is_reward()
if (this.refresh_timer.update(dt)) {
this.setp_num=smc.vm_data.mission.once
@@ -100,12 +106,26 @@ export class MapMonsterComp extends CCComp {
// this.shuaxin(dt)
}
mission_start(){
this.total=smc.vm_data.mission.m_less=smc.vm_data.mission.m_alive=smc.vm_data.mission.total;
this.hero_total=smc.vm_data.role.hero_num
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
this.cur_mission = num[0]
this.mission_list = MonsetList[this.cur_mission]
this.boss_list = BossList[this.cur_mission]
// console.log("当前关卡方案",this.cur_mission,this.mission_list)
this.refresh_timer= new Timer(smc.vm_data.mission.refresh_timer);
this.boss_num=1
this.boss_timer = new Timer(smc.vm_data.mission.boss_cd)
this.hero_x=0
this.hero_index=0
smc.vm_data.mission.coin = 0
this.load_role()
this.load_boss()
}
on_normal_call(){
let hero:any =RandomManager.instance.getRandomByObjectList(smc.cards, 1);
this.addHero(hero[0].uuid)
this.hero_total -= 1
}
on_better_call(){
let hero:any =RandomManager.instance.getRandomByObjectList(smc.cards, 1);
@@ -127,7 +147,7 @@ export class MapMonsterComp extends CCComp {
this.mon_index = 0
}
smc.vm_data.mission.m_less=this.total -= 1
this.setp_num -= 1
// this.setp_num -= 1
}
is_reward(){
if(smc.vm_data.mission.reward_num < smc.vm_data.mission.reward) return
@@ -223,17 +243,18 @@ export class MapMonsterComp extends CCComp {
private addHero(uuid:number=1001) {
let hero = ecs.getEntity<Hero>(Hero);
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(-240,BoxSet.GAME_LINE+this.start_ys[this.hero_index]);
let pos:Vec3 = v3(-210-this.hero_x*30,BoxSet.GAME_LINE+this.start_ys[this.hero_index]);
let monster_layer = scene.entityLayer!.node!
let scale = 1
hero.load(pos,scale,uuid,monster_layer);
this.hero_index += 1
if(this.hero_index > 2){
this.hero_index = 0
this.hero_x +=1
}
this.set_start_point()
}
load_boss(){
let bs:any = RandomManager.instance.getRandomByObjectList(this.boss_list[this.monster_level],1)
var scene = smc.map.MapView.scene;
@@ -242,6 +263,7 @@ export class MapMonsterComp extends CCComp {
let b = ecs.getEntity<Boss>(Boss);
let scale = -1
b.load(pos,scale,bs[0],layer);
this.boss_num -= 1
}
/** 视图层逻辑代码分离演示 */

View File

@@ -0,0 +1,69 @@
import { _decorator } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { MonViewComp } from "../mon/MonViewComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { RoleViewComp } from "../Role/RoleViewComp";
import { BossViewComp } from "../Boss/BossViewComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('VictoryComp')
@ecs.register('Victory', false)
export class VictoryComp extends CCComp {
/** 视图层逻辑代码分离演示 */
start() {
// console.log("VictoryComp start")
oops.message.on("minssion_victory", this.do_victiry, this);
oops.message.on("minssion_defeat", this.do_defeat, this);
}
private do_victiry() {
smc.vm_data.mission.play=false
if(smc.vm_data.role.mission%10==0){
smc.vm_data.role.mission_finish == true
}else{
smc.vm_data.role.mission += 1
}
this.node.getChildByName("Node").active = true;
this.node.getChildByName("Node").getChildByName("defeat").active = false
this.node.getChildByName("Node").getChildByName("victory").active = true;
}
private do_defeat() {
smc.vm_data.mission.play=false
this.node.getChildByName("Node").active = true;
this.node.getChildByName("Node").getChildByName("victory").active = false;
this.node.getChildByName("Node").getChildByName("defeat").active = true
}
end_mission(){
this.node.getChildByName("Node").active=false
this.empty_mission()
oops.message.dispatchEvent("to_mission")
console.log("end_mission")
}
empty_mission(){
let monsters:any= ecs.query(ecs.allOf(MonViewComp));
let heros:any= ecs.query(ecs.allOf(HeroViewComp));
let roles:any= ecs.query(ecs.allOf(RoleViewComp));
let boss:any= ecs.query(ecs.allOf(BossViewComp));
for(let i=0;i<monsters.length;i++){
monsters[i].MonView.ent.destroy()
}
for(let i=0;i<heros.length;i++){
heros[i].HeroView.ent.destroy()
}
for(let i=0;i<roles.length;i++){
roles[i].RoleView.ent.destroy()
}
for(let i=0;i<boss.length;i++){
boss[i].BossView.ent.destroy()
}
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "463c788d-edc9-436c-b06e-b89e9fa9642f",
"files": [],
"subMetas": {},
"userData": {}
}