boss需要改用spine 动画 先放一放

This commit is contained in:
pan@work
2024-09-19 16:22:39 +08:00
parent 29a6f6a8b6
commit 3c9fab6889
43 changed files with 2179 additions and 2679 deletions

View File

@@ -0,0 +1 @@
{"ver":"1.2.0","importer":"directory","imported":true,"uuid":"59681a02-4a5e-464a-a391-21c0ad9a20e7","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,94 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, tween, Vec3,Label,resources ,SpriteAtlas,Sprite,v3} 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 { BossModelComp } from "./BossModelComp";
import { BossSpine } from "./BossSpine";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { BossViewComp } from "./BossViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { MonSet } from "../common/config/heroSet";
/** 角色实体 */
@ecs.register(`Boss`)
export class Boss extends ecs.Entity {
// 数据层
BossModel!: BossModelComp;
BossMoveTo!: MoveToComp; // 移动
// 视图层
BossView!: BossViewComp;
protected init() {
this.addComponents<ecs.Comp>(
BossModelComp);
}
destroy(): void {
this.remove(BossViewComp);
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 bs = node.getComponent(BossViewComp)!;
// console.log("hero_init",buff)
bs.speed =bs.ospeed = smc.monsters[uuid].speed;
bs.hero_name= smc.monsters[uuid].name;
bs.hp= bs.hp_max = smc.monsters[uuid].hp;
bs.level = smc.monsters[uuid].level;
bs.atk = smc.monsters[uuid].atk;
bs.atk_cd = smc.monsters[uuid].atk_cd;
bs.atk_dis = smc.monsters[uuid].atk_dis;
bs.power = smc.monsters[uuid].power;
bs.power_max = smc.monsters[uuid].power_max;
bs.type = smc.monsters[uuid].type;
bs.scale = -1;
bs.Tpos = v3(0,0,0);
this.add(bs);
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"dc2a1db4-c531-4d4b-8de4-318efb5dbf58","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,27 @@
/*
* @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('BossModel')
export class BossModelComp extends ecs.Comp {
/** 角色编号 */
id: number = -1;
/** 角色名 */
name: string = "Boss";
/** 动画名资源 */
anim: string = "Boss";
reset() {
this.id = -1;
this.name = "";
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"258ce138-d7ba-4393-ad1c-fc037fb912e1","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,56 @@
/*
* @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 "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/**
* SPINE角色模型
*/
@ccclass('BossSpine')
export class BossSpine extends Component {
private loop: boolean = true;
private spine!: sp.Skeleton;
private default:string = "idle";
private atk_name: string = "atk";
private move_name: string = "move";
private max_name: string = "max";
private idel_name: string = "idle";
start() {
this.spine.setAnimation(0, this.default, true);
}
mixTime:number= 0.2;
onLoad() {
this.spine = this.node.getChildByName("anm")!.getComponent(sp.Skeleton);
this.spine.setEndListener(trackEntry => {
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
// console.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
if (animationName == "atk" || animationName== "max" ) {
this.spine.setAnimation(0, this.default, true);
}
});
}
protected play(animName: string, loop: boolean) {
}
atk(){
this.spine.setAnimation(0, this.atk_name, false);
}
idle(){
this.spine.setAnimation(0, this.idel_name, true);
}
move(){
this.spine.setAnimation(0, this.move_name, true);
}
max(){
this.spine.setAnimation(0, this.max_name, false);
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"3a58952a-5c4c-4f38-a65c-e82553ff7fcd","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,454 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:42:59
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, v3,_decorator ,Collider2D,Contact2DType,Label,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite,Animation, director, Vertex} 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 { BossSpine } from "./BossSpine";
import {BoxSet} from "../common/config/BoxSet"
import { smc } from "../common/SingletonModuleComp";
import { SkillCom } from "../skills/SkillCom";
import { Skill } from "../skills/Skill";
import { SkillSet } from "../common/config/SkillSet";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
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 { Tooltip } from "../skills/Tooltip";
import { MonViewComp } from "../mon/MonViewComp";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@ccclass('BossViewComp') // 定义为 Cocos Creator 组件
@ecs.register('BossView', false) // 定义为 ECS 组件
export class BossViewComp extends CCComp {
@property(Material)
hitFlashMaterial: Material;
orginalFlashMaterial: Material;
@property(Material)
atkMaterial: Material;
sprite: Sprite;
/** 角色动画 */
as:BossSpine =null!;
is_role:boolean = false;
enemy_pos:Vec3=null!;
enemy:any=null!;
atk_enemy:any=null!;
neraster_enemy:any=null!;
/** 角色动画 */
hero_uuid:number = 1001;
hero_name : string = "role";
level:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :monster */
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:8001;
skills:{
1:{uuid:8001,cd:2,alive:true },
2:{uuid:8001,cd:2,alive:false},
3:{uuid:8001,cd:2,alive:false},
4:{uuid:8001,cd:2,alive:false},
5:{uuid:8001,cd:2,alive:false},
}
buff_atks:any = [];
buff_atk:number = 0;
atk: number = 10; /**攻击力 */
mission_atk:number = 0;//局内攻击
// atk_speed: number = 1;
atk_cd: number = 1.3; /**攻击速度 攻击间隔 */
atk_dis: number = 800;
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 = BoxSet.HERO;
atk_range:number = 150;
private timer:Timer = new Timer(0.1); //计时器
is_dead:boolean = false; //是否摧毁
is_stop:boolean = false;
is_atking:boolean = false;
type:number = 0;
onLoad() {
// this.BoxRang = this.node.getChildByName("range_box");
this.as = this.node.getComponent(BossSpine);
}
start () {
// 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);
this.node.setSiblingIndex(100)
// 注册单个碰撞体的回调函数
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) {
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&&selfCollider.tag==otherCollider.tag){
if(selfCollider.node.position.y < otherCollider.node.position.y){
if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
// console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
}
}
}
}
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.timer.update(dt)) {
}
this.in_destroy();
this.check_buff_atks(dt)
this.in_shield(dt);
this.in_stop(dt);
this.atk_time += dt;
this.in_atk();
// this.move();
this.check_enemys()
}
check_enemys(){
let enemys=ecs.query(ecs.allOf(MonViewComp));
if(enemys.length > 0){
let x= 720
for (let i = 0; i < enemys.length; i++) {
let enemy:any = enemys[i];
if(!enemy.MonView) continue
let node=enemy.MonView.node
if(node.isValid){
if(node.position.x < x){
x=node.position.x
this.enemy = node.position;
}
}
}
}else{
this.enemy = v3(720,this.node.position.y);
}
}
move(){
if(this.stop_cd > 0){
return
}
if(this.enemy){
this.move_to(this.enemy.position)
}else{
this.move_to(v3(0,0));
}
}
move_to(enemy:Vec3){
// console.log("move to ",enemy);
var move = this.ent.get(MoveToComp) || this.ent.add(MoveToComp);
move.target = v3(enemy.x-100,enemy.y);
move.node = this.node;
move.speed = this.ospeed;
if(enemy.x < this.node.position.x){
this.node.setScale(-1,1);
}else{
this.node.setScale(1,1);
}
}
shoot(skill_uuid:number,y:number=0,x:number=0){
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[skill_uuid].atk+this.atk+this.buff_atk+this.mission_atk;
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
pos.x=pos.x + x
skill.load(pos,BoxSet.HERO,this.node,skill_uuid,atk,t_pos);
// this.tooltip(3,smc.skills[skill_uuid].name,this.skill_uuid);
}
//使用max_skill
get_enemy_pos(){
let pos = v3(0,50)
let t_pos:Vec3 = v3(0,0)
if(this.enemy){
t_pos = v3(this.enemy.x-this.node.position.x,this.enemy.y-this.node.position.y)
}else{
t_pos=v3(720,0)
}
return {pos,t_pos}
}
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
return true
}else{
return false
}
}
in_atk() {
if(this.atk_time >= this.atk_cd){
// if(this.is_atking&&this.check_enemy_alive()){
// this.atk_time = 0;
// // console.log("atk_cd:"+this.atk_cd);
// this.as.atk();
// this.scheduleOnce(()=>{
// this.shoot(this.skill,-30);
// },0.4)
// }
this.atk_time = 0;
this.as.atk();
this.scheduleOnce(()=>{
this.shoot(this.skill,-30);
},0.2)
}
}
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.is_dead = true;
this.ent.remove(MoveToComp)
smc.vm_data.game_over = true;
setTimeout(() => {
this.ent.destroy();
}, 15);
}
}
heathed(){
this.node.getChildByName("heathed").active=true
}
add_hp(hp: number=0){
this.heathed();
this.tooltip(2,hp.toString());
let hp_progress= this.hp/this.hp_max;
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
}
add_atk(atk: number,time:number=0){
if(time > 0){
this.buff_atk=0
let buff={atk:atk,time:time}
this.buff_atks.push(buff);
this.buff_atks.forEach((element: { atk: number; }) => {
this.buff_atk += element.atk
});
}else{
this.mission_atk += atk;
}
// this.sprite.setSharedMaterial(this.atkMaterial, 0);
// this.scheduleOnce(() => {
// this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
// }, 0.3);
}
check_buff_atks(dt: number){
for(let i=0;i<this.buff_atks.length;i++){
let buff=this.buff_atks[i];
buff.time -= dt;
if(buff.time <= 0){
this.buff_atk -= buff.atk
this.buff_atks.splice(i,1);
}
}
if(this.buff_atks.length <= 0){
this.buff_atk = 0
this.buff_icon_change("atk",false)
}else{
this.buff_icon_change("atk",true)
}
}
buff_icon_change(icon:string,value:boolean){
this.node.getChildByName("top").getChildByName("buff").getChildByName(icon).active=value
}
add_shield(shield: number,time:number=0){
this.shield =this.shield_max=shield
this.shield_time = time;
}
shield_change(hp: number){
let ls=this.shield - hp;
if(ls <= 0){
this.shield = 0;
return ls;
}else{
this.shield = ls;
return 0;
}
}
in_shield(dt: number){
if(this.shield <= 0){
this.shield_time=0
this.node.getChildByName("shielded").active=false
}else{
this.node.getChildByName("shielded").active=true
}
if(this.shield_time <= 0){
this.shield = this.shield_max=0;
this.node.getChildByName("shielded").active=false
return
}
if(this.shield_time > 0){
this.shield_time -= dt;
if(this.shield_time <= 0){
this.shield_time = 0;
this.shield = this.shield_max=0;
// this.node.getChildByName("top").getChildByName("shield").active=false
}
// let shield_progress= this.shield/this.shield_max;
// this.node.getChildByName("top").getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
}
}
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

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"2e4e5f05-fb79-401b-9376-7e006b9c8247","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"d07463ae-fffe-4c3b-af60-c40a1253e9a3","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"34c56beb-469d-4134-a4bb-e0e79fef03e3","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"16ff69cd-f95d-4898-acdf-8d53e61e2f89","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"243e34fa-bcfe-4b88-83c4-bda211a7abaf","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"880fb02e-7bb2-4ee8-9a8a-f7c161eca401","files":[],"subMetas":{},"userData":{}}

