This commit is contained in:
2024-09-11 18:00:43 +08:00
parent ef4e502adf
commit 4501876c37
44 changed files with 518 additions and 4634 deletions

View File

@@ -48,6 +48,8 @@ export class BoxRangComp extends CCComp {
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
this.HeroViewComp.is_atking = false;
this.HeroViewComp.enemy = null;
this.HeroViewComp.as.change_default("move");
this.HeroViewComp.as.move();
}
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
@@ -66,6 +68,7 @@ export class BoxRangComp extends CCComp {
if(Math.abs(other_pos.x-self_pos.x) < this.HeroViewComp.atk_dis){
this.HeroViewComp.is_atking = true;
this.HeroViewComp.stop_cd = 0.1
this.HeroViewComp.as.change_default("idle");
}
}

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18
*/
import { _decorator,Sprite,Color} from "cc";
import { _decorator,Sprite,Color, Prefab, instantiate} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroSpine } from "./HeroSpine";
@@ -33,6 +33,7 @@ export class HeroBuffComp extends CCComp {
timer:Timer = new Timer(0.1);
buffs:any=[];
group:number=BoxSet.HERO;
/**
skill_uuid:number=0;
atk:number=0;
@@ -77,7 +78,12 @@ export class HeroBuffComp extends CCComp {
this.node.destroy();
}
show_buff_atk(){
var path = "game/skills/buff/atk"
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setPosition(this.node.position.x,this.node.position.y+40,this.node.position.z);
}
buff_add(buff:any){
if(!this.node.isValid){ return }
let i = 0
@@ -106,6 +112,7 @@ export class HeroBuffComp extends CCComp {
this.buffs.push(buff);
if(buff.atk>0){
this.mv.atk+=(buff.atk+buff.args.atk);
this.show_buff_atk();
}
if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp);

View File

@@ -52,10 +52,12 @@ export class HeroSpine extends Component {
}
change_default(value:string){
this.default_clip=value;
this.animator.play(this.default_clip);
}
default() {
this.animator.play(this.default_clip);
if(!this.animator.getState(this.default_clip).isPlaying){
this.animator.play(this.default_clip);
}
}
idle(){
if(!this.animator.getState(this.idle_clip.name).isPlaying){

View File

@@ -84,6 +84,8 @@ export class HeroViewComp extends CCComp {
is_stop:boolean = false;
is_atking:boolean = false;
buffs:any=[];
onLoad() {
this.as = this.getComponent(HeroSpine);
this.buff=this.node.getComponent(HeroBuffComp);
@@ -346,6 +348,14 @@ export class HeroViewComp extends CCComp {
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
add_atk(atk: number,time:number=0){
if(time > 0){
let buff={atk:atk,time:time}
this.buffs.push(buff);
}else{
this.atk += atk;
}
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
@@ -356,6 +366,17 @@ export class HeroViewComp extends CCComp {
return 0;
}
}
check_buffs(dt: number){
for(let i=0;i<this.buffs.length;i++){
let buff=this.buffs[i];
buff.time -= dt;
if(buff.time <= 0){
if(buff.atk > 0)this.atk -= buff.atk;
if(buff.shield > 0)this.shield=this.shield_max=0;
this.buffs.splice(i,1);
}
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);