From a968281bdc89376673e0ae63fa759de7f9652827 Mon Sep 17 00:00:00 2001 From: panw Date: Fri, 6 Dec 2024 16:34:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=9D=E6=AD=A5=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/Boss/Boss.ts | 22 ++++++++-------- .../script/game/common/SingletonModuleComp.ts | 16 ++++++------ assets/script/game/common/config/RoleSet.ts | 25 +------------------ assets/script/game/hero/Hero.ts | 8 +++--- assets/script/game/hero/HeroCard.ts | 17 +++++++------ assets/script/game/initialize/Initialize.ts | 2 -- assets/script/game/map/CardController.ots | 2 +- assets/script/game/map/HeroHomeComp.ts | 23 +++++++++++++---- assets/script/game/map/MIssionController.ts | 6 ++--- 9 files changed, 54 insertions(+), 67 deletions(-) diff --git a/assets/script/game/Boss/Boss.ts b/assets/script/game/Boss/Boss.ts index c8ca407f..3badb656 100644 --- a/assets/script/game/Boss/Boss.ts +++ b/assets/script/game/Boss/Boss.ts @@ -73,17 +73,17 @@ export class Boss extends ecs.Entity { hero_init(uuid:number=1001,node:Node,pos:Vec3=v3(0,0,0)){ var bs = node.getComponent(BossViewComp)!; // console.log("hero_init",buff) - bs.speed =bs.ospeed = smc.monsters[uuid].speed; - bs.boos_name= smc.monsters[uuid].name; - bs.hp= bs.hp_max = smc.monsters[uuid].hp; - bs.level = smc.monsters[uuid].level; - bs.atk = smc.monsters[uuid].atk; - bs.atk_cd = smc.monsters[uuid].atk_cd; - bs.atk_dis = smc.monsters[uuid].atk_dis; - bs.power = smc.monsters[uuid].power; - bs.power_max = smc.monsters[uuid].power_max; - bs.skill = smc.monsters[uuid].skill_uuid; - bs.type = smc.monsters[uuid].type; + bs.speed =bs.ospeed = MonSet[uuid].speed; + bs.boos_name= MonSet[uuid].name; + bs.hp= bs.hp_max = MonSet[uuid].hp; + bs.level = MonSet[uuid].level; + bs.atk = MonSet[uuid].atk; + bs.atk_cd = MonSet[uuid].atk_cd; + bs.atk_dis = MonSet[uuid].atk_dis; + bs.power = MonSet[uuid].power; + bs.power_max = MonSet[uuid].power_max; + bs.skill = MonSet[uuid].skill_uuid; + bs.type = MonSet[uuid].type; bs.box_group = BoxSet.MONSTER; bs.scale = -1; bs.Tpos = v3(0,0,0); diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 0c1ec509..1acffec7 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -29,7 +29,6 @@ export class SingletonModuleComp extends ecs.Comp { // {uuid:6213,type:2},{uuid:6214,type:2},{uuid:6215,type:2}, // {uuid:6216,type:2},{uuid:6217,type:2},{uuid:6218,type:2} ]; - items: any = [] sitems:any = [] player_skills: any = [ ]; @@ -46,7 +45,11 @@ export class SingletonModuleComp extends ecs.Comp { ]; monster_buffs: any = []; /** 游戏主角 */ - heros:any = []; + heros:any={ + 9001:{uuid:9001,lv:1,exp:0,slv:1,stone:0}, + 9002:{uuid:9002,lv:2,exp:0,slv:2,stone:0}, + 9003:{uuid:9003,lv:3,exp:0,slv:3,stone:0}, + }; mheros:any = []; monsters:any = []; skills:any = [] @@ -96,10 +99,10 @@ export class SingletonModuleComp extends ecs.Comp { }, fight_heros:[9001,], items:{ - 1001:0, + 1001:1000, 1002:0, 1003:0, - 1004:0, + 1004:1000, 1005:0, 1006:0, 1007:0, @@ -112,11 +115,6 @@ export class SingletonModuleComp extends ecs.Comp { 1027:0, 1028:0, }, - heros:{ - 9001:{uuid:9001,lv:1,exp:0,slv:1,stone:0}, - 9002:{uuid:9002,lv:2,exp:0,slv:2,stone:0}, - 9003:{uuid:9003,lv:3,exp:0,slv:3,stone:0}, - }, talent:{ 1001:{uuid:1001,lv:0,}, }, diff --git a/assets/script/game/common/config/RoleSet.ts b/assets/script/game/common/config/RoleSet.ts index aa8ef10c..ef43ce30 100644 --- a/assets/script/game/common/config/RoleSet.ts +++ b/assets/script/game/common/config/RoleSet.ts @@ -1,25 +1,2 @@ -/* - * @Author: dgflash - * @Date: 2021-11-23 15:28:39 - * @LastEditors: dgflash - * @LastEditTime: 2022-01-26 16:42:00 - */ -export const RoleType = { - 1: "前排", - 2: "后排", -} - - -export const RoleSet ={ - 101:{uuid:"101", name:'魔法师', path:"101",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 102:{uuid:"102", name:'魔法师', path:"102",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 103:{uuid:"103", name:'魔法师', path:"103",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 104:{uuid:"104", name:'魔法师', path:"104",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 105:{uuid:"105", name:'魔法师', path:"105",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 106:{uuid:"106", name:'魔法师', path:"106",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 107:{uuid:"107", name:'魔法师', path:"107",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 108:{uuid:"108", name:'魔法师', path:"108",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 109:{uuid:"109", name:'魔法师', path:"109",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, - 110:{uuid:"110", name:'魔法师', path:"110",atk:6,atk_cd:2, hp:30, power:50, speed:150,skill:{ }}, -} +export const SlvSet =[0,20,40,80,160] diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index bbd5a852..c5580bd5 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -54,7 +54,7 @@ export class Hero extends ecs.Entity { this.addComponents( MonModelComp); } - var path = "game/heros/"+smc.heros[uuid].path; + var path = "game/heros/"+HeroInfo[uuid].path; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); @@ -69,9 +69,9 @@ export class Hero extends ecs.Entity { hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO){ var hv = node.getComponent(HeroViewComp)!; // console.log("hero_init",buff) - let HInf= smc.heros[uuid] // 角色数据 + let HInf= HeroInfo[uuid] // 角色数据 let talent= smc.vmdata.talent - let hero =smc.vmdata.heros[uuid] + let hero =smc.heros[uuid] let talents=Talents; hv.scale = scale; hv.box_group = box_group; @@ -112,7 +112,7 @@ export class Hero extends ecs.Entity { } set_ratio(uuid:number){ let ratio=1; - switch (smc.heros[uuid].level) { + switch (HeroInfo[uuid].level) { case 2: ratio=1.05 break; diff --git a/assets/script/game/hero/HeroCard.ts b/assets/script/game/hero/HeroCard.ts index bc0545d7..484863fa 100644 --- a/assets/script/game/hero/HeroCard.ts +++ b/assets/script/game/hero/HeroCard.ts @@ -3,6 +3,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { HeroCardComp } from "./HeroCardComp"; import { smc } from "../common/SingletonModuleComp"; +import { HeroInfo } from "../common/config/heroSet"; /** HeroCard 模块 */ @ecs.register(`HeroCard`) @@ -18,17 +19,17 @@ export class HeroCard extends ecs.Entity { var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.parent = parent; - node.getChildByName("name").getComponent(Label).string = smc.heros[uuid].name + node.getChildByName("name").getComponent(Label).string = HeroInfo[uuid].name resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { const sprite = node.getChildByName("Mask").getChildByName("hero").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(smc.heros[uuid].path); + sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path); }); - node.getChildByName("lv").getComponent(Label).string = smc.vmdata.heros[uuid].lv.toString(); - if(smc.vmdata.heros[uuid].slv>=1) node.getChildByName("slv").getChildByName("s1").active=true; - if(smc.vmdata.heros[uuid].slv>=2) node.getChildByName("slv").getChildByName("s2").active=true; - if(smc.vmdata.heros[uuid].slv>=3) node.getChildByName("slv").getChildByName("s3").active=true; - if(smc.vmdata.heros[uuid].slv>=4) node.getChildByName("slv").getChildByName("s4").active=true; - if(smc.vmdata.heros[uuid].slv>=5) node.getChildByName("slv").getChildByName("s5").active=true; + node.getChildByName("lv").getComponent(Label).string = smc.heros[uuid].lv.toString(); + if(smc.heros[uuid].slv>=1) node.getChildByName("slv").getChildByName("s1").active=true; + if(smc.heros[uuid].slv>=2) node.getChildByName("slv").getChildByName("s2").active=true; + if(smc.heros[uuid].slv>=3) node.getChildByName("slv").getChildByName("s3").active=true; + if(smc.heros[uuid].slv>=4) node.getChildByName("slv").getChildByName("s4").active=true; + if(smc.heros[uuid].slv>=5) node.getChildByName("slv").getChildByName("s5").active=true; let hcc = node.getComponent(HeroCardComp)!; hcc.hcc_uuid = uuid; this.add(hcc); diff --git a/assets/script/game/initialize/Initialize.ts b/assets/script/game/initialize/Initialize.ts index 261143f4..d7bbc7f0 100644 --- a/assets/script/game/initialize/Initialize.ts +++ b/assets/script/game/initialize/Initialize.ts @@ -86,8 +86,6 @@ export class Initialize extends ecs.Entity { /** 加载完成进入游戏内容加载界面 */ private onComplete(queue: AsyncQueue) { queue.complete = () => { - smc.heros = HeroInfo; - smc.monsters=MonSet; // console.log("加载完成!",smc.heros); smc.skills=SkillSet; smc.sitems=Sitems; diff --git a/assets/script/game/map/CardController.ots b/assets/script/game/map/CardController.ots index 68b012ec..a2e6ede8 100644 --- a/assets/script/game/map/CardController.ots +++ b/assets/script/game/map/CardController.ots @@ -247,7 +247,7 @@ export class CardControllerComp extends CCComp { let cost: number = 0; let { uuid, type } = card[0]; url = "game/hero/hero_icon"; - ({ uuid: pathName, name, level ,cost} = smc.heros[uuid]); + ({ uuid: pathName, name, level ,cost} = HeroInfo[uuid]); this.cards[index].lv=level this.cards[index].cost = cost let node=this.node.getChildByName('cards').getChildByName('card'+index) diff --git a/assets/script/game/map/HeroHomeComp.ts b/assets/script/game/map/HeroHomeComp.ts index 29c34e89..7d3324ca 100644 --- a/assets/script/game/map/HeroHomeComp.ts +++ b/assets/script/game/map/HeroHomeComp.ts @@ -1,13 +1,14 @@ import { _decorator,Button,EventHandler,EventTouch,instantiate,Label,NodeEventType,Prefab,resources,Sprite,SpriteAtlas,tween,UITransform,v3 } 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 { HeroList } from "../common/config/heroSet"; +import { HeroInfo, HeroList } from "../common/config/heroSet"; import { HeroCard } from "../hero/HeroCard"; import { smc } from "../common/SingletonModuleComp"; import { UIID } from "../common/config/GameUIConfig"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { Items } from "../common/config/Items"; import { SkillSet } from "../common/config/SkillSet"; +import { SlvSet } from "../common/config/RoleSet"; const { ccclass, property } = _decorator; /** 视图层对象 */ @@ -39,8 +40,8 @@ export class HeroHomeComp extends CCComp { } hero_show(uuid:number) { console.log("hero_home hero_show:",uuid) - let role = smc.vmdata.heros[uuid] - let hero =smc.heros[uuid] + let role = smc.heros[uuid] + let hero =HeroInfo[uuid] this.h_uuid=uuid let slv_node=this.node.getChildByName("name").getChildByName("slv"); let tal=this.node.getChildByName("slvup").getChildByName("tal"); @@ -105,10 +106,22 @@ export class HeroHomeComp extends CCComp { } lv_up(){ - console.log("lvup h_uuid:",this.h_uuid) + console.log("升级",smc.vmdata.items[1001],smc.heros[this.h_uuid].lv*HeroInfo[this.h_uuid].lvexp) + if(smc.vmdata.items[1001] < smc.heros[this.h_uuid].lv*HeroInfo[this.h_uuid].lvexp){ + console.log("材料不足") + return + } + smc.heros[this.h_uuid].lv++ + smc.vmdata.items[1001] -= smc.heros[this.h_uuid].lv*HeroInfo[this.h_uuid].lvexp } slv_up(){ - console.log("lvup slv_up:",this.h_uuid) + console.log("smc.vmdata.items[1004] SlvSet[smc.heros[this.h_uuid].slv]:",smc.vmdata.items[1004],SlvSet[smc.heros[this.h_uuid].slv]) + if(smc.vmdata.items[1004] < SlvSet[smc.heros[this.h_uuid].slv]){ + console.log("材料不足") + return + } + smc.heros[this.h_uuid].slv++ + smc.vmdata.items[1004] -= SlvSet[smc.heros[this.h_uuid].slv] } item_show(e:any,val:any){ oops.gui.open(UIID.ItemInfo, Items[val]); diff --git a/assets/script/game/map/MIssionController.ts b/assets/script/game/map/MIssionController.ts index 1a2c99c4..73fbf47d 100644 --- a/assets/script/game/map/MIssionController.ts +++ b/assets/script/game/map/MIssionController.ts @@ -15,7 +15,7 @@ import { Talents } from "../common/config/TalentSet"; import { HeroViewComp } from "../hero/HeroViewComp"; import { BossViewComp } from "../Boss/BossViewComp"; import { Hero } from "../hero/Hero"; -import { HeroSet } from "../common/config/heroSet"; +import { HeroInfo, HeroSet } from "../common/config/heroSet"; import { Boss } from "../Boss/Boss"; import { MonModelComp } from "../hero/MonModelComp"; import { BossList, MissionNum, MissionSet, MonsetList } from "../common/config/MissionSet"; @@ -253,14 +253,14 @@ export class MissionComp extends CCComp { private addHero(uuid:number=1001,i:number=0) { let hero = ecs.getEntity(Hero); let scale = 1 - let pos:Vec3 = v3(HeroSet.StartPos[smc.heros[uuid].type]-i*15,BoxSet.GAME_LINE); + let pos:Vec3 = v3(HeroSet.StartPos[HeroInfo[uuid].type]-i*15,BoxSet.GAME_LINE); // console.log("addHero:",pos) hero.load(pos,scale,uuid); } private addMonster(uuid:number=1001,i:number=0) { let monster = ecs.getEntity(Hero); let scale = -1 - let pos:Vec3 = v3(-1*HeroSet.StartPos[smc.heros[uuid].type]+i*15,BoxSet.GAME_LINE); + let pos:Vec3 = v3(-1*HeroSet.StartPos[HeroInfo[uuid].type]+i*15,BoxSet.GAME_LINE); console.log("addMonster:",pos) monster.load(pos,scale,uuid,false); }