dd
This commit is contained in:
@@ -95,6 +95,8 @@ export const SkillSet={
|
||||
4040:{uuid: 4010,path: "1010",type: 1,level: 4,name: "治愈-终极",sp_name:"fire",dis:720,count:1,atk: 4,sd:10,cd:1,speed:400,},
|
||||
4011:{uuid: 4011,path: "1011",type: 1,level: 6,name: "火焰风暴-终极",sp_name:"fire",dis:720,count:1,atk: 4,sd:10,cd:1,speed:400,},
|
||||
4012:{uuid: 4012,path: "1012",type: 1,level: 6,name: "冰晶风暴-终极",sp_name:"fire",dis:720,count:1,atk: 4,sd:10,cd:1,speed:400,},
|
||||
9001:{uuid: 9001,path: "9001",type: 1,level: 1,name: "基础攻击1",sp_name:"base",dis:90,count:1,atk: 4,sd:10,cd:1,speed:400,},
|
||||
9002:{uuid: 9001,path: "9001",type: 1,level: 1,name: "基础攻击2",sp_name:"base2",dis:90,count:1,atk: 4,sd:10,cd:1,speed:400,},
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export class MapMonsterComp extends CCComp {
|
||||
this.monster_refresh()
|
||||
}
|
||||
if (this.refresh_timer.update(dt)) {
|
||||
// this.setp_num = RandomManager.instance.getRandomInt(this.min_monster_num,this.max_monster_num,2)
|
||||
this.setp_num = RandomManager.instance.getRandomInt(this.min_monster_num,this.max_monster_num,2)
|
||||
}
|
||||
if (this.mission_up_timer.update(dt)) {
|
||||
// 刷新怪物定时器
|
||||
|
||||
51
assets/script/game/monster/BoxRangComp.ts
Normal file
51
assets/script/game/monster/BoxRangComp.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { _decorator,Contact2DType,Collider2D ,IPhysics2DContact} 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 { BoxSet } from "../common/config/BoxSet";
|
||||
import { MonsterViewComp } from "./MonsterViewComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('BoxRangComp')
|
||||
@ecs.register('BoxRang', false)
|
||||
export class BoxRangComp extends CCComp {
|
||||
@property(MonsterViewComp)
|
||||
Hero_node:MonsterViewComp = null!;
|
||||
|
||||
box_group:number = BoxSet.DEFAULT;
|
||||
box_tag:number = BoxSet.ATK_RANGE;
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
collider.tag = this.box_tag;
|
||||
// console.log(collider,this.Hero_node);
|
||||
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);
|
||||
}
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
}
|
||||
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(selfCollider.group != otherCollider.group&&otherCollider.tag != BoxSet.ATK_RANGE){
|
||||
this.Hero_node.is_atking = true;
|
||||
}
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
9
assets/script/game/monster/BoxRangComp.ts.meta
Normal file
9
assets/script/game/monster/BoxRangComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "330a455c-5623-4654-87a9-e37bf3a226f7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import { MonsterSpine } from "./MonsterSpine";
|
||||
import { MonsterViewComp } from "./MonsterViewComp";
|
||||
import {HeroModelComp} from "./HeroModelComp";
|
||||
import { CardSet } from "../common/config/CardSet";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Hero`)
|
||||
export class Hero extends ecs.Entity {
|
||||
@@ -63,12 +64,15 @@ export class Hero extends ecs.Entity {
|
||||
mv.hero_uuid=uuid;
|
||||
mv.speed =mv.ospeed = smc.heros[uuid].speed;
|
||||
mv.hero_name= smc.heros[uuid].name;
|
||||
mv.box_group= BoxSet.HERO;
|
||||
mv.hp= mv.hp_max = smc.heros[uuid].hp;
|
||||
mv.level = smc.heros[uuid].level;
|
||||
mv.atk = smc.heros[uuid].atk;
|
||||
mv.atk_cd = smc.heros[uuid].atk_cd;
|
||||
mv.power = smc.heros[uuid].power;
|
||||
mv.type = smc.heros[uuid].type;
|
||||
mv.skill_uuid = 9001;
|
||||
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;
|
||||
mv.Tpos = v3(0,0,0);
|
||||
mv.scale = 1;
|
||||
mv.change_name(smc.heros[uuid].name,1)
|
||||
|
||||
@@ -15,6 +15,7 @@ import { MonsterModelComp } from "./MonsterModelComp";
|
||||
import { MonsterSpine } from "./MonsterSpine";
|
||||
import { MonsterViewComp } from "./MonsterViewComp";
|
||||
import { CardSet } from "../common/config/CardSet";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Monster`)
|
||||
export class Monster extends ecs.Entity {
|
||||
@@ -61,14 +62,15 @@ export class Monster extends ecs.Entity {
|
||||
var mv = node.getComponent(MonsterViewComp)!;
|
||||
mv.speed =mv.ospeed = smc.heros[uuid].speed;
|
||||
mv.hero_name= smc.heros[uuid].name;
|
||||
mv.box_group= BoxSet.MONSTER;
|
||||
mv.hp= mv.hp_max = smc.heros[uuid].hp;
|
||||
mv.level = smc.heros[uuid].level;
|
||||
mv.atk = smc.heros[uuid].atk;
|
||||
mv.atk_cd = smc.heros[uuid].atk_cd;
|
||||
mv.power = smc.heros[uuid].power;
|
||||
mv.type = smc.heros[uuid].type;
|
||||
mv.skill_name = "base2";
|
||||
mv.max_skill_name = "fire";
|
||||
mv.skill_uuid = 9002;
|
||||
mv.max_skill_uuid = smc.heros[uuid].max_skill_uuid;
|
||||
mv.scale = -1;
|
||||
mv.Tpos = v3(0,0,0);
|
||||
mv.change_name(smc.heros[uuid].name,-1)
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -28,15 +28,14 @@ export class Skill extends ecs.Entity {
|
||||
this.remove(SkillCom);
|
||||
super.destroy();
|
||||
}
|
||||
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,dis:number = 50,scale:number = 1,parent:Node,skill_name:string = "base",atk:number =10,angle = 0,t_pos:Vec3 = null) {
|
||||
var path = "game/skills/"+skill_name;
|
||||
load(pos: Vec3 = Vec3.ZERO,speed:number = 100,dis:number = 50,scale:number = 1,parent:Node,sp_name:string = "base",atk:number =10,angle = 0,t_pos:Vec3 = null) {
|
||||
var path = "game/skills/"+sp_name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent;
|
||||
node.setScale(scale,1)
|
||||
//转换pos为世界坐标
|
||||
node.setPosition(pos)
|
||||
console.log(speed)
|
||||
var sv = node.getComponent(SkillCom)!;
|
||||
sv.speed = speed;
|
||||
sv.dis = dis;
|
||||
|
||||
@@ -32,6 +32,7 @@ export class SkillCom extends CCComp {
|
||||
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
// console.log("skill group",this.box_group)
|
||||
collider.tag = this.box_tag;
|
||||
collider.sensor = true;
|
||||
if (collider) {
|
||||
@@ -62,7 +63,7 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
if(otherCollider.group != selfCollider.group){
|
||||
console.log("skill end contact")
|
||||
// console.log("skill end contact",selfCollider.group,otherCollider.group)
|
||||
setTimeout(() => {
|
||||
this.toDestroy()
|
||||
}, 10);
|
||||
|
||||
Reference in New Issue
Block a user