添加buff comp
This commit is contained in:
@@ -59,10 +59,13 @@
|
||||
},
|
||||
{
|
||||
"__id__": 85
|
||||
},
|
||||
{
|
||||
"__id__": 87
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 87
|
||||
"__id__": 89
|
||||
},
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
@@ -1673,7 +1676,7 @@
|
||||
"fileId": "14OhXRCixNOaApgow/hFbp"
|
||||
},
|
||||
{
|
||||
"__type__": "sp.Skeleton",
|
||||
"__type__": "482c2FsvvZJ+5BgN3d7gY+D",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
@@ -1684,6 +1687,70 @@
|
||||
"__prefab": {
|
||||
"__id__": 78
|
||||
},
|
||||
"animator": {
|
||||
"__id__": 24
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "6cDIo6gXFNnbPNuWVAqhBD"
|
||||
},
|
||||
{
|
||||
"__type__": "dc1b7IQTVxHfIHFfWu0u4I/",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 80
|
||||
},
|
||||
"hitFlashMaterial": {
|
||||
"__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264",
|
||||
"__expectedType__": "cc.Material"
|
||||
},
|
||||
"BoxRang": {
|
||||
"__id__": 65
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "88a6VdbQBB7YwXovYCN2Sy"
|
||||
},
|
||||
{
|
||||
"__type__": "26574P1wEtBHZdyLJvQFWoJ",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 82
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "5fIwQdqmtEi7HN7Oz8K15G"
|
||||
},
|
||||
{
|
||||
"__type__": "sp.Skeleton",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 84
|
||||
},
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
@@ -1714,52 +1781,6 @@
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "3dWWGO2rFK4LL+PeQ7ANRn"
|
||||
},
|
||||
{
|
||||
"__type__": "482c2FsvvZJ+5BgN3d7gY+D",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 80
|
||||
},
|
||||
"animator": {
|
||||
"__id__": 24
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "6cDIo6gXFNnbPNuWVAqhBD"
|
||||
},
|
||||
{
|
||||
"__type__": "dc1b7IQTVxHfIHFfWu0u4I/",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {},
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 82
|
||||
},
|
||||
"hitFlashMaterial": {
|
||||
"__uuid__": "a8f34051-ccff-4050-b9d9-234f62977264",
|
||||
"__expectedType__": "cc.Material"
|
||||
},
|
||||
"BoxRang": {
|
||||
"__id__": 65
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.CompPrefabInfo",
|
||||
"fileId": "88a6VdbQBB7YwXovYCN2Sy"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RigidBody2D",
|
||||
"_name": "",
|
||||
@@ -1770,7 +1791,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 84
|
||||
"__id__": 86
|
||||
},
|
||||
"enabledContactListener": true,
|
||||
"bullet": true,
|
||||
@@ -1804,7 +1825,7 @@
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": {
|
||||
"__id__": 86
|
||||
"__id__": 88
|
||||
},
|
||||
"tag": 0,
|
||||
"_group": 2,
|
||||
|
||||
@@ -17,13 +17,15 @@ import { MonsterViewComp } from "./MonsterViewComp";
|
||||
import { CardSet } from "../common/config/CardSet";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { MonsterBuffComp } from "./MonsterBuffComp";
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Monster`)
|
||||
export class Monster extends ecs.Entity {
|
||||
// 数据层
|
||||
MonsterModel!: MonsterModelComp;
|
||||
// 视图层
|
||||
MonsterView!: MonsterViewComp; // 移动
|
||||
MonsterView!: MonsterViewComp;
|
||||
MonsterBuff!: MonsterBuffComp; // 移动
|
||||
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>(
|
||||
@@ -34,6 +36,7 @@ export class Monster extends ecs.Entity {
|
||||
destroy(): void {
|
||||
|
||||
this.remove(MonsterViewComp);
|
||||
this.remove(MonsterBuffComp);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
@@ -81,6 +84,7 @@ export class Monster extends ecs.Entity {
|
||||
}
|
||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(MonsterViewComp)!;
|
||||
var buff = node.getComponent(MonsterBuffComp)!;
|
||||
mv.speed =mv.ospeed = smc.heros[uuid].speed;
|
||||
mv.hero_name= smc.heros[uuid].name;
|
||||
mv.box_group= BoxSet.MONSTER;
|
||||
@@ -95,6 +99,7 @@ export class Monster extends ecs.Entity {
|
||||
mv.scale = -1;
|
||||
mv.Tpos = v3(0,0,0);
|
||||
this.add(mv);
|
||||
this.add(buff)
|
||||
|
||||
}
|
||||
}
|
||||
93
assets/script/game/monster/MonsterBuffComp.ts
Normal file
93
assets/script/game/monster/MonsterBuffComp.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* @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();
|
||||
}
|
||||
|
||||
}
|
||||
1
assets/script/game/monster/MonsterBuffComp.ts.meta
Normal file
1
assets/script/game/monster/MonsterBuffComp.ts.meta
Normal file
@@ -0,0 +1 @@
|
||||
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"265743f5-c04b-411d-9772-2c9bd0156a09","files":[],"subMetas":{},"userData":{}}
|
||||
@@ -138,6 +138,7 @@ export class MonsterViewComp extends CCComp {
|
||||
if(self_pos.x > other_pos.x&&Math.abs(self_pos.x-other_pos.x) <= BoxSet.MOVE_RANGE_X && self_pos.y==other_pos.y){
|
||||
this.stop_cd=0.1
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,16 +123,16 @@ export class SkillCom extends CCComp {
|
||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
// this.move(deltaTime)
|
||||
this.toDestroy()
|
||||
// if(this.t_pos){
|
||||
// this.t_move(deltaTime)
|
||||
// }else{
|
||||
// this.line_move(deltaTime)
|
||||
// }
|
||||
this.t_move(deltaTime)
|
||||
|
||||
if (this.node.position.x > 400||this.node.position.x < -400||this.node.position.y > 1000||this.node.position.y < BoxSet.GAME_LINE) {
|
||||
this.is_destroy=true
|
||||
}
|
||||
}
|
||||
t_move(dt: number){
|
||||
if(!this.t_pos){
|
||||
return
|
||||
}
|
||||
this.node.setPosition(v3(this.node.position.x+this.x_speed*dt*this.scale,this.node.position.y+this.y_speed*dt))
|
||||
}
|
||||
line_move(dt: number) {
|
||||
|
||||
Reference in New Issue
Block a user