dd
This commit is contained in:
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user