From 425a8bac64c65b5f24573ebfe10ae79acb1e42ef Mon Sep 17 00:00:00 2001 From: "pan@work" Date: Fri, 15 Nov 2024 09:38:36 +0800 Subject: [PATCH] =?UTF-8?q?hero=20=E6=A0=B9=E6=8D=AEtype=20=E7=A1=AE?= =?UTF-8?q?=E5=AE=9A=E5=87=BA=E7=94=9F=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/common/config/heroSet.ts | 12 +++++-- assets/script/game/hero/Hero.ts | 8 +++-- assets/script/game/hero/HeroViewComp.ts | 37 ++++++++++----------- assets/script/game/initialize/Initialize.ts | 4 +-- assets/script/game/map/MapMonsterComp.ts | 19 +++++------ assets/script/game/mon/Mon.ts | 2 +- 6 files changed, 44 insertions(+), 38 deletions(-) diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index 8ca7a850..13212da5 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -1,5 +1,5 @@ -export const HeroSet = { +export const HeroInfo = { 9001: { uuid: 9001, path: "k1", type: 1, lv: 1,name: "白骑士", wp:1001,arm:2001,ring:3001,shoes:4001, exp_type:0,lv2:5,lv3:10,lv4:20,lv5:30,a_exp:1,ua_exp:1,d_exp:10,ed_exp:1, @@ -18,4 +18,12 @@ export const HeroSet = { export const MonSet = { -} \ No newline at end of file +} +export const HeroSet = { + StartPos:{ + 1: -200, + 2: -250, + 3: -300, + } + +} diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 76a73155..79335c39 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -16,7 +16,7 @@ import { HeroSpine } from "./HeroSpine"; import { HeroViewComp } from "./HeroViewComp"; import { BoxSet } from "../common/config/BoxSet"; import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager"; -import { HeroSet,MonSet } from "../common/config/heroSet"; +import { HeroInfo,MonSet } from "../common/config/heroSet"; import { Role } from "../Role/Role"; import { MoveToComp } from "../common/ecs/position/MoveTo"; import { Talents } from "../common/config/TalentSet"; @@ -42,7 +42,7 @@ export class Hero extends ecs.Entity { } /** 加载角色 */ - load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,layer:Node=smc.map.MapView.scene.entityLayer!.node!,index:number=-1,is_hero:boolean=true) { + load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,index:number=-1,is_hero:boolean=true) { let box_group= 0 if (is_hero) { @@ -58,7 +58,9 @@ export class Hero extends ecs.Entity { var path = "game/hero/"+smc.heros[uuid].path; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); - node.parent=layer + + var scene = smc.map.MapView.scene; + node.parent = scene.entityLayer!.node! node.setPosition(pos) this.hero_init(uuid,node,index,scale,box_group) diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 43929192..8c745ef4 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -89,17 +89,12 @@ export class HeroViewComp extends CCComp { crit_rate: number = 0;//暴击伤害加成 dodge: number = 10; //闪避率 - shield:number = 0; //护盾,免伤1次减1 speed: number = 100; /** 角色移动速度 */ ospeed: number = 100; /** 角色初始速度 */ Tpos: Vec3 = v3(0,-60,0); stop_cd: number = 0.5; /*停止倒计时*/ - - - - dir_y:number = 0; speek_time:number = 0; @@ -537,9 +532,10 @@ export class HeroViewComp extends CCComp { if(this.hp <= 0){ this.dead(); this.is_dead = true; - setTimeout(() => { - this.ent.destroy(); - }, 15); + // setTimeout(() => { + // this.ent.destroy(); + // }, 15); + this.toDestroy() } } add_atk(atk: number,time:number=0){ @@ -610,16 +606,16 @@ export class HeroViewComp extends CCComp { } in_atked() { - // var path = "game/skills/atked"; - // var prefab: Prefab = oops.res.get(path, Prefab)!; - // var node = instantiate(prefab); - // let pos = v3(0,60) - // node.setPosition(pos) - // node.parent = this.node; - this.sprite.setSharedMaterial(this.hitFlashMaterial, 0); - this.scheduleOnce(() => { - this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0); - }, 0.1); + var path = "game/skills/atked"; + var prefab: Prefab = oops.res.get(path, Prefab)!; + var node = instantiate(prefab); + let pos = v3(0,60) + node.setPosition(pos) + node.parent = this.node; + // this.sprite.setSharedMaterial(this.hitFlashMaterial, 0); + // this.scheduleOnce(() => { + // this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0); + // }, 0.1); } @@ -631,8 +627,11 @@ export class HeroViewComp extends CCComp { node.parent = this.node.parent; } toDestroy(){ - + this.node.setPosition(this.scale*9999,this.node.position.y) } + toAlive(){ + this.node.setPosition(-1*this.scale*BoxSet.HERO_START,this.node.position.y) + } reset() { this.is_dead = false; this.node.destroy(); diff --git a/assets/script/game/initialize/Initialize.ts b/assets/script/game/initialize/Initialize.ts index 7ecc3845..261143f4 100644 --- a/assets/script/game/initialize/Initialize.ts +++ b/assets/script/game/initialize/Initialize.ts @@ -12,7 +12,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { UIID } from "../common/config/GameUIConfig"; import { LoadingViewComp } from "./view/LoadingViewComp"; import { smc } from "../common/SingletonModuleComp"; -import { MonSet, HeroSet } from "../common/config/heroSet"; +import { MonSet, HeroInfo } from "../common/config/heroSet"; import { SkillSet } from "../common/config/SkillSet"; import { Sitems } from "../common/config/ItemSet"; @@ -86,7 +86,7 @@ export class Initialize extends ecs.Entity { /** 加载完成进入游戏内容加载界面 */ private onComplete(queue: AsyncQueue) { queue.complete = () => { - smc.heros = HeroSet; + smc.heros = HeroInfo; smc.monsters=MonSet; // console.log("加载完成!",smc.heros); smc.skills=SkillSet; diff --git a/assets/script/game/map/MapMonsterComp.ts b/assets/script/game/map/MapMonsterComp.ts index 7907ea03..dedac74f 100644 --- a/assets/script/game/map/MapMonsterComp.ts +++ b/assets/script/game/map/MapMonsterComp.ts @@ -17,6 +17,7 @@ import { Boss} from "../Boss/Boss"; import { UIID } from "../common/config/GameUIConfig"; import { Talents } from "../common/config/TalentSet"; import { HeroViewComp } from "../hero/HeroViewComp"; +import { HeroSet } from "../common/config/heroSet"; const { ccclass, property } = _decorator; /** 视图层对象 */ @@ -159,10 +160,7 @@ export class MapMonsterComp extends CCComp { return } let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1) - var scene = smc.map.MapView.scene; - let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE) - let monster_layer = scene.entityLayer!.node! - this.addMonster(m[0],monster_layer,pos) + this.addMonster(m[0]) this.mon_index += 1 if(this.mon_index>2){ this.mon_index = 0 @@ -184,7 +182,7 @@ export class MapMonsterComp extends CCComp { var scene = smc.map.MapView.scene; let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE) let monster_layer = scene.entityLayer!.node! - this.addMonster(args.uuid,monster_layer,pos) + this.addMonster(args.uuid) } set_start_point(){ // this.start_p.setPosition(-240,BoxSet.GAME_LINE+this.start_ys[this.hero_index]+30,0) @@ -218,18 +216,17 @@ export class MapMonsterComp extends CCComp { /** 添加玩家 */ private addHero(uuid:number=1001) { let hero = ecs.getEntity(Hero); - var scene = smc.map.MapView.scene; - let pos:Vec3 = v3(-210-this.hero_x*30,BoxSet.GAME_LINE); - let monster_layer = scene.entityLayer!.node! let scale = 1 - hero.load(pos,scale,uuid,monster_layer); + let pos:Vec3 = v3(HeroSet[smc.heros[uuid].type],BoxSet.GAME_LINE); + hero.load(pos,scale,uuid); this.set_start_point() } - private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) { + private addMonster(uuid:number=1001) { let monster = ecs.getEntity(Hero); let scale = -1 let index = -1 - monster.load(pos,scale,uuid,layer,index,false); + let pos:Vec3 = v3(-1*HeroSet[smc.heros[uuid].type],BoxSet.GAME_LINE); + monster.load(pos,scale,uuid,index,false); } load_boss(){ diff --git a/assets/script/game/mon/Mon.ts b/assets/script/game/mon/Mon.ts index 94bb0f0d..55416d02 100644 --- a/assets/script/game/mon/Mon.ts +++ b/assets/script/game/mon/Mon.ts @@ -16,7 +16,7 @@ import { MonSpine } from "./MonSpine"; import { MonViewComp } from "./MonViewComp"; import { BoxSet } from "../common/config/BoxSet"; import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager"; -import { HeroSet,MonSet } from "../common/config/heroSet"; +import { HeroInfo,MonSet } from "../common/config/heroSet"; /** 角色实体 */ @ecs.register(`Mon`) export class Mon extends ecs.Entity {