View File

@@ -13,10 +13,8 @@ import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp";
import { RoleModelComp } from "./RoleModelComp";
import { RoleSpine } from "./RoleSpine";
import { RoleSet } from "../common/config/RoleSet";
import { MoveToComp } from "../common/ecs/position/MoveTo";
import { RoleViewComp } from "./RoleViewComp";
import { RoleBuffComp } from "./RoleBuffComp";
import { BoxSet } from "../common/config/BoxSet";
/** 角色实体 */
@ecs.register(`Role`)

View File

@@ -35,8 +35,7 @@ export class RoleViewComp extends CCComp {
atkMaterial: Material;
sprite: Sprite;
/** 角色动画 */
@property(Node)
BoxRang:Node =null!
as:RoleSpine =null!;
is_role:boolean = false;
@@ -103,18 +102,8 @@ export class RoleViewComp extends CCComp {
// 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("hp_max").getComponent(Label).string=this.hp_max.toString();
// this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
// 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);
// 注册单个碰撞体的回调函数
let collider = this.getComponent(Collider2D);
collider.group = this.box_group;

View File

@@ -38,20 +38,12 @@ export enum BoxSet {
MAX_SKILL_BY = 80,
ATK_Y = 20,
ROLE_FUX=80,
ROLE_FUY=40,
ROLE_FDX=80,
ROLE_FDY=-40,
ROLE_BUX=-80,
ROLE_BUY=40,
ROLE_BDX=-80,
ROLE_BDY=-40,
}
export enum GameSet {
ATK_TO_ATK_RATIO=0.1,
ATK_TO_HP_RATIO=0.2,
ATK_TO_SHIELD_RATIO=2
ATK_TO_SHIELD_RATIO=2,
ATK_LINES = 3,
}

View File

@@ -5,7 +5,12 @@ export const MonsetList = {
}
}
export const BossList = {
1:{
1:[5001],
}
}
export const MissionSet = {
1:{
lv1_num:10,

View File

@@ -36,9 +36,9 @@ export const SkillSet={
2001:{uuid: 2001,path: "2001",type: 91,tg:1,angle:false,level: 1,name: "治愈术",sp_name:"heath",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0,run:1,atk:0,hp:30,shield:0,sd:10,cd:1,bsd:0,bcd:0,sk_uuid:1001,sk_count:0,speed:450, },
2002:{uuid: 2002,path: "2002",type: 91,tg:0,angle:false,level: 1,name: "魔法盾",sp_name:"shield",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0.2,run:2,atk:0,hp:0,shield:50,sd:0,cd:0,bsd:30,bcd:0,sk_uuid:1001,sk_count:0,speed:450, },
dis:1,count:1,in:0.2,run:2,atk:0,hp:0,shield:50,sd:0,cd:0,bsd:8,bcd:0,sk_uuid:1001,sk_count:0,speed:450, },
2003:{uuid: 2003,path: "2003",type: 91,tg:0,angle:false,level: 1,name: "狂暴",sp_name:"atkup",info:"释放一个寒冰箭攻击敌人",
dis:1,count:1,in:0.2,run:2,atk:10,hp:0,shield:0,sd:0,cd:0,bsd:30,bcd:0,sk_uuid:1001,sk_count:0,speed:450, },
dis:1,count:1,in:0.2,run:2,atk:10,hp:0,shield:0,sd:0,cd:0,bsd:8,bcd:0,sk_uuid:1001,sk_count:0,speed:450, },
3001:{uuid: 3001,path: "3001",type: 1,tg:3,angle:true,level: 1,name: "三连击",sp_name:"patk",info:"释放一个魔法球攻击敌人",

View File

@@ -1,31 +1,31 @@
export const HeroSet = {
9001: {
uuid: 9001, path: "k3", type: 1, level: 1,cost:2, name: "骑士", atk: 4, hp: 60, atk_dis: 40, atk_cd: 1, power: 0, power_max: 10, speed: 30,
uuid: 9001, path: "k3", type: 1, level: 1,cost:2, name: "骑士", atk: 4, hp: 60, atk_dis: 40, atk_cd: 1, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 2002, word: "守护", info: "自身护盾", atktype: 1,
},
9002: {
uuid: 9002, path: "k1", type: 1, level: 1,cost:2, name: "战士", atk: 8, hp: 30, atk_dis: 40, atk_cd: 1, power: 0, power_max: 10, speed: 30,
uuid: 9002, path: "k1", type: 1, level: 1,cost:2, name: "战士", atk: 8, hp: 30, atk_dis: 40, atk_cd: 1, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 2003, word: "守护", info: "自身护盾", atktype: 1,
},
9011: {
uuid: 9004, path: "m1", type: 3, level: 1,cost:2, name: "冰法", atk: 15, hp: 20, atk_dis: 260, atk_cd: 2.5, power: 0, power_max: 10, speed: 30,
uuid: 9004, path: "m1", type: 3, level: 1,cost:2, name: "冰法", atk: 15, hp: 20, atk_dis: 260, atk_cd: 2.5, power: 0, power_max: 20, speed: 30,
max_skill: "寒冰箭", skill_uuid: 9002, max_skill_uuid: 1002, word: "守护", info: "自身护盾", atktype: 1,
},
9021: {
uuid: 9006, path: "m3", type: 3, level: 1,cost:2, name: "火法", atk: 10, hp: 20, atk_dis: 260, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 9006, path: "m3", type: 3, level: 1,cost:2, name: "火法", atk: 10, hp: 20, atk_dis: 260, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "火球术", skill_uuid: 9002, max_skill_uuid: 1001, word: "守护", info: "自身护盾", atktype: 2
},
9031: {
uuid: 9005, path: "m2", type: 3, level: 1,cost:2, name: "牧师", atk: 3, hp: 20, atk_dis: 260, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 9005, path: "m2", type: 3, level: 1,cost:2, name: "牧师", atk: 3, hp: 20, atk_dis: 260, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "治愈术", skill_uuid: 9002, max_skill_uuid: 2001, word: "守护", info: "自身护盾", atktype: 2
},
9041: {
uuid: 9009, path: "arc1", type: 2, level: 1,cost:2, name: "弓箭手", atk: 5, hp: 30, atk_dis: 200, atk_cd: 1.5, power: 0, power_max: 10, speed: 30,
uuid: 9009, path: "arc1", type: 2, level: 1,cost:2, name: "弓箭手", atk: 5, hp: 30, atk_dis: 200, atk_cd: 1.5, power: 0, power_max: 20, speed: 30,
max_skill: "精准射击", skill_uuid: 9003, max_skill_uuid: 1003, word: "狂暴", info: "全体攻击", atktype: 2
},
@@ -34,15 +34,15 @@ export const HeroSet = {
export const MonSet = {
1011: {
uuid: 1011, path: "orc1", type: 1, level: 1,cost:2, name: "森林兽人", atk: 8, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 1011, path: "orc1", type: 1, level: 1,cost:2, name: "森林兽人", atk: 8, hp: 30, atk_dis: 40, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1012: {
uuid: 1012, path: "orc2", type: 1, level: 1,cost:2, name: "荒野兽人", atk: 8, hp: 40, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 1012, path: "orc2", type: 1, level: 1,cost:2, name: "荒野兽人", atk: 8, hp: 40, atk_dis: 40, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
1013: {
uuid: 1013, path: "orc3", type: 1, level: 1,cost:2, name: "兽人战士", atk: 8, hp: 60, atk_dis: 40, atk_cd: 2, power: 0, power_max: 10, speed: 30,
uuid: 1013, path: "orc3", type: 1, level: 1,cost:2, name: "兽人战士", atk: 8, hp: 60, atk_dis: 40, atk_cd: 2, power: 0, power_max: 20, speed: 30,
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
@@ -59,4 +59,10 @@ export const MonSet = {
max_skill: "精准打击", skill_uuid: 9001, max_skill_uuid: 0, word: "守护", info: "自身护盾", atktype: 1
},
5001: {
uuid: 5001, path: "boss1", type: 1, level: 1,cost:2, name: "骷髅王", atk: 20, hp: 1000, atk_dis: 200, atk_cd: 2, power: 0, power_max: 10, speed: 7,
max_skill: "精准打击", skill_uuid: 1001, max_skill_uuid: 1002, word: "守护", info: "自身护盾", atktype: 1
},
}

View File

@@ -11,7 +11,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { HeroSpine } from "./HeroSpine";
import { Hero } from "./Hero";
import { HeroModelComp } from "./HeroModelComp";
import { BoxSet } from "../common/config/BoxSet";
import { BoxSet, GameSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { Skill } from "../skills/Skill";
@@ -192,7 +192,26 @@ export class HeroViewComp extends CCComp {
// this.move_to()
// }
}
check_enemy_alive(){
let dir = 320
for (let i = 0; i < GameSet.ATK_LINES; i++) {
let mon:any = smc.enemy_pos[i];
let x=Math.abs(mon.x-this.node.position.x)
let y = Math.abs(mon.y-this.node.position.y)
let squaredDistance =x*x+y*y
let distance = Math.sqrt(squaredDistance);
if(distance < dir){
dir = distance
this.enemy = mon
}
}
if(dir < this.atk_dis){
this.is_atking=true
}else{
this.is_atking=false
}
}
move(dt: number){
if(this.stop_cd > 0){
return
@@ -356,24 +375,7 @@ export class HeroViewComp extends CCComp {
}
}
check_enemy_alive(){
let dir = 320
for (let i = 0; i <= 2; i++) {
let mon:any = smc.enemy_pos[i];
let squaredDistance =mon.x*mon.x+mon.y*mon.y
let distance = Math.sqrt(squaredDistance);
if(distance < dir){
dir = distance
this.enemy = mon
}
}
if(dir < this.atk_dis){
this.is_atking=true
}else{
this.is_atking=false
}
}
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking){
@@ -437,10 +439,6 @@ export class HeroViewComp extends CCComp {
}else{
this.atk += atk;
}
this.sprite.setSharedMaterial(this.atkMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.3);
// console.log(this.buff_atks)
}
@@ -455,15 +453,17 @@ export class HeroViewComp extends CCComp {
}
if(this.buff_atks.length <= 0){
this.buff_atk = 0
this.buff_icon_change("atk",false)
// this.buff_icon_change("atk",false)
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}else{
this.buff_icon_change("atk",true)
// this.buff_icon_change("atk",true)
this.sprite.setSharedMaterial(this.atkMaterial, 0);
}
}
buff_icon_change(icon:string,value:boolean){
this.node.getChildByName("top").getChildByName("buff").getChildByName(icon).active=value
// this.node.getChildByName("top").getChildByName("buff").getChildByName(icon).active=value
}

View File

@@ -6,13 +6,14 @@ import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { MapViewScene } from "./view/MapViewScene";
import { MissionSet,MissionNum,MonsetList } from "../common/config/MissionSet";
import { MissionSet,MissionNum,MonsetList, BossList } from "../common/config/MissionSet";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { Role } from "../Role/Role";
import { Hero } from "../hero/Hero";
import { HeroModelComp } from "../hero/HeroModelComp";
import { Mon } from "../mon/Mon";
import { MonModelComp } from "../mon/MonModelComp";
import { Boss} from "../Boss/Boss";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -32,6 +33,7 @@ export class MapMonsterComp extends CCComp {
mission_up_timer: Timer = new Timer(30); //波次增加
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
boss_list:any = []
setp_timer: Timer = new Timer(0.3);
target_timer: Timer = new Timer(0.1);
setp_num:number = 6;
@@ -60,10 +62,12 @@ export class MapMonsterComp extends CCComp {
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
this.cur_mission = num[0]
this.mission_list = MonsetList[this.cur_mission]
this.boss_list = BossList[this.cur_mission]
// console.log("当前关卡方案",this.cur_mission,this.mission_list)
this.refresh_timer= new Timer(smc.vm_data.gold.cd*5);
this.monster_refresh()
this.load_role()
// this.load_boss()
}
@@ -175,7 +179,7 @@ export class MapMonsterComp extends CCComp {
if (this.setp_num <= 0){
return
}
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],3)
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+this.start_ys[this.mon_index])
let monster_layer = scene.entityLayer!.node!
@@ -198,6 +202,15 @@ export class MapMonsterComp extends CCComp {
let monster_layer = scene.entityLayer!.node!
this.addMonster(args.uuid,monster_layer,pos)
}
load_boss(){
let bs:any = RandomManager.instance.getRandomByObjectList(this.boss_list[this.monster_level],1)
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(400,BoxSet.GAME_LINE-50)
let layer = scene.entityLayer!.node!
let b = ecs.getEntity<Boss>(Boss);
let scale = -1
b.load(pos,scale,bs[0],layer);
}0
/** 视图层逻辑代码分离演示 */
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */

View File

@@ -11,7 +11,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { MonSpine } from "./MonSpine";
import { Mon } from "./Mon";
import { MonModelComp } from "./MonModelComp";
import { BoxSet } from "../common/config/BoxSet";
import { BoxSet, GameSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { Skill } from "../skills/Skill";
@@ -32,8 +32,8 @@ export class MonViewComp extends CCComp {
orginalFlashMaterial: Material;
sprite: Sprite;
@property(Node)
BoxRang:Node =null!
// @property(Node)
// BoxRang:Node =null!
is_role:boolean = false;
enemy_pos:Vec3=null!;
@@ -100,8 +100,8 @@ export class MonViewComp extends CCComp {
// 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).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);
@@ -119,7 +119,6 @@ export class MonViewComp extends CCComp {
// 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) {
@@ -138,19 +137,21 @@ export class MonViewComp extends CCComp {
}
onEndContact (selfCollider: Collider2D, otherCollider: Collider2D) { }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
if(selfCollider.node.position.y < otherCollider.node.position.y){
if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
// console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
}
// if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
// if(selfCollider.node.position.y < otherCollider.node.position.y){
// if(selfCollider.node.getSiblingIndex() < otherCollider.node.getSiblingIndex()){
// selfCollider.node.setSiblingIndex(otherCollider.node.getSiblingIndex()+1)
// // console.log("onPreSolve b:"+selfCollider.node.uuid+":"+selfCollider.node.getSiblingIndex()+"/"+otherCollider.node.uuid+":"+otherCollider.node.getSiblingIndex());
// }
}
// }
// }
if(selfCollider.group != otherCollider.group&&otherCollider.tag == 0){
this.stop_cd = 0.1;
this.is_atking=true
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D) {}
update(dt: number){
@@ -161,13 +162,36 @@ export class MonViewComp extends CCComp {
this.in_speek(dt);
this.in_shield(dt);
this.in_stop(dt);
this.check_enemy_alive()
this.atk_time += dt;
this.in_atk(dt);
this.hp_show()
this.move(dt);
// if(this.m_timer.update(dt)){
// this.move_to()
// }
}
check_enemy_alive(){
let dir = 320
for (let i = 0; i < GameSet.ATK_LINES; i++) {
let hero:any = smc.hero_pos[i];
let x=Math.abs(hero.x-this.node.position.x)
let y = Math.abs(hero.y-this.node.position.y)
let squaredDistance =x*x+y*y
let distance = Math.sqrt(squaredDistance);
if(distance < dir){
dir = distance
this.enemy = hero
}
}
if(dir < this.atk_dis){
this.is_atking=true
}else{
this.is_atking=false
}
}
hp_show(){
if(this.hp == this.hp_max){
this.node.getChildByName("top").getChildByName("hp").active = false;
@@ -199,9 +223,9 @@ export class MonViewComp extends CCComp {
return
}
this.power += power;
if(this.power >= this.power_max&&this.check_enemy_alive()){
if(this.power >= this.power_max){
this.as.atk()
this.to_speek(smc.skills[this.max_skill_uuid].name)
// this.to_speek(smc.skills[this.max_skill_uuid].name)
this.scheduleOnce(()=>{
this.do_max_skill();
},0.5)
@@ -214,7 +238,7 @@ export class MonViewComp extends CCComp {
// console.log("mon shoot");
let skill = ecs.getEntity<Skill>(Skill);
let atk = smc.skills[skill_uuid].atk+this.atk;
let {pos,angle,t_pos}=this.get_enemy_pos()
let {pos,t_pos}=this.get_enemy_pos()
pos.y=pos.y + y
pos.x=pos.x + x
skill.load(pos,BoxSet.MONSTER,this.node,skill_uuid,atk,t_pos);
@@ -242,33 +266,16 @@ export class MonViewComp extends CCComp {
}
get_enemy_pos(){
let pos = v3(35*this.scale,25)
let angle=0
let t_pos:Vec3 = v3(0,0)
let t_pos:Vec3 = v3(-720,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+pos.x)*1.1,(this.enemy.position.y-(this.node.position.y+pos.y)+BoxSet.ATK_Y)*1.1)
}else{
t_pos=v3(-720,BoxSet.GAME_LINE)
}
return {pos,t_pos,angle}
}
check_enemy_alive(){
if(this.enemy){
if(!this.enemy.isValid){
return false
}
if(Math.abs(this.enemy.position.x-this.node.position.x) < this.atk_dis) return true;
return false
}else{
return false
t_pos = v3(this.enemy.x-this.node.position.x,this.enemy.y-this.node.position.y)
}
return {pos,t_pos}
}
in_atk(dt: number) {
if(this.atk_time >= this.atk_cd){
if(this.is_atking&&this.check_enemy_alive()){
if(this.is_atking){
this.atk_time = 0;
// console.log("atk_cd:"+this.atk_cd);
this.as.atk();