战斗经验统一,由站前选择局内buff

This commit is contained in:
2024-12-08 23:29:38 +08:00
parent 59f965dc1c
commit 6d518794f4
12 changed files with 4183 additions and 4161 deletions

View File

@@ -60,10 +60,16 @@ export class HeroViewComp extends CCComp {
pw: number = 0; /**能量**/
pwm: number = 15; /** 能量最大值 */
pws: number = 1; //能量回复速度每0.1秒回复量
apw:number=0;
uapw:number=0;
cpw:number=0;
dopw:number=0;
dpw:number=0;
pwt:Timer = new Timer(1); //计时器
sk1:number = 9001;
sk2:number = 1001;
sk3:number = 1001;
akr:number=0; //攻击触发机率
uar:number=0; //受伤触发机率
dgr:number=0; //闪避触发机率
@@ -72,9 +78,12 @@ export class HeroViewComp extends CCComp {
uac:number=0; //受伤次数触发
dgc:number=0; //闪避次数触发
crc:number=0; //暴击次数触发
aep:number=0;
uaep:number=0;
dep:number=0;
aexp:number=0; //攻击经验
uaexp:number=0; //受伤经验
cexp:number=0; //暴击经验 */
doexp:number=0; //闪避经验 */
dexp:number=0; //死亡经验 */
ap: number = 10; /**攻击力 */
ap_buff: number = 0;
@@ -153,28 +162,8 @@ export class HeroViewComp extends CCComp {
if(selfCollider.group != otherCollider.group){
let skill = otherCollider.node.getComponent(SkillCom)!;
// console.log('onPostSolve',skill);
if(this.hp <= 0 ){
return
}
if(this.shield > 0){
this.shield -= 1
if(this.shield <= 0){
this.shield = 0
this.node.getChildByName("shielded").active = false
}
return
}
if(this.check_dodge()) return
this.in_atked();
let l_hp=(skill.ap-this.def)*-1
if(skill.is_crit){
l_hp = l_hp * (150+skill.crit_add)/100
}
if(l_hp >= 0){
l_hp=-1 //最低1点伤害
}
this.hp_change(l_hp,skill.is_crit);
if(this.hp <= 0 ) return
this.check_uatk(skill);
}
}
@@ -258,6 +247,7 @@ export class HeroViewComp extends CCComp {
this.is_atking=false
}
}
//进入墓地
to_grave(){
let pos =v3(-999,this.node.position.y)
if(this.box_group == BoxSet.MONSTER){
@@ -265,9 +255,11 @@ export class HeroViewComp extends CCComp {
}
this.node.setPosition(pos)
}
//是否在墓地
in_grave(){
return this.node.position.x < -900 || this.node.position.x > 900;
}
//状态切换
status_change(type:string){
this.status=type
if(type == "idle"){
@@ -279,6 +271,7 @@ export class HeroViewComp extends CCComp {
// this.as.change_default("move")
}
}
//移动
move(dt: number){
if(this.stop_cd > 0||smc.vmdata.mission.is_victory||smc.vmdata.mission.is_defeat){
this.status_change("idle")
@@ -328,6 +321,27 @@ export class HeroViewComp extends CCComp {
return {pos,t_pos}
}
//受伤判断
check_uatk(skill:any){
if(this.shield > 0){
this.shield -= 1
if(this.shield <= 0){
this.shield = 0
this.node.getChildByName("shielded").active = false
}
return
}
if(this.check_dodge()) return
this.in_atked();
let l_hp=(skill.ap-this.def)*-1
if(skill.is_crit){
l_hp = l_hp * (150+skill.crit_add)/100
}
if(l_hp >= 0){
l_hp=-1 //最低1点伤害
}
this.hp_change(l_hp,skill.is_crit);
}
//能量判断
check_power(){
if(this.pw >= this.pwm){
@@ -348,6 +362,8 @@ export class HeroViewComp extends CCComp {
if(i < this.crit){
this.tooltip(5,"*会心一击*");
this.crit_count += 1
this.exp_add(this.cexp) // 暴击经验
this.power_add(this.cpw)
return true
}else{
return false
@@ -359,6 +375,8 @@ export class HeroViewComp extends CCComp {
if(i < this.dodge){
console.log("闪避触发: i="+i+":dodge="+this.dodge);
this.tooltip(5,"闪避");
this.exp_add(this.doexp) // 闪避经验
this.power_add(this.dopw)
this.dodge_count += 1
return true
}else{
@@ -377,7 +395,7 @@ export class HeroViewComp extends CCComp {
this.scheduleOnce(()=>{
this.node.getChildByName("max").active=false
},0.8)
this.handle_skill(this.sk2)
this.handle_skill(this.sk3)
}
}
if(this.dodge_count >= this.dgc){
@@ -391,7 +409,7 @@ export class HeroViewComp extends CCComp {
this.scheduleOnce(()=>{
this.node.getChildByName("max").active=false
},0.8)
this.handle_skill(this.sk2)
this.handle_skill(this.sk3)
}
}
if(this.crit_count >= this.crc){
@@ -400,12 +418,13 @@ export class HeroViewComp extends CCComp {
let i = RandomManager.instance.getRandomInt(0,100,3)
// console.log("暴击判断: i="+i+":crr="+this.crr);
if(i < this.crr){
// console.log("闪避触发: i="+i+":crr="+this.crr);
// console.log("暴击触发: i="+i+":crr="+this.crr);
this.node.getChildByName("max").active=true
this.scheduleOnce(()=>{
this.node.getChildByName("max").active=false
},0.8)
this.handle_skill(this.sk2)
this.handle_skill(this.sk3)
}
}
if(this.atked_count >= this.uac){
@@ -418,7 +437,7 @@ export class HeroViewComp extends CCComp {
this.scheduleOnce(()=>{
this.node.getChildByName("max").active=false
},0.8)
this.handle_skill(this.sk2)
this.handle_skill(this.sk3)
}
}
}
@@ -427,7 +446,8 @@ export class HeroViewComp extends CCComp {
if(this.is_atking){
this.at = 0;
this.atk_count++
this.exp_add(this.aep)
this.exp_add(this.aexp) //攻击经验
this.power_add(this.apw)
// console.log("cd:"+this.cd);
this.as.atk();
this.scheduleOnce(()=>{
@@ -436,24 +456,17 @@ export class HeroViewComp extends CCComp {
}
}
}
exp_add(exp:number){
exp_add(exp:number=0){
if(this.box_group==BoxSet.HERO){
if(this.type == 1)smc.vmdata.mission.a_exp +=exp
if(this.type == 2)smc.vmdata.mission.h_exp +=exp
if(this.type == 3){
smc.vmdata.mission.a_exp +=exp
smc.vmdata.mission.h_exp +=exp
}
smc.vmdata.mission.exp +=exp
}
if(this.box_group==BoxSet.MONSTER){
if(this.type == 1)smc.vmdata.mission.ma_exp +=exp
if(this.type == 2)smc.vmdata.mission.mh_exp +=exp
if(this.type == 3){
smc.vmdata.mission.ma_exp +=exp
smc.vmdata.mission.mh_exp +=exp
}
smc.vmdata.mission.m_exp +=exp
}
}
power_add(p:number){
this.pw+= p
}
//使用max_skill
handle_skill(skill:number){
this.as.max()
@@ -678,7 +691,8 @@ export class HeroViewComp extends CCComp {
node.parent = this.node;
// this.as.atked();
this.atked_count++;
this.exp_add(this.uaep)
this.exp_add(this.uaexp)
this.power_add(this.uapw)
}
dead(){
var path = "game/skills/dead";
@@ -687,7 +701,8 @@ export class HeroViewComp extends CCComp {
let pos = v3(this.node.position.x,this.node.position.y+30,this.node.position.z);
node.parent = this.node.parent;
node.setPosition(pos);
this.exp_add(this.dep)
this.exp_add(this.dexp)
this.power_add(this.dpw)
}
toDestroy(){