This commit is contained in:
walkpan
2024-11-13 08:14:10 +08:00
parent 220f595ff6
commit 3f8cf727d9
16 changed files with 1680 additions and 106 deletions

View File

@@ -86,7 +86,7 @@ export class SingletonModuleComp extends ecs.Comp {
bboss_cd:10,
victory:0,
once:6, //每波刷新怪物数量
total:120, //总怪物数
total:1, //总怪物数
m_less:0,
m_alive:120,
g_level:1,

View File

@@ -59,11 +59,7 @@ export class Hero extends ecs.Entity {
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent=layer
// var as = node.getComponent(HeroSpine);
// let ratio=this.set_ratio(uuid);
// node.setScale(node.scale.x*scale*ratio, node.scale.y*ratio, 0);
// pos.x=smc.Role.RoleView.node.position.x+pos.x;
// pos.y=smc.Role.RoleView.node.position.y+pos.y;
node.setPosition(pos)
this.hero_init(uuid,node,index,scale,box_group)
oops.message.dispatchEvent("hero_load",this)
@@ -88,12 +84,12 @@ export class Hero extends ecs.Entity {
hv.max_skill_uuid = hero_set.max_skill_uuid;
hv.role_heros_index = index;
hv.type = hero_set.type;
hv.hp= hv.hp_max =Math.floor(hero_set.hp*(1+talents[1011].bonus*role_talent[1011].lv)*smc.vm_data.mission.hero.hp);
hv.atk = Math.floor(hero_set.atk*(1+talents[1012].bonus*role_talent[1012].lv))
hv.atk_cd = hero_set.atk_cd*(1-talents[1013].bonus*role_talent[1013].lv);
hv.st_boncus=1+talents[1015].bonus*role_talent[1015].lv;
hv.s_boncus=1+talents[1016].bonus*role_talent[1016].lv;
hv.power_max= hero_set.power_max*(1-talents[1014].bonus*role_talent[1014].lv);;
hv.hp= hv.hp_max =hero_set.hp;
hv.atk = hero_set.atk;
hv.atk_cd = hero_set.atk_cd
hv.st_boncus=1
hv.s_boncus=1
hv.power_max= hero_set.power_max
this.add(hv);
}
set_ratio(uuid:number){

View File

@@ -44,43 +44,53 @@ export class HeroSpine extends Component {
// console.log("mon spine init",this.animator);
}
in_playing(){
if(this.animator.getState(this.atk_clip.name).isPlaying) return true;
if(this.animator.getState(this.max_clip.name).isPlaying) return true;
if(this.animator.getState(this.idle_clip.name).isPlaying) return true;
if(this.animator.getState(this.move_clip.name).isPlaying) return true;
return false;
}
onAnimationEvent(type: Animation.EventType, state: AnimationState){
if(type==Animation.EventType.FINISHED){
console.log("animator end",state.name);
if(state.name==this.atk_clip.name||state.name==this.max_clip.name){
console.log("animator no atk and no max");
this.default();
}
}
}
change_default(value:string){
console.log("change default",value);
this.default_clip=value;
}
default() {
if(!this.animator.getState(this.default_clip).isPlaying){
if(!this.in_playing()){
console.log("do default");
this.animator.play(this.default_clip);
}
}
idle(){
if(!this.animator.getState(this.idle_clip.name).isPlaying){
if(!this.in_playing()){
console.log("do idle");
this.animator.play(this.idle_clip.name);
}
}
atk() {
if(!this.animator.getState(this.atk_clip.name).isPlaying){
this.animator.play(this.atk_clip.name);
}
console.log("do atk");
this.animator.play(this.atk_clip.name);
}
max(){
if(!this.animator.getState(this.max_clip.name).isPlaying){
console.log("do max");
this.animator.play(this.max_clip.name);
}
}
move(){
if(!this.animator.getState(this.move_clip.name).isPlaying){
if(!this.in_playing()){
console.log("do move");
this.animator.play(this.move_clip.name);
}
}

View File

@@ -99,7 +99,7 @@ export class HeroViewComp extends CCComp {
role_heros_index:number = -1;
anm_timer:Timer = new Timer(2);
anm_name="idle"
status:String = "idle"
onLoad() {
this.as = this.getComponent(HeroSpine);
// this.BoxRang = this.node.getChildByName("range_box");
@@ -124,10 +124,7 @@ export class HeroViewComp extends CCComp {
// this.BoxRang.getComponent(BoxRangComp).offset_x = 300;
// console.log("monseter ",this.BoxRang);
// console.log("monseter ",this.BoxRang);
// if(this.box_group == BoxSet.MON){
// this.enemy=smc.Role.RoleView.node
// // console.log("mon enemy ",this.enemy);
// }
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
@@ -185,7 +182,15 @@ export class HeroViewComp extends CCComp {
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
}
status_change(type:string){
if(this.status == type) return
this.status=type
if(type != "move"){
this.as.change_default("idle")
}else{
this.as.change_default("move")
}
}
update(dt: number){
if(!smc.vm_data.mission.play||smc.vm_data.pause){
@@ -194,18 +199,18 @@ export class HeroViewComp extends CCComp {
if (this.timer.update(dt)) {
this.power_change(this.power_speed)
}
if(this.anm_timer.update(dt)) {
this.change_anm()
}
// this.in_destroy();
// this.check_buff_atks(dt)
// this.in_shield(dt);
// this.in_stop(dt);
// this.atk_time += dt;
// this.check_enemy_alive()
// this.in_atk(dt);
// this.hp_show()
// this.move(dt);
// if(this.anm_timer.update(dt)) {
// this.change_anm()
// }
this.in_destroy();
this.check_buff_atks(dt)
this.in_shield(dt);
this.in_stop(dt);
this.atk_time += dt;
this.check_enemy_alive()
this.in_atk(dt);
this.hp_show()
this.move(dt);
// this.in_speek(dt);
@@ -266,8 +271,11 @@ export class HeroViewComp extends CCComp {
}
}
move(dt: number){
if(this.stop_cd > 0){
this.as.idle()
this.status_change("idle")
return
}
if (this.node.position.x >= 360 && this.scale==1) {
@@ -276,11 +284,14 @@ export class HeroViewComp extends CCComp {
if(this.scale===-1&&this.node.position.x <= -360){
return;
}
this.as.move()
this.status_change("move")
// if(this.enemy){
// return
// }
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
}
hp_show(){
if(this.hp == this.hp_max){
this.node.getChildByName("top").getChildByName("hp").active = false;
@@ -397,13 +408,7 @@ export class HeroViewComp extends CCComp {
}
if(t_hero){ //血量最少单体
if(smc.Role.RoleView){
let role_hp=smc.Role.RoleView.hp_max-smc.Role.RoleView.hp
if(role_hp > least_hp){
least_hp = role_hp
t_hero = smc.Role.RoleView
}
}
this.to_add_buff(t_hero,skill)
}
@@ -453,10 +458,10 @@ export class HeroViewComp extends CCComp {
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd/smc.vm_data.mission.hero.atk_cd){
if(this.atk_time >= this.atk_cd){
if(this.is_atking){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.handle_skill(this.skill_uuid)

View File

@@ -82,7 +82,7 @@ export class MapMonsterComp extends CCComp {
}
if(this.setp_timer.update(dt)){
if(this.total<=0) return
// this.monster_refresh()
this.monster_refresh()
}
if(this.call_hero_timer.update(dt)){
if(this.hero_total <= 0) return
@@ -90,7 +90,7 @@ export class MapMonsterComp extends CCComp {
}
if(this.boss_timer.update(dt)){
if(this.boss_num <=0 ) return
this.load_boss()
// this.load_boss()
}
this.is_reward()
if (this.refresh_timer.update(dt)) {
@@ -122,7 +122,6 @@ export class MapMonsterComp extends CCComp {
this.hero_x=0
this.hero_index=0
smc.vm_data.mission.coin = 0
// this.load_role()
}
on_mon_dead(){
let coin =(GameSet.MON_COIN_ADD*smc.vm_data.mission.coin_reward_add*(1+Talents[1006].bonus*smc.vm_data.talent[1006].lv)).toFixed(0)
@@ -190,10 +189,11 @@ export class MapMonsterComp extends CCComp {
count_mon_pos(){
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
for(let i=0;i<monsters.length;i++){
if(monsters[i].MonView == undefined) return
let mon:any = monsters[i].MonView.node.position
if(monsters[i].HeroView == undefined) return
let mon:any = monsters[i].HeroView.node.position
smc.enemy_pos[i].x= mon.x
}
console.log("count_mon_pos",smc.enemy_pos);
}
count_hero_pos(){
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
@@ -202,15 +202,9 @@ export class MapMonsterComp extends CCComp {
let ho:any = heros[i].HeroView.node.position
smc.hero_pos[i].x= ho.x
}
// console.log("count_hero_pos",smc.hero_pos);
}
load_role(){
let role = ecs.getEntity<Role>(Role);
let pos = v3(BoxSet.HERO_START-100,BoxSet.GAME_LINE-5)
role.load(pos,109)
smc.Role=role
// console.log("加载玩家",role)
console.log("count_hero_pos",smc.hero_pos);
}
private on_do_add_hero(event: string, args: any) {
this.addHero(args.uuid)
}

View File

@@ -41,15 +41,7 @@ export class MapSkillComp extends CCComp {
}
useItem(event: string, args: any){
console.log("useItem");
if(smc.sitems[args.uuid].hp > 0){ //buff加血
smc.Role.RoleView.add_hp(smc.sitems[args.uuid].hp)
}
if(smc.sitems[args.uuid].atk > 0){ //buff加攻击
smc.Role.RoleView.add_atk(smc.sitems[args.uuid].atk,smc.sitems[args.uuid].sd)
}
if(smc.sitems[args.uuid].shield > 0){ //buff护盾
smc.Role.RoleView.add_shield(smc.sitems[args.uuid].shield,smc.sitems[args.uuid].sd)
}
}
/** 视图层逻辑代码分离演示 */
start() {

View File

@@ -106,10 +106,7 @@ export class MonViewComp extends CCComp {
// this.BoxRang.getComponent(BoxRangComp).offset_x = 300;
// console.log("monseter ",this.BoxRang);
// console.log("monseter ",this.BoxRang);
// if(this.box_group == BoxSet.MON){
// this.enemy=smc.Role.RoleView.node
// // console.log("mon enemy ",this.enemy);
// }
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
@@ -172,10 +169,7 @@ export class MonViewComp extends CCComp {
this.in_atk(dt);
this.hp_show()
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
// }
}
check_enemy_alive(){
let dir = 320
@@ -222,12 +216,7 @@ export class MonViewComp extends CCComp {
set_diry(){
this.dir_y=-(this.node.position.y-BoxSet.GAME_LINE)/20
}
move_to(){
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(smc.Role.RoleView.node.position.x+10,smc.Role.RoleView.node.position.y);
move.node = this.node;
move.speed = this.ospeed;
}
power_change(power: number){
if(this.max_skill_uuid == 0){
return

View File

@@ -74,7 +74,7 @@ export class CSkillComp extends CCComp {
angle = randian * (180 / Math.PI);
let scale = this.scale
let atk = smc.skills[this.skill_uuid].atk+this.atk;
skill.load(pos,scale,this.node,this.skill_uuid,atk,angle,t_pos);
skill.load(pos,scale,this.node,this.skill_uuid,atk,t_pos);
}
add_buff(){
// 1 远距离攻击,碰撞后 结束
@@ -89,7 +89,7 @@ export class CSkillComp extends CCComp {
// 94role 临时buff
// 95role 永久buff
let uuid= this.skill_uuid;
let atk:number=smc.Role.RoleView.atk?smc.Role.RoleView.atk:0
let atk:number=0
let args:any = {
atk:atk*GameSet.ATK_TO_ATK_RATIO,
hp:atk*GameSet.ATK_TO_HP_RATIO,