改了 好多
This commit is contained in:
@@ -103,13 +103,14 @@ export class BuffComp extends Component {
|
||||
this.node.getChildByName("buff").active = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
max_show(name:string){
|
||||
var path = "game/skills/"+name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
node.parent = this.node;
|
||||
}
|
||||
|
||||
show_do_buff(name:string){
|
||||
var path = "game/skills/"+name;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
|
||||
@@ -46,29 +46,17 @@ export class Hero extends ecs.Entity {
|
||||
node.parent = scene.entityLayer!.node!
|
||||
let pos=HeroPos[0].pos
|
||||
node.setPosition(pos)
|
||||
var hv = node.getComponent(HeroViewComp)!;
|
||||
let hero= HeroInfo[uuid] // 共用英雄数据
|
||||
var hv = this.hero_init(uuid,node)
|
||||
hv.scale = 1;
|
||||
hv.fac = FacSet.HERO;
|
||||
hv.is_master=true;
|
||||
hv.type = hero.type;
|
||||
hv.box_group = box_group;
|
||||
hv.hero_uuid= uuid;
|
||||
hv.hero_name= hero.name;
|
||||
hv.speed =hv.ospeed = hero.speed;
|
||||
hv.dis = hero.dis;
|
||||
hv.hp= hv.hp_max =hero.hp;
|
||||
hv.ap = hero.ap;
|
||||
hv.lv=1
|
||||
hv.cd = hero.a_cd
|
||||
hv.hp_up=hero.hp_up
|
||||
hv.atk_skill=hero.skills[0]
|
||||
console.log(hv.hero_name+"dis=>"+hv.dis)
|
||||
this.add(hv);
|
||||
this.addComponents<ecs.Comp>(MasterModelComp)
|
||||
console.log("[Hero]:master",hv)
|
||||
|
||||
}
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0},fight_pos:number=1) {
|
||||
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crt:0,crt_d:0,dod:0,dod_no:false,crt_no:false},fight_pos:number=1) {
|
||||
// console.log("英雄加载:",uuid,pos,scale,info)
|
||||
scale = 1
|
||||
let box_group=BoxSet.HERO
|
||||
@@ -79,29 +67,39 @@ export class Hero extends ecs.Entity {
|
||||
node.parent = scene.entityLayer!.node!
|
||||
node.setPosition(pos)
|
||||
// console.log("hero load",pos)
|
||||
var hv = this.hero_init(uuid,node,info)
|
||||
hv.fight_pos=fight_pos
|
||||
this.add(hv);
|
||||
this.addComponents<ecs.Comp>(FriendModelComp);
|
||||
// const move = this.get(BattleMoveComp);
|
||||
// move.direction = 1; // 向右移动
|
||||
// move.targetX = 800; // 右边界'
|
||||
oops.message.dispatchEvent("hero_load",this)
|
||||
console.log("[Hero]:friend",hv)
|
||||
|
||||
}
|
||||
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crt:0,crt_d:0,dod:0,dod_no:false,crt_no:false}) {
|
||||
var hv = node.getComponent(HeroViewComp)!;
|
||||
let hero= HeroInfo[uuid] // 共用英雄数据
|
||||
hv.scale = scale;
|
||||
hv.scale = 1;
|
||||
hv.lv=info.lv
|
||||
hv.fac = FacSet.HERO;
|
||||
hv.fight_pos=fight_pos
|
||||
hv.type = hero.type;
|
||||
hv.box_group = box_group;
|
||||
hv.box_group = BoxSet.HERO;
|
||||
hv.hero_uuid= uuid;
|
||||
hv.hero_name= hero.name;
|
||||
hv.speed =hv.ospeed = hero.speed;
|
||||
hv.dis = hero.dis;
|
||||
hv.hp= hv.hp_max =hero.hp+info.hp;
|
||||
hv.ap = hero.ap+info.ap;
|
||||
hv.lv=info.lv+1
|
||||
hv.cd = hero.a_cd
|
||||
hv.hp_up=hero.hp_up
|
||||
hv.hp= hv.hp_max =hero.hp+info.hp
|
||||
hv.ap = hero.ap+info.ap;
|
||||
hv.crt=hero.crt+info.crt
|
||||
hv.crt_d=hero.crt_d+info.crt_d
|
||||
hv.dod=hero.dod+info.dod
|
||||
hv.dod_no=info.dod_no
|
||||
hv.crt_no=info.crt_no
|
||||
hv.atk_skill=hero.skills[0]
|
||||
this.add(hv);
|
||||
this.addComponents<ecs.Comp>(FriendModelComp);
|
||||
const move = this.get(BattleMoveComp);
|
||||
move.direction = 1; // 向右移动
|
||||
move.targetX = 800; // 右边界'
|
||||
oops.message.dispatchEvent("hero_load",this)
|
||||
return hv
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import { HeroSpine } from "./HeroSpine";
|
||||
import { BoxSet, FacSet } from "../common/config/BoxSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
||||
import { SkillSet, TGroup, TType } from "../common/config/SkillSet";
|
||||
import { BuffComp } from "./BuffComp";
|
||||
import { BuffAttr, DebuffAttr, SkillSet, TGroup, TType } from "../common/config/SkillSet";
|
||||
import { BuffComp } from "./BuffComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { FightConComp } from "../map/FightConComp";
|
||||
@@ -62,8 +62,11 @@ export class HeroViewComp extends CCComp {
|
||||
def: number = 0; //防御
|
||||
vun: number = 0; //易伤
|
||||
|
||||
dodge: number = 10; //闪避率
|
||||
|
||||
dod: number = 10; //闪避率
|
||||
dod_no:boolean=false;
|
||||
crt:number=0; //暴击率
|
||||
crt_no:boolean=false; //暴击免疫
|
||||
crt_d:number=0; //暴击伤害
|
||||
|
||||
shield:number = 0; //护盾,免伤1次减1
|
||||
speed: number = 100; /** 角色移动速度 */
|
||||
@@ -73,14 +76,17 @@ export class HeroViewComp extends CCComp {
|
||||
atked_count: number = 0;
|
||||
atk_add_count:number=0;
|
||||
stop_cd: number = 0; /*停止倒计时*/
|
||||
yun_cd: number = 0; //眩晕倒计时
|
||||
ice_cd: number = 0; //冰冻倒计时
|
||||
dir_y:number = 0;
|
||||
speek_time:number = 0;
|
||||
is_stop_temp:boolean = false;i
|
||||
Friend_alive_cd:Timer=new Timer(10)
|
||||
double_dead:boolean=false
|
||||
double_atked:boolean=false
|
||||
DEBUFF_BURN: Array<{burn: number, count: number}> = []
|
||||
DEBUFF_SLOW: number = 0;
|
||||
DEBUFF_FROST: number = 0;
|
||||
DEBUFF_STUN: number = 0;
|
||||
BUFF_DEF: Array<{def: number, count: number}> = []
|
||||
private damageQueue: Array<{
|
||||
damage: number,
|
||||
isCrit: boolean,
|
||||
@@ -130,12 +136,12 @@ export class HeroViewComp extends CCComp {
|
||||
if(this.timer.update(dt)){
|
||||
// this.add_ap(10)
|
||||
};
|
||||
if(this.ice_cd > 0){
|
||||
this.ice_cd -=dt;
|
||||
if(this.DEBUFF_FROST > 0){
|
||||
this.DEBUFF_FROST -=dt;
|
||||
return
|
||||
}
|
||||
if(this.yun_cd > 0){
|
||||
this.yun_cd -=dt;
|
||||
if(this.DEBUFF_STUN > 0){
|
||||
this.DEBUFF_STUN -=dt;
|
||||
return
|
||||
}
|
||||
this.in_stop(dt);
|
||||
@@ -150,7 +156,7 @@ export class HeroViewComp extends CCComp {
|
||||
}else if(data.fire){
|
||||
this.atk_skill=6012
|
||||
}else if(data.wind){
|
||||
this.atk_skill=6016
|
||||
this.atk_skill=6013
|
||||
}else{
|
||||
this.atk_skill=6001
|
||||
}
|
||||
@@ -320,35 +326,147 @@ export class HeroViewComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
do_atked(remainingDamage:number){
|
||||
this.do_atked_trigger()
|
||||
if (this.shield > 0) {
|
||||
add_debuff(type:number,debuff:number,count:number,){
|
||||
switch(type){
|
||||
case DebuffAttr.BURN:
|
||||
this.DEBUFF_BURN.push({burn:debuff,count:count})
|
||||
break
|
||||
case DebuffAttr.SLOW:
|
||||
this.DEBUFF_SLOW+=debuff
|
||||
break
|
||||
case DebuffAttr.FROST:
|
||||
this.BUFFCOMP.in_iced(debuff)
|
||||
this.DEBUFF_FROST+=debuff
|
||||
break
|
||||
case DebuffAttr.STUN:
|
||||
this.BUFFCOMP.in_yun(debuff)
|
||||
this.DEBUFF_STUN+=debuff
|
||||
this.is_stop=true
|
||||
break
|
||||
case DebuffAttr.DECD:
|
||||
this.cd-=debuff
|
||||
break
|
||||
case DebuffAttr.DEHP:
|
||||
this.hp_max-=debuff
|
||||
if(this.hp-this.hp_max>0) this.hp=this.hp_max
|
||||
break
|
||||
case DebuffAttr.DEATK:
|
||||
this.ap-=debuff
|
||||
break
|
||||
case DebuffAttr.DECOUNT:
|
||||
this.atk_count-=debuff
|
||||
if(this.atk_count<0) this.atk_count=1
|
||||
break
|
||||
case DebuffAttr.BACK:
|
||||
if(this.fac==FacSet.MON) {
|
||||
let tx=this.node.position.x+50
|
||||
if(tx > 320) tx=320
|
||||
tween(this.node).to(0.3, { position:v3(tx,this.node.position.y,0)}).start()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
add_buff(buff:number,count:number,type:number){
|
||||
switch(type){
|
||||
case BuffAttr.DEF:
|
||||
this.BUFF_DEF.push({def:buff,count:count})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
do_atked(remainingDamage:number,crt:number=0,crt_d:number=0){
|
||||
this.do_atked_trigger()
|
||||
|
||||
if(this.check_shield()) return
|
||||
if(this.check_dodge()) return
|
||||
let is_crit = this.check_crit(crt)
|
||||
|
||||
if(this == null) return;
|
||||
let damage = this.count_damage(remainingDamage)
|
||||
if(is_crit) {
|
||||
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crt_d)/100))
|
||||
}
|
||||
this.hp -= damage;
|
||||
if(this.hp <= 0) {
|
||||
if(this == null) return;
|
||||
this.is_dead=true
|
||||
this.BUFFCOMP.dead()
|
||||
this.do_dead()
|
||||
console.log("[HeroViewComp]:dead,fac => "+(this.fac==FacSet.HERO?"hero":"monster"))
|
||||
if(this.ent == null) return;
|
||||
if(this.fac ==FacSet.HERO){
|
||||
this.to_grave()
|
||||
}else{
|
||||
this.ent.destroy();
|
||||
}
|
||||
}
|
||||
this.BUFFCOMP.update_info_hp()
|
||||
this.showDamage(damage, is_crit);
|
||||
|
||||
}
|
||||
//伤害计算 debuff 易伤
|
||||
count_damage(remainingDamage:number){
|
||||
let damage = 0;
|
||||
let Burn = 0;
|
||||
let def = 0;
|
||||
for(let i=0;i<this.DEBUFF_BURN.length;i++){
|
||||
Burn+=this.DEBUFF_BURN[i].burn
|
||||
this.DEBUFF_BURN[i].count-=1
|
||||
if(this.DEBUFF_BURN[i].count<=0){
|
||||
this.DEBUFF_BURN.splice(i,1)
|
||||
}
|
||||
}
|
||||
for(let i=0;i<this.BUFF_DEF.length;i++){
|
||||
def+=this.BUFF_DEF[i].def
|
||||
this.BUFF_DEF[i].count-=1
|
||||
if(this.BUFF_DEF[i].count<=0){
|
||||
this.BUFF_DEF.splice(i,1)
|
||||
}
|
||||
}
|
||||
if(this.fac == FacSet.HERO ){
|
||||
damage=remainingDamage*(100-(this.FIGHTCON.hero_buff.DEF+def)+(this.FIGHTCON.hero_debuff.BURN+Burn))/100
|
||||
}
|
||||
if(this.fac == FacSet.MON){
|
||||
damage=remainingDamage*(100-(this.FIGHTCON.enemy_buff.DEF+def)+(this.FIGHTCON.enemy_debuff.BURN+Burn))/100
|
||||
}
|
||||
return Math.floor(damage)
|
||||
}
|
||||
check_shield(){
|
||||
if(this.shield>0){
|
||||
this.shield -= 1
|
||||
this.BUFFCOMP.tooltip(5,"*吸收*");
|
||||
remainingDamage = 0
|
||||
if (this.shield <= 0) {
|
||||
if(this == null) return;
|
||||
this.BUFFCOMP.show_shield(false);
|
||||
}
|
||||
}else{
|
||||
if(this == null) return;
|
||||
this.hp -= remainingDamage;
|
||||
if(this.hp <= 0) {
|
||||
if(this == null) return;
|
||||
this.is_dead=true
|
||||
this.BUFFCOMP.dead()
|
||||
this.do_dead()
|
||||
console.log("[HeroViewComp]:dead,fac => "+(this.fac==FacSet.HERO?"hero":"monster"))
|
||||
if(this.ent == null) return;
|
||||
if(this.fac ==FacSet.HERO){
|
||||
this.to_grave()
|
||||
}else{
|
||||
this.ent.destroy();
|
||||
}
|
||||
}
|
||||
this.BUFFCOMP.update_info_hp()
|
||||
this.showDamage(remainingDamage, true);
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
check_dodge(){
|
||||
if(this.dod > 0){
|
||||
let random = Math.random()*100
|
||||
if(random < this.dod) {
|
||||
this.BUFFCOMP.tooltip(6,"*闪避*");
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
check_crit(crt:number=0){
|
||||
if(this.crt_no) return false
|
||||
if(crt > 0){
|
||||
let random = Math.random()*100
|
||||
if(random < crt) {
|
||||
console.log("[HeroViewComp]:crit",crt,random)
|
||||
return true
|
||||
}
|
||||
}
|
||||
console.log("[HeroViewComp]:crit",crt)
|
||||
return false
|
||||
}
|
||||
// dead(){
|
||||
// this.BUFFCOMP.dead()
|
||||
@@ -440,7 +558,16 @@ export class HeroViewComp extends CCComp {
|
||||
delay: this.damageInterval
|
||||
});
|
||||
}
|
||||
|
||||
ex_show(text:string){
|
||||
switch(text){
|
||||
case "blue":
|
||||
this.BUFFCOMP.max_show("max_blue")
|
||||
break
|
||||
case "red":
|
||||
this.BUFFCOMP.max_show("max_red")
|
||||
break
|
||||
}
|
||||
}
|
||||
/** 处理伤害队列 */
|
||||
private processDamageQueue() {
|
||||
if (this.isProcessingDamage || this.damageQueue.length === 0) return;
|
||||
|
||||
@@ -67,6 +67,11 @@ export class Monster extends ecs.Entity {
|
||||
hv.hp= hv.hp_max =hero.hp;
|
||||
hv.ap = hero.ap;
|
||||
hv.cd = hero.a_cd
|
||||
hv.crt=hero.crt
|
||||
hv.crt_d=hero.crt_d
|
||||
hv.dod=hero.dod
|
||||
hv.dod_no=hero.dod_no
|
||||
hv.crt_no=hero.crt_no
|
||||
hv.atk_skill=hero.skills[0]
|
||||
this.add(hv);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { CCComp } from 'db://oops-framework/module/common/CCComp';
|
||||
import { FightConComp } from '../map/FightConComp';
|
||||
import { MonModelComp } from './MonModelComp';
|
||||
import { HeroModelComp } from './HeroModelComp';
|
||||
import { FightSet } from '../common/config/Mission';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('SkillCon')
|
||||
@@ -37,7 +38,7 @@ export class SkillConComp extends CCComp {
|
||||
|
||||
update(dt: number) {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
this.HeroView.at += dt;
|
||||
if(this.HeroView.DEBUFF_STUN <= 0) this.HeroView.at += dt;
|
||||
|
||||
let cd = this.get_cd(this.HeroView.cd,this.HeroView)
|
||||
let count=this.get_count(1,this.HeroView)
|
||||
@@ -55,29 +56,6 @@ export class SkillConComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
get_cd(cd:number,view:HeroViewComp){
|
||||
if(view.fac==FacSet.HERO){
|
||||
if(view.is_master){
|
||||
return cd*(100-this.FIGHTCON.hero_buff.ATK_CD+this.FIGHTCON.hero_debuff.DECD)/100
|
||||
}else{
|
||||
return cd*(100-this.FIGHTCON.friend_buff.ATK_CD+this.FIGHTCON.friend_debuff.DECD)/100
|
||||
}
|
||||
}else{
|
||||
return cd*(100-this.FIGHTCON.enemy_buff.ATK_CD+this.FIGHTCON.enemy_debuff.DECD)/100
|
||||
}
|
||||
}
|
||||
get_count(count:number,view:HeroViewComp){
|
||||
if(view.fac==FacSet.HERO){
|
||||
if(view.is_master){
|
||||
return count+(this.FIGHTCON.hero_buff.ATK_COUNT-this.FIGHTCON.hero_debuff.DECOUNT)
|
||||
}else{
|
||||
return count+(this.FIGHTCON.friend_buff.ATK_COUNT-this.FIGHTCON.friend_debuff.DECOUNT)
|
||||
}
|
||||
}else{
|
||||
return count+(this.FIGHTCON.enemy_buff.ATK_COUNT-this.FIGHTCON.enemy_debuff.DECOUNT)
|
||||
}
|
||||
|
||||
}
|
||||
cast_master_skill(e:string,uuid:any){
|
||||
if(!this.HeroView) return
|
||||
if(!this.HeroView.is_master) return
|
||||
@@ -85,15 +63,15 @@ export class SkillConComp extends CCComp {
|
||||
const config = SkillSet[uuid];
|
||||
this.castSkill(config,1,this.FIGHTCON.hero_buff.SKILL_DMG)
|
||||
}
|
||||
|
||||
/** 施放技能 */
|
||||
castSkill(config: typeof SkillSet[keyof typeof SkillSet],count:number=1,dmg:number=0) {
|
||||
castSkill(config: typeof SkillSet[keyof typeof SkillSet],count:number=1,dmg:number=0) {
|
||||
// console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid);
|
||||
|
||||
this.doSkill(config,count,dmg);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private doSkill(config: typeof SkillSet[keyof typeof SkillSet],count:number=1,angle:number=0,dmg:number=0) {
|
||||
// 添加节点有效性检查
|
||||
if (!this.node || !this.node.isValid || !this.HeroView || !this.HeroView.node || !this.HeroView.node.isValid) {
|
||||
@@ -144,17 +122,22 @@ export class SkillConComp extends CCComp {
|
||||
dmg
|
||||
);
|
||||
}, 300);
|
||||
count-=1
|
||||
if(count>0){
|
||||
let angle=10*count
|
||||
if(count > 1 && this.check_double_atk(count)){
|
||||
this.scheduleOnce(()=>{
|
||||
this.doSkill(config,count,angle)
|
||||
},0.1)
|
||||
this.HeroView.ex_show("blue")
|
||||
this.doSkill(config,1)
|
||||
},0.05)
|
||||
}
|
||||
// 保存定时器ID
|
||||
this._timers[`skill_${config.uuid}`] = timerId;
|
||||
}
|
||||
|
||||
check_double_atk(count:number){
|
||||
let random = Math.random()*100
|
||||
if(random < FightSet.DOUBLE_ATK_RATE*count){
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/** 筛选最前排单位 */
|
||||
@@ -202,7 +185,29 @@ export class SkillConComp extends CCComp {
|
||||
// console.log("clear_timer");
|
||||
Object.values(this._timers).forEach(clearTimeout);
|
||||
}
|
||||
|
||||
get_cd(cd:number,view:HeroViewComp){
|
||||
if(view.fac==FacSet.HERO){
|
||||
if(view.is_master){
|
||||
return cd*(100-this.FIGHTCON.hero_buff.ATK_CD+this.FIGHTCON.hero_debuff.DECD)/100
|
||||
}else{
|
||||
return cd*(100-this.FIGHTCON.friend_buff.ATK_CD+this.FIGHTCON.friend_debuff.DECD)/100
|
||||
}
|
||||
}else{
|
||||
return cd*(100-this.FIGHTCON.enemy_buff.ATK_CD+this.FIGHTCON.enemy_debuff.DECD)/100
|
||||
}
|
||||
}
|
||||
get_count(count:number,view:HeroViewComp){
|
||||
if(view.fac==FacSet.HERO){
|
||||
if(view.is_master){
|
||||
return count+(this.FIGHTCON.hero_buff.ATK_COUNT-this.FIGHTCON.hero_debuff.DECOUNT)
|
||||
}else{
|
||||
return count+(this.FIGHTCON.friend_buff.ATK_COUNT-this.FIGHTCON.friend_debuff.DECOUNT)
|
||||
}
|
||||
}else{
|
||||
return count+(this.FIGHTCON.enemy_buff.ATK_COUNT-this.FIGHTCON.enemy_debuff.DECOUNT)
|
||||
}
|
||||
|
||||
}
|
||||
reset() {
|
||||
this.clear_timer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user