dd 56卡牌栏 为role 专有物品,不在有针对小兵的 卡牌技能, 小兵的强化靠role,没有驻场 技能,role 修改为多技能

This commit is contained in:
2024-09-12 17:19:14 +08:00
parent 5f1b081374
commit f80115e251
47 changed files with 1191 additions and 1524 deletions

View File

@@ -19,7 +19,6 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { SkillCom } from "../skills/SkillCom";
import { SkillSet } from "../common/config/SkillSet";
import { Tooltip } from "../skills/Tooltip";
import { MonBuffComp } from "./MonBuffComp";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
const { ccclass, property } = _decorator;
@@ -36,7 +35,6 @@ export class MonViewComp extends CCComp {
@property(Node)
BoxRang:Node =null!
buff:MonBuffComp =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
@@ -83,10 +81,11 @@ export class MonViewComp extends CCComp {
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
buff_shields:any=[];
buff_atks:any = [];
dir_y:number = 0;
onLoad() {
this.as = this.getComponent(MonSpine);
this.buff=this.node.getComponent(MonBuffComp);
// this.BoxRang = this.node.getChildByName("range_box");
// this.BoxRang = this.node.getChildByName("range_box");
} /** 视图层逻辑代码分离演示 */
@@ -108,7 +107,6 @@ export class MonViewComp extends CCComp {
// this.enemy=smc.Role.RoleView.node
// // console.log("mon enemy ",this.enemy);
// }
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
@@ -170,7 +168,7 @@ export class MonViewComp extends CCComp {
this.power_change(this.power_speed)
}
this.in_destroy();
this.in_shield();
this.in_shield(dt);
this.in_stop(dt);
this.in_atk(dt);
this.move(dt);
@@ -193,9 +191,12 @@ export class MonViewComp extends CCComp {
// if(this.enemy){
// return
// }
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
this.set_diry()
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y+dt*this.dir_y, this.node.position.z);
}
move_to(){
set_diry(){
this.dir_y=-(this.node.position.y-BoxSet.GAME_LINE)/60
} move_to(){
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(smc.Role.RoleView.node.position.x+10,smc.Role.RoleView.node.position.y);
move.node = this.node;
@@ -241,8 +242,8 @@ export class MonViewComp extends CCComp {
},0.5)
this.power = 0
}
let power_progress= this.power/this.power_max;
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
// let power_progress= this.power/this.power_max;
// this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number){
// console.log("mon shoot");
@@ -309,16 +310,7 @@ export class MonViewComp extends CCComp {
this.atk_time += dt;
}
}
in_shield(){
let shield_progress= this.shield/this.shield_max;
this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
// if(this.shield <= 0){
// this.node.getChildByName("shield").active=false
// }else{
// this.node.getChildByName("shield").active=true
// }
}
hp_change(hp: number){
if(this.is_dead){
return;
@@ -353,10 +345,36 @@ export class MonViewComp extends CCComp {
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.hp+=hp;
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
this.tooltip(2,hp.toString());
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.buff_atks.push(buff);
}else{
this.atk += atk;
}
}
check_buff_atks(dt: number){
for(let i=0;i<this.buff_atks.length;i++){
let buff=this.buff_atks[i];
buff.time -= dt;
if(buff.time <= 0){
if(buff.atk > 0)this.atk -= buff.atk;
this.buff_atks.splice(i,1);
}
}
}
add_shield(shield: number,time:number=0){
this.shield =this.shield_max=shield
this.shield_time = time;
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
@@ -367,6 +385,27 @@ export class MonViewComp extends CCComp {
return 0;
}
}
in_shield(dt){
if(this.shield_time <= 0){
return
}
if(this.shield_time > 0){
this.shield_time -= dt;
if(this.shield_time <= 0){
this.shield_time = 0;
this.shield = this.shield_max=0;
// this.node.getChildByName("top").getChildByName("shield").active=false
}
// let shield_progress= this.shield/this.shield_max;
// this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
}
if(this.shield <= 0){
this.shield_time=0
// this.node.getChildByName("top").getChildByName("shield").active=false
}else{
// this.node.getChildByName("top").getChildByName("shield").active=true
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
@@ -401,23 +440,12 @@ export class MonViewComp extends CCComp {
// }
}
in_atked() {
if(this.is_role){
var path = "game/skills/atked";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let pos = v3(0,60)
node.setPosition(pos)
node.parent = this.node;
in_atked() {
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.1);
}else{
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.1);
}
}
dead(){
var path = "game/skills/dead";