基础技能完善
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} from "cc";
|
||||
import { Vec3, _decorator , v3,Collider2D,Contact2DType,IPhysics2DContact,PhysicsSystem2D,EPhysics2DDrawFlags,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";
|
||||
@@ -24,6 +24,12 @@ const { ccclass, property } = _decorator;
|
||||
@ccclass('MonsterViewComp') // 定义为 Cocos Creator 组件
|
||||
@ecs.register('MonsterView', false) // 定义为 ECS 组件
|
||||
export class MonsterViewComp extends CCComp {
|
||||
|
||||
@property(Material)
|
||||
hitFlashMaterial: Material;
|
||||
orginalFlashMaterial: Material;
|
||||
sprite: Sprite;
|
||||
|
||||
/** 角色动画 */
|
||||
as: MonsterSpine = null!;
|
||||
hero_uuid:number = 1001;
|
||||
@@ -41,7 +47,7 @@ export class MonsterViewComp extends CCComp {
|
||||
power_max: number = 100; /** 能量最大值 */
|
||||
power_speed: number = 1; //能量回复速度每0.1秒回复量
|
||||
|
||||
skill_name: string = "base"; //技能名称
|
||||
skill_name: string = "atk"; //技能名称
|
||||
max_skill_name: string = "base"; //大技能名称
|
||||
|
||||
atk: number = 10; /**攻击力 */
|
||||
@@ -63,6 +69,8 @@ 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);
|
||||
if (collider) {
|
||||
@@ -147,7 +155,7 @@ export class MonsterViewComp extends CCComp {
|
||||
* 如果角色属于正向阵营 (scale == 1) 且 x 轴位置大于等于 0,则直接返回。
|
||||
* 如果角色属于反向阵营 (scale != 1) 且 x 轴位置小于等于 0,则直接返回。
|
||||
*/
|
||||
if ((this.scale === 1 && this.node.position.x >= 0) || (this.scale !== 1 && this.node.position.x <= -180)) {
|
||||
if ((this.scale === 1 && this.node.position.x >= 120) || (this.scale !== 1 && this.node.position.x <= -180)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -226,22 +234,33 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
});
|
||||
}
|
||||
load_skill(skill_name){
|
||||
load_skill(skill_name:string){
|
||||
// console.log("load_skill");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let pos = v3(this.scale*30,30)
|
||||
let speed =400
|
||||
let x=30
|
||||
if(this.scale==1){
|
||||
x=40
|
||||
}else{
|
||||
x=-20
|
||||
}
|
||||
let pos = v3(x,50)
|
||||
let speed =350
|
||||
let scale = this.scale
|
||||
let range = 120;
|
||||
skill.load(pos,speed,range,scale,this.node,skill_name,this.atk);
|
||||
let dis = 30;
|
||||
console.log(speed);
|
||||
skill.load(pos,speed,dis,scale,this.node,skill_name,this.atk);
|
||||
}
|
||||
in_atked() {
|
||||
var path = "game/skills/atked";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let pos = v3(0,30)
|
||||
node.setPosition(pos)
|
||||
node.parent = this.node;
|
||||
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
|
||||
this.scheduleOnce(() => {
|
||||
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
|
||||
}, 0.1);
|
||||
// var path = "game/skills/atked";
|
||||
// var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
// var node = instantiate(prefab);
|
||||
// let pos = v3(0,30)
|
||||
// node.setPosition(pos)
|
||||
// node.parent = this.node;
|
||||
}
|
||||
dead(){
|
||||
var path = "game/skills/dead";
|
||||
@@ -252,8 +271,7 @@ export class MonsterViewComp extends CCComp {
|
||||
}
|
||||
toDestroy(){
|
||||
this.dead();
|
||||
smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid);
|
||||
smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid);
|
||||
|
||||
this.ent.destroy();
|
||||
}
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user