继续
This commit is contained in:
@@ -53,6 +53,7 @@ export class Role extends ecs.Entity {
|
||||
let role=smc.vm_data.role;
|
||||
rv.hero_uuid=uuid;
|
||||
rv.speed =rv.ospeed = role.speed;
|
||||
rv.atk_dis = role.atk_dis;
|
||||
rv.hero_name= "role";
|
||||
rv.hp= rv.hp_max = role.hp*(1+smc.vm_data.talent[1].bonus*smc.vm_data.talent[1].lv);
|
||||
rv.level = role.lv;
|
||||
@@ -62,15 +63,15 @@ export class Role extends ecs.Entity {
|
||||
rv.s_boncus=1+smc.vm_data.talent[16].bonus*smc.vm_data.talent[16].lv;
|
||||
rv.power = role.power;
|
||||
rv.skill1 = role.skill1;
|
||||
rv.skill1.cd=rv.skill1.cd_max=1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv
|
||||
rv.skill1.cd=rv.skill1.cd_max=rv.skill1.cd_max*(1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv)
|
||||
rv.skill2 = role.skill2;
|
||||
rv.skill2.cd=rv.skill2.cd_max=1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv
|
||||
rv.skill2.cd=rv.skill2.cd_max=rv.skill1.cd_max*(1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv)
|
||||
rv.skill3 = role.skill3;
|
||||
rv.skill3.cd=rv.skill3.cd_max=1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv
|
||||
rv.skill3.cd=rv.skill3.cd_max=rv.skill1.cd_max*(1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv)
|
||||
rv.skill4 = role.skill4;
|
||||
rv.skill4.cd=rv.skill4.cd_max=1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv
|
||||
rv.skill4.cd=rv.skill4.cd_max=rv.skill1.cd_max*(1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv)
|
||||
rv.skill5 = role.skill5;
|
||||
rv.skill5.cd=rv.skill5.cd_max=1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv
|
||||
rv.skill5.cd=rv.skill5.cd_max=rv.skill1.cd_max*(1-smc.vm_data.talent[4].bonus*smc.vm_data.talent[4].lv)
|
||||
rv.skill = role.skill;
|
||||
rv.box_group = BoxSet.HERO;
|
||||
this.add(rv);
|
||||
|
||||
@@ -22,7 +22,7 @@ export class RoleSpine extends Component {
|
||||
private atk_name: string = "atk";
|
||||
private move_name: string = "move";
|
||||
private max_name: string = "max";
|
||||
private idel_name: string = "idle";
|
||||
private idel_name: string = "move";
|
||||
start() {
|
||||
this.spine.setAnimation(0, this.default, true);
|
||||
}
|
||||
@@ -45,9 +45,11 @@ export class RoleSpine extends Component {
|
||||
this.spine.setAnimation(0, this.atk_name, false);
|
||||
}
|
||||
idle(){
|
||||
this.default = this.idel_name;
|
||||
this.spine.setAnimation(0, this.idel_name, true);
|
||||
}
|
||||
move(){
|
||||
this.default = this.move_name;
|
||||
this.spine.setAnimation(0, this.move_name, true);
|
||||
}
|
||||
max(){
|
||||
|
||||
@@ -91,6 +91,7 @@ export class RoleViewComp extends CCComp {
|
||||
is_dead:boolean = false; //是否摧毁
|
||||
is_stop:boolean = false;
|
||||
is_atking:boolean = false;
|
||||
is_moving:boolean = false;
|
||||
type:number = 0;
|
||||
onLoad() {
|
||||
// this.BoxRang = this.node.getChildByName("range_box");
|
||||
@@ -131,14 +132,17 @@ export class RoleViewComp extends CCComp {
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
|
||||
|
||||
if(selfCollider.node.position.y < otherCollider.node.position.y){
|
||||
if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
|
||||
|
||||
selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
||||
// console.log(selfCollider.node.position.y+":role:hero:"+otherCollider.node.position.y);
|
||||
if(selfCollider.node.position.y <= otherCollider.node.position.y){
|
||||
if(selfCollider.node.getSiblingIndex() <= otherCollider.node.getSiblingIndex()){
|
||||
selfCollider.node.setSiblingIndex(200)
|
||||
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
|
||||
// console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
||||
|
||||
}else{
|
||||
selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()-1)
|
||||
selfCollider.node.setSiblingIndex(-1)
|
||||
// console.log("onPreSolve f:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -180,17 +184,41 @@ export class RoleViewComp extends CCComp {
|
||||
this.atk_time += dt;
|
||||
this.in_atk();
|
||||
this.skill_cds(dt);
|
||||
// this.move();
|
||||
this.move(dt);
|
||||
this.check_enemys()
|
||||
}
|
||||
skill_cds(dt:number){
|
||||
this.skill1.cd -= dt;
|
||||
if(this.skill1.alive) this.skill1.cd -= dt;
|
||||
if(this.skill2.alive) this.skill2.cd -= dt;
|
||||
if(this.skill3.alive) this.skill3.cd -= dt;
|
||||
if(this.skill4.alive) this.skill4.cd -= dt;
|
||||
if(this.skill5.alive) this.skill5.cd -= dt;
|
||||
|
||||
if(this.skill1.cd <= 0){
|
||||
this.shoot(this.skill1.uuid);
|
||||
this.skill1.cd=this.skill1.cd_max
|
||||
console.log("shoot uuid :"+this.skill1.uuid);
|
||||
}
|
||||
|
||||
}
|
||||
if(this.skill2.cd <= 0){
|
||||
this.shoot(this.skill2.uuid);
|
||||
this.skill2.cd=this.skill2.cd_max
|
||||
console.log("shoot uuid :"+this.skill2.uuid);
|
||||
}
|
||||
if(this.skill3.cd <= 0){
|
||||
this.shoot(this.skill3.uuid);
|
||||
this.skill3.cd=this.skill3.cd_max
|
||||
console.log("shoot uuid :"+this.skill3.uuid);
|
||||
}
|
||||
if(this.skill4.cd <= 0){
|
||||
this.shoot(this.skill4.uuid);
|
||||
this.skill4.cd=this.skill4.cd_max
|
||||
console.log("shoot uuid :"+this.skill4.uuid);
|
||||
}
|
||||
if(this.skill5.cd <= 0){
|
||||
this.shoot(this.skill5.uuid);
|
||||
this.skill5.cd=this.skill5.cd_max
|
||||
console.log("shoot uuid :"+this.skill5.uuid);
|
||||
}
|
||||
// this.skills.forEach((e:any) => {
|
||||
// if(e.cd > 0&&e.alive){
|
||||
// e.cd -= dt;
|
||||
@@ -222,41 +250,29 @@ export class RoleViewComp extends CCComp {
|
||||
this.enemy = v3(720,this.node.position.y);
|
||||
}
|
||||
}
|
||||
move(){
|
||||
move(dt:number){
|
||||
if(this.stop_cd > 0){
|
||||
this.as.idle()
|
||||
this.is_moving=false
|
||||
return
|
||||
}
|
||||
if(this.enemy){
|
||||
this.move_to(this.enemy.position)
|
||||
this.move_to()
|
||||
let move_x=1
|
||||
let move_y=1
|
||||
if(Math.abs(this.enemy.x - this.node.position.x) < this.atk_dis) move_x = 0
|
||||
if(Math.abs(this.enemy.y - this.node.position.y) < this.atk_dis) move_y = 0
|
||||
if(this.enemy.x < this.node.position.x){
|
||||
this.scale = -1
|
||||
}else{
|
||||
this.move_to(v3(0,0));
|
||||
this.scale = 1
|
||||
}
|
||||
this.node.setScale(this.scale,1);
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale*move_x, this.node.position.y+dt*this.speed*move_y, this.node.position.z);
|
||||
}
|
||||
move_to(enemy:Vec3){
|
||||
// console.log("move to ",enemy);
|
||||
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
|
||||
move.target = v3(enemy.x-100,enemy.y);
|
||||
move.node = this.node;
|
||||
move.speed = this.ospeed;
|
||||
if(enemy.x < this.node.position.x){
|
||||
this.node.setScale(-1,1);
|
||||
}else{
|
||||
this.node.setScale(1,1);
|
||||
}
|
||||
}
|
||||
shoot(skill_uuid:number,y:number=0,x:number=0){
|
||||
// console.log("mon shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let atk = smc.skills[skill_uuid].atk+this.atk+this.buff_atk+this.mission_atk;
|
||||
let {pos,t_pos}=this.get_enemy_pos()
|
||||
pos.y=pos.y + y
|
||||
pos.x=pos.x + x
|
||||
if(smc.skills[skill_uuid].type==11){
|
||||
pos.y=300
|
||||
t_pos.y=t_pos.y-300
|
||||
}
|
||||
skill.load(pos,this.box_group,this.node,skill_uuid,atk,t_pos);
|
||||
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
||||
move_to(){
|
||||
if(this.is_moving) return
|
||||
this.is_moving=true
|
||||
this.as.move()
|
||||
}
|
||||
//使用max_skill
|
||||
|
||||
@@ -298,6 +314,20 @@ export class RoleViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
shoot(skill_uuid:number,y:number=0,x:number=0){
|
||||
// console.log("mon shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let atk = smc.skills[skill_uuid].atk+this.atk+this.buff_atk+this.mission_atk;
|
||||
let {pos,t_pos}=this.get_enemy_pos()
|
||||
pos.y=pos.y + y
|
||||
pos.x=pos.x + x
|
||||
if(smc.skills[skill_uuid].type==11){
|
||||
pos.y=300
|
||||
t_pos.y=t_pos.y-300
|
||||
}
|
||||
skill.load(pos,this.box_group,this.node,skill_uuid,atk,t_pos,this.atk_dis);
|
||||
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
|
||||
}
|
||||
hp_change(hp: number){
|
||||
if(this.is_dead){
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user