heros 卡片 细节完善 思考下步内容

This commit is contained in:
2024-11-19 10:52:20 +08:00
parent ce8b47de7d
commit e89f590979
6 changed files with 694 additions and 529 deletions

View File

@@ -1406,13 +1406,13 @@
"_restitution": 0, "_restitution": 0,
"_offset": { "_offset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": -1.3, "x": 8.4,
"y": 39.7 "y": 46.3
}, },
"_size": { "_size": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 38.2, "width": 57.6,
"height": 59.6 "height": 71
}, },
"_id": "" "_id": ""
}, },

File diff suppressed because it is too large Load Diff

View File

@@ -19282,7 +19282,7 @@
], ],
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 141, "x": 283,
"y": -100, "y": -100,
"z": 0 "z": 0
} }

View File

@@ -170,11 +170,10 @@ export class HeroViewComp extends CCComp {
} }
onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) { onPreSolve (selfCollider: Collider2D, otherCollider: Collider2D) {
let self_x = selfCollider.node.position.x;
let other_x = otherCollider.node.position.x;
if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){ if(selfCollider.group == otherCollider.group&&selfCollider.tag==otherCollider.tag){
if(otherCollider.node.name=="role") return if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 15 ){
let self_x = selfCollider.node.position.x;
let other_x = otherCollider.node.position.x;
if(otherCollider.node.getComponent(HeroViewComp).type == this.type && self_x < other_x && Math.abs(other_x-self_x) < 30 ){
this.stop_cd = 0.1; this.stop_cd = 0.1;
} }
// if(selfCollider.node.position.y < otherCollider.node.position.y){ // if(selfCollider.node.position.y < otherCollider.node.position.y){
@@ -265,7 +264,7 @@ export class HeroViewComp extends CCComp {
if(dir < this.dis){ if(dir < this.dis){
this.is_atking=true this.is_atking=true
this.stop_cd = 0.1 if(this.dis-dir > 45 ) this.stop_cd = 0.1
}else{ }else{
this.is_atking=false this.is_atking=false
} }

View File

@@ -1,4 +1,4 @@
import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,resources,Sprite,SpriteAtlas,UITransform,v3 } from "cc"; import { _decorator,Button,EventHandler,EventTouch,Label,NodeEventType,ProgressBar,resources,Sprite,SpriteAtlas,UITransform,v3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
@@ -13,16 +13,32 @@ const { ccclass, property } = _decorator;
@ecs.register('HCardComp', false) @ecs.register('HCardComp', false)
export class HCardComp extends CCComp { export class HCardComp extends CCComp {
hi: number = 0; hi: number = 0;
heros:any = []
icon:any=[]
hc_name:any=[]
ap:any=[]
hp:any=[]
life:any=[]
protected onLoad(): void { protected onLoad(): void {
} }
start() { start() {
let heros:any= ecs.query(ecs.allOf(HeroModelComp)); this.heros= ecs.query(ecs.allOf(HeroModelComp));
this.node.getChildByName("name").getComponent(Label)!.string = heros[this.hi].HeroView.hero_name this.hc_name=this.node.getChildByName("name").getComponent(Label)!
this.icon=this.node.getChildByName("icon").getComponent(Sprite)!
this.hp=this.node.getChildByName("hp").getChildByName("num").getComponent(Label)!
this.ap=this.node.getChildByName("ap").getChildByName("num").getComponent(Label)!
this.life=this.node.getChildByName("life").getComponent(ProgressBar)!
this.hc_name.string= this.heros[this.hi].HeroView.hero_name
console.log("hcard start")
}
protected update(dt: number): void {
this.hp.string=this.heros[this.hi].HeroView.hp_max
this.ap.string=this.heros[this.hi].HeroView.ap
this.life.progress=this.heros[this.hi].HeroView.hp/this.heros[this.hi].HeroView.hp_max
} }
/** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */ /** 视图对象通过 ecs.Entity.remove(ControllerComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() { reset() {
console.log("hcard reset"); console.log("hcard reset");

View File

@@ -119,7 +119,8 @@ export class MissionComp extends CCComp {
} }
mission_end(){ mission_end(){
smc.vm_data.mission.play=false smc.vm_data.mission.play=false
let heros:any= ecs.query(ecs.allOf(HeroViewComp)); let heros:any= ecs.query(ecs.allOf(HeroModelComp));
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
let hcards:any= ecs.query(ecs.allOf(HCardComp)); let hcards:any= ecs.query(ecs.allOf(HCardComp));
let hcns=this.node.getChildByName("hcards") let hcns=this.node.getChildByName("hcards")
for(let i=0;i<hcns.children.length;i++){ for(let i=0;i<hcns.children.length;i++){
@@ -127,10 +128,14 @@ export class MissionComp extends CCComp {
} }
for(let i=0;i<heros.length;i++){ for(let i=0;i<heros.length;i++){
heros[i].HeroView.ent.destroy() heros[i].HeroView.ent.destroy()
} }
for(let i=0;i<hcards.length;i++){ for(let i=0;i<hcards.length;i++){
hcards[i].HCardComp.ent.destroy() hcards[i].HCardComp.ent.destroy()
} }
for(let i=0;i<monsters.length;i++){
monsters[i].HeroView.ent.destroy()
}
} }
on_mon_dead(){ on_mon_dead(){
let coin =(GameSet.MON_COIN_ADD*smc.vm_data.mission.coin_reward_add*(1+Talents[1006].bonus*smc.vm_data.talent[1006].lv)).toFixed(0) let coin =(GameSet.MON_COIN_ADD*smc.vm_data.mission.coin_reward_add*(1+Talents[1006].bonus*smc.vm_data.talent[1006].lv)).toFixed(0)
@@ -217,7 +222,7 @@ export class MissionComp extends CCComp {
for(let i=0;i<heros.length;i++){ for(let i=0;i<heros.length;i++){
let hcard = ecs.getEntity<HCard>(HCard) let hcard = ecs.getEntity<HCard>(HCard)
console.log("hcard:",hcard) console.log("hcard:",hcard)
hcard.load(1001,0,node) hcard.load(1001,i,node)
} }
} }