伤害技能添加,技能还需完善
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @LastEditTime: 2022-08-17 12:36:18
|
||||
*/
|
||||
|
||||
import { Vec3, _decorator , v3,Collider2D,Contact2DType,IPhysics2DContact,PhysicsSystem2D,EPhysics2DDrawFlags,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} from "cc";
|
||||
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} 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 { MonsterSpine } from "./MonsterSpine";
|
||||
@@ -20,6 +20,7 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
|
||||
import { SkillCom } from "../skills/SkillCom";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { BoxRangComp } from "./BoxRangComp";
|
||||
import { Tooltip } from "../skills/Tooltip";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 角色显示组件 */
|
||||
@@ -47,7 +48,7 @@ export class MonsterViewComp extends CCComp {
|
||||
hp_speed: number = 0; //每秒回复量
|
||||
|
||||
power: number = 0; /**能量**/
|
||||
power_max: number = 600*3; /** 能量最大值 */
|
||||
power_max: number = 60; /** 能量最大值 */
|
||||
power_speed: number = 1; //能量回复速度每0.1秒回复量
|
||||
|
||||
skill_name: string = "base"; //技能名称
|
||||
@@ -76,11 +77,7 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(MonsterSpine);
|
||||
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
// | EPhysics2DDrawFlags.Pair
|
||||
// |EPhysics2DDrawFlags.CenterOfMass
|
||||
// |EPhysics2DDrawFlags.Joint
|
||||
// |EPhysics2DDrawFlags.Shape;
|
||||
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
@@ -105,7 +102,7 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
|
||||
if(selfCollider.group != otherCollider.group){
|
||||
let skill = otherCollider.node.getComponent(SkillCom)!;
|
||||
@@ -118,20 +115,15 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
|
||||
this.is_atking = true;
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
||||
if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
|
||||
let self_pos=selfCollider.node.getPosition();
|
||||
let other_pos=otherCollider.node.getPosition();
|
||||
@@ -148,24 +140,9 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
change_name(hero_name:string='hero',scale:number=1){
|
||||
this.name=hero_name;
|
||||
// let label:any =this.node.getChildByName("lab_name")
|
||||
// label.getComponent(Label)!.string = hero_name;
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if(scale==1){
|
||||
collider.group=BoxSet.HERO;
|
||||
}else{
|
||||
collider.group=BoxSet.MONSTER;
|
||||
}
|
||||
}
|
||||
|
||||
update(dt: number){
|
||||
if (this.timer.update(dt)) {
|
||||
this.power_change(this.power_speed)
|
||||
@@ -174,7 +151,6 @@ export class MonsterViewComp extends CCComp {
|
||||
this.in_stop(dt);
|
||||
this.in_act(dt);
|
||||
this.move(dt);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -182,23 +158,18 @@ export class MonsterViewComp extends CCComp {
|
||||
if(this.stop_cd > 0){
|
||||
return
|
||||
}
|
||||
/**
|
||||
* 根据角色的阵营检查角色的 x 轴位置是否满足特定条件。
|
||||
* 如果角色属于正向阵营 (scale == 1) 且 x 轴位置大于等于 0,则直接返回。
|
||||
* 如果角色属于反向阵营 (scale != 1) 且 x 轴位置小于等于 0,则直接返回。
|
||||
*/
|
||||
if (this.scale === 1 && this.node.position.x >= 120) {
|
||||
return;
|
||||
}
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
|
||||
}
|
||||
get_monster_pos(){
|
||||
return this.node.getPosition()
|
||||
}
|
||||
power_change(power: number){
|
||||
this.power += power;
|
||||
if(this.power >= this.power_max){
|
||||
this.shoot(this.max_skill_uuid);
|
||||
this.as.maxSkill()
|
||||
this.scheduleOnce(()=>{
|
||||
this.do_max_skill();
|
||||
},0.5)
|
||||
this.power = 0
|
||||
}
|
||||
let power_progress= this.power/this.power_max;
|
||||
@@ -208,12 +179,25 @@ export class MonsterViewComp extends CCComp {
|
||||
// console.log("monster shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=32
|
||||
let pos = v3(35,40)
|
||||
let pos = v3(35*this.scale,40)
|
||||
let scale = this.scale
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
let atk = SkillSet[skill_uuid].atk+this.atk;
|
||||
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk);
|
||||
// this.tooltip(3,SkillSet[skill_uuid].name,this.skill_uuid);
|
||||
}
|
||||
//使用max_skill
|
||||
do_max_skill(){
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=32
|
||||
let pos = v3(35*this.scale,40)
|
||||
let scale = this.scale
|
||||
let speed =SkillSet[this.max_skill_uuid].speed;
|
||||
let dis = SkillSet[this.max_skill_uuid].dis;
|
||||
let atk = SkillSet[this.max_skill_uuid].atk+this.atk;
|
||||
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
|
||||
this.tooltip(3,SkillSet[this.max_skill_uuid].name,this.max_skill_uuid);
|
||||
}
|
||||
in_act(dt: number) {
|
||||
|
||||
@@ -235,6 +219,7 @@ export class MonsterViewComp extends CCComp {
|
||||
return;
|
||||
}
|
||||
this.hp -= hp;
|
||||
this.tooltip(1,hp.toString());
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
}
|
||||
@@ -246,9 +231,19 @@ export class MonsterViewComp extends CCComp {
|
||||
setTimeout(() => {
|
||||
this.ent.destroy();
|
||||
}, 15);
|
||||
|
||||
}
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
||||
// console.log("tooltip",type);
|
||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
||||
let pos = this.node.getPosition();
|
||||
let node =this.node.parent
|
||||
pos.y=pos.y+60;
|
||||
tip.load(pos,type,value,s_uuid,node);
|
||||
}
|
||||
get_monster_pos(){
|
||||
return this.node.getPosition()
|
||||
}
|
||||
/** 静止时间 */
|
||||
in_stop (dt: number) {
|
||||
if(this.stop_cd > 0){
|
||||
|
||||
Reference in New Issue
Block a user