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

@@ -1,4 +1,4 @@
import { _decorator ,Label} from "cc";
import { _decorator ,Label,NodeEventType,EventTouch} 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 { data } from "../data/data";
@@ -16,16 +16,49 @@ export class HeroCardViewComp extends CCComp {
card_type:string = "hero";
card_uid:number = 1000;
in_destroy:boolean = false;
pos_x:number = 0;
pos_y:number = 0;
protected onLoad(): void {
// this.node.on(NodeEventType.TOUCH_START, this.onTouch, this);
// this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
// this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
// this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this);
this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
// oops.message.on("active_card_eid", this.do_active_card_eid, this);
}
/** 视图层逻辑代码分离演示 */
start() {
this.pos_x=this.node.position.x;
this.pos_y=this.node.position.y;
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString();
this.node.getChildByName("name").getComponent(Label).string = this.card_name
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.in_destroy = false;
this.node.destroy();
}
onTouchMove(event: EventTouch) {
let delta = event.getDelta();
this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y);
}
onTouchEnd(){
if(this.node.position.y-this.pos_y > 150){
this.use_card()
}else{
this.node.setPosition(this.pos_x,this.pos_y);
}
}
private do_active_card_eid(event: string, args: any) {
console.log("active_card_eid",args,this.ent.eid)
if(this.ent.eid != args.eid){
@@ -36,19 +69,19 @@ export class HeroCardViewComp extends CCComp {
do_active(){
// console.log(this.node.getChildByName("active"),this.node.getChildByName("use"), this.node.getChildByName("bag"))
let active = this.node.getChildByName("active")
let use = this.node.getChildByName("use")
let bag = this.node.getChildByName("bag")
// let use = this.node.getChildByName("use")
// let bag = this.node.getChildByName("bag")
active.active = !active.active
use.active = !use.active
bag.active = !bag.active
// use.active = !use.active
// bag.active = !bag.active
}
no_active(){
let active = this.node.getChildByName("active")
let use = this.node.getChildByName("use")
let bag = this.node.getChildByName("bag")
// let use = this.node.getChildByName("use")
// let bag = this.node.getChildByName("bag")
active.active = false
use.active = false
bag.active = false
// use.active = false
// bag.active = false
}
doit(){
// this.do_active()
@@ -71,26 +104,7 @@ export class HeroCardViewComp extends CCComp {
smc.vm_data.gold.min -= CardSet[this.card_uid].level;
}else{
oops.gui.toast("金币不够");
this.node.setPosition(this.pos_x,this.pos_y);
}
}
/** 视图层逻辑代码分离演示 */
start() {
this.node.getChildByName("level").getChildByName("level").getComponent(Label).string = CardSet[this.card_uid].level.toString();
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {
// switch (event) {
// case ModuleEvent.Cmd:
// break;
// }
// }
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.in_destroy = false;
this.node.destroy();
}
}

View File

@@ -43,7 +43,6 @@ export class MonsterSpine extends Component {
setSkin(value: string): void {
console.log("MonsterSpine setSkin", value);
this.spine.setSkin(value);
}
play(animName: string, loop: boolean): void {

View File

@@ -36,9 +36,8 @@ export default class MonsterSpineAnimator extends Component {
this.spine.setAnimation(0, "move", true);
}
});
}
lateUpdate(dt: number) {
//
}

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() {