245 lines
8.8 KiB
TypeScript
245 lines
8.8 KiB
TypeScript
import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, tween, v3, Vec3 } from 'cc';
|
|
import { oops } from 'db://oops-framework/core/Oops';
|
|
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
|
import { Tooltip } from '../skills/Tooltip';
|
|
import { timedCom } from '../skills/timedCom';
|
|
import { smc } from '../common/SingletonModuleComp';
|
|
import { BuffGet } from '../skills/BuffGet';
|
|
import { HeroViewComp } from './HeroViewComp';
|
|
import { FightConComp } from '../map/FightConComp';
|
|
import { BuffAttr, DebuffAttr } from '../common/config/SkillSet';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('BuffComp')
|
|
export class BuffComp extends Component {
|
|
top_node:any=null;
|
|
ap_node:any=null;
|
|
cd_node:any=null;
|
|
def_node:any=null;
|
|
hp_node:any=null;
|
|
crit_node:any=null;
|
|
ap_cd:number=0;
|
|
cd_cd:number=0;
|
|
def_cd:number=0;
|
|
hp_cd:number=0;
|
|
crit_cd:number=0;
|
|
|
|
deap_cd:number=0;
|
|
decd_cd:number=0;
|
|
dedef_cd:number=0;
|
|
dehp_cd:number=0;
|
|
decrit_cd:number=0;
|
|
|
|
buff_cd:number=0;
|
|
wind_cd:number=0;
|
|
speek_time:number=0;
|
|
HeroView:HeroViewComp=null!
|
|
FIGHTCON:FightConComp=null!
|
|
start() {
|
|
this.info_init()
|
|
}
|
|
|
|
info_init(){
|
|
this.HeroView=this.node.getComponent(HeroViewComp)
|
|
this.FIGHTCON=this.node.parent.getComponent(FightConComp)
|
|
this.top_node = this.node.getChildByName("top");
|
|
this.top_node.getChildByName("lv").active=false
|
|
// this.top_node.getChildByName("hp").active=(this.node.getComponent(HeroViewComp).fac == 1 ? true : false)
|
|
this.top_node.getChildByName("sboss").active= this.HeroView.is_boss
|
|
|
|
this.top_node.getChildByName("lv").getChildByName("lv").getComponent(Label)!.string = this.HeroView.lv.toFixed(0)
|
|
this.top_node.getChildByName("ihp").getChildByName("num").getComponent(Label)!.string = this.HeroView.hp.toFixed(0)
|
|
this.top_node.getChildByName("iap").getChildByName("num").getComponent(Label)!.string = this.HeroView.ap.toFixed(0)
|
|
this.top_node.getChildByName("ihp").active=false
|
|
this.top_node.getChildByName("iap").active=false
|
|
|
|
this.vmdata_update(this.HeroView.VM_TYPE.ALL)
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
if(smc.mission.pause) return
|
|
this.hp_show()
|
|
if(this.wind_cd > 0 ) this.wind_cd -= deltaTime;
|
|
if(this.wind_cd <= 0 && this.node.getChildByName("wind").active){
|
|
this.node.getChildByName("wind").active = false;
|
|
}
|
|
|
|
if(this.buff_cd > 0 ) this.buff_cd -= deltaTime;
|
|
if(this.buff_cd <= 0 && this.node.getChildByName("buff").active){
|
|
this.node.getChildByName("buff").active = false;
|
|
}
|
|
this.in_speek(deltaTime)
|
|
}
|
|
hp_show(){
|
|
// if(this.node.getComponent(HeroViewComp).fac == 0) return
|
|
let hp=this.HeroView.hp;
|
|
let hp_max=this.HeroView.hp_max;
|
|
let hp_progress= hp/hp_max;
|
|
this.top_node.getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
|
if(this.HeroView.is_boss) return
|
|
this.top_node.getChildByName("hp").active = (hp == hp_max) ? false : true;
|
|
}
|
|
show_shield(val:boolean){
|
|
this.node.getChildByName("shielded").active=val
|
|
}
|
|
|
|
vmdata_update(data_type:string){
|
|
let target_key=null
|
|
let buff_key=null
|
|
if(this.HeroView.is_master) {target_key="hero";buff_key="hero"}
|
|
if(this.HeroView.is_friend) {target_key="friend";buff_key="friend"}
|
|
if(this.HeroView.is_boss) {target_key="boss";buff_key="enemy"}
|
|
if(target_key==null) return
|
|
|
|
switch(data_type){
|
|
case this.HeroView.VM_TYPE.ALL:
|
|
smc.vmdata[target_key].hp=this.HeroView.hp
|
|
smc.vmdata[target_key].hp_max=this.HeroView.hp_max
|
|
smc.vmdata[target_key].ap=this.HeroView.ap
|
|
break
|
|
case this.HeroView.VM_TYPE.HP:
|
|
smc.vmdata[target_key].hp=this.HeroView.hp
|
|
smc.vmdata[target_key].hp_max=this.HeroView.hp_max
|
|
break
|
|
case this.HeroView.VM_TYPE.OTHER:
|
|
let view_atk = 0 //临时buff
|
|
for(let i=0;i<this.HeroView.BUFF_ATKS.length;i++){
|
|
view_atk += this.HeroView.BUFF_ATKS[i].value
|
|
}
|
|
let view_deatk = 0 //临时debuff
|
|
for(let i=0;i<this.HeroView.DEBUFF_DEATKS.length;i++){
|
|
view_deatk += this.HeroView.DEBUFF_DEATKS[i].value
|
|
}
|
|
|
|
let buff=this.FIGHTCON[buff_key+"_buff"]
|
|
|
|
|
|
smc.vmdata[target_key].ap=this.HeroView.ap
|
|
smc.vmdata[target_key].equip_ap=buff.ATK
|
|
smc.vmdata[target_key].buff_ap=view_atk
|
|
smc.vmdata[target_key].debuff_ap=view_deatk
|
|
smc.vmdata[target_key].damage=this.HeroView.ap*(100+buff.ATK)/100*(100+view_atk-view_deatk)/100
|
|
|
|
|
|
|
|
break
|
|
}
|
|
}
|
|
|
|
update_info_hp(){
|
|
let ihp_node = this.top_node.getChildByName("ihp");
|
|
ihp_node.getChildByName("num").getComponent(Label)!.string = this.HeroView.hp.toFixed(0)
|
|
}
|
|
|
|
update_info_ap(){
|
|
let iap_node = this.top_node.getChildByName("iap");
|
|
iap_node.getChildByName("num").getComponent(Label)!.string = this.HeroView.ap.toFixed(0)
|
|
}
|
|
|
|
update_info_lv(){
|
|
let lv_node = this.top_node.getChildByName("lv");
|
|
lv_node.getChildByName("lv").getComponent(Label)!.string = this.HeroView.lv.toFixed(0)
|
|
}
|
|
|
|
show_wind(t:number=1){
|
|
this.wind_cd = t;
|
|
this.node.getChildByName("wind").active = true;
|
|
}
|
|
|
|
|
|
show_buff(t:number=1){
|
|
this.buff_cd = t;
|
|
this.node.getChildByName("buff").active = true;
|
|
}
|
|
|
|
|
|
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;
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
let pos = v3(this.node.position.x,this.node.position.y+20,this.node.position.z);
|
|
node.parent = this.node.parent;
|
|
node.setPosition(pos);
|
|
}
|
|
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.parent;
|
|
node.setPosition(pos);
|
|
}
|
|
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;
|
|
}
|
|
in_iced(t:number=1,ap:number=0) {
|
|
var path = "game/skills/iced";
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
node.getComponent(timedCom).time = t;
|
|
node.getComponent(timedCom).ap = ap;
|
|
node.parent = this.node;
|
|
}
|
|
in_fired(t:number=1,ap:number=0) {
|
|
var path = "game/skills/fired";
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
node.getComponent(timedCom).time = t;
|
|
node.getComponent(timedCom).ap = ap;
|
|
node.parent = this.node;
|
|
}
|
|
in_yun(t:number=1,ap:number=0) {
|
|
var path = "game/skills/yun";
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
node.setPosition(v3(0,0));
|
|
node.getComponent(timedCom).time = t;
|
|
node.getComponent(timedCom).ap = ap;
|
|
node.parent = this.node;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
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,10);
|
|
pos.y=pos.y+y;
|
|
tip.load(pos,type,value,s_uuid,this.node);
|
|
}
|
|
heathed(){
|
|
var path = "game/skills/heathed";
|
|
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
|
var node = instantiate(prefab);
|
|
node.parent = this.node;
|
|
}
|
|
|
|
}
|
|
|
|
|