This commit is contained in:
2024-09-09 07:56:18 +08:00
parent 47af795c12
commit 9bac2d5c5b
264 changed files with 96262 additions and 53551 deletions

View File

@@ -13,11 +13,10 @@ import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp";
import { RoleModelComp } from "./RoleModelComp";
import { RoleSpine } from "./RoleSpine";
import { RoleViewComp } from "./RoleViewComp";
import { RoleSet } from "../common/config/RoleSet";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { MonsterViewComp } from "../monster/MonsterViewComp";
import { MonsterBuffComp } from "../monster/MonsterBuffComp";
import { RoleViewComp } from "./RoleViewComp";
import { RoleBuffComp } from "./RoleBuffComp";
import { BoxSet } from "../common/config/BoxSet";
/** 角色实体 */
@ecs.register(`Role`)
@@ -27,7 +26,7 @@ export class Role extends ecs.Entity {
RoleMoveTo!: MoveToComp; // 移动
// 视图层
MonsterView!: MonsterViewComp;
RoleView!: RoleViewComp;
protected init() {
this.addComponents<ecs.Comp>(
@@ -35,7 +34,7 @@ export class Role extends ecs.Entity {
}
destroy(): void {
this.remove(MonsterViewComp);
this.remove(RoleViewComp);
super.destroy();
}
@@ -57,14 +56,14 @@ export class Role extends ecs.Entity {
// sprite.spriteFrame = atlas.getSpriteFrame(RoleSet[uuid].path);
// });
// var rv = node.getComponent(MonsterViewComp)!;
// var rv = node.getComponent(RoleViewComp)!;
// this.add(rv);
this.hero_init(uuid,node)
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!;
var buff =node.getComponent(MonsterBuffComp)!;
var mv = node.getComponent(RoleViewComp)!;
var buff =node.getComponent(RoleBuffComp)!;
mv.is_role=true;
mv.hero_uuid=uuid;
mv.speed =mv.ospeed = 0;
@@ -88,7 +87,7 @@ export class Role extends ecs.Entity {
move(target: Vec3) {
var move = this.get(MoveToComp) || this.add(MoveToComp);
move.target = target;
move.node = this.MonsterView.node;
move.node = this.RoleView.node;
move.speed = 300;
}

View File

@@ -12,7 +12,7 @@ const { ccclass, property } = _decorator;
@ccclass('RoleBuffComp')
@ecs.register('RoleBuff', false)
export class RoleBuffComp extends CCComp {
as: RoleSpine = null!;
// as: RoleSpine = null!;
mv!: RoleViewComp
timer:Timer = new Timer(0.1);
@@ -28,7 +28,7 @@ export class RoleBuffComp extends CCComp {
onLoad() {
this.as = this.node.getComponent(RoleSpine);
// this.as = this.node.getComponent(RoleSpine);
this.mv= this.getComponent(RoleViewComp);
} /** 视图层逻辑代码分离演示 */
start () {
@@ -73,7 +73,7 @@ export class RoleBuffComp extends CCComp {
b.time=buff.time;
if(buff.atk>0){
this.node.getChildByName("avatar").setScale(1.2,1.2)
// this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
}
if(buff.hp>0){
@@ -95,7 +95,7 @@ export class RoleBuffComp extends CCComp {
if(buff.atk>0){
this.mv.atk+=(buff.atk+buff.args.atk);
this.node.getChildByName("avatar").setScale(1.2,1.2)
// this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
}
if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp);

View File

@@ -0,0 +1,82 @@
import { _decorator,Contact2DType,Collider2D ,IPhysics2DContact,v3, v2,Vec3} 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 { RoleViewComp } from "./RoleViewComp";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('RoleRangComp')
@ecs.register('RoleRang', false)
export class RoleRangComp extends CCComp {
Hero_node: any=null!;
RoleViewComp:RoleViewComp = null!;
box_group:number = BoxSet.DEFAULT;
box_tag:number = BoxSet.ATK_RANGE;
offset_x:number = 0;
atk_range:number = 150;
/** 视图层逻辑代码分离演示 */
start() {
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
collider.tag = this.box_tag;
this.Hero_node = this.node.parent;
this.RoleViewComp=this.Hero_node.getComponent(RoleViewComp);
// console.log("range box",this.RoleViewComp);
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) {
// if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
// console.log(this.node.name+"onBeginContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
// this.RoleViewComp.is_atking = true;
// if(Math.abs(otherCollider.node.position.x-selfCollider.node.position.x) < 120){
// this.RoleViewComp.stop_cd = 0.1
// }
// }
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0 ){
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
this.RoleViewComp.is_atking = false;
this.RoleViewComp.enemy = null;
}
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
let scene =smc.map.MapView.scene.mapLayer!.node!
let other_pos = otherCollider.node.getWorldPosition() ;
let self_pos = this.node.getWorldPosition();
// console.log("onPreSolve:",self_pos,other_pos);
if(this.RoleViewComp.enemy==null){
this.RoleViewComp.enemy = otherCollider.node;
}else{
if(this.RoleViewComp.enemy.isValid==false){
this.RoleViewComp.enemy = otherCollider.node;
}
}
if(Math.abs(other_pos.x-self_pos.x) < this.atk_range){
this.RoleViewComp.is_atking = true;
this.RoleViewComp.stop_cd = 0.1
}
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "d67dc462-2b08-4fe2-922c-502509f68ff4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -4,7 +4,7 @@
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:26:26
*/
import { Color, Component, EventTouch, sp, Vec3, _decorator } from "cc";
import { Color, Component, EventTouch, sp, Vec3, _decorator ,Animation, AnimationClip, AnimationState} from "cc";
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
import { smc } from "../common/SingletonModuleComp";
import RoleSpineAnimator from "./RoleSpineAnimator";
@@ -16,9 +16,12 @@ const { ccclass, property } = _decorator;
*/
@ccclass('RoleSpine')
export class RoleSpine extends Component {
@property({ type: RoleSpineAnimator, tooltip: '动画控制器' })
animator: RoleSpineAnimator = null!;
@property({ type: Animation, tooltip: '动画控制器' })
animator: Animation = null!;
atk_clip: AnimationClip = null!;
idle_clip: AnimationClip = null!;
move_clip: AnimationClip = null!;
dead_clip: AnimationClip = null!;
private spine!: sp.Skeleton;
onLoad() {
@@ -26,35 +29,39 @@ export class RoleSpine extends Component {
this.initAnimator();
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
this.atk_clip = this.animator.clips[1];
this.idle_clip = this.animator.clips[0];
this.move_clip = this.animator.clips[2];
this.dead_clip = this.animator.clips[3];
let animation = this.animator.getComponent(Animation);
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
}
/** 初始化动画 */
protected initAnimator() {
this.spine = this.animator.getComponent(sp.Skeleton)!;
this.animator=this.node.getChildByName("hero").getComponent(Animation);
console.log("role view comp init",this.animator);
}
onAnimationEvent(type: Animation.EventType, state: AnimationState){
// console.log("onAnimationEvent",type,state);
if(type==Animation.EventType.FINISHED){
if(state.name==this.atk_clip.name){
this.idle();
}
}
}
atk() {
this.spine.setAnimation(0, "atk2", false);
if(!this.animator.getState(this.atk_clip.name).isPlaying){
this.animator.play(this.atk_clip.name);
}
}
magic() {
this.spine.setAnimation(0, "max", false);
}
setSkin(value: string): void {
console.log("RoleSpine setSkin", value);
this.spine.setSkin(value);
}
play(animName: string, loop: boolean): void {
this.spine.setAnimation(0, animName, loop);
}
setAlpha(value: number): void {
var color: Color = this.spine.color;
color.a = 255 * (value / 1);
this.spine.color = color;
}
setPos(value: Vec3): void {
this.node.position = value;
}
checkTouch(event: EventTouch): boolean {
return false;
@@ -69,6 +76,8 @@ export class RoleSpine extends Component {
}
idle() {
if(!this.animator.getState(this.idle_clip.name).isPlaying){
this.animator.play(this.idle_clip.name);
}
}
}

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, v3,_decorator ,Collider2D,Contact2DType,IPhysics2DContact,Material,Sprite,ProgressBar, Prefab, instantiate} from "cc";
import { Vec3, v3,_decorator ,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite,Animation, director} 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 { RoleSpine } from "./RoleSpine";
@@ -18,6 +18,9 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { RoleBuffComp } from "./RoleBuffComp";
import { RoleRangComp } from "./RoleRangComp";
import { Tooltip } from "../skills/Tooltip";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -29,38 +32,90 @@ export class RoleViewComp extends CCComp {
orginalFlashMaterial: Material;
sprite: Sprite;
/** 角色动画 */
as: RoleSpine = null!;
/** 角色属性 */
hp: number = 1000;
hp_max:number = 1000;
power: number = 0;
stop_cd:number = 0;
atk_cd:number = 5;
atk:number = 10;
skill_uuid:number = 9003;
@property(Node)
BoxRang:Node =null!
as:RoleSpine =null!;
buff:RoleBuffComp =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
/** 角色动画 */
hero_uuid:number = 1001;
hero_name : string = "hero";
level:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :monster */
type: number = 1; /**角色类型 1前排 2 后排 */
state: number = 1; /** 状态 1move ,2: act 3: stop */
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_speed: number = 0; //每秒回复量
power: number = 0; /**能量**/
power_max: number = 1200; /** 能量最大值 */
power_speed: number = 1; //能量回复速度每0.1秒回复量
skill_name: string = "base"; //技能名称
max_skill_name: string = "base"; //大技能名称
skill_uuid:number = 9001;
max_skill_uuid:number = 1001;
shield:number = 0;
atk: number = 10; /**攻击力 */
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
atk_time: number = 0; /** 冷却时间 */
speed: number = 100; /** 角色移动速度 */
ospeed: number = 100; /** 角色初始速度 */
Tpos: Vec3 = v3(0,-60,0);
stop_cd: number = 0.5; /*停止倒计时*/
shield:number = 0; //护盾量
shield_max:number = 200;
skin="Character01";
private atk_time:Timer = new Timer(1);
shield_time:number = 0; //护盾持续时间
box_group:number = 2;
atk_range:number = 150;
private timer:Timer = new Timer(0.1); //计时器
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
onLoad() {
this.as = this.getComponent(RoleSpine);
this.buff=this.node.getComponent(RoleBuffComp);
this.BoxRang = this.node.getChildByName("range_box");
this.as = this.node.getComponent(RoleSpine);
}
start () {
// let x = RandomManager.instance.getRandomInt(1,9,2)
// this.as.setSkin("Character0"+x);
this.atk_time = new Timer(this.atk_cd);
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
this.sprite = this.node.getChildByName("hero").getComponent(Sprite);
this.node.getChildByName("top").setScale(this.scale,1);
// this.node.getChildByName("atk").setScale(this.scale,1);
// this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
// this.node.getChildByName("hp_max").setScale(this.scale,1);
// this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
console.log("Role view start")
this.BoxRang.getComponent(RoleRangComp).box_group = this.box_group;
this.BoxRang.getComponent(RoleRangComp).atk_range = this.atk_range
// this.BoxRang.getComponent(RoleRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis/3;
// console.log("monseter ",this.BoxRang);
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
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) {
if(otherCollider.tag==BoxSet.SKILL_TAG){
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
if(selfCollider.group != otherCollider.group){
let skill = otherCollider.node.getComponent(SkillCom)!;
// console.log('onPostSolve',skill);
@@ -72,68 +127,235 @@ export class RoleViewComp extends CCComp {
}
}
}
// onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
// onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
// onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.is_atking = true;
this.stop_cd = 0.1;
}
}
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:
if(self_pos.x < other_pos.x){
this.stop_cd=0.1
}
break;
case BoxSet.MONSTER:
if(self_pos.x > other_pos.x){
this.stop_cd=0.1
}
break
}
}
}
update(dt: number){
if (this.atk_time.update(dt)) {
this.toAtk(this.skill_uuid);
if (this.timer.update(dt)) {
this.power_change(this.power_speed)
}
this.in_destroy();
this.in_shield();
this.in_stop(dt);
this.in_atk(dt);
this.move(dt);
}
add_hp(hp:number){
console.log("role add hp",hp);
move(dt: number){
if(this.stop_cd > 0){
return
}
if (this.scale === 1 && this.node.position.x >= 120) {
return;
}
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
}
setSkin(){
this.as.setSkin(this.skin);
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
// this.as.maxSkill()
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
this.power = 0
}
let power_progress= this.power/this.power_max;
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
reset() {
this.node.destroy();
}
toAtk(uuid) {
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
},1)
}
shoot(skill_uuid:number){
// console.log("monster shoot");
let skill = ecs.getEntity<Skill>(Skill);
let pos = v3(35,55)
let scale = 1
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale
let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk;
let uuid = skill_uuid;
skill.load(pos,speed,dis,scale,this.node,uuid,atk,2);
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
}
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
in_atked() {
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;
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking){
this.atk_time = 0;
// console.log("atk_cd:",this.as);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
},0.4)
}
}else{
this.atk_time += dt;
}
}
in_shield(){
let shield_progress= this.shield/this.shield_max;
this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
// if(this.shield <= 0){
// this.node.getChildByName("shield").active=false
// }else{
// this.node.getChildByName("shield").active=true
// }
}
hp_change(hp: number){
this.hp -= hp;
if(this.is_dead){
return;
}
let lhp=this.shield_change(hp);
if(lhp == 0){
return;
}
this.hp += lhp;
this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
console.log("dead");
this.dead();
this.is_dead = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.tooltip(2,hp.toString());
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
this.shield = 0;
return ls;
}else{
this.shield = ls;
return 0;
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
let pos = this.node.getPosition();
let node =this.node.parent
pos.y=pos.y+60;
tip.load(pos,type,value,s_uuid,node);
}
get_monster_pos(){
return this.node.getPosition()
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){
this.stop_cd -= dt;
if(this.stop_cd <= 0){
this.stop_cd = 0;
this.is_atking = false;
}
}
}
in_destroy(){
// switch (this.scale) {
// case -1:
// if(this.node.position.x < BoxSet.LETF_END){
// this.toDestroy();
// }
// break;
// case 1:
// if(this.node.position.x > BoxSet.RIGHT_END){
// this.toDestroy();
// }
// break;
// }
}
in_atked() {
// var path = "game/skills/atked";
// var prefab: Prefab = oops.res.get(path, Prefab)!;
// var node = instantiate(prefab);
// let pos = v3(0,60)
// node.setPosition(pos)
// node.parent = this.node;
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.1);
}
dead(){
var path = "game/skills/dead";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
}
toDestroy(){
}
reset() {
this.is_dead = false;
// director.pause();
this.node.destroy();
}
}

View File

@@ -11,6 +11,7 @@ import { GameMap } from "../map/GameMap";
import { BoxSet } from "./config/BoxSet";
import { Role } from "../Role/Role";
import { Monster } from "../monster/Monster";
import { v3 } from "cc";
// import { Role } from "../role/Role";
// import { data } from "../data/data";
@@ -38,11 +39,14 @@ export class SingletonModuleComp extends ecs.Comp {
monster_buffs: any = [];
/** 游戏主角 */
Role: Role = null;
t_monster:any={eid:0,pos:v3(0,0,0)};
t_hero:any={eid:0,pos:v3(0,0,0)};
/** 游戏数据 */
// data:data = null!;
/**怪物数据 数组 */
/**heros 数据 */
heros:any = [];
monsters:any = [];
skills:any = []
sk_info:any = []
monsters_dead:any = []
@@ -71,7 +75,7 @@ export class SingletonModuleComp extends ecs.Comp {
exp:0,
next_exp:100,
power:300,
atk_cd:1.5,
atk_cd:2,
},
/** 当前等级 */
cards:{
@@ -101,6 +105,7 @@ export class SingletonModuleComp extends ecs.Comp {
name:"",
skillcd:0,
skillsd:0,
shield:0,
info:"",
}

View File

@@ -10,6 +10,7 @@ export enum BoxSet {
//物理碰撞tag
SKILL_TAG=8,
ATK_RANGE = 4,
//group
DEFAULT = 1,
MONSTER = 2,
HERO = 4,

View File

@@ -2,100 +2,11 @@
CardList type: 1:精灵 2:技能 3:装备
*/
export const CardList={
1:[
{uuid:1101,type:1},{uuid:1102,type:1},{uuid:1201,type:1},{uuid:1202,type:1},{uuid:1301,type:1},{uuid:1302,type:1},
{uuid:2101,type:1},{uuid:2102,type:1},{uuid:2201,type:1},{uuid:2202,type:1},{uuid:2301,type:1},{uuid:2302,type:1},
{uuid:3101,type:1},{uuid:3102,type:1},{uuid:3201,type:1},{uuid:3202,type:1},{uuid:3301,type:1},{uuid:3302,type:1},
{uuid:4101,type:1},{uuid:4102,type:1},{uuid:4201,type:1},{uuid:4202,type:1},{uuid:4301,type:1},{uuid:4302,type:1},
export const CardList=[
// {uuid:1101,type:1},{uuid:1102,type:1},{uuid:1103,type:1},{uuid:1104,type:1},{uuid:1105,type:1},{uuid:1106,type:1},{uuid:1107,type:1},
// {uuid:1108,type:1},{uuid:1109,type:1},{uuid:1110,type:1},{uuid:1113,type:1},{uuid:1114,type:1},{uuid:1115,type:1},{uuid:1116,type:1},
{uuid:1001,type:2},{uuid:1002,type:2},{uuid:4011,type:2},{uuid:4012,type:2},
{uuid:6001,type:3},{uuid:6004,type:3},{uuid:6101,type:3},{uuid:6002,type:3},{uuid:6003,type:3},{uuid:6005,type:3},{uuid:6006,type:3},{uuid:6102,type:3},{uuid:6103,type:3},
{uuid:6210,type:3},{uuid:6213,type:3},{uuid:6216,type:3},{uuid:6211,type:3},{uuid:6212,type:3},{uuid:6214,type:3},{uuid:6215,type:3},{uuid:6217,type:3},{uuid:6218,type:3},
],
2:[
{uuid:1001,type:2},{uuid:1002,type:2},
{uuid:6001,type:3},{uuid:6004,type:3},{uuid:6101,type:3},
],
3:[
{uuid:1001,type:2},{uuid:1002,type:2},{uuid:4011,type:2},{uuid:4012,type:2},
{uuid:6001,type:3},{uuid:6004,type:3},{uuid:6101,type:3},{uuid:6002,type:3},{uuid:6003,type:3},{uuid:6005,type:3},{uuid:6006,type:3},{uuid:6102,type:3},{uuid:6103,type:3},
{uuid:6210,type:3},{uuid:6213,type:3},{uuid:6216,type:3},
],
4:[
{uuid:5001,type:1},{uuid:5002,type:1},{uuid:5003,type:1},{uuid:5004,type:1}
],
5:[{uuid:5001,type:1},{uuid:5002,type:1},{uuid:5003,type:1},{uuid:5004,type:1}],
// 1:[1101,1102,1103,1104,1105,1106,1201,1202,1203,1204,1205,1301,1302,1303,1304,],
// 2:[2101,2102,2103,2104,2105,2201,2202,2203,2204,2301,2302,2303,2304,2305,],
// 3:[3101,3102,3103,3104,3201,3202,3203,3204,3205,3301,3302,3303,3304,],
// 4:[4101,4102,4103,4104,4201,4202,4203,4204,4301,4302,4303,4304,],
// 5:[5001,5002,5003,5004],
}
/*
CardSet type: 1:近战 2:远程 3:法术 暂定
*/
]
export const CardSet = {
1101:{uuid: 1101,path: "1101",type: 1,level: 1,name: "守护犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "守护", info: "自身护盾",atktype: "攻击型", mon: "狗"},
1102:{uuid: 1102,path: "1102",type: 1,level: 1,name: "狂暴犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "狂暴", info: "全体攻击",atktype: "攻击型", mon: "狗"},
1103:{uuid: 1103,path: "1103",type: 1,level: 1,name: "火焰犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "火焰", info: "大火球",atktype: "攻击型", mon: "狗"},
1104:{uuid: 1104,path: "1104",type: 1,level: 1,name: "机甲犬",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "攻击型", mon: "狗"},
1105:{uuid: 1105,path: "1105",type: 1,level: 1,name: "战斗蚁",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "攻击型", mon: "蚂蚁"},
1106:{uuid: 1106,path: "1106",type: 1,level: 1,name: "战斗蚁",atk: 4,hp: 8,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "攻击型", mon: "蚂蚁"},
2101:{uuid: 2101,path: "2101",type: 1,level: 2,name: "金刚鹦鹉",atk: 6,hp: 12,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,word: "金刚", info: "全体招架",atktype: "攻击型", mon: "鹦鹉"},
2102:{uuid: 2102,path: "2102",type: 1,level: 2,name: "狂暴鹦鹉",atk: 6,hp: 12,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,word: "狂暴", info: "全体攻击",atktype: "攻击型", mon: "鹦鹉"},
2103:{uuid: 2103,path: "2103",type: 1,level: 2,name: "鹰",atk: 6,hp: 12,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "攻击型", mon: "鹰"},
2104:{uuid: 2104,path: "2104",type: 1,level: 2,name: "鹰",atk: 6,hp: 12,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "攻击型", mon: "base+U9"},
2105:{uuid: 2105,path: "2105",type: 1,level: 2,name: "鹰",atk: 6,hp: 12,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "攻击型", mon: "鹰"},
3101:{uuid: 3101,path: "3101",type: 1,level: 3,name: "火焰山羊",atk: 9,hp: 18,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,word: "火焰", info: "大火球",atktype: "攻击型", mon: "山羊"},
3102:{uuid: 3102,path: "3102",type: 1,level: 3,name: "坚韧山羊",atk: 9,hp: 18,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,word: "守护", info: "全体护盾",atktype: "攻击型", mon: "山羊"},
3103:{uuid: 3103,path: "3103",type: 1,level: 3,name: "山羊",atk: 9,hp: 18,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,atktype: "攻击型", mon: "山羊"},
3104:{uuid: 3104,path: "3104",type: 1,level: 3,name: "山羊",atk: 9,hp: 18,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,atktype: "攻击型", mon: "山羊"},
4101:{uuid: 4101,path: "4101",type: 1,level: 4,name: "炎爆麋鹿",atk: 13,hp: 27,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,word: "炎爆", info: "炎爆",atktype: "攻击型", mon: "鹿"},
4102:{uuid: 4102,path: "4102",type: 1,level: 4,name: "金刚麋鹿",atk: 13,hp: 27,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,word: "金刚", info: "全体招架",atktype: "攻击型", mon: "鹿"},
4103:{uuid: 4103,path: "4103",type: 1,level: 4,name: "鹿",atk: 13,hp: 27,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,atktype: "攻击型", mon: "鹿"},
4104:{uuid: 4104,path: "4104",type: 1,level: 4,name: "鹿",atk: 13,hp: 27,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,atktype: "攻击型", mon: "鹿"},
1201:{uuid: 1201,path: "1201",type: 2,level: 1,name: "守护熊猫",atk: 2,hp: 16,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,word: "守护", info: "自身护盾",atktype: "血量型", mon: "熊猫"},
1202:{uuid: 1202,path: "1202",type: 2,level: 1,name: "再生绵羊",atk: 2,hp: 16,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,word: "再生", info: "全体回血",atktype: "血量型", mon: "绵羊"},
1203:{uuid: 1203,path: "1203",type: 2,level: 1,name: "坚韧绵羊",atk: 2,hp: 16,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1, info: "全体护盾",atktype: "血量型", mon: "绵羊"},
1204:{uuid: 1204,path: "1204",type: 2,level: 1,name: "绵羊",atk: 2,hp: 16,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,atktype: "血量型", mon: "绵羊"},
1205:{uuid: 1205,path: "1205",type: 2,level: 1,name: "绵羊",atk: 2,hp: 16,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,atktype: "血量型", mon: "绵羊"},
2201:{uuid: 2201,path: "2201",type: 2,level: 2,name: "坚韧龟",atk: 3,hp: 24,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,word: "坚韧", info: "全体护盾",atktype: "血量型", mon: "龟"},
2202:{uuid: 2202,path: "2202",type: 2,level: 2,name: "狂暴龟",atk: 3,hp: 24,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,word: "狂暴", info: "全体攻击",atktype: "血量型", mon: "龟"},
2203:{uuid: 2203,path: "2203",type: 2,level: 2,name: "龟",atk: 3,hp: 24,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,atktype: "血量型", mon: "龟"},
2204:{uuid: 2204,path: "2204",type: 2,level: 2,name: "龟",atk: 3,hp: 24,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,atktype: "血量型", mon: "龟"},
3201:{uuid: 3201,path: "3201",type: 2,level: 3,name: "风刃野猪",atk: 5,hp: 36,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "风刃", info: "风刃",atktype: "血量型", mon: "野猪"},
3202:{uuid: 3202,path: "3202",type: 2,level: 3,name: "急速野猪",atk: 5,hp: 36,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "急速", info: "全体闪避",atktype: "血量型", mon: "野猪"},
3203:{uuid: 3203,path: "3203",type: 2,level: 3,name: "野猪",atk: 5,hp: 36,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "血量型", mon: "野猪"},
3204:{uuid: 3204,path: "3204",type: 2,level: 3,name: "野猪",atk: 5,hp: 36,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "血量型", mon: "野猪"},
3205:{uuid: 3205,path: "3205",type: 2,level: 3,name: "野猪",atk: 5,hp: 36,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "血量型", mon: "野猪"},
4201:{uuid: 4201,path: "4201",type: 2,level: 4,name: "坚韧犀牛",atk: 7,hp: 54,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,word: "坚韧", info: "全体护盾",atktype: "血量型", mon: "犀牛"},
4202:{uuid: 4202,path: "4202",type: 2,level: 4,name: "雷暴犀牛",atk: 7,hp: 54,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,word: "雷暴", info: "雷暴",atktype: "血量型", mon: "犀牛"},
4203:{uuid: 4203,path: "4203",type: 2,level: 4,name: "犀牛",atk: 7,hp: 54,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "血量型", mon: "犀牛"},
4204:{uuid: 4204,path: "4204",type: 2,level: 4,name: "犀牛",atk: 7,hp: 54,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "血量型", mon: "犀牛"},
1301:{uuid: 1301,path: "1301",type: 3,level: 1,name: "守护喵",atk: 3,hp: 6,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,word: "守护", info: "自身护盾",atktype: "攻速型", mon: "猫"},
1302:{uuid: 1302,path: "1302",type: 3,level: 1,name: "急速喵",atk: 3,hp: 6,atk_cd: 2,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 1,word: "急速", info: "全体闪避",atktype: "攻速型", mon: "猫"},
1303:{uuid: 1303,path: "1303",type: 3,level: 1,name: "狂暴喵",atk: 3,hp: 6,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,word: "狂暴", info: "全体攻击",atktype: "攻速型", mon: "松鼠"},
1304:{uuid: 1304,path: "1304",type: 3,level: 1,atk: 3,hp: 6,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 2,atktype: "攻速型", mon: "鼠"},
2301:{uuid: 2301,path: "2301",type: 3,level: 2,name: "狂爆山猫",atk: 4,hp: 9,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,word: "狂爆", info: "全体攻击",atktype: "攻速型", mon: "山猫"},
2302:{uuid: 2302,path: "2302",type: 3,level: 2,name: "急速山猫",atk: 4,hp: 9,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,word: "急速", info: "全体闪避",atktype: "攻速型", mon: "山猫"},
2303:{uuid: 2303,path: "2303",type: 3,level: 2,atk: 4,hp: 9,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "攻速型", mon: "山猫"},
2304:{uuid: 2304,path: "2304",type: 3,level: 2,atk: 4,hp: 9,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "攻速型", mon: "机械蜜蜂"},
2305:{uuid: 2305,path: "2305",type: 3,level: 2,atk: 4,hp: 9,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 3,atktype: "攻速型", mon: "机械山猫"},
3301:{uuid: 3301,path: "3301",type: 3,level: 3,name: "坚韧狮",atk: 6,hp: 15,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,word: "坚韧", info: "全体护盾",atktype: "攻速型", mon: "狮子"},
3302:{uuid: 3302,path: "3302",type: 3,level: 3,name: "冰封狮",atk: 6,hp: 15,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,word: "冰封", info: "冰封",atktype: "攻速型", mon: "狮子"},
3303:{uuid: 3303,path: "3303",type: 3,level: 3,atk: 6,hp: 15,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,atktype: "攻速型", mon: "狮子"},
3304:{uuid: 3304,path: "3304",type: 3,level: 3,atk: 6,hp: 15,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 4,atktype: "攻速型", mon: "狮子"},
4301:{uuid: 4301,path: "4301",type: 3,level: 4,name: "急速独角兽",atk: 10,hp: 22,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,word: "急速", info: "全体闪避",atktype: "攻速型", mon: "独角兽"},
4302:{uuid: 4302,path: "4302",type: 3,level: 4,name: "潮汐独角兽",atk: 10,hp: 22,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,word: "潮汐", info: "潮汐",atktype: "攻速型", mon: "独角兽"},
4303:{uuid: 4303,path: "4303",type: 3,level: 4,atk: 10,hp: 22,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,atktype: "攻速型", mon: "独角兽"},
4304:{uuid: 4304,path: "4304",type: 3,level: 4,atk: 10,hp: 22,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 6,atktype: "攻速型", mon: "独角兽"},
5001:{uuid: 5001,path: "5001",type: 0,level: 5,atk: 15,hp: 60,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 10,atktype: "精英型", mon: "雷电犀牛"},
5002:{uuid: 5002,path: "5002",type: 0,level: 5,atk: 15,hp: 60,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 10,atktype: "精英型", mon: "闪电鼠"},
5003:{uuid: 5003,path: "5003",type: 0,level: 5,atk: 15,hp: 60,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 10,atktype: "精英型", mon: "龙"},
5004:{uuid: 5004,path: "5004",type: 0,level: 5,atk: 15,hp: 60,atk_cd: 1,power: 50,speed: 80,skill: "base",max_skill: "base",int1: null,int2: null,dps: 10,atktype: "精英型", mon: "龙"
}
}

View File

@@ -1,25 +1,13 @@
export const MissionNum = [1,2,3]
export const MonsetList = {
1:{
1:[1101,1102,],
2:[1101,1102,2101,2102,],
3:[2101,2102,3101,3102,],
4:[3101,3102,4101,4102],
5:[5001],
1:[1001,1002,1003],
},
2:{
1:[1201,1202,],
2:[1201,1202,2201,2202,],
3:[2201,2202,3201,3202,],
4:[3201,3202,4201,4202,],
5:[5003,5004],
1:[1001,1002,1003],
},
3:{
1:[1301,1302,],
2:[1301,1302,2301,2302,],
3:[32301,2302,301,3302,],
4:[301,3302,4301,4302,],
5:[5002],
1:[1001,1002,1003],
},
}
@@ -49,7 +37,7 @@ export const MissionSet = {
lv4_skill_num:10,
lv5_skill_num:10,
},
3:{
3:{
lv1_num:10,
lv2_num:10,
lv3_num:10,
@@ -60,5 +48,5 @@ export const MissionSet = {
lv3_skill_num:10,
lv4_skill_num:10,
lv5_skill_num:10,
}
}
}

View File

@@ -0,0 +1,11 @@
export const MonSet={
1001:{uuid: 1101,path: "orc1",type: 1,level: 1,name: "绿洲兽人",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1002:{uuid: 1002,path: "orc2",type: 1,level: 1,name: "荒野兽人",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
1003:{uuid: 1003,path: "orc3",type: 1,level: 1,name: "高阶兽人",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "orc"},
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "42f65183-72b1-4150-a850-00ff62389bbd",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,174 +1,31 @@
export const HeroSet={
1101:{uuid: 1101,path: 1101,type: 1,level: 1,name: "守护犬",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 50,
1101:{uuid: 1101,path: 1101,type: 1,level: 1,name: "守护犬",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻击型",mon: "狗"},
1102:{uuid: 1102,path: 1102,type: 1,level: 1,name: "狂暴犬",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: "攻击型",mon: "狗"},
1103:{uuid: 1103,path: 1103,type: 1,level: 1,name: "火焰犬",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "火焰",info: "大火球", atktype: "攻击型",mon: "狗"},
1104:{uuid: 1104,path: 1104,type: 1,level: 1,name: "机甲犬",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "狗"},
1105:{uuid: 1105,path: 1105,type: 1,level: 1,name: "战斗蚁",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "蚂蚁"},
1106:{uuid: 1106,path: 1106,type: 1,level: 1,name: "战斗蚁",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "蚂蚁"},
2101:{uuid: 2101,path: 2101,type: 1,level: 2,name: "金刚鹦鹉",atk: 6,hp: 36,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "金刚",info: "全体招架", atktype: "攻击型",mon: "鹦鹉"},
2102:{uuid: 2102,path: 2102,type: 1,level: 2,name: "狂暴鹦鹉",atk: 6,hp: 36,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: "攻击型",mon: "鹦鹉"},
2103:{uuid: 2103,path: 2103,type: 1,level: 2,name: "鹰",atk: 6,hp: 36,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
2104:{uuid: 2104,path: 2104,type: 1,level: 2,name: "鹰",atk: 6,hp: 36,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
2105:{uuid: 2105,path: 2105,type: 1,level: 2,name: "鹰",atk: 6,hp: 36,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
3101:{uuid: 3101,path: 3101,type: 1,level: 3,name: "火焰山羊",atk: 9,hp: 54,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "火焰",info: "大火球", atktype: "攻击型",mon: "山羊"},
3102:{uuid: 3102,path: 3102,type: 1,level: 3,name: "坚韧山羊",atk: 9,hp: 54,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "全体护盾", atktype: "攻击型",mon: "山羊"},
3103:{uuid: 3103,path: 3103,type: 1,level: 3,name: "山羊",atk: 9,hp: 54,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "山羊"},
3104:{uuid: 3104,path: 3104,type: 1,level: 3,name: "山羊",atk: 9,hp: 54,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "山羊"},
4101:{uuid: 4101,path: 4101,type: 1,level: 4,name: "炎爆麋鹿",atk: 13,hp: 81,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "炎爆",info: "炎爆", atktype: "攻击型",mon: "鹿"},
4102:{uuid: 4102,path: 4102,type: 1,level: 4,name: "金刚麋鹿",atk: 13,hp: 81,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "金刚",info: "全体招架", atktype: "攻击型",mon: "鹿"},
4103:{uuid: 4103,path: 4103,type: 1,level: 4,name: "鹿",atk: 13,hp: 81,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹿"},
4104:{uuid: 4104,path: 4104,type: 1,level: 4,name: "鹿",atk: 13,hp: 81,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹿"},
1201:{uuid: 1201,path: 1201,type: 2,level: 1,name: "守护绵羊",atk: 2,hp: 48,atk_cd: 2,power: 50,speed: 50,
1102:{uuid: 1102,path: 1102,type: 2,level: 1,name: "羊咩咩",atk: 2,hp: 48,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "血量型",mon: "绵羊"},
1202:{uuid: 1202,path: 1202,type: 2,level: 1,name: "再生绵羊",atk: 2,hp: 48,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "再生",info: "全体回血", atktype: "血量型",mon: "绵羊"},
1203:{uuid: 1203,path: 1203,type: 2,level: 1,name: "坚韧绵羊",atk: 2,hp: 48,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,info: "全体护盾", atktype: "血量型",mon: "绵羊"},
1204:{uuid: 1204,path: 1204,type: 2,level: 1,name: "绵羊",atk: 2,hp: 48,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "绵羊"},
2201:{uuid: 2201,path: 2201,type: 2,level: 2,name: "坚韧龟",atk: 3,hp: 72,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "坚韧",info: "全体护盾", atktype: "血量型",mon: "龟"},
2202:{uuid: 2202,path: 2202,type: 2,level: 2,name: "狂暴龟",atk: 3,hp: 72,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: "血量型",mon: "龟"},
2203:{uuid: 2203,path: 2203,type: 2,level: 2,name: "龟",atk: 3,hp: 72,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "龟"},
2204:{uuid: 2204,path: 2204,type: 2,level: 2,name: "龟",atk: 3,hp: 72,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "龟"},
3201:{uuid: 3201,path: 3201,type: 2,level: 3,name: "风刃野猪",atk: 5,hp: 108,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "风刃",info: "风刃", atktype: "血量型",mon: "野猪"},
3202:{uuid: 3202,path: 3202,type: 2,level: 3,name: "急速野猪",atk: 5,hp: 108,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "急速",info: "全体闪避", atktype: "血量型",mon: "野猪"},
3203:{uuid: 3203,path: 3203,type: 2,level: 3,name: "野猪",atk: 5,hp: 108,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "野猪"},
3204:{uuid: 3204,path: 3204,type: 2,level: 3,name: "野猪",atk: 5,hp: 108,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "野猪"},
3205:{uuid: 3205,path: 3205,type: 2,level: 3,name: "野猪",atk: 5,hp: 108,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "野猪"},
4201:{uuid: 4201,path: 4201,type: 2,level: 4,name: "坚韧犀牛",atk: 7,hp: 162,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "坚韧",info: "全体护盾", atktype: "血量型",mon: "犀牛"},
4202:{uuid: 4202,path: 4202,type: 2,level: 4,name: "雷暴犀牛",atk: 7,hp: 162,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "雷暴",info: "雷暴", atktype: "血量型",mon: "犀牛"},
4203:{uuid: 4203,path: 4203,type: 2,level: 4,name: "犀牛",atk: 7,hp: 162,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "犀牛"},
4204:{uuid: 4204,path: 4204,type: 2,level: 4,name: "犀牛",atk: 7,hp: 162,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "犀牛"},
1301:{uuid: 1301,path: 1301,type: 3,level: 1,name: "守护喵",atk: 3,hp: 18,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻速型",mon: "猫"},
1302:{uuid: 1302,path: 1302,type: 3,level: 1,name: "急速喵",atk: 3,hp: 18,atk_cd: 2,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "急速",info: "全体闪避", atktype: "攻速型",mon: "猫"},
1303:{uuid: 1303,path: 1303,type: 3,level: 1,name: "狂暴喵",atk: 3,hp: 18,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: "攻速型",mon: "松鼠"},
1304:{uuid: 1304,path: 1304,type: 3,level: 1,atk: 3,hp: 18,atk_cd: 1,power: 50,speed: 50,
1103:{uuid: 1103,path: 1103,type: 1,level: 1,name: "战斗蚁",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "蚂蚁"},
1104:{uuid: 1104,path: 1104,type: 1,level: 1,name: "搬运蚁",atk: 4,hp: 24,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "蚂蚁"},
1105:{uuid: 1105,path: 1105,type: 3,level: 1,name: "闪电鼠",atk: 3,hp: 18,atk_cd: 1,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "鼠"},
2301:{uuid: 2301,path: 2301,type: 3,level: 2,name: "狂爆山猫",atk: 4,hp: 27,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂爆",info: "全体攻击", atktype: "攻速型",mon: "山猫"},
2302:{uuid: 2302,path: 2302,type: 3,level: 2,name: "急速山猫",atk: 4,hp: 27,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "急速",info: "全体闪避", atktype: "攻速型",mon: "山猫"},
2303:{uuid: 2303,path: 2303,type: 3,level: 2,atk: 4,hp: 27,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "山猫"},
2304:{uuid: 2304,path: 2304,type: 3,level: 2,atk: 4,hp: 27,atk_cd: 1,power: 50,speed: 50,
1106:{uuid: 1106,path: 1106,type: 3,level: 1,name: "闪电喵",atk: 3,hp: 18,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "守护",info: "自身护盾", atktype: "攻速型",mon: "猫"},
1107:{uuid: 1107,path: 1107,type: 3,level: 1,name: "灵巧松鼠",atk: 3,hp: 18,atk_cd: 1,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "狂暴",info: "全体攻击", atktype: "攻速型",mon: "松鼠"},
1108:{uuid: 1108,path: 1108,type: 3,level: 2,name: "机械蜜",atk: 4,hp: 27,atk_cd: 1,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "机械蜜蜂"},
2305:{uuid: 2305,path: 2305,type: 3,level: 2,atk: 4,hp: 27,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "机械山猫"},
3301:{uuid: 3301,path: 3301,type: 3,level: 3,name: "坚韧狮",atk: 6,hp: 45,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "坚韧",info: "全体护盾", atktype: "攻速型",mon: "狮子"},
3302:{uuid: 3302,path: 3302,type: 3,level: 3,name: "冰封狮",atk: 6,hp: 45,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "冰封",info: "冰封", atktype: "攻速型",mon: "狮子"},
3303:{uuid: 3303,path: 3303,type: 3,level: 3,atk: 6,hp: 45,atk_cd: 1,power: 50,speed: 50,
1109:{uuid: 1109,path: 1109,type: 1,level: 2,name: "猎鹰",atk: 6,hp: 36,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
1110:{uuid: 1110,path: 1110,type: 2,level: 3,name: "憨憨猪",atk: 5,hp: 108,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "血量型",mon: "野猪"},
1113:{uuid: 1113,path: 1113,type: 3,level: 3,name: "憨憨猪",atk: 6,hp: 45,atk_cd: 1,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "狮子"},
3304:{uuid: 3304,path: 3304,type: 3,level: 3,atk: 6,hp: 45,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "狮子"},
4301:{uuid: 4301,path: 4301,type: 3,level: 4,name: "急速独角兽",atk: 10,hp: 66,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "急速",info: "全体闪避", atktype: "攻速型",mon: "独角兽"},
4302:{uuid: 4302,path: 4302,type: 3,level: 4,name: "潮汐独角兽",atk: 10,hp: 66,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "潮汐",info: "潮汐", atktype: "攻速型",mon: "独角兽"},
4303:{uuid: 4303,path: 4303,type: 3,level: 4,atk: 10,hp: 66,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "独角兽"},
4304:{uuid: 4304,path: 4304,type: 3,level: 4,atk: 10,hp: 66,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "独角兽"},
5001:{uuid: 5001,path: 5001,type: 6,level: 5,atk: 15,hp: 180,atk_cd: 1,power: 50,speed: 50,
1114:{uuid: 1114,path: 1114,type: 2,level: 4,name: "黑耀犀牛",atk: 7,hp: 162,atk_cd: 2,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001,word: "雷暴",info: "雷暴", atktype: "血量型",mon: "犀牛"},
1115:{uuid: 1115,path: 1115,type: 6,level: 5,name: "雷暴犀牛",atk: 15,hp: 180,atk_cd: 1,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "精英型",mon: "雷电犀牛"},
5002:{uuid: 5002,path: 5002,type: 6,level: 5,atk: 15,hp: 180,atk_cd: 1,power: 50,speed: 50,
1116:{uuid: 1116,path: 1116,type: 6,level: 5,name: "雷暴鼠",atk: 15,hp: 180,atk_cd: 1,power: 50,speed: 30,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "精英型",mon: "闪电鼠"},
5003:{uuid: 5003,path: 5003,type: 6,level: 5,atk: 15,hp: 180,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "精英型",mon: "龙"},
5004:{uuid: 5004,path: 5004,type: 6,level: 5,atk: 15,hp: 180,atk_cd: 1,power: 50,speed: 50,
skill: "base",max_skill: "base",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "精英型",mon: "龙"
}
}

View File

@@ -14,6 +14,7 @@ import { LoadingViewComp } from "./view/LoadingViewComp";
import { smc } from "../common/SingletonModuleComp";
import { HeroSet } from "../common/config/heroSet";
import { SkillSet } from "../common/config/SkillSet";
import { MonSet } from "../common/config/MonSet";
// import {data} from "../data/data";
/**
@@ -86,6 +87,8 @@ export class Initialize extends ecs.Entity {
private onComplete(queue: AsyncQueue) {
queue.complete = () => {
smc.heros = HeroSet;
smc.monsters=MonSet;
// console.log("加载完成!",smc.heros);
smc.skills=SkillSet;
var uic: UICallbacks = {

View File

@@ -1,4 +1,4 @@
import { _decorator,v3 } from "cc";
import { _decorator,Label,resources,Sprite,SpriteAtlas,v3 } 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 { smc } from "../common/SingletonModuleComp";
@@ -15,6 +15,12 @@ const { ccclass, property } = _decorator;
export class CardControllerComp extends CCComp {
card_level:number = 1;
in_load:boolean = false
card1:any ={x:0,y:0,uuid:1101,type:1,active:false}
card2:any ={x:0,y:0,uuid:1102,type:1,active:false}
card3:any ={x:0,y:0,uuid:1103,type:1,active:false}
card4:any ={x:0,y:0,uuid:1104,type:1,active:false}
card5:any ={x:0,y:0,uuid:1105,type:1,active:false}
card6:any ={x:0,y:0,uuid:1106,type:1,active:false}
start() {
this.load_cards()
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
@@ -76,40 +82,54 @@ export class CardControllerComp extends CCComp {
}
load_cards() {
this.in_load = true
let old_cards = ecs.query(ecs.allOf(HeroCardViewComp))
if (old_cards.length > 0) {
old_cards.forEach(element => {
if (!element.get(HeroCardViewComp).in_destroy) {
element.destroy();
}
let card:any=null
for (let index = 1; index <= 6; index++) {
card=RandomManager.instance.getRandomByObjectList(CardList, 1);
this['card'+index].uuid=card[0].uuid
this['card'+index].type=card[0].type
let url: string = "";
let pathName: string = "";
let name: string = "";
let level: number = 0;
let { uuid, type } = card[0];
switch (type) {
case 1:
url = "game/heros/heros";
({ path: pathName, name, level } = smc.heros[uuid]);
break;
case 2:
url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]);
break;
case 3:
default:
url = "game/heros/skill";
({ path: pathName, name, level } = smc.skills[uuid]);
}
let node=this.node.getChildByName('cards').getChildByName('card'+index)
node.getChildByName('cost').getComponent(Label).string=level.toString()
node.getChildByName('name').getComponent(Label).string=name
// const sprite = node.getChildByName("item").getComponent(Sprite);
// console.log(this['card'+index],url,pathName,sprite)
resources.load(url, SpriteAtlas, (err: any, atlas) => {
const sprite = node.getChildByName("item").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(pathName);
});
this['card'+index].active=true
}
// console.log(old_cards)
let cards_node= this.node.getChildByName("front")
let x=0
let y=0
let lists = this.get_card_list()
lists.forEach(element => {
let card = ecs.getEntity<HeroCard>(HeroCard);
let pos = v3(x,y)
card.load(pos,element[0].uuid,cards_node,element[0].type);
x=x+142
});
this.in_load = false;
}
load_card(){
}
/** 转场 */
protected update(dt: number): void {
this.shuaxin(dt)
}
get_card_list(){
let lists:any = []
for (let index = 0; index < 5; index++) {
let list = RandomManager.instance.getRandomByObjectList(CardList[smc.vm_data.cards.level], 1);
lists.push(list)
}
return lists
let list = RandomManager.instance.getRandomByObjectList(CardList, 1);
return list
}
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */

View File

@@ -11,6 +11,10 @@ import { MissionSet,MissionNum,MonsetList } from "../common/config/MissionSet";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { Role } from "../Role/Role";
import { Hero } from "../monster/Hero";
import { HeroModelComp } from "../monster/HeroModelComp";
import { MonsterModelComp } from "../monster/MonsterModelComp";
import { MonsterViewComp } from "../monster/MonsterViewComp";
import { Mon } from "../mon/Mon";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -31,7 +35,8 @@ export class MapMonsterComp extends CCComp {
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
setp_timer: Timer = new Timer(0.5);
setp_num:number = 3;
target_timer: Timer = new Timer(0.1);
setp_num:number = 1;
onLoad(){
// 监听全局事件
oops.message.on("other_add_monster", this.on_other_add_monster, this);
@@ -57,17 +62,62 @@ 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 = 1
}
if (this.mission_up_timer.update(dt)) {
// 刷新怪物定时器
this.cur_count += 1;
}
// if(this.target_timer.update(dt)){
// this.target_update()
// }
// if (this.game_timer.update(dt)) {
// smc.vm_data.game.g_time += 1;
// }
// this.shuaxin(dt)
}
target_update(){
console.log("map ",smc.t_hero,smc.t_monster)
let heros:any = ecs.query(ecs.allOf(HeroModelComp));
let monsters:any =ecs.query(ecs.allOf(MonsterModelComp));
let h_x=-1000
let m_x=1000
let thi=9999
let tmi=9999
for (let i = 0; i < heros.length; i++) {
const hero = heros[i];
if(hero.MonsterView.node.position.x > h_x){
h_x = hero.MonsterView.node.position.x
thi = i
if(smc.t_hero.eid == hero.MonsterView.eid){
break
}
}
}
for (let i = 0; i < monsters.length; i++) {
const monster = monsters[i];
if(monster.MonsterView.node.position.x < m_x){
m_x = monster.MonsterView.node.position.x
tmi = i
if(smc.t_monster.eid == monster.MonsterView.eid){
break
}
}
}
if(thi==9999){
smc.t_hero={eid:0,pos:v3(0,0,0)}
}else{
smc.t_hero = {eid:heros[thi].MonsterView.eid,pos:v3(heros[thi].MonsterView.node.position,heros[thi].MonsterView.node.position.y)}
}
if(tmi==9999){
smc.t_monster={eid:0,pos:v3(0,0,0)}
}else{
smc.t_monster ={eid:monsters[tmi].MonsterView.eid,pos:v3(monsters[tmi].MonsterView.node.position,monsters[tmi].MonsterView.node.position.y)}
}
}
load_role(){
let role = ecs.getEntity<Role>(Role);
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
@@ -93,15 +143,26 @@ export class MapMonsterComp extends CCComp {
// console.log("当前波数",this.cur_count)
// console.log("当前怪物池",this.mission_list[this.monster_level])
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
let m1:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
let m2:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
// console.log("刷怪",m)
this.addMonster(m[0])
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let pos1:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+60)
let pos2:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE-60)
let monster_layer = scene.entityLayer!.node!
let monster_layer1 = scene.entityLayer1!.node!;
let monster_layer2 = scene.entityLayer2!.node!;
this.addMonster(m[0],monster_layer,pos)
this.addMonster(m1[0],monster_layer1,pos1)
this.addMonster(m2[0],monster_layer2,pos2)
this.setp_num -= 1
}
private addMonster(uuid:number=1101) {
let monster = ecs.getEntity<Monster>(Monster);
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {
let monster = ecs.getEntity<Mon>(Mon);
let scale = -1
let {pos,monster_layer}=this.set_layer(BoxSet.MONSTER_START)
monster.load(pos,scale,uuid,monster_layer);
monster.load(pos,scale,uuid,layer);
}
set_layer(start:number=0){
var scene = smc.map.MapView.scene;
@@ -122,7 +183,10 @@ export class MapMonsterComp extends CCComp {
return {pos,monster_layer}
}
private on_other_add_monster(event: string, args: any) {
this.addMonster(args.uuid)
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let monster_layer = scene.entityLayer!.node!
this.addMonster(args.uuid,monster_layer,pos)
}
/** 视图层逻辑代码分离演示 */

View File

@@ -8,7 +8,6 @@ import { Monster } from "../../monster/Monster";
import { MapViewScene } from "./MapViewScene";
import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { CardSet } from "../../common/config/CardSet";
import { Role } from "../../Role/Role";
const { ccclass, property } = _decorator;

View File

@@ -0,0 +1 @@
{"ver":"1.2.0","importer":"directory","imported":true,"uuid":"b7c4b5b8-e8b2-4730-8c73-11759c02c1b1","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,83 @@
import { _decorator,Contact2DType,Collider2D ,IPhysics2DContact,v3, v2,Vec3} 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 { MonViewComp } from "./MonViewComp";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('BoxRangComp')
@ecs.register('BoxRang', false)
export class BoxRangComp extends CCComp {
Hero_node: any=null!;
MonViewComp:MonViewComp = null!;
box_group:number = BoxSet.DEFAULT;
box_tag:number = BoxSet.ATK_RANGE;
offset_x:number = 300;
atk_range:number = 150;
/** 视图层逻辑代码分离演示 */
start() {
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
collider.tag = this.box_tag;
// collider.offset = v2(300*this.Hero_node.MonView.scale,collider.offset.y);
this.Hero_node = this.node.parent;
this.MonViewComp=this.Hero_node.getComponent(MonViewComp);
// console.log("range box",this.MonViewComp);
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) {
// if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
// console.log(this.node.name+"onBeginContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
// this.MonViewComp.is_atking = true;
// if(Math.abs(otherCollider.node.position.x-selfCollider.node.position.x) < 120){
// this.MonViewComp.stop_cd = 0.1
// }
// }
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0 ){
// console.log(this.node.name+"onEndContact: seft:"+selfCollider.group+"|other:"+otherCollider.group+"| tag: seft:"+selfCollider.tag+"|other:"+otherCollider.tag);
this.MonViewComp.is_atking = false;
this.MonViewComp.enemy = null;
}
}
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
let scene =smc.map.MapView.scene.mapLayer!.node!
let other_pos = otherCollider.node.getWorldPosition() ;
let self_pos = this.node.getWorldPosition();
// console.log("onPreSolve:",self_pos,other_pos);
if(this.MonViewComp.enemy==null){
this.MonViewComp.enemy = otherCollider.node;
}else{
if(this.MonViewComp.enemy.isValid==false){
this.MonViewComp.enemy = otherCollider.node;
}
}
if(Math.abs(other_pos.x-self_pos.x) < this.atk_range){
this.MonViewComp.is_atking = true;
// this.MonViewComp.stop_cd = 0.1
}
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"14659f87-1333-46e0-9b7d-69c369c6f852","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,95 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas} from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp";
import { MonModelComp } from "./MonModelComp";
import { MonSpine } from "./MonSpine";
import { MonViewComp } from "./MonViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { MonBuffComp } from "./MonBuffComp";
import { HeroSet } from "../common/config/heroSet";
import { MonSet } from "../common/config/MonSet";
/** 角色实体 */
@ecs.register(`Mon`)
export class Mon extends ecs.Entity {
// 数据层
MonModel!: MonModelComp;
// 视图层
MonView!: MonViewComp;
MonBuff!: MonBuffComp; // 移动
protected init() {
this.addComponents<ecs.Comp>( MonModelComp);
}
destroy(): void {
this.remove(MonViewComp);
this.remove(MonBuffComp);
super.destroy();
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = -1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!) {
var path = "game/monster/"+MonSet[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent=layer
// var as = node.getComponent(MonSpine);
// let ratio=this.set_ratio(uuid);
// node.setScale(node.scale.x*scale*ratio, node.scale.y*ratio, 0);
node.setPosition(pos)
this.hero_init(uuid,node)
oops.message.dispatchEvent("mon_load",this)
}
set_ratio(uuid:number){
let ratio=1;
switch (MonSet[uuid].level) {
case 2:
ratio=1.05
break;
case 3:
ratio=1.1
break;
case 4:
ratio=1.15
break;
case 5:
ratio=1.2
break;
default:
ratio=1
}
return ratio;
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonViewComp)!;
var buff =node.getComponent(MonBuffComp)!;
// console.log("hero_init",buff)
mv.speed =mv.ospeed = smc.monsters[uuid].speed;
mv.hero_name= smc.monsters[uuid].name;
buff.group=mv.box_group= BoxSet.MONSTER;
mv.hp= mv.hp_max = smc.monsters[uuid].hp;
mv.level = smc.monsters[uuid].level;
mv.atk = smc.monsters[uuid].atk;
mv.atk_cd = smc.monsters[uuid].atk_cd;
mv.power = smc.monsters[uuid].power;
mv.type = smc.monsters[uuid].type;
mv.skill_uuid = 9001;
mv.max_skill_uuid = smc.monsters[uuid].max_skill_uuid;
mv.scale = -1;
mv.Tpos = v3(0,0,0);
this.add(mv);
this.add(buff);
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"7a43618b-14af-4545-b90a-e87402ae1875","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,153 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:42:59
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 12:36:18
*/
import { _decorator,Sprite,Color} 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 { MonSpine } from "./MonSpine";
import { Mon } from "./Mon";
import { MonModelComp } from "./MonModelComp";
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 { BoxRangComp } from "./BoxRangComp";
import { Tooltip } from "../skills/Tooltip";
import { MonViewComp } from "./MonViewComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@ccclass('MonBuffComp') // 定义为 Cocos Creator 组件
@ecs.register('MonBuff', false) // 定义为 ECS 组件
export class MonBuffComp extends CCComp {
/** 角色动画 */
as: MonSpine = null!;
mv!: MonViewComp;
timer:Timer = new Timer(0.1);
buffs:any=[];
group:number=0;
/**
skill_uuid:number=0;
atk:number=0;
hp:number=0;
shield:number=0;
time:number=0;
**/
onLoad() {
this.as = this.node.getComponent(MonSpine);
this.mv= this.getComponent(MonViewComp);
} /** 视图层逻辑代码分离演示 */
start () {
}
add_buff(uuid:number=0,args:any[]){
// console.log("add_buff",smc.skills[uuid]);
let new_buff={
skill_uuid:uuid,
skill_name:smc.skills[uuid].name,
atk:smc.skills[uuid].atk,
hp:smc.skills[uuid].hp,
shield:smc.skills[uuid].shield,
time:smc.skills[uuid].bsd,
bcd:smc.skills[uuid].bcd,
sk_uuid:smc.skills[uuid].uuid,
args:args
}
this.buff_add(new_buff);
}
update(dt: number){
if (this.timer.update(dt)) {
this.buff_update()
}
}
reset() {
this.node.destroy();
}
buff_add(buff:any){
if(!this.node.isValid){ return }
let i = 0
if(this.buffs.length >=0){
this.buffs.forEach((b:any,index:number)=>{
if(b.skill_uuid==buff.skill_uuid){
b.time=buff.time;
if(buff.atk>0){
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
this.mv.atk+=(buff.atk+buff.args.atk-b.atk);
}
if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp);
this.mv.add_hp(buff.hp+buff.args.hp);
// this.mv.hp_max+=(buff.hp-b.hp);
}
if(buff.shield>0){
this.mv.shield=(buff.shield+buff.args.shield);
// this.mv.shield_max=(buff.shield+buff.args.shield);
}
i=index
}
})
}
if (i==0||this.buffs.length==0) {
this.buffs.push(buff);
if(buff.atk>0){
this.mv.atk+=(buff.atk+buff.args.atk);
this.node.getChildByName("avatar").setScale(1.2,1.2)
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#F16F6F");
}
if(buff.hp>0){
this.mv.hp+=(buff.hp+buff.args.hp);
this.mv.add_hp(buff.hp+buff.args.hp);
// this.mv.hp_max+=buff.hp;
}
if(buff.shield>0){
this.mv.shield=(buff.shield+buff.args.shield);
// this.mv.shield_max=(buff.shield+buff.args.shield);
}
}
console.log("buff add:",this.mv);
}
buff_remove(index:number){
if(this.buffs[index].atk>0){
this.mv.atk-=(this.buffs[index].atk+this.buffs[index].args.atk);
this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite).color= new Color().fromHEX("#FFFFFF");
this.node.getChildByName("avatar").setScale(1,1)
}
if(this.buffs[index].shield>0){
this.mv.shield=0
// this.mv.shield_max-=(this.buffs[index].shield+this.buffs[index].args.shield);
}
// if(this.buffs[index].hp>0){
// this.mv.hp_max-=this.buffs[index].hp;
// }
console.log("buff remove:",this.mv,this.buffs[index]);
}
buff_update(){
this.buffs.forEach((buff:any,index:number)=>{
buff.time -= 0.1;
if(buff.time <= 0){
this.buff_remove(index);
}
})
this.buffs = this.buffs.filter((buff:any) => buff.time > 0);
// console.log(this.buffs,this.buffs);
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"dc9c4c07-be34-4d1c-8141-8ec3f9ff8275","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,29 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 15:56:01
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 13:43:25
*/
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/**
* 角色属性数据
*/
@ecs.register('MonModel')
export class MonModelComp extends ecs.Comp {
/** 角色编号 */
id: number = -1;
/** 角色名 */
name: string = "mon";
/** speed */
// speed: number = 0;
/** 动画名资源 */
anim: string = "mon";
reset() {
this.id = -1;
// this.speed = 0;
this.name = "";
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"2200259d-84cb-479b-97d2-75fb61dc135b","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,63 @@
/*
* @Author: dgflash
* @Date: 2022-08-04 15:08:35
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:26:26
*/
import { Color, Component, EventTouch, sp, Vec3, _decorator ,Animation, AnimationClip, AnimationState,} from "cc";
import { LayerUtil } from "../../../../extensions/oops-plugin-framework/assets/core/utils/LayerUtil";
import { smc } from "../../../script/game/common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/**
* SPINE角色模型
*/
@ccclass('MonSpine')
export class MonSpine extends Component {
@property(Animation)
animator: Animation = null!;
atk_clip: AnimationClip = null!;
move_clip: AnimationClip = null!;
onLoad() {
// 角色控制组件
this.initAnimator();
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
this.atk_clip = this.animator.clips[1];
this.move_clip = this.animator.clips[0];
let animation = this.animator.getComponent(Animation);
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
}
/** 初始化动画 */
protected initAnimator() {
this.animator=this.node.getChildByName("mon").getComponent(Animation);
// console.log("mon spine init",this.animator);
}
onAnimationEvent(type: Animation.EventType, state: AnimationState){
if(type==Animation.EventType.FINISHED){
if(state.name==this.atk_clip.name){
this.move();
}
}
}
atk() {
if(!this.animator.getState(this.atk_clip.name).isPlaying){
this.animator.play(this.atk_clip.name);
}
}
move(){
if(!this.animator.getState(this.move_clip.name).isPlaying){
this.animator.play(this.move_clip.name);
}
}
onDestroy() {
this.node.destroy();
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"0ca2f72a-0c8c-41d7-8572-673428a71537","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,72 @@
/*
* @Author: dgflash
* @Date: 2022-08-04 15:08:35
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:26:38
*/
import { sp, _decorator ,Component} from "cc";
const { ccclass, property, requireComponent, disallowMultiple } = _decorator;
/**
* Spine状态机组件主状态机trackIndex为0
*/
@ccclass
@disallowMultiple
@requireComponent(sp.Skeleton)
export default class MonSpineAnimator extends Component {
private animName: string = "move";
private loop: boolean = true;
private spine!: sp.Skeleton;
start() {
this.spine = this.getComponent(sp.Skeleton)!;
// console.log("MonSpineAnimator start");
this.playAnimation(this.animName, this.loop);
}
mixTime:number= 0.2;
protected onLoad(): void {
this.spine = this.getComponent(sp.Skeleton)!;
// this.spine?.setMix('atk', 'move', this.mixTime);
// this.spine?.setMix('move','atk', this.mixTime);
this.spine.setEndListener(trackEntry => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
if (animationName == "atk2" ||animationName == "magic"||animationName=="max") {
this.spine.setAnimation(0, "move", true);
}
});
}
lateUpdate(dt: number) {
//
}
play(animName: string, loop: boolean) {
if (animName) {
this.animName = animName;
this.loop = loop;
this.spine.setAnimation(0, this.animName, this.loop);
}
else {
}
}
/**
* 播放动画
* @override
* @param animName 动画名
* @param loop 是否循环播放
*/
protected playAnimation(animName: string, loop: boolean) {
// console.log("MonSpineAnimator playAnimation");
if (animName) {
// console.log("MonSpineAnimator playAnimation animName", animName);
this.animName = animName;
this.loop = loop;
this.spine.setAnimation(0, this.animName, this.loop);
}
else {
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"5fd6bb0b-8ab2-4ffe-8682-108d9e999004","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,427 @@
/*
* @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,RigidBody2D ,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 { MonSpine } from "./MonSpine";
import { Mon } from "./Mon";
import { MonModelComp } from "./MonModelComp";
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 { Tooltip } from "../skills/Tooltip";
import { MonBuffComp } from "./MonBuffComp";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@ccclass('MonViewComp') // 定义为 Cocos Creator 组件
@ecs.register('MonView', false) // 定义为 ECS 组件
export class MonViewComp extends CCComp {
@property(Material)
hitFlashMaterial: Material;
orginalFlashMaterial: Material;
sprite: Sprite;
@property(Node)
BoxRang:Node =null!
buff:MonBuffComp =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
/** 角色动画 */
as: MonSpine = null!;
hero_uuid:number = 1001;
hero_name : string = "hero";
level:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :mon */
type: number = 1; /**角色类型 1前排 2 后排 */
state: number = 1; /** 状态 1move ,2: act 3: stop */
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_speed: number = 0; //每秒回复量
power: number = 0; /**能量**/
power_max: number = 1200; /** 能量最大值 */
power_speed: number = 1; //能量回复速度每0.1秒回复量
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; /**攻击速度 攻击间隔 */
atk_time: number = 0; /** 冷却时间 */
speed: number = 100; /** 角色移动速度 */
ospeed: number = 100; /** 角色初始速度 */
Tpos: Vec3 = v3(0,-60,0);
stop_cd: number = 0.5; /*停止倒计时*/
shield:number = 0; //护盾量
shield_max:number = 200;
shield_time:number = 0; //护盾持续时间
box_group:number = 2;
atk_range:number = 150;
private timer:Timer = new Timer(1); //计时器
private m_timer:Timer = new Timer(0.1);
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
onLoad() {
this.as = this.getComponent(MonSpine);
this.buff=this.node.getComponent(MonBuffComp);
// this.BoxRang = this.node.getChildByName("range_box");
// this.BoxRang = this.node.getChildByName("range_box");
} /** 视图层逻辑代码分离演示 */
start () {
this.as.move()
this.sprite = this.node.getChildByName("mon").getComponent(Sprite);
// this.node.getChildByName("top").setScale(this.scale,1);
// this.node.getChildByName("atk").setScale(this.scale,1);
// this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
// this.node.getChildByName("hp_max").setScale(this.scale,1);
// this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
this.BoxRang.getComponent(BoxRangComp).atk_range = this.atk_range
// this.BoxRang.getComponent(BoxRangComp).offset_x = 300;
// console.log("monseter ",this.BoxRang);
// console.log("monseter ",this.BoxRang);
// if(this.box_group == BoxSet.MON){
// this.enemy=smc.Role.RoleView.node
// // console.log("mon enemy ",this.enemy);
// }
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
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){
let skill = otherCollider.node.getComponent(SkillCom)!;
// console.log('onPostSolve',skill);
this.in_atked();
if(this.hp <= 0 ){
return
}
this.hp_change(skill.atk);
}
}
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.is_atking = true;
this.stop_cd = 0.1;
}
}
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('mon view group 相同');
switch (selfCollider.group) {
case BoxSet.HERO:
if(self_pos.x < other_pos.x){
// this.stop_cd=0.1
}
break;
case BoxSet.MONSTER:
if(self_pos.x > other_pos.x){
// this.stop_cd=0.1
}
break
}
}
}
update(dt: number){
if (this.timer.update(dt)) {
this.power_change(this.power_speed)
}
this.in_destroy();
this.in_shield();
this.in_stop(dt);
this.in_act(dt);
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
// }
}
move(dt: number){
if(this.stop_cd > 0){
return
}
if (this.scale === 1 && this.node.position.x >= 120) {
return;
}
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
return;
}
// if(this.enemy){
// return
// }
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
}
move_to(){
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(smc.Role.RoleView.node.position.x+10,smc.Role.RoleView.node.position.y);
move.node = this.node;
move.speed = this.ospeed;
// if(this.box_group == BoxSet.MON){
// if(smc.t_hero.eid != 0){
// var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
// if(smc.t_hero.pos.x < this.node.position.x){
// // this.node.setScale(-Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_hero.pos.x+20,smc.t_hero.pos.y);
// }else{
// // this.node.setScale(Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_hero.pos.x-20,smc.t_hero.pos.y);
// }
// move.node = this.node;
// move.speed = this.ospeed;
// }
// }
// if(this.box_group == BoxSet.HERO){
// if(smc.t_mon.eid != 0){
// var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
// if(smc.t_mon.pos.x < this.node.position.x){
// // this.node.setScale(-Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_mon.pos.x+20,smc.t_mon.pos.y);
// }else{
// // this.node.setScale(Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_mon.pos.x-20,smc.t_mon.pos.y);
// }
// move.node = this.node;
// move.speed = this.ospeed;
// }
// }
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
this.as.atk()
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
this.power = 0
}
let power_progress= this.power/this.power_max;
this.node.getChildByName("top").getChildByName("power").getComponent(ProgressBar)!.progress = power_progress;
}
shoot(skill_uuid:number){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(35*this.scale,50)
let scale = this.scale
let speed =smc.skills[skill_uuid].speed;
let dis = smc.skills[skill_uuid].dis;
let atk = smc.skills[skill_uuid].atk+this.atk;
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
angle = angle +180
}
}else{
t_pos=null
}
skill.load(pos,speed,dis,scale,this.node,skill_uuid,atk,angle,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
do_max_skill(){
let skill = ecs.getEntity<Skill>(Skill);
let x=32
let pos = v3(-40*this.scale,BoxSet.MAX_SKILL_SY)
let scale = this.scale
let speed =smc.skills[this.max_skill_uuid].speed;
let dis = smc.skills[this.max_skill_uuid].dis;
let atk = smc.skills[this.max_skill_uuid].atk+this.atk;
skill.load(pos,speed,dis,scale,this.node,this.max_skill_uuid,atk);
this.tooltip(3,smc.skills[this.max_skill_uuid].name,this.max_skill_uuid);
}
in_act(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill_uuid);
},0.4)
}
}else{
this.atk_time += dt;
}
}
in_shield(){
let shield_progress= this.shield/this.shield_max;
this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
// if(this.shield <= 0){
// this.node.getChildByName("shield").active=false
// }else{
// this.node.getChildByName("shield").active=true
// }
}
hp_change(hp: number){
if(this.is_dead){
return;
}
let lhp=this.shield_change(hp);
if(lhp == 0){
return;
}
this.hp += lhp;
this.tooltip(1,hp.toString());
if(this.hp > this.hp_max){
this.hp = this.hp_max;
}
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.remove_smc_data()
this.is_dead = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
remove_smc_data(){
if(smc.t_monster.eid == this.ent.eid){
smc.t_monster = {eid:0,pos:v3(0,0,0)}
}
if(smc.t_hero.eid == this.ent.eid){
smc.t_hero = {eid:0,pos:v3(0,0,0)}
}
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.tooltip(2,hp.toString());
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
this.shield = 0;
return ls;
}else{
this.shield = ls;
return 0;
}
}
tooltip(type:number=1,value:string="",s_uuid:number=1001){
// console.log("tooltip",type);
let tip =ecs.getEntity<Tooltip>(Tooltip);
let pos = this.node.getPosition();
let node =this.node.parent
pos.y=pos.y+60;
tip.load(pos,type,value,s_uuid,node);
}
get_mon_pos(){
return this.node.getPosition()
}
/** 静止时间 */
in_stop (dt: number) {
if(this.stop_cd > 0){
this.stop_cd -= dt;
if(this.stop_cd <= 0){
this.stop_cd = 0;
this.is_atking = false;
}
}
}
in_destroy(){
// switch (this.scale) {
// case -1:
// if(this.node.position.x < BoxSet.LETF_END){
// this.toDestroy();
// }
// break;
// case 1:
// if(this.node.position.x > BoxSet.RIGHT_END){
// this.toDestroy();
// }
// break;
// }
}
in_atked() {
if(this.is_role){
var path = "game/skills/atked";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let pos = v3(0,60)
node.setPosition(pos)
node.parent = this.node;
}else{
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.1);
}
}
dead(){
var path = "game/skills/dead";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setPosition(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
}
toDestroy(){
}
reset() {
this.is_dead = false;
this.node.destroy();
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"18359c9e-1232-4a7b-aebd-5cd49e882d86","files":[],"subMetas":{},"userData":{}}

View File

@@ -14,14 +14,14 @@ export class BoxRangComp extends CCComp {
MonsterViewComp:MonsterViewComp = null!;
box_group:number = BoxSet.DEFAULT;
box_tag:number = BoxSet.ATK_RANGE;
offset_x:number = 0;
offset_x:number = 300;
atk_range:number = 150;
/** 视图层逻辑代码分离演示 */
start() {
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;
collider.tag = this.box_tag;
// collider.offset = v2(this.offset_x,40);
// collider.offset = v2(300*this.Hero_node.MonsterView.scale,collider.offset.y);
this.Hero_node = this.node.parent;
this.MonsterViewComp=this.Hero_node.getComponent(MonsterViewComp);
// console.log("range box",this.MonsterViewComp);
@@ -64,9 +64,8 @@ export class BoxRangComp extends CCComp {
}
}
if(Math.abs(other_pos.x-self_pos.x) < this.atk_range){
this.MonsterViewComp.is_atking = true;
this.MonsterViewComp.stop_cd = 0.1
// this.MonsterViewComp.stop_cd = 0.1
}
}

View File

@@ -12,6 +12,7 @@ import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroModelComp } from "./HeroModelComp";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { MonModelComp } from "../mon/MonModelComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -62,9 +63,9 @@ export class CSkillComp extends CCComp {
let t_pos = v3(0,0)
let angle = 0
let m_pos=v3(0,0)
let monsters:any = ecs.query(ecs.allOf(MonsterModelComp));
let monsters:any = ecs.query(ecs.allOf(MonModelComp));
if (monsters.length > 0) {
m_pos = monsters[0].MonsterView.get_monster_pos()
m_pos = monsters[0].MonView.node.position
}else{
m_pos = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
@@ -98,7 +99,7 @@ export class CSkillComp extends CCComp {
// 94role 临时buff
// 95role 永久buff
let uuid= this.skill_uuid;
let atk:number=smc.Role.MonsterView.atk
let atk:number=smc.Role.RoleView.atk
let args:any = {
atk:atk*GameSet.ATK_TO_ATK_RATIO,
hp:atk*GameSet.ATK_TO_HP_RATIO,

View File

@@ -15,7 +15,6 @@ import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterSpine } from "./MonsterSpine";
import { MonsterViewComp } from "./MonsterViewComp";
import {HeroModelComp} from "./HeroModelComp";
import { CardSet } from "../common/config/CardSet";
import { BoxSet } from "../common/config/BoxSet";
import { MonsterBuffComp } from "./MonsterBuffComp";
/** 角色实体 */

View File

@@ -12,7 +12,6 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp";
import{HeroCardViewComp} from "./HeroCardViewComp";
import { CardSet } from "../common/config/CardSet";
import { SkillSet } from "../common/config/SkillSet";
/** 角色实体 */
@ecs.register(`HeroCard`)

View File

@@ -4,7 +4,6 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { data } from "../data/data";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { CardSet } from "../common/config/CardSet";
import { SkillSet } from "../common/config/SkillSet";
import { HeroCard } from "./HeroCard";
import { HeroModelComp } from "./HeroModelComp";

View File

@@ -14,7 +14,6 @@ import { smc } from "../common/SingletonModuleComp";
import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterSpine } from "./MonsterSpine";
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";
@@ -46,8 +45,8 @@ export class Monster extends ecs.Entity {
var node = instantiate(prefab);
node.parent=layer
// var as = node.getComponent(MonsterSpine);
// let ratio=this.set_ratio(uuid);
node.setScale(node.scale.x*scale, node.scale.y, node.scale.z);
let ratio=this.set_ratio(uuid);
node.setScale(node.scale.x*scale*ratio, node.scale.y*ratio, 0);
// node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*scale, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z);
node.setPosition(pos)
@@ -60,29 +59,30 @@ 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;
// }
set_ratio(uuid:number){
let ratio=1;
switch (smc.heros[uuid].level) {
case 2:
ratio=1.05
break;
case 3:
ratio=1.1
break;
case 4:
ratio=1.15
break;
case 5:
ratio=1.2
break;
default:
ratio=1
}
return ratio;
}
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
var mv = node.getComponent(MonsterViewComp)!;
var buff =node.getComponent(MonsterBuffComp)!;
// console.log("hero_init",smc.heros,uuid)
mv.speed =mv.ospeed = smc.heros[uuid].speed;
mv.hero_name= smc.heros[uuid].name;
buff.group=mv.box_group= BoxSet.MONSTER;

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite} from "cc";
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label,RigidBody2D ,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";
@@ -19,9 +19,10 @@ 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";
import { MonsterBuffComp } from "./MonsterBuffComp";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BoxRangComp } from "./BoxRangComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -78,6 +79,7 @@ export class MonsterViewComp extends CCComp {
box_group:number = 2;
atk_range:number = 150;
private timer:Timer = new Timer(1); //计时器
private m_timer:Timer = new Timer(0.1);
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
@@ -85,24 +87,26 @@ export class MonsterViewComp extends CCComp {
onLoad() {
this.as = this.getComponent(MonsterSpine);
this.buff=this.node.getComponent(MonsterBuffComp);
this.BoxRang = this.node.getChildByName("range_box");
// this.BoxRang = this.node.getChildByName("range_box");
// this.BoxRang = this.node.getChildByName("range_box");
} /** 视图层逻辑代码分离演示 */
start () {
this.sprite = this.node.getChildByName("avatar").getChildByName("TNode").getChildByName("bb").getComponent(Sprite);
this.node.getChildByName("top").setScale(this.scale,1);
this.node.getChildByName("atk").setScale(this.scale,1);
this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
this.node.getChildByName("hp_max").setScale(this.scale,1);
this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
this.node.getChildByName("top").setScale(this.scale,1);
// this.node.getChildByName("atk").setScale(this.scale,1);
// this.node.getChildByName("atk").getComponent(Label).string = this.atk.toString();
// this.node.getChildByName("hp_max").setScale(this.scale,1);
// this.node.getChildByName("hp_max").getComponent(Label).string=this.hp_max.toString();
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
this.BoxRang.getComponent(BoxRangComp).box_group = this.box_group;
this.BoxRang.getComponent(BoxRangComp).atk_range = this.atk_range
// this.BoxRang.getComponent(BoxRangComp).offset_x = this.scale*smc.skills[this.skill_uuid].dis/3;
// this.BoxRang.getComponent(BoxRangComp).offset_x = 300;
// console.log("monseter ",this.BoxRang);
// console.log("monseter ",this.BoxRang);
// if(this.box_group == BoxSet.MONSTER){
// this.enemy=smc.Role.RoleView.node
// // console.log("monster enemy ",this.enemy);
// }
this.buff.group=this.box_group
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
@@ -118,6 +122,7 @@ export class MonsterViewComp extends CCComp {
}
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D) {
if(otherCollider.tag==BoxSet.SKILL_TAG &&selfCollider.tag!=BoxSet.SKILL_TAG){
if(selfCollider.group != otherCollider.group){
let skill = otherCollider.node.getComponent(SkillCom)!;
@@ -132,11 +137,11 @@ export class MonsterViewComp extends CCComp {
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.is_atking = true;
this.stop_cd = 0.1;
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&otherCollider.tag == 0&&selfCollider.tag == 0){
@@ -146,12 +151,12 @@ export class MonsterViewComp extends CCComp {
switch (selfCollider.group) {
case BoxSet.HERO:
if(self_pos.x < other_pos.x){
this.stop_cd=0.1
// this.stop_cd=0.1
}
break;
case BoxSet.MONSTER:
if(self_pos.x > other_pos.x){
this.stop_cd=0.1
// this.stop_cd=0.1
}
break
}
@@ -168,7 +173,9 @@ export class MonsterViewComp extends CCComp {
this.in_stop(dt);
this.in_act(dt);
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
// }
}
move(dt: number){
@@ -178,8 +185,52 @@ export class MonsterViewComp extends CCComp {
if (this.scale === 1 && this.node.position.x >= 120) {
return;
}
if(this.scale===-1&&this.node.position.x <= BoxSet.HERO_START){
return;
}
// if(this.enemy){
// return
// }
this.node.setPosition(this.node.position.x+dt*this.speed*this.scale, this.node.position.y, this.node.position.z);
}
move_to(){
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(smc.Role.RoleView.node.position.x+10,smc.Role.RoleView.node.position.y);
move.node = this.node;
move.speed = this.ospeed;
// if(this.box_group == BoxSet.MONSTER){
// if(smc.t_hero.eid != 0){
// var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
// if(smc.t_hero.pos.x < this.node.position.x){
// // this.node.setScale(-Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_hero.pos.x+20,smc.t_hero.pos.y);
// }else{
// // this.node.setScale(Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_hero.pos.x-20,smc.t_hero.pos.y);
// }
// move.node = this.node;
// move.speed = this.ospeed;
// }
// }
// if(this.box_group == BoxSet.HERO){
// if(smc.t_monster.eid != 0){
// var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
// if(smc.t_monster.pos.x < this.node.position.x){
// // this.node.setScale(-Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_monster.pos.x+20,smc.t_monster.pos.y);
// }else{
// // this.node.setScale(Math.abs(this.node.scale.x),this.node.scale.y)
// move.target = v3(smc.t_monster.pos.x-20,smc.t_monster.pos.y);
// }
// move.node = this.node;
// move.speed = this.ospeed;
// }
// }
}
power_change(power: number){
this.power += power;
if(this.power >= this.power_max){
@@ -204,6 +255,10 @@ export class MonsterViewComp extends CCComp {
let angle=0
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
if(!this.enemy.isValid){
console.log("move_to",this.enemy.isValid);
return
}
t_pos = v3(this.enemy.position.x-this.node.position.x,this.enemy.position.y-this.node.position.y)
angle = Math.atan2(t_pos.y,t_pos.x) * 180 / Math.PI;
if(this.scale == -1){
@@ -269,12 +324,21 @@ export class MonsterViewComp extends CCComp {
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
if(this.hp <= 0){
this.dead();
this.remove_smc_data()
this.is_dead = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
remove_smc_data(){
if(smc.t_monster.eid == this.ent.eid){
smc.t_monster = {eid:0,pos:v3(0,0,0)}
}
if(smc.t_hero.eid == this.ent.eid){
smc.t_hero = {eid:0,pos:v3(0,0,0)}
}
}
add_hp(hp: number=0){
console.log("hero 加血动画");
this.tooltip(2,hp.toString());
@@ -335,7 +399,7 @@ export class MonsterViewComp extends CCComp {
let pos = v3(0,60)
node.setPosition(pos)
node.parent = this.node;
}else{
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {