dd
This commit is contained in:
@@ -40,7 +40,7 @@ export class RoleSpine extends Component {
|
||||
/** 初始化动画 */
|
||||
protected initAnimator() {
|
||||
this.animator=this.node.getChildByName("hero").getComponent(Animation);
|
||||
console.log("role view comp init",this.animator);
|
||||
// console.log("role view comp init",this.animator);
|
||||
|
||||
}
|
||||
onAnimationEvent(type: Animation.EventType, state: AnimationState){
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -51,7 +51,7 @@ export class Initialize extends ecs.Entity {
|
||||
// 加载多语言对应字体
|
||||
oops.res.load("language/font/" + oops.language.current, next);
|
||||
//加载精灵配置表
|
||||
oops.res.load("config/game/heros", next);
|
||||
// oops.res.load("config/game/heros", next);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ export class MapMonsterComp extends CCComp {
|
||||
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
|
||||
role.load(pos,109)
|
||||
smc.Role=role
|
||||
console.log("加载玩家",role)
|
||||
// console.log("加载玩家",role)
|
||||
}
|
||||
private on_do_add_hero(event: string, args: any) {
|
||||
this.addHero(args.uuid)
|
||||
|
||||
@@ -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.MonViewComp.is_atking = false;
|
||||
this.MonViewComp.enemy = null;
|
||||
this.MonViewComp.as.change_default("move");
|
||||
this.MonViewComp.as.move();
|
||||
}
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
@@ -66,6 +68,8 @@ export class BoxRangComp extends CCComp {
|
||||
if(Math.abs(other_pos.x-self_pos.x) < this.MonViewComp.atk_dis){
|
||||
this.MonViewComp.is_atking = true;
|
||||
this.MonViewComp.stop_cd = 0.1
|
||||
this.MonViewComp.as.change_default("idle");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,10 +50,11 @@ export class MonSpine 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){
|
||||
|
||||
@@ -127,6 +127,16 @@ export class CSkillComp extends CCComp {
|
||||
}
|
||||
// oops.message.dispatchEvent("add_buff",{uuid:this.skill_uuid,eid:0,group:BoxSet.HERO})
|
||||
}
|
||||
single_least_add_buff(target:any,uuid:number,args:any) {
|
||||
let buff = SkillSet[uuid]
|
||||
if(buff.hp > 0 ){
|
||||
target.HeroView.add_hp(buff.hp+args.hp)
|
||||
}
|
||||
if(buff.atk > 0 ){
|
||||
target.HeroView.add_atk(buff.atk+args.atk,buff.bsd)
|
||||
}
|
||||
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user