dd
This commit is contained in:
@@ -21,16 +21,16 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
initialize: Initialize = null!;
|
||||
/** 游戏地图 */
|
||||
map: GameMap = null!;
|
||||
player_buffs: any = {
|
||||
1:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0},
|
||||
2:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0},
|
||||
3:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0},
|
||||
4:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0},
|
||||
5:{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
6:{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
7:{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
8:{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
};
|
||||
player_buffs: any = [
|
||||
{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y,eid:0},
|
||||
{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y,eid:0},
|
||||
{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y,eid:0},
|
||||
{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y,eid:0},
|
||||
{x:-BoxSet.CSKILL_X,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
{x:-BoxSet.CSKILL_X+70,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
{x:-BoxSet.CSKILL_X+140,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
{x:-BoxSet.CSKILL_X+210,y:BoxSet.CSKILL_Y-70,eid:0},
|
||||
];
|
||||
monster_buffs: any = [];
|
||||
/** 游戏主角 */
|
||||
Role: Role = null;
|
||||
|
||||
@@ -31,6 +31,6 @@ export enum BoxSet {
|
||||
CSKILL_X = 280,
|
||||
CSKILL_Y = 420,
|
||||
//攻击距离
|
||||
ATK_RANGE_X = 35,
|
||||
ATK_RANGE_X = 40,
|
||||
MOVE_RANGE_X = 15,
|
||||
}
|
||||
@@ -20,12 +20,19 @@ export class MapSkillComp extends CCComp {
|
||||
oops.message.on("do_use_skill", this.doSkill, this);
|
||||
}
|
||||
doSkill(event: string, args: any){
|
||||
this.addSkill(args.uuid);
|
||||
this.addCSkill(args.uuid);
|
||||
}
|
||||
addSkill(uuid:number=1001){
|
||||
addSkill(){
|
||||
|
||||
}
|
||||
addCSkill(uuid:number=1001,args:any=null){
|
||||
let csk =ecs.getEntity<CSkill>(CSkill);
|
||||
let scale = 1
|
||||
let pos = v3(BoxSet.CSKILL_X*-scale,BoxSet.CSKILL_Y)
|
||||
if(args){
|
||||
pos = v3(args.x,args.y)
|
||||
scale = args.scale
|
||||
}
|
||||
csk.load(pos,scale,uuid);
|
||||
}
|
||||
doMonsterLoad(){
|
||||
|
||||
@@ -20,7 +20,7 @@ export class BoxRangComp extends CCComp {
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
collider.tag = this.box_tag;
|
||||
// collider.offset = v2(this.offset_x,45);
|
||||
collider.offset = v2(this.offset_x,0);
|
||||
this.Hero_node = this.node.parent;
|
||||
this.MonsterViewComp=this.Hero_node.getComponent(MonsterViewComp);
|
||||
// console.log("range box",this.MonsterViewComp);
|
||||
|
||||
@@ -4,11 +4,13 @@ import { CSkillComp } from "./CSkillComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
|
||||
/** CSkill 模块 */
|
||||
@ecs.register(`CSkill`)
|
||||
export class CSkill extends ecs.Entity {
|
||||
CSkillView!: CSkillComp;
|
||||
|
||||
/** 实始添加的数据层组件 */
|
||||
protected init() {
|
||||
|
||||
@@ -28,22 +30,14 @@ export class CSkill extends ecs.Entity {
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001) {
|
||||
// var path = "game/monster/"+prefab_path;
|
||||
// console.log("load skill",this)
|
||||
var path = "game/heros/skill";
|
||||
var path = "game/heros/cskill";
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
node.getChildByName("skill").setScale(node.getChildByName("skill").scale.x*scale, node.getChildByName("skill").scale.y, node.getChildByName("skill").scale.z);
|
||||
// let cskills = ecs.query(ecs.allOf(CSkillComp))
|
||||
for (let index = 1; index <= 8; index++) {
|
||||
if(smc.player_buffs[index].eid == 0){
|
||||
pos.x=smc.player_buffs[index].x
|
||||
pos.y=smc.player_buffs[index].y
|
||||
smc.player_buffs[index].eid=this.eid
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
pos = this.add_buff()
|
||||
// console.log("load skill",pos,smc.player_buffs)
|
||||
node.setPosition(pos.x*scale,pos.y,pos.z)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
@@ -56,7 +50,19 @@ export class CSkill extends ecs.Entity {
|
||||
oops.message.dispatchEvent("cskill_load",this)
|
||||
|
||||
}
|
||||
|
||||
add_buff(){
|
||||
let pos = v3(0,0,0)
|
||||
for (let index = 0; index < 8; index++) {
|
||||
if(smc.player_buffs[index].eid == 0){
|
||||
pos.x=smc.player_buffs[index].x
|
||||
pos.y=smc.player_buffs[index].y
|
||||
smc.player_buffs[index].eid=this.eid
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
return pos
|
||||
}
|
||||
skill_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(CSkillComp)
|
||||
mv.scale = 1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { _decorator,v3,Vec3 } from "cc";
|
||||
import { _decorator,v3,Vec3 ,Label} 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 { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
@@ -8,6 +8,7 @@ import { Monster } from "./Monster";
|
||||
import { MonsterModelComp } from "./MonsterModelComp";
|
||||
import { MonsterViewComp } from "./MonsterViewComp";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -18,6 +19,7 @@ export class CSkillComp extends CCComp {
|
||||
private sd:Timer = new Timer(5)
|
||||
private cd:Timer = new Timer(1)
|
||||
private is_destroy:boolean = false;
|
||||
time:number = 0;
|
||||
scale:number = 1;
|
||||
speed:number = 0;
|
||||
dis:number = 0;
|
||||
@@ -29,6 +31,8 @@ export class CSkillComp extends CCComp {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.sd =new Timer(SkillSet[this.skill_uuid].sd)
|
||||
this.cd = new Timer(SkillSet[this.skill_uuid].cd)
|
||||
this.time =SkillSet[this.skill_uuid].sd
|
||||
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
|
||||
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
@@ -39,6 +43,8 @@ export class CSkillComp extends CCComp {
|
||||
this.to_destroy()
|
||||
}
|
||||
if (this.cd.update(dt)) {
|
||||
this.time -=1
|
||||
this.node.getChildByName("time").getComponent(Label).string = this.time.toString()
|
||||
this.shoot()
|
||||
}
|
||||
}
|
||||
@@ -78,6 +84,7 @@ export class CSkillComp extends CCComp {
|
||||
// }
|
||||
to_destroy() {
|
||||
this.is_destroy = true
|
||||
this.remove_buff()
|
||||
// console.log("CSkillComp toDestroy");
|
||||
if (this.node.isValid) {
|
||||
// console.log("CSkillComp.node.isValid");
|
||||
@@ -85,6 +92,14 @@ export class CSkillComp extends CCComp {
|
||||
this.ent.destroy()
|
||||
}
|
||||
}
|
||||
remove_buff(){
|
||||
for (let index = 0; index < 8; index++) {
|
||||
if(smc.player_buffs[index].eid == this.ent.eid){
|
||||
smc.player_buffs[index].eid=0
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.sd.reset()
|
||||
|
||||
@@ -45,7 +45,10 @@ export class Hero extends ecs.Entity {
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
// var as = node.getComponent(MonsterSpine);
|
||||
|
||||
|
||||
let ratio=this.set_ratio(uuid);
|
||||
node.setScale(ratio*node.scale.x, ratio*node.scale.y, node.scale.z);
|
||||
|
||||
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
@@ -58,7 +61,26 @@ export class Hero extends ecs.Entity {
|
||||
this.hero_init(uuid,node)
|
||||
oops.message.dispatchEvent("hero_load",this)
|
||||
}
|
||||
|
||||
set_ratio(uuid:number){
|
||||
let ratio=1;
|
||||
switch (smc.heros[uuid].level) {
|
||||
case 2:
|
||||
ratio=1.1
|
||||
break;
|
||||
case 3:
|
||||
ratio=1.2
|
||||
break;
|
||||
case 4:
|
||||
ratio=1.3
|
||||
break;
|
||||
case 5:
|
||||
ratio=1.4
|
||||
break;
|
||||
default:
|
||||
ratio=1
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(MonsterViewComp)!;
|
||||
mv.hero_uuid=uuid;
|
||||
|
||||
@@ -45,7 +45,10 @@ export class Monster extends ecs.Entity {
|
||||
var node = instantiate(prefab);
|
||||
node.parent=layer
|
||||
// var as = node.getComponent(MonsterSpine);
|
||||
node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||
let ratio=this.set_ratio(uuid);
|
||||
node.setScale(ratio*node.scale.x*scale, ratio*node.scale.y, node.scale.z);
|
||||
|
||||
// node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
|
||||
node.setPosition(pos)
|
||||
// console.log(node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite))
|
||||
const url = 'game/heros/heros';
|
||||
@@ -56,6 +59,26 @@ export class Monster extends ecs.Entity {
|
||||
this.hero_init(uuid,node)
|
||||
oops.message.dispatchEvent("monster_load",this)
|
||||
}
|
||||
set_ratio(uuid:number){
|
||||
let ratio=1;
|
||||
switch (smc.heros[uuid].level) {
|
||||
case 2:
|
||||
ratio=1.1
|
||||
break;
|
||||
case 3:
|
||||
ratio=1.2
|
||||
break;
|
||||
case 4:
|
||||
ratio=1.3
|
||||
break;
|
||||
case 5:
|
||||
ratio=1.4
|
||||
break;
|
||||
default:
|
||||
ratio=1
|
||||
}
|
||||
return ratio;
|
||||
}
|
||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(MonsterViewComp)!;
|
||||
mv.speed =mv.ospeed = smc.heros[uuid].speed;
|
||||
|
||||
@@ -76,7 +76,7 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(MonsterSpine);
|
||||
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb
|
||||
// | EPhysics2DDrawFlags.Pair
|
||||
// |EPhysics2DDrawFlags.CenterOfMass
|
||||
// |EPhysics2DDrawFlags.Joint
|
||||
@@ -156,8 +156,8 @@ export class MonsterViewComp extends CCComp {
|
||||
|
||||
change_name(hero_name:string='hero',scale:number=1){
|
||||
this.name=hero_name;
|
||||
let label:any =this.node.getChildByName("lab_name")
|
||||
label.getComponent(Label)!.string = hero_name;
|
||||
// let label:any =this.node.getChildByName("lab_name")
|
||||
// label.getComponent(Label)!.string = hero_name;
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if(scale==1){
|
||||
collider.group=BoxSet.HERO;
|
||||
@@ -208,7 +208,7 @@ export class MonsterViewComp extends CCComp {
|
||||
// console.log("monster shoot");
|
||||
let skill = ecs.getEntity<Skill>(Skill);
|
||||
let x=32
|
||||
let pos = v3(this.scale*32,30)
|
||||
let pos = v3(32,30)
|
||||
let scale = this.scale
|
||||
let speed =SkillSet[skill_uuid].speed;
|
||||
let dis = SkillSet[skill_uuid].dis;
|
||||
|
||||
@@ -34,7 +34,7 @@ export class Skill extends ecs.Entity {
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = parent;
|
||||
node.setScale(scale,1)
|
||||
// node.setScale(scale,1)
|
||||
//转换pos为世界坐标
|
||||
node.setPosition(pos)
|
||||
var sv = node.getComponent(SkillCom)!;
|
||||
|
||||
Reference in New Issue
Block a user