英雄技能相关字段修改

This commit is contained in:
walkpan
2025-02-02 20:58:25 +08:00
parent 215fcd3a76
commit 2e53786aa0
24 changed files with 143 additions and 840 deletions

View File

@@ -1,89 +0,0 @@
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 { HeroViewComp } from "./HeroViewComp";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('BoxRangComp')
@ecs.register('BoxRang', false)
export class BoxRangComp extends CCComp {
Hero_node: any=null!;
HeroViewComp:HeroViewComp = null!;
box_group:number = BoxSet.HERO;
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.HeroViewComp=this.Hero_node.getComponent(HeroViewComp);
// console.log("range box",this.HeroViewComp);
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.HeroViewComp.is_atking = true;
// if(Math.abs(otherCollider.node.position.x-selfCollider.node.position.x) < 120){
// this.HeroViewComp.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.HeroViewComp.is_atking = false;
this.HeroViewComp.enemy = null;
this.HeroViewComp.as.change_default("move");
this.HeroViewComp.as.move();
}
}
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(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
}
}
}
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"4d46fe9a-6a73-4e21-994b-ae00e9f624d0","files":[],"subMetas":{},"userData":{}}

View File

@@ -54,6 +54,7 @@ export class Hero extends ecs.Entity {
let talents=Talents;
hv.scale = scale;
hv.fac = 0;
hv.type = hero.type;
hv.box_group = box_group;
hv.hero_uuid= uuid;
hv.hero_name= hero.name;
@@ -68,21 +69,7 @@ export class Hero extends ecs.Entity {
hv.dpw=hero.dpw;
hv.dopw=hero.dopw;
hv.lv = role.lv;
hv.type = hero.type;
let slv= Math.floor(( hv.lv) / 5);
let sklv=slv
if(sklv >= 5) sklv=5;
hv.sk1 = hero.sk1[sklv];
hv.sk2 = hero.sk2[sklv];
hv.sk3 = hero.sk3[sklv];
hv.akc = hero.akc[sklv];
hv.uac = hero.uac[sklv];
hv.crc = hero.crc[sklv];
hv.dgc = hero.dgc[sklv];
hv.akr = hero.akr[sklv];
hv.uar = hero.uar[sklv];
hv.crr = hero.crr[sklv];
hv.dgr = hero.dgr[sklv];
hv.rhp_max=hv.hp= hv.hp_max =(hero.hp+hero.hp_up*hv.lv)*(1+hero.shp_up/100*slv) ;
hv.ap = (hero.ap+hero.ap_up*hv.lv) *(1+hero.sap_up/100*slv);
hv.def= (hero.def+hero.def_up*hv.lv)*(1+hero.sdef_up/100*slv);

View File

@@ -1,93 +0,0 @@
/*
* @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('HeroSpine')
export class HeroSpine extends Component {
@property(Animation)
animator: Animation = null!;
idle_clip: AnimationClip = null!;
atk_clip: AnimationClip = null!;
move_clip: AnimationClip = null!;
default_clip:string = "";
onLoad() {
// 角色控制组件
this.initAnimator();
LayerUtil.setNodeLayer(LayerUtil.MAP, this.node);
this.idle_clip = this.animator.clips[0];
this.atk_clip = this.animator.clips[1];
this.move_clip = this.animator.clips[2];
this.default_clip=this.move_clip.name;
let animation = this.animator.getComponent(Animation);
animation.on(Animation.EventType.FINISHED, this.onAnimationEvent, this)
}
protected start(): void {
this.move();
}
/** 初始化动画 */
protected initAnimator() {
this.animator=this.node.getChildByName("anm").getComponent(Animation);
// console.log("mon spine init",this.animator);
}
in_playing(){
if(this.animator.getState(this.atk_clip.name).isPlaying) return true;
if(this.animator.getState(this.idle_clip.name).isPlaying) return true;
if(this.animator.getState(this.move_clip.name).isPlaying) return true;
return false;
}
onAnimationEvent(type: Animation.EventType, state: AnimationState){
if(type==Animation.EventType.FINISHED){
// console.log("animator end",state.name);
if(state.name==this.atk_clip.name){
this.default();
}
}
}
change_default(value:string){
// console.log("change default",value);
this.default_clip=value;
}
default() {
if(!this.in_playing()){
// console.log("do default");
this.animator.play(this.default_clip);
}
}
idle(){
if(!this.in_playing()){
console.log("do idle");
this.animator.play(this.idle_clip.name);
}
}
atk() {
// console.log("do atk");
this.animator.play(this.atk_clip.name);
}
move(){
if(!this.animator.getState(this.move_clip.name).isPlaying) {
console.log("doing move");
this.animator.play(this.move_clip.name);
}
}
onDestroy() {
this.node.destroy();
}
}

View File

@@ -1 +0,0 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"8bf79351-aad1-411f-a117-97ccba1fe15f","files":[],"subMetas":{},"userData":{}}

View File

@@ -62,9 +62,6 @@ export class HeroViewComp extends CCComp {
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; //闪避触发机率
@@ -328,50 +325,50 @@ export class HeroViewComp extends CCComp {
* 使用do_skill方法处理触发的技能。
*/
check_atk_counts() {
if (this.atk_count >= this.akc) {
this.atk_count = 0
// console.log("atk_count 清零:"+this.atk_count);
let i = RandomManager.instance.getRandomInt(0,100,3)
// console.log("攻击判断: i="+i+":akr="+this.akr);
if(i < this.akr){
// console.log("攻击触发: i="+i+":akr="+this.akr);
// this.BUFFCOMP.max_show()
this.do_skill(this.sk3)
}
}
if(this.dodge_count >= this.dgc){
this.dodge_count = 0
// console.log("dodge_count 清零:"+this.dodge_count);
let i = RandomManager.instance.getRandomInt(0,100,3)
// console.log("闪避判断: i="+i+":dgr="+this.dgr);
if(i < this.dgr){
// console.log("闪避触发: i="+i+":dgr="+this.dgr);
// this.BUFFCOMP.max_show()
this.do_skill(this.sk3)
}
}
if(this.crit_count >= this.crc){
this.crit_count = 0
// console.log("crit_count 清零:"+this.crit_count);
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);
// if (this.atk_count >= this.akc) {
// this.atk_count = 0
// // console.log("atk_count 清零:"+this.atk_count);
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("攻击判断: i="+i+":akr="+this.akr);
// if(i < this.akr){
// // console.log("攻击触发: i="+i+":akr="+this.akr);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
// if(this.dodge_count >= this.dgc){
// this.dodge_count = 0
// // console.log("dodge_count 清零:"+this.dodge_count);
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("闪避判断: i="+i+":dgr="+this.dgr);
// if(i < this.dgr){
// // console.log("闪避触发: i="+i+":dgr="+this.dgr);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
// if(this.crit_count >= this.crc){
// this.crit_count = 0
// // console.log("crit_count 清零:"+this.crit_count);
// 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);
// this.BUFFCOMP.max_show()
this.do_skill(this.sk3)
}
}
if(this.atked_count >= this.uac){
this.atked_count = 0
let i = RandomManager.instance.getRandomInt(0,100,3)
// console.log("受伤判断i="+i+":akr="+this.uar);
if(i < this.uar){
// console.log("受伤触发: i="+i+":uar="+this.uar);
// this.BUFFCOMP.max_show()
this.do_skill(this.sk3)
}
}
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
// if(this.atked_count >= this.uac){
// this.atked_count = 0
// let i = RandomManager.instance.getRandomInt(0,100,3)
// // console.log("受伤判断i="+i+":akr="+this.uar);
// if(i < this.uar){
// // console.log("受伤触发: i="+i+":uar="+this.uar);
// // this.BUFFCOMP.max_show()
// this.do_skill(this.sk3)
// }
// }
}
in_atk(dt: number) {
if(this.at >= this.cd){
@@ -382,9 +379,6 @@ export class HeroViewComp extends CCComp {
this.power_add(this.apw)
// console.log("cd:"+this.cd);
this.as.atk();
this.scheduleOnce(()=>{
this.shoot_enemy(this.sk1)
},0.3)
}
}
}
@@ -393,7 +387,6 @@ export class HeroViewComp extends CCComp {
if(this.pw >= this.pwm){
this.pw = 0
this.BUFFCOMP.max_show()
this.do_skill(this.sk2)
return true
}else{
return false

View File

@@ -68,6 +68,7 @@ export class Monster extends ecs.Entity {
let talents=Talents;
hv.scale = scale;
hv.fac = 1;
hv.type = hero.type;
hv.is_boss = is_boss;
hv.box_group = box_group;
hv.hero_uuid= uuid;
@@ -84,21 +85,6 @@ export class Monster extends ecs.Entity {
hv.dopw=hero.dopw;
hv.lv = lv;
let slv= Math.floor(( hv.lv) / 5);
let sklv=slv
if(sklv >= 5) sklv=5;
hv.type = hero.type;
hv.sk1 = hero.sk1[sklv];
hv.sk2 = hero.sk2[sklv];
hv.sk3 = hero.sk3[sklv];
hv.akc = hero.akc[sklv];
hv.uac = hero.uac[sklv];
hv.crc = hero.crc[sklv];
hv.dgc = hero.dgc[sklv];
hv.akr = hero.akr[sklv];
hv.uar = hero.uar[sklv];
hv.crr = hero.crr[sklv];
hv.dgr = hero.dgr[sklv];
hv.rhp_max=hv.hp= hv.hp_max =(hero.hp+hero.hp_up*hv.lv)*(1+hero.shp_up/100*slv);
hv.ap = (hero.ap+hero.ap_up*hv.lv) *(1+hero.sap_up/100*slv);
hv.def= (hero.def+hero.def_up*hv.lv)*(1+hero.sdef_up/100*slv);

View File

@@ -12,18 +12,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
@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 = "";
}
}