dd
This commit is contained in:
@@ -18,6 +18,8 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { Skill } from "../skills/Skill";
|
||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
import { SkillCom } from "../skills/SkillCom";
|
||||
import { SkillSet } from "../common/config/CardSet";
|
||||
import { BoxRangComp } from "./BoxRangComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 角色显示组件 */
|
||||
@@ -29,7 +31,8 @@ export class MonsterViewComp extends CCComp {
|
||||
hitFlashMaterial: Material;
|
||||
orginalFlashMaterial: Material;
|
||||
sprite: Sprite;
|
||||
|
||||
@property(BoxRangComp)
|
||||
BoxRang:BoxRangComp = null!;
|
||||
/** 角色动画 */
|
||||
as: MonsterSpine = null!;
|
||||
hero_uuid:number = 1001;
|
||||
@@ -49,7 +52,8 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
skill_name: string = "base"; //技能名称
|
||||
max_skill_name: string = "base"; //大技能名称
|
||||
|
||||
skill_uuid:number = 9001;
|
||||
max_skill_uuid:number = 1001;
|
||||
atk: number = 10; /**攻击力 */
|
||||
// atk_speed: number = 1;
|
||||
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
|
||||
@@ -63,6 +67,7 @@ export class MonsterViewComp extends CCComp {
|
||||
shield:number = 0; //护盾量
|
||||
shield_time:number = 0; //护盾持续时间
|
||||
|
||||
box_group:number = 2;
|
||||
|
||||
private timer:Timer = new Timer(0.1); //计时器
|
||||
is_dead:boolean = false; //是否摧毁
|
||||
@@ -79,10 +84,13 @@ export class MonsterViewComp extends CCComp {
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
|
||||
|
||||
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
|
||||
// 注册单个碰撞体的回调函数
|
||||
let collider = this.getComponent(Collider2D);
|
||||
console.log(collider);
|
||||
collider.group = this.box_group;
|
||||
this.BoxRang.box_group = this.box_group;
|
||||
// console.log(collider);
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||
@@ -108,13 +116,11 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE){
|
||||
this.is_atking = true;
|
||||
if(otherCollider.tag != BoxSet.SKILL_TAG&&selfCollider.tag != BoxSet.ATK_RANGE){
|
||||
this.stop_cd = 0.1;
|
||||
}
|
||||
}
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE){
|
||||
this.is_atking = true;
|
||||
}
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
@@ -189,7 +195,6 @@ export class MonsterViewComp extends CCComp {
|
||||
if ((this.scale === 1 && this.node.position.x >= 120) || (this.scale !== 1 && this.node.position.x <= -180)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
|
||||
}
|
||||
get_monster_pos(){
|
||||
@@ -198,12 +203,24 @@ export class MonsterViewComp extends CCComp {
|
||||
power_change(power: number){
|
||||
this.power += power;
|
||||
if(this.power >= this.power_max){
|
||||
this.shoot(this.max_skill_name);
|
||||
this.shoot(this.max_skill_uuid);
|
||||
this.power = 0
|
||||
}
|
||||
let power_progress= this.power/this.power_max;
|
||||
this.node.getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
|
||||
}
|
||||
shoot(skill_uuid:number){
|
||||
console.log("monster shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=0
|
||||
let pos = v3(x,40)
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let scale = this.scale
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
let atk = SkillSet[skill_uuid].atk+this.atk;
|
||||
let sp_name = SkillSet[skill_uuid].sp_name;
|
||||
skill.load(pos,speed,dis,scale,this.node,sp_name,atk);
|
||||
}
|
||||
in_act(dt: number) {
|
||||
|
||||
if(this.atk_time >= this.atk_cd){
|
||||
@@ -212,7 +229,7 @@ export class MonsterViewComp extends CCComp {
|
||||
// console.log("atk_cd:"+this.atk_cd);
|
||||
this.as.atk();
|
||||
this.scheduleOnce(()=>{
|
||||
this.shoot(this.skill_name);
|
||||
this.shoot(this.skill_uuid);
|
||||
},0.2)
|
||||
}
|
||||
}else{
|
||||
@@ -269,22 +286,7 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
});
|
||||
}
|
||||
shoot(skill_name:string){
|
||||
console.log("monster shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=30
|
||||
if(this.scale==1){
|
||||
x=0
|
||||
}else{
|
||||
x=-0
|
||||
}
|
||||
let pos = v3(x,40)
|
||||
let speed =350
|
||||
let scale = this.scale
|
||||
let dis = 50;
|
||||
console.log(speed);
|
||||
skill.load(pos,speed,dis,scale,this.node,skill_name,this.atk);
|
||||
}
|
||||
|
||||
in_atked() {
|
||||
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
||||
this.scheduleOnce(() => {
|
||||
|
||||
Reference in New Issue
Block a user