角色buff 动画控制交由 buffcomp
This commit is contained in:
@@ -22,13 +22,14 @@ import { Tooltip } from "../skills/Tooltip";
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { TimerManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/TimerManager";
|
||||
import { HeroSet } from "../common/config/heroSet";
|
||||
import { BuffComp } from "./BuffComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 角色显示组件 */
|
||||
@ccclass('HeroViewComp') // 定义为 Cocos Creator 组件
|
||||
@ecs.register('HeroView', false) // 定义为 ECS 组件
|
||||
export class HeroViewComp extends CCComp {
|
||||
|
||||
BUFFCOMP:any=null!;
|
||||
enemy_pos:Vec3=null!;
|
||||
enemy:any=null!;
|
||||
|
||||
@@ -127,7 +128,10 @@ export class HeroViewComp extends CCComp {
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
|
||||
start () {
|
||||
|
||||
this.as.idle()
|
||||
this.BUFFCOMP=this.node.getComponent(BuffComp);
|
||||
|
||||
/** 方向 */
|
||||
this.node.setScale(this.scale,1);
|
||||
this.node.getChildByName("top").setScale(this.scale,1);
|
||||
@@ -218,7 +222,6 @@ export class HeroViewComp extends CCComp {
|
||||
this.at += dt;
|
||||
this.check_enemy_alive()
|
||||
this.in_atk(dt);
|
||||
this.hp_show()
|
||||
this.move(dt);
|
||||
this.check_mission_buf()
|
||||
}
|
||||
@@ -311,15 +314,6 @@ export class HeroViewComp extends CCComp {
|
||||
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(){
|
||||
let hp_progress= this.hp/this.rhp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
if(this.hp == this.rhp_max){
|
||||
this.node.getChildByName("top").getChildByName("hp").active = false;
|
||||
} else{
|
||||
this.node.getChildByName("top").getChildByName("hp").active = true;
|
||||
}
|
||||
}
|
||||
skill_pos(){
|
||||
return v3(0,35)
|
||||
}
|
||||
@@ -360,8 +354,8 @@ export class HeroViewComp extends CCComp {
|
||||
if(skill.is_crit){
|
||||
l_hp = l_hp * (150+skill.crit_add)/100
|
||||
}
|
||||
l_hp=-1*Math.ceil(l_hp)
|
||||
this.hp_change(l_hp,skill.is_crit);
|
||||
l_hp=Math.ceil(l_hp)
|
||||
this.hp_less(l_hp,skill.is_crit);
|
||||
}
|
||||
//能量判断
|
||||
check_power(){
|
||||
@@ -389,7 +383,7 @@ export class HeroViewComp extends CCComp {
|
||||
{
|
||||
let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
if(i < this.crit_max){
|
||||
this.tooltip(5,"*会心一击*");
|
||||
this.BUFFCOMP.tooltip(5,"*会心一击*");
|
||||
this.crit_count += 1
|
||||
this.exp_add(this.cexp) // 暴击经验
|
||||
this.power_add(this.cpw)
|
||||
@@ -409,7 +403,7 @@ export class HeroViewComp extends CCComp {
|
||||
let i = RandomManager.instance.getRandomInt(0,100,3)
|
||||
if(i < this.dodge_max){
|
||||
// console.log("闪避触发: i="+i+":dodge="+dodge);
|
||||
this.tooltip(5,"闪避");
|
||||
this.BUFFCOMP.tooltip(5,"闪避");
|
||||
this.exp_add(this.doexp) // 闪避经验
|
||||
this.power_add(this.dopw)
|
||||
this.dodge_count += 1
|
||||
@@ -512,7 +506,7 @@ export class HeroViewComp extends CCComp {
|
||||
handle_skill(skill:number){
|
||||
this.as.max()
|
||||
this.at = 0;
|
||||
this.tooltip(3,SkillSet[skill].name,skill);
|
||||
this.BUFFCOMP.tooltip(3,SkillSet[skill].name,skill);
|
||||
|
||||
switch (SkillSet[skill].tg) {
|
||||
case 0: //自己
|
||||
@@ -605,52 +599,30 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
}
|
||||
|
||||
to_speek(words:string,time:number=0.5){
|
||||
this.speek_time=0.5
|
||||
this.node.getChildByName("tooltip").active=true
|
||||
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = words
|
||||
}
|
||||
in_speek(dt: number){
|
||||
if(this.speek_time <= 0){
|
||||
return;
|
||||
}
|
||||
this.speek_time -= dt;
|
||||
if(this.speek_time <= 0){
|
||||
this.speek_time = 0;
|
||||
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = "";
|
||||
this.node.getChildByName("tooltip").active=false;
|
||||
}
|
||||
}
|
||||
|
||||
heathed(){
|
||||
this.node.getChildByName("heathed").active=true
|
||||
}
|
||||
hp_max_add(){
|
||||
console.log("hp_max_add 动画");
|
||||
}
|
||||
add_hp(hp: number=0){
|
||||
this.heathed();
|
||||
this.BUFFCOMP.heathed();
|
||||
this.hp+=hp;
|
||||
if(this.hp > this.rhp_max){
|
||||
this.hp = this.rhp_max;
|
||||
}
|
||||
this.tooltip(2,hp.toFixed(0));
|
||||
this.BUFFCOMP.tooltip(2,hp.toFixed(0));
|
||||
}
|
||||
add_hp_max(hp: number=0){
|
||||
this.hp_max_add()
|
||||
this.hp += hp/100*this.hp_max;
|
||||
}
|
||||
hp_change(hp: number,is_crit:boolean=false){
|
||||
hp_less(hp: number,is_crit:boolean=false){
|
||||
if(this.is_dead){
|
||||
return;
|
||||
}
|
||||
|
||||
this.hp += hp;
|
||||
|
||||
this.hp -= hp;
|
||||
if(is_crit){
|
||||
this.tooltip(4,hp.toFixed(0),250);
|
||||
this.BUFFCOMP.tooltip(4,hp.toFixed(0),250);
|
||||
}else{
|
||||
this.tooltip(1,hp.toFixed(0),250);
|
||||
this.BUFFCOMP.tooltip(1,hp.toFixed(0),250);
|
||||
}
|
||||
|
||||
if(this.hp > this.rhp_max){
|
||||
@@ -692,18 +664,7 @@ export class HeroViewComp extends CCComp {
|
||||
add_shield(shield:number){
|
||||
this.shield =shield
|
||||
console.log("shield:",shield);
|
||||
if(this.shield > 0){
|
||||
this.node.getChildByName("shielded").active=true
|
||||
}
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=90){
|
||||
// console.log("tooltip",type);
|
||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
||||
let pos = v3(0,0);
|
||||
pos.y=pos.y+y;
|
||||
tip.load(pos,type,value,s_uuid,this.node);
|
||||
}
|
||||
|
||||
/** 静止时间 */
|
||||
in_stop (dt: number) {
|
||||
if(this.stop_cd > 0){
|
||||
@@ -716,24 +677,14 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
|
||||
in_atked() {
|
||||
var path = "game/skills/atked";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let pos =v3(15,30);
|
||||
node.setPosition(pos)
|
||||
node.parent = this.node;
|
||||
this.BUFFCOMP.in_atked()
|
||||
// this.as.atked();
|
||||
this.atked_count++;
|
||||
this.exp_add(this.uaexp)
|
||||
this.power_add(this.uapw)
|
||||
}
|
||||
dead(){
|
||||
var path = "game/skills/dead";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let pos = v3(this.node.position.x,this.node.position.y+30,this.node.position.z);
|
||||
node.parent = this.node;
|
||||
node.setPosition(pos);
|
||||
this.BUFFCOMP.dead()
|
||||
this.exp_add(this.dexp)
|
||||
this.power_add(this.dpw)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user