93 lines
3.4 KiB
TypeScript
93 lines
3.4 KiB
TypeScript
/*
|
|
* @Author: dgflash
|
|
* @Date: 2021-11-18 17:42:59
|
|
* @LastEditors: dgflash
|
|
* @LastEditTime: 2022-08-17 12:36:18
|
|
*/
|
|
|
|
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";
|
|
import { Monster } from "./Monster";
|
|
import { Hero } from "./Hero";
|
|
import { MonsterModelComp } from "./MonsterModelComp";
|
|
import { BoxSet } from "../common/config/BoxSet";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
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/SkillSet";
|
|
import { BoxRangComp } from "./BoxRangComp";
|
|
import { Tooltip } from "../skills/Tooltip";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/** 角色显示组件 */
|
|
@ccclass('MonsterBuffComp') // 定义为 Cocos Creator 组件
|
|
@ecs.register('MonsterBuff', false) // 定义为 ECS 组件
|
|
export class MonsterBuffComp extends CCComp {
|
|
/** 角色动画 */
|
|
as: MonsterSpine = null!;
|
|
num:number=0;
|
|
timer:Timer = new Timer(0.5);
|
|
|
|
onLoad() {
|
|
this.as = this.getComponent(MonsterSpine);
|
|
|
|
} /** 视图层逻辑代码分离演示 */
|
|
start () {
|
|
console.log("MonsterBuffComp start nmu:"+this.num);
|
|
// 注册单个碰撞体的回调函数
|
|
let collider = this.getComponent(Collider2D);
|
|
if (collider) {
|
|
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
|
collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
|
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
|
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
|
}
|
|
// this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = this.level.toString();
|
|
|
|
|
|
}
|
|
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
|
|
if(selfCollider.group != otherCollider.group){
|
|
|
|
}
|
|
}
|
|
}
|
|
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
|
|
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
|
|
|
|
}
|
|
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();
|
|
// console.log('monster view group 相同');
|
|
switch (selfCollider.group) {
|
|
case BoxSet.HERO:
|
|
|
|
break;
|
|
case BoxSet.MONSTER:
|
|
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
update(dt: number){
|
|
if (this.timer.update(dt)) {
|
|
this.num++;
|
|
|
|
}
|
|
}
|
|
|
|
reset() {
|
|
|
|
this.node.destroy();
|
|
}
|
|
|
|
} |