释放技能动画 设定在技能参数中+伤害系统建立
This commit is contained in:
@@ -80,11 +80,11 @@ export class BuffComp extends Component {
|
||||
}
|
||||
|
||||
|
||||
max_show(){
|
||||
// this.node.getChildByName("max").active=true
|
||||
// this.scheduleOnce(()=>{
|
||||
// this.node.getChildByName("max").active=false
|
||||
// },0.8)
|
||||
max_show(name:string){
|
||||
var path = "game/skills/"+name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = this.node;
|
||||
}
|
||||
show_do_buff(name:string){
|
||||
var path = "game/skills/"+name;
|
||||
|
||||
@@ -49,12 +49,30 @@ export class HeroSpine extends Component {
|
||||
// console.log("do max");
|
||||
this.anm.max()
|
||||
}
|
||||
play(name:string){
|
||||
switch(name){
|
||||
case "max":
|
||||
this.max()
|
||||
break
|
||||
case "atk":
|
||||
this.atk()
|
||||
break
|
||||
case "idle":
|
||||
this.idle()
|
||||
break
|
||||
case "move":
|
||||
this.move()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
move(){
|
||||
// console.log("doing move");
|
||||
if(this.status=="move") return
|
||||
this.status="move"
|
||||
this.anm.move()
|
||||
}
|
||||
|
||||
atked() {
|
||||
// console.log("do atked");
|
||||
this.anm.atked()
|
||||
|
||||
@@ -177,18 +177,39 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
//受伤判断
|
||||
check_uatk(skill:any){
|
||||
check_uatk(damage:number,is_crit:boolean){
|
||||
|
||||
if(this.check_dodge()) return
|
||||
this.in_atked();
|
||||
let l_hp=this.check_less(skill.ap,skill.is_crit,skill.crit_add)
|
||||
this.check_debuff(skill,l_hp)
|
||||
let l_hp=damage
|
||||
// this.check_debuff(skill,l_hp)
|
||||
if(this.shield > 0){
|
||||
this.shield -=1
|
||||
if(this.shield == 0) this.BUFFCOMP.show_shield(false)
|
||||
l_hp = 0
|
||||
this.shield -= damage
|
||||
if(this.shield <= 0) {
|
||||
l_hp = -this.shield
|
||||
this.shield = 0
|
||||
this.BUFFCOMP.show_shield(false)
|
||||
}
|
||||
}
|
||||
this.hp_less(l_hp,is_crit);
|
||||
}
|
||||
hp_less(hp: number,is_crit:boolean=false){
|
||||
if(this.is_dead) return
|
||||
hp=Math.floor(hp)
|
||||
this.hp -= hp
|
||||
if(is_crit){
|
||||
this.BUFFCOMP.tooltip(4,hp.toFixed(0),250);
|
||||
}else{
|
||||
this.BUFFCOMP.tooltip(1,hp.toFixed(0),250);
|
||||
}
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
}
|
||||
if(this.hp <= 0){
|
||||
this.dead();
|
||||
this.to_grave()
|
||||
this.is_dead = true;
|
||||
}
|
||||
this.hp_less(l_hp,skill.is_crit);
|
||||
}
|
||||
check_less(ap:number,is_crit:boolean,crit_add:number=0){
|
||||
let d=this.def/ap
|
||||
@@ -455,24 +476,7 @@ export class HeroViewComp extends CCComp {
|
||||
this.hp += Math.floor(hprate/100*this.hp_max) ;
|
||||
}
|
||||
|
||||
hp_less(hp: number,is_crit:boolean=false){
|
||||
if(this.is_dead) return
|
||||
hp=Math.floor(hp)
|
||||
this.hp -= hp
|
||||
if(is_crit){
|
||||
this.BUFFCOMP.tooltip(4,hp.toFixed(0),250);
|
||||
}else{
|
||||
this.BUFFCOMP.tooltip(1,hp.toFixed(0),250);
|
||||
}
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
}
|
||||
if(this.hp <= 0){
|
||||
this.dead();
|
||||
this.to_grave()
|
||||
this.is_dead = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** 静止时间 */
|
||||
in_stop (dt: number) {
|
||||
if(this.stop_cd > 0){
|
||||
@@ -548,8 +552,18 @@ export class HeroViewComp extends CCComp {
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
playSkillEffect() {
|
||||
this.as.max()
|
||||
playSkillEffect(skill_id:number) {
|
||||
let skill = SkillSet[skill_id]
|
||||
switch(skill.act){
|
||||
case "max":
|
||||
this.as.max()
|
||||
this.BUFFCOMP.max_show(skill.fname)
|
||||
this.BUFFCOMP.tooltip(3,skill.name,skill_id)
|
||||
break
|
||||
case "atk":
|
||||
this.as.atk()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public revive() {
|
||||
|
||||
@@ -19,18 +19,21 @@ import { HeroInfo } from "../common/config/heroSet";
|
||||
import { Talents } from "../common/config/TalentSet";
|
||||
import { MonModelComp } from "./MonModelComp";
|
||||
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
|
||||
import { HeroSkillsComp } from "../skill/heroSkillsComp";
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Monster`)
|
||||
export class Monster extends ecs.Entity {
|
||||
// 数据层
|
||||
MonModelComp!: MonModelComp;
|
||||
// 视图层
|
||||
HeroView!: HeroViewComp;
|
||||
|
||||
HeroModel!: MonModelComp;
|
||||
HeroView!: HeroViewComp;
|
||||
BattleMove!: BattleMoveComp;
|
||||
HeroSkills!: HeroSkillsComp;
|
||||
|
||||
protected init() {
|
||||
|
||||
|
||||
this.addComponents<ecs.Comp>(
|
||||
BattleMoveComp,
|
||||
HeroSkillsComp,
|
||||
MonModelComp
|
||||
);
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
@@ -99,25 +102,42 @@ export class Monster extends ecs.Entity {
|
||||
hv.dexp=hero.dexp;
|
||||
|
||||
this.add(hv);
|
||||
// 初始化多个技能组件
|
||||
const skillsComp = this.get(HeroSkillsComp);
|
||||
// 正确初始化已有技能
|
||||
hero.skills.forEach(skillId => {
|
||||
this.addSkill(skillId); // 使用addSkill方法确保初始化
|
||||
});
|
||||
|
||||
// 初始化移动参数
|
||||
const move = this.get(BattleMoveComp);
|
||||
move.direction = 1; // 向右移动
|
||||
move.targetX = 800; // 右边界
|
||||
}
|
||||
set_ratio(uuid:number){
|
||||
let ratio=1;
|
||||
switch (HeroInfo[uuid].level) {
|
||||
case 2:
|
||||
ratio=1.05
|
||||
break;
|
||||
case 3:
|
||||
ratio=1.1
|
||||
break;
|
||||
case 4:
|
||||
ratio=1.15
|
||||
break;
|
||||
case 5:
|
||||
ratio=1.2
|
||||
break;
|
||||
default:
|
||||
ratio=1
|
||||
// 添加技能
|
||||
public addSkill(skillId: number) {
|
||||
const comp = this.get(HeroSkillsComp);
|
||||
if (comp.skills.indexOf(skillId) === -1) {
|
||||
comp.skills.push(skillId);
|
||||
comp.cooldowns.set(skillId, 0);
|
||||
comp.counters.set(skillId, 0);
|
||||
console.log(`技能${skillId}初始化完成`,
|
||||
'当前cooldowns:', comp.cooldowns,
|
||||
'当前counters:', comp.counters);
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
|
||||
// 移除技能
|
||||
public removeSkill(skillId: number) {
|
||||
const comp = this.get(HeroSkillsComp);
|
||||
comp.skills = comp.skills.filter(id => id !== skillId);
|
||||
}
|
||||
|
||||
public levelUp() {
|
||||
// ...升级逻辑...
|
||||
const comp = this.get(HeroSkillsComp);
|
||||
comp.skills.forEach(skillId => {
|
||||
comp.resetCooldown(skillId);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user