技能系统还要,伤害逻辑交给碰撞系统处理
This commit is contained in:
@@ -55,22 +55,10 @@ export class Hero extends ecs.Entity {
|
||||
hv.hero_name= hero.name;
|
||||
hv.speed =hv.ospeed = hero.speed;
|
||||
hv.dis = hero.dis;
|
||||
hv.pw = hero.pw;
|
||||
hv.pwm= hero.pwm;
|
||||
hv.pws= hero.pws
|
||||
hv.apw=hero.apw;
|
||||
hv.uapw=hero.uapw;
|
||||
hv.cpw=hero.cpw;
|
||||
hv.dpw=hero.dpw;
|
||||
hv.dopw=hero.dopw;
|
||||
let slv= Math.floor(( hv.lv) / 5);
|
||||
hv.hp= hv.hp_max =hero.hp;
|
||||
hv.ap = hero.ap;
|
||||
hv.def= hero.def;
|
||||
hv.cd = hero.a_cd
|
||||
hv.crit = hero.crit; //暴击率
|
||||
hv.crit_add = hero.crit_add;//暴击伤害加成
|
||||
hv.dodge = hero.dodge; //闪避率
|
||||
hv.atk_skill=hero.skills[0]
|
||||
this.add(hv);
|
||||
|
||||
// 初始化多个技能组件
|
||||
|
||||
@@ -51,45 +51,17 @@ export class HeroViewComp extends CCComp {
|
||||
hp: number = 100; /** 血量 */
|
||||
hp_max: number = 100; /** 最大血量 */
|
||||
hp_speed: number = 0; //每秒回复量
|
||||
|
||||
pw: number = 0; // 当前能量值
|
||||
pwm: number = 100; // 最大能量值
|
||||
pws: number = 1; //能量回复速度每0.1秒回复量
|
||||
apw:number=0;
|
||||
uapw:number=0;
|
||||
cpw:number=0;
|
||||
dopw:number=0;
|
||||
dpw:number=0;
|
||||
|
||||
pwt:Timer = new Timer(1); //计时器
|
||||
|
||||
akr:number=0; //攻击触发机率
|
||||
uar:number=0; //受伤触发机率
|
||||
dgr:number=0; //闪避触发机率
|
||||
crr:number=0; //暴击触发机率
|
||||
akc:number=0; //攻击次数触发
|
||||
uac:number=0; //受伤次数触发
|
||||
dgc:number=0; //闪避次数触发
|
||||
crc:number=0; //暴击次数触发
|
||||
|
||||
aexp:number=0; //攻击经验
|
||||
uaexp:number=0; //受伤经验
|
||||
cexp:number=0; //暴击经验 */
|
||||
doexp:number=0; //闪避经验 */
|
||||
dexp:number=0; //死亡经验 */
|
||||
|
||||
ap: number = 10; /**攻击力 */
|
||||
ap_buff: number = 0;
|
||||
ap_buffs:any = [];
|
||||
// atk_speed: number = 1;
|
||||
cd: number = 1.3; /**攻击速度 攻击间隔 */
|
||||
dis: number = 80;
|
||||
at: number = 0; /** 冷却时间 */
|
||||
|
||||
atk_skill:number=0;
|
||||
def: number = 0; //防御
|
||||
vun: number = 0; //易伤
|
||||
|
||||
crit: number = 0; //暴击率
|
||||
crit_add: number = 0;//暴击伤害加成
|
||||
dodge: number = 10; //闪避率
|
||||
|
||||
|
||||
@@ -99,9 +71,6 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
atk_count: number = 0;
|
||||
atked_count: number = 0;
|
||||
dodge_count: number = 0;
|
||||
crit_count: number = 0;
|
||||
|
||||
|
||||
stop_cd: number = 0; /*停止倒计时*/
|
||||
yun_cd: number = 0; //眩晕倒计时
|
||||
@@ -139,18 +108,12 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞开始 ",this.scale,seCol,oCol);
|
||||
|
||||
|
||||
}
|
||||
|
||||
onEndContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞结束 ",this.scale,seCol,oCol);
|
||||
}
|
||||
onPreSolve (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞预处理 ",this.scale,seCol,oCol);
|
||||
}
|
||||
|
||||
onPostSolve (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞后处理 ",this.scale,seCol,oCol);
|
||||
}
|
||||
onEndContact (seCol: Collider2D, oCol: Collider2D) { console.log("碰撞结束 ",this.scale,seCol,oCol);}
|
||||
onPreSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞预处理 ",this.scale,seCol,oCol);}
|
||||
onPostSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞后处理 ",this.scale,seCol,oCol); }
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
@@ -172,9 +135,6 @@ export class HeroViewComp extends CCComp {
|
||||
if(!this.in_grave()) this.to_grave()
|
||||
return
|
||||
}
|
||||
if (this.pwt.update(dt)) {
|
||||
this.pw+=this.pws
|
||||
}
|
||||
this.hp_show()
|
||||
if(this.ice_cd > 0){
|
||||
this.ice_cd -=dt;
|
||||
@@ -240,27 +200,6 @@ export class HeroViewComp extends CCComp {
|
||||
this.ap -= Math.floor(ap);
|
||||
this.BUFFCOMP.buff_get("deap")
|
||||
}
|
||||
add_def(def: number){
|
||||
this.def += Math.floor(def);
|
||||
this.BUFFCOMP.buff_get("def")
|
||||
}
|
||||
de_def(def: number){
|
||||
this.def -= Math.floor(def);
|
||||
this.BUFFCOMP.buff_get("dedef")
|
||||
}
|
||||
/**
|
||||
* 增加英雄的暴击率。
|
||||
* @param crit 要增加的暴击率。
|
||||
*/
|
||||
|
||||
add_crit(critRate: number) {
|
||||
this.crit += Math.floor(critRate);
|
||||
this.BUFFCOMP.buff_get("crit");
|
||||
}
|
||||
de_crit(critRate: number) {
|
||||
this.crit += Math.floor(critRate);
|
||||
this.BUFFCOMP.buff_get("decrit");
|
||||
}
|
||||
/**
|
||||
* 增加英雄的闪避率。
|
||||
* @param dodge 要增加的闪避率。
|
||||
@@ -293,8 +232,7 @@ export class HeroViewComp extends CCComp {
|
||||
add_hp2(hprate: number=0){
|
||||
this.hp += Math.floor(hprate/100*this.hp_max) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 静止时间 */
|
||||
in_stop (dt: number) {
|
||||
if(this.stop_cd > 0){
|
||||
@@ -315,9 +253,6 @@ export class HeroViewComp extends CCComp {
|
||||
let Drops = getMonsterDrops(1, MonsterType.Normal, 1.2);
|
||||
if(this.is_boss) Drops =getMonsterDrops(1, MonsterType.Elite, 1.2);
|
||||
if(this.is_big_boss) Drops =getMonsterDrops(1, MonsterType.Boss, 1.2);
|
||||
|
||||
|
||||
|
||||
}
|
||||
//进入墓地
|
||||
to_grave(){
|
||||
@@ -329,13 +264,11 @@ export class HeroViewComp extends CCComp {
|
||||
in_grave(){
|
||||
return this.node.position.y <= -900;
|
||||
}
|
||||
|
||||
to_alive(){
|
||||
let pos =v3(HeroSet.StartPos[this.type],this.node.position.y,this.node.position.z)
|
||||
this.node.setPosition(pos)
|
||||
this.revive()
|
||||
}
|
||||
|
||||
to_console(value:any,value2:any=null,value3:any=null){
|
||||
console.log("["+this.scale+this.hero_name+']'+value,value2,value3)
|
||||
}
|
||||
@@ -343,7 +276,6 @@ export class HeroViewComp extends CCComp {
|
||||
this.is_dead = false;
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
playSkillEffect(skill_id:number) {
|
||||
let skill = SkillSet[skill_id]
|
||||
switch(skill.act){
|
||||
@@ -357,7 +289,6 @@ export class HeroViewComp extends CCComp {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public revive() {
|
||||
this.hp = this.hp_max;
|
||||
const skills = this.ent.get(HeroSkillsComp);
|
||||
|
||||
Reference in New Issue
Block a user