This commit is contained in:
2024-08-18 23:38:55 +08:00
parent e8dbb9bab3
commit 8f57f57c1d
1004 changed files with 234067 additions and 16087 deletions

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18
*/
import { Vec3, _decorator , v3,Collider2D,Contact2DType,IPhysics2DContact,EPhysics2DDrawFlags,Label,Node,Prefab,instantiate,ProgressBar} from "cc";
import { Vec3, _decorator , v3,Collider2D,Contact2DType,IPhysics2DContact,PhysicsSystem2D,EPhysics2DDrawFlags,Label,Node,Prefab,instantiate,ProgressBar} 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 { MonsterSpine } from "./MonsterSpine";
@@ -15,7 +15,6 @@ import { MonsterModelComp } from "./MonsterModelComp";
import { BoxSet } from "../common/config/BoxSet";
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { baseCom } from "../skills/baseCom";
import { Skill } from "../skills/Skill";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { SkillCom } from "../skills/SkillCom";
@@ -36,7 +35,7 @@ export class MonsterViewComp extends CCComp {
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_speed: number = 0; //回复速度
hp_speed: number = 0; //每秒回复量
power: number = 0; /**能量**/
power_max: number = 100; /** 能量最大值 */
@@ -55,16 +54,12 @@ export class MonsterViewComp extends CCComp {
Tpos: Vec3 = v3(0,-60,0);
stop_cd: number = 0; /*停止倒计时*/
private timer:Timer = new Timer(0.1); //计时器
is_dead:boolean = false; //是否摧毁
/*暴击*/
crit_rate:number = 0; //暴击率
crit_damage:number = 2; //暴击伤害倍率
/*闪避*/
dodge_rate:number = 0; //闪避率
shield:number = 0; //护盾量
shield_time:number = 0; //护盾持续时间
private timer:Timer = new Timer(0.1); //计时器
is_dead:boolean = false; //是否摧毁
/** 视图层逻辑代码分离演示 */
start () {
@@ -99,44 +94,11 @@ export class MonsterViewComp extends CCComp {
this.in_atked();
this.hp_change(skill.atk);
}
// switch (selfCollider.group) {
// case BoxSet.HERO:
// switch (otherCollider.group){
// case BoxSet.MONSTER:
// break;
// case BoxSet.MONSTER_SKILL:
// this.in_atked();
// this.hp_change(10);
// break;
// }
// case BoxSet.MONSTER:
// switch (otherCollider.group){
// case BoxSet.HERO:
// // console.log('onBeginContact',selfCollider,otherCollider);
// // setTimeout(() => {
// // this.toDestroy();
// // }, 10);
// // this.speed = 0;
// // this.stop_cd = 1;
// // console.log("speed:"+this.speed+" | stop_cd:"+this.stop_cd);
// break;
// case BoxSet.HERO_SKILL:
// this.in_atked();
// this.hp_change(10);
// break;
// // case BoxSet.MONSTER_SKILL:
// // break;
// }
// break;
// }
}
onLoad() {
this.as = this.getComponent(MonsterSpine);
// console.log('hero load ent:',this);
// PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb |
// EPhysics2DDrawFlags.Pair |
// EPhysics2DDrawFlags.CenterOfMass |
@@ -177,11 +139,16 @@ export class MonsterViewComp extends CCComp {
}
move(dt: number){
this.node.setPosition(this.node.position.x+dt*this.speed*this.camp, this.node.position.y, this.node.position.z);
if(Math.abs(this.node.position.x) >= BoxSet.END_POINT){
this.node.setPosition(v3(this.camp*-BoxSet.END_POINT,BoxSet.GAME_LINE,this.node.position.z))
// console.log("speed:"+this.speed+" | stop_cd:"+this.stop_cd);
/**
* 根据角色的阵营检查角色的 x 轴位置是否满足特定条件。
* 如果角色属于正向阵营 (camp == 1) 且 x 轴位置大于等于 0则直接返回。
* 如果角色属于反向阵营 (camp != 1) 且 x 轴位置小于等于 0则直接返回。
*/
if ((this.camp === 1 && this.node.position.x >= 180) || (this.camp !== 1 && this.node.position.x <= -180)) {
return;
}
this.node.setPosition(this.node.position.x+dt*this.speed*this.camp, this.node.position.y, this.node.position.z);
}
power_change(power: number){
this.power += power;
@@ -253,10 +220,10 @@ export class MonsterViewComp extends CCComp {
load_skill(skill_name){
// console.log("load_skill");
let skill = ecs.getEntity<Skill>(Skill);
let pos = v3(0,40)
let speed =110
let pos = v3(this.camp*30,30)
let speed =400
let scale = this.camp
let range = 100
let range = 360;
skill.load(pos,speed,range,scale,this.node,skill_name,this.atk);
}
in_atked() {