dd
This commit is contained in:
@@ -24,11 +24,11 @@ export enum BoxSet {
|
||||
//地图边界
|
||||
LETF_END = -420,
|
||||
RIGHT_END = 420,
|
||||
HERO_START = -280,
|
||||
MONSTER_START = 400,
|
||||
HERO_START = -360,
|
||||
MONSTER_START = 360,
|
||||
END_POINT = 360,
|
||||
//游戏地平线
|
||||
GAME_LINE = 100,
|
||||
GAME_LINE = 150,
|
||||
CSKILL_X = 320,
|
||||
CSKILL_Y = 400,
|
||||
//攻击距离
|
||||
|
||||
@@ -6,19 +6,19 @@ export const CardList={
|
||||
1:[
|
||||
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
|
||||
|
||||
{uuid:9010,type:1},
|
||||
// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
],
|
||||
2:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
|
||||
// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
{uuid:9010,type:1},// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
],
|
||||
3:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
|
||||
// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
{uuid:9010,type:1},// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
],
|
||||
4:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
|
||||
{uuid:9010,type:1},{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9003,type:1},{uuid:9004,type:1},{uuid:9005,type:1},{uuid:9006,type:1},{uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},
|
||||
],
|
||||
5:[
|
||||
{uuid:1001,type:2},{uuid:1002,type:2},{uuid:4011,type:2},{uuid:4012,type:2},
|
||||
|
||||
@@ -18,5 +18,7 @@ export const HeroSet={
|
||||
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻速型",mon: "机械蜜蜂"},
|
||||
9009:{uuid: 9009,path: "arc3",type: 1,level: 2,name: "弓箭手3",atk: 6,hp: 36,atk_dis:500,atk_cd: 2,power: 50,speed: 30,
|
||||
skill: "base3",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
|
||||
9010:{uuid: 9009,path: "m4",type: 1,level: 2,name: "大火法",atk: 6,hp: 36,atk_dis:500,atk_cd: 2,power: 50,speed: 30,
|
||||
skill: "fire",max_skill: "base3",skill_uuid: 9001,max_skill_uuid: 1001, atktype: "攻击型",mon: "鹰"},
|
||||
|
||||
}
|
||||
@@ -58,14 +58,15 @@ export class BoxRangComp extends CCComp {
|
||||
let other_pos = otherCollider.node.getWorldPosition() ;
|
||||
let self_pos = this.node.getWorldPosition();
|
||||
// console.log("onPreSolve:",self_pos,other_pos);
|
||||
if(this.HeroViewComp.enemy==null){
|
||||
this.HeroViewComp.enemy = otherCollider.node;
|
||||
}else{
|
||||
if(this.HeroViewComp.enemy.isValid==false){
|
||||
this.HeroViewComp.enemy = otherCollider.node;
|
||||
}
|
||||
}
|
||||
|
||||
if(Math.abs(other_pos.x-self_pos.x) < this.HeroViewComp.atk_dis){
|
||||
if(this.HeroViewComp.enemy==null){
|
||||
this.HeroViewComp.enemy = otherCollider.node;
|
||||
}else{
|
||||
if(this.HeroViewComp.enemy.isValid==false){
|
||||
this.HeroViewComp.enemy = otherCollider.node;
|
||||
}
|
||||
}
|
||||
this.HeroViewComp.is_atking = true;
|
||||
this.HeroViewComp.stop_cd = 0.1
|
||||
this.HeroViewComp.as.change_default("idle");
|
||||
|
||||
@@ -16,7 +16,6 @@ import { HeroSpine } from "./HeroSpine";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
|
||||
import { HeroBuffComp } from "./HeroBuffComp";
|
||||
import { HeroSet } from "../common/config/heroSet";
|
||||
import { MonSet } from "../common/config/MonSet";
|
||||
/** 角色实体 */
|
||||
@@ -26,7 +25,6 @@ export class Hero extends ecs.Entity {
|
||||
HeroModel!: HeroModelComp;
|
||||
// 视图层
|
||||
HeroView!: HeroViewComp;
|
||||
HeroBuff!: HeroBuffComp; // 移动
|
||||
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>( HeroModelComp);
|
||||
@@ -35,7 +33,6 @@ export class Hero extends ecs.Entity {
|
||||
|
||||
destroy(): void {
|
||||
this.remove(HeroViewComp);
|
||||
this.remove(HeroBuffComp);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
@@ -75,11 +72,9 @@ export class Hero extends ecs.Entity {
|
||||
}
|
||||
hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){
|
||||
var mv = node.getComponent(HeroViewComp)!;
|
||||
var buff =node.getComponent(HeroBuffComp)!;
|
||||
// console.log("hero_init",buff)
|
||||
mv.speed =mv.ospeed = smc.heros[uuid].speed;
|
||||
mv.hero_name= smc.heros[uuid].name;
|
||||
buff.group=mv.box_group= BoxSet.HERO;
|
||||
mv.hp= mv.hp_max = smc.heros[uuid].hp;
|
||||
mv.level = smc.heros[uuid].level;
|
||||
mv.atk = smc.heros[uuid].atk;
|
||||
@@ -92,6 +87,5 @@ export class Hero extends ecs.Entity {
|
||||
mv.scale = 1;
|
||||
mv.Tpos = v3(0,0,0);
|
||||
this.add(mv);
|
||||
this.add(buff);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
|
||||
import { SkillCom } from "../skills/SkillCom";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { Tooltip } from "../skills/Tooltip";
|
||||
import { HeroBuffComp } from "./HeroBuffComp";
|
||||
import { MoveToComp } from "../common/ecs/position/MoveTo";
|
||||
import { BoxRangComp } from "./BoxRangComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -36,7 +35,6 @@ export class HeroViewComp extends CCComp {
|
||||
@property(Node)
|
||||
BoxRang:Node =null!
|
||||
|
||||
buff:HeroBuffComp =null!
|
||||
is_role:boolean = false;
|
||||
enemy_pos:Vec3=null!;
|
||||
enemy:any=null!;
|
||||
@@ -84,17 +82,18 @@ export class HeroViewComp extends CCComp {
|
||||
is_stop:boolean = false;
|
||||
is_atking:boolean = false;
|
||||
|
||||
buffs:any=[];
|
||||
buff_shields:any=[];
|
||||
buff_atks:any = [];
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(HeroSpine);
|
||||
this.buff=this.node.getComponent(HeroBuffComp);
|
||||
// this.BoxRang = this.node.getChildByName("range_box");
|
||||
// this.BoxRang = this.node.getChildByName("range_box");
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
this.as.move()
|
||||
this.sprite = this.node.getChildByName("anm").getComponent(Sprite);
|
||||
this.node.getChildByName("top").getChildByName("shield").active = false;
|
||||
// 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();
|
||||
@@ -110,7 +109,6 @@ export class HeroViewComp extends CCComp {
|
||||
// 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;
|
||||
@@ -140,30 +138,8 @@ export class HeroViewComp 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){
|
||||
// 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
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -171,8 +147,9 @@ export class HeroViewComp extends CCComp {
|
||||
if (this.timer.update(dt)) {
|
||||
this.power_change(this.power_speed)
|
||||
}
|
||||
this.check_buff_atks(dt)
|
||||
this.in_destroy();
|
||||
this.in_shield();
|
||||
this.in_shield(dt);
|
||||
this.in_stop(dt);
|
||||
this.in_act(dt);
|
||||
this.move(dt);
|
||||
@@ -185,7 +162,7 @@ export class HeroViewComp extends CCComp {
|
||||
if(this.stop_cd > 0){
|
||||
return
|
||||
}
|
||||
if (this.scale === 1 && this.node.position.x >= BoxSet.MONSTER_START) {
|
||||
if (this.scale === 1 && this.node.position.x >= BoxSet.MONSTER_START-this.atk_dis) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -286,7 +263,6 @@ export class HeroViewComp extends CCComp {
|
||||
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;
|
||||
@@ -300,16 +276,7 @@ export class HeroViewComp extends CCComp {
|
||||
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;
|
||||
@@ -344,6 +311,10 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
add_hp(hp: number=0){
|
||||
console.log("hero 加血动画");
|
||||
this.hp+=hp;
|
||||
if(this.hp > this.hp_max){
|
||||
this.hp = this.hp_max;
|
||||
}
|
||||
this.tooltip(2,hp.toString());
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
@@ -351,11 +322,25 @@ export class HeroViewComp extends CCComp {
|
||||
add_atk(atk: number,time:number=0){
|
||||
if(time > 0){
|
||||
let buff={atk:atk,time:time}
|
||||
this.buffs.push(buff);
|
||||
this.buff_atks.push(buff);
|
||||
}else{
|
||||
this.atk += atk;
|
||||
}
|
||||
}
|
||||
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){
|
||||
if(buff.atk > 0)this.atk -= buff.atk;
|
||||
this.buff_atks.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
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){
|
||||
@@ -366,15 +351,25 @@ export class HeroViewComp extends CCComp {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
check_buffs(dt: number){
|
||||
for(let i=0;i<this.buffs.length;i++){
|
||||
let buff=this.buffs[i];
|
||||
buff.time -= dt;
|
||||
if(buff.time <= 0){
|
||||
if(buff.atk > 0)this.atk -= buff.atk;
|
||||
if(buff.shield > 0)this.shield=this.shield_max=0;
|
||||
this.buffs.splice(i,1);
|
||||
in_shield(dt: number){
|
||||
if(this.shield_time <= 0){
|
||||
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;
|
||||
}
|
||||
if(this.shield <= 0){
|
||||
this.shield_time=0
|
||||
this.node.getChildByName("top").getChildByName("shield").active=false
|
||||
}else{
|
||||
this.node.getChildByName("top").getChildByName("shield").active=true
|
||||
}
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
||||
@@ -385,9 +380,7 @@ export class HeroViewComp extends CCComp {
|
||||
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){
|
||||
|
||||
@@ -122,7 +122,7 @@ export class MapMonsterComp extends CCComp {
|
||||
}
|
||||
load_role(){
|
||||
let role = ecs.getEntity<Role>(Role);
|
||||
let pos = v3(BoxSet.HERO_START,BoxSet.GAME_LINE)
|
||||
let pos = v3(BoxSet.HERO_START+50,BoxSet.GAME_LINE)
|
||||
role.load(pos,109)
|
||||
smc.Role=role
|
||||
// console.log("加载玩家",role)
|
||||
|
||||
@@ -364,9 +364,7 @@ export class MonViewComp extends CCComp {
|
||||
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){
|
||||
|
||||
@@ -104,7 +104,7 @@ export class CSkillComp extends CCComp {
|
||||
if (heros.length > 0) {
|
||||
if(SkillSet[uuid].type==92){ //随机添加buff
|
||||
let i = RandomManager.instance.getRandomInt(0,heros.length-1,3)
|
||||
heros[i].HeroBuff.add_buff(uuid,args);
|
||||
this.do_add_buff(heros[i],uuid,args)
|
||||
}else{
|
||||
for (let i = 0; i < heros.length; i++) {
|
||||
let hero = heros[i];
|
||||
@@ -114,12 +114,12 @@ export class CSkillComp extends CCComp {
|
||||
t_hero = hero
|
||||
}
|
||||
}else{ //群体
|
||||
hero.HeroBuff.add_buff(uuid,args);
|
||||
this.do_add_buff(hero,uuid,args)
|
||||
}
|
||||
|
||||
}
|
||||
if(t_hero){ //血量最少单体
|
||||
t_hero.HeroBuff.add_buff(uuid,args);
|
||||
this.do_add_buff(t_hero,uuid,args)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export class CSkillComp extends CCComp {
|
||||
}
|
||||
// oops.message.dispatchEvent("add_buff",{uuid:this.skill_uuid,eid:0,group:BoxSet.HERO})
|
||||
}
|
||||
single_least_add_buff(target:any,uuid:number,args:any) {
|
||||
do_add_buff(target:any,uuid:number,args:any) {
|
||||
let buff = SkillSet[uuid]
|
||||
if(buff.hp > 0 ){
|
||||
target.HeroView.add_hp(buff.hp+args.hp)
|
||||
@@ -135,8 +135,12 @@ export class CSkillComp extends CCComp {
|
||||
if(buff.atk > 0 ){
|
||||
target.HeroView.add_atk(buff.atk+args.atk,buff.bsd)
|
||||
}
|
||||
if(buff.shield > 0 ){
|
||||
target.HeroView.add_shield(buff.shield+args.shield,buff.bsd)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user