英雄出战选择 +英雄相关 ui 改变
This commit is contained in:
@@ -3,11 +3,17 @@ import { HeroInfo, HQuality, HType } from '../common/config/heroSet';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { UIID } from '../common/config/GameUIConfig';
|
||||
import { GameSet, HeroConSet } from '../common/config/BoxSet';
|
||||
import { HttpReturn } from 'db://oops-framework/libs/network/HttpRequest';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HCardUICom')
|
||||
export class HCardUICom extends Component {
|
||||
h_uuid:number=0
|
||||
type:number=0
|
||||
slot:number=0
|
||||
|
||||
start() {
|
||||
console.log("[HCardUICom]:start")
|
||||
}
|
||||
@@ -15,9 +21,12 @@ export class HCardUICom extends Component {
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
update_data(uuid:number){
|
||||
console.log("[HCardUICom]:update_data",uuid)
|
||||
update_data(uuid:number,args:any){
|
||||
this.type=args.type
|
||||
if(args.slot) this.slot=args.slot
|
||||
console.log("[HCardUICom]:update_data",uuid,this.type,this.slot,args)
|
||||
this.h_uuid=uuid
|
||||
this.node.getChildByName("in_fight").active=this.check_in_fight(uuid)
|
||||
let hero_data = HeroInfo[uuid]
|
||||
let hero= this.node.getChildByName("hero")
|
||||
let anm_path=hero_data.path
|
||||
@@ -26,7 +35,10 @@ export class HCardUICom extends Component {
|
||||
hero.getComponent(Animation).play("idle");
|
||||
});
|
||||
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[uuid].lv.toString()
|
||||
let lv=smc.heros[uuid]?.lv??0
|
||||
this.node.getChildByName("luck").active=lv==0
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=lv > 0 ? lv.toString() : ""
|
||||
this.node.getChildByName("lv").active=lv > 0
|
||||
// this.node.getChildByName("slv").getChildByName("lv1").active=smc.heros[uuid].slv>=1
|
||||
// this.node.getChildByName("slv").getChildByName("lv2").active=smc.heros[uuid].slv>=2
|
||||
// this.node.getChildByName("slv").getChildByName("lv3").active=smc.heros[uuid].slv>=3
|
||||
@@ -43,9 +55,37 @@ export class HCardUICom extends Component {
|
||||
this.node.getChildByName("type").getChildByName("w").active=hero_data.type==HType.warrior
|
||||
this.node.getChildByName("type").getChildByName("r").active=hero_data.type==HType.remote
|
||||
this.node.getChildByName("type").getChildByName("m").active=hero_data.type==HType.mage
|
||||
|
||||
}
|
||||
show_info(){
|
||||
oops.gui.open(UIID.HeroInfo,this.h_uuid)
|
||||
do_click(){
|
||||
switch(this.type){
|
||||
case HeroConSet.INFO:
|
||||
oops.gui.open(UIID.HeroInfo,this.h_uuid)
|
||||
break
|
||||
case HeroConSet.SELECT:
|
||||
if(oops.gui.has(UIID.HeroSelect)) {
|
||||
this.check_in_slot(this.h_uuid)
|
||||
smc.setFightHero(this.slot,this.h_uuid,true)
|
||||
oops.message.dispatchEvent(GameEvent.UpdateHero)
|
||||
oops.gui.remove(UIID.HeroSelect)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
check_in_slot(uuid:number){ //如果英雄在出战位,则移除久的出战位
|
||||
let heros=smc.fight_heros
|
||||
for(let i=0;i<GameSet.HERO_NUM;i++){
|
||||
if(heros[i]==uuid) {
|
||||
smc.setFightHero(i,0,true)
|
||||
}
|
||||
}
|
||||
}
|
||||
check_in_fight(uuid:number){
|
||||
let heros=smc.fight_heros
|
||||
for(let i=0;i<GameSet.HERO_NUM;i++){
|
||||
if(heros[i]==uuid) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { UIID } from '../common/config/GameUIConfig';
|
||||
import { getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType } from '../common/config/heroSet';
|
||||
import { getHeroList, getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType } from '../common/config/heroSet';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -26,7 +26,7 @@ export class HInfoComp extends Component {
|
||||
this.h_uuid=uuid
|
||||
let hero_data = HeroInfo[uuid]
|
||||
let hero= this.node.getChildByName("hero")
|
||||
let lv=smc.heros[uuid].lv
|
||||
let lv=smc.heros[uuid]?.lv??1
|
||||
let anm_path=hero_data.path
|
||||
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
||||
hero.getComponent(Animation).addClip(clip);
|
||||
@@ -48,6 +48,12 @@ export class HInfoComp extends Component {
|
||||
this.node.getChildByName("type").getChildByName("w").active=hero_data.type==HType.warrior
|
||||
this.node.getChildByName("type").getChildByName("r").active=hero_data.type==HType.remote
|
||||
this.node.getChildByName("type").getChildByName("m").active=hero_data.type==HType.mage
|
||||
this.show_luck(smc.heros[uuid]?.lv??0)
|
||||
}
|
||||
show_luck(lv:number){
|
||||
this.node.getChildByName("upBtn").active=lv > 0
|
||||
this.node.getChildByName("upNeed").active=lv > 0
|
||||
this.node.getChildByName("luck").active=lv == 0
|
||||
}
|
||||
uplevel(){
|
||||
let hero_data = HeroInfo[this.h_uuid]
|
||||
@@ -64,7 +70,7 @@ export class HInfoComp extends Component {
|
||||
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
|
||||
}
|
||||
next_hero(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
let heros=getHeroList()
|
||||
let index = heros.indexOf(this.h_uuid);
|
||||
index++
|
||||
if(index==heros.length) index=0
|
||||
@@ -72,7 +78,7 @@ export class HInfoComp extends Component {
|
||||
this.update_data(nextHero)
|
||||
}
|
||||
prev_hero(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
let heros=getHeroList()
|
||||
let index = heros.indexOf(this.h_uuid);
|
||||
index--
|
||||
if(index==-1) index=heros.length-1
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
|
||||
import { _decorator, Component, instantiate, Node, Prefab, UITransform } from 'cc';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { HCardUICom } from './HCardUICom';
|
||||
import { HeroConSet } from '../common/config/BoxSet';
|
||||
import { getHeroList } from '../common/config/heroSet';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroPageComp')
|
||||
@@ -14,10 +16,12 @@ export class HeroPageComp extends Component {
|
||||
|
||||
}
|
||||
update_heros(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
let heros=getHeroList()
|
||||
console.log("[HeroPageComp]:update_heros",heros)
|
||||
let height= Math.ceil(heros.length/3)*315+30
|
||||
this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform).height=height
|
||||
this.clear_heros()
|
||||
for(let i=0;i<3;i++){
|
||||
for(let i=0;i<heros.length;i++){
|
||||
let hero=heros[i]
|
||||
console.log("[HeroPageComp]:hero",hero)
|
||||
if(hero){
|
||||
@@ -37,7 +41,7 @@ export class HeroPageComp extends Component {
|
||||
const node = instantiate(prefab);
|
||||
node.parent=parent
|
||||
let hcard=node.getComponent(HCardUICom)!
|
||||
hcard.update_data(uuid)
|
||||
hcard.update_data(uuid,{type:HeroConSet.INFO})
|
||||
}
|
||||
clear_heros(){
|
||||
let parent=this.node.getChildByName("main").getChildByName("view").getChildByName("heros")
|
||||
|
||||
@@ -3,16 +3,20 @@ import { smc } from '../common/SingletonModuleComp';
|
||||
import { HeroInfo } from '../common/config/heroSet';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { UIID } from '../common/config/GameUIConfig';
|
||||
import { GameSet } from '../common/config/BoxSet';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroReadyCom')
|
||||
export class HeroReadyCom extends Component {
|
||||
@property(CCInteger)
|
||||
slot: number=0;
|
||||
|
||||
protected onLoad(): void {
|
||||
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
|
||||
}
|
||||
start() {
|
||||
this.update_hero()
|
||||
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
@@ -24,6 +28,7 @@ export class HeroReadyCom extends Component {
|
||||
this.no_hero()
|
||||
return
|
||||
}
|
||||
this.node.getChildByName("icon").active=true
|
||||
this.node.getChildByName("add").active=false
|
||||
let hero_data = HeroInfo[hero]
|
||||
console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data)
|
||||
@@ -32,6 +37,7 @@ export class HeroReadyCom extends Component {
|
||||
this.node.getChildByName("icon").getComponent(Animation).addClip(clip);
|
||||
this.node.getChildByName("icon").getComponent(Animation).play("idle");
|
||||
});
|
||||
this.node.getChildByName("lv").active=true
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[hero].lv.toString()
|
||||
// console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation))
|
||||
|
||||
@@ -39,7 +45,13 @@ export class HeroReadyCom extends Component {
|
||||
no_hero(){
|
||||
this.node.getChildByName("lv").active=false
|
||||
this.node.getChildByName("add").active=true
|
||||
this.node.getChildByName("icon").active=false
|
||||
}
|
||||
select_hero(){
|
||||
if(oops.gui.has(UIID.HeroSelect)) return
|
||||
oops.gui.open(UIID.HeroSelect,{slot:this.slot})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
67
assets/script/game/map/HeroSelectCom.ts
Normal file
67
assets/script/game/map/HeroSelectCom.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { HCardUICom } from './HCardUICom';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { HeroConSet } from '../common/config/BoxSet';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroSelectCom')
|
||||
export class HeroSelectCom extends Component {
|
||||
slot:number=0
|
||||
start() {
|
||||
|
||||
}
|
||||
onAdded(args: any) {
|
||||
console.log("[HeroSelectCom]:onAdded",args)
|
||||
this.slot=args.slot
|
||||
this.update_heros()
|
||||
}
|
||||
protected onDisable(): void {
|
||||
console.log("[HeroSelectCom]:onDisable")
|
||||
this.clear_heros()
|
||||
}
|
||||
update_heros(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
console.log("[HeroPageComp]:update_heros",heros)
|
||||
let width= heros.length*235+30
|
||||
for(let i=0;i<heros.length;i++){
|
||||
let hero=heros[i]
|
||||
console.log("[HeroPageComp]:hero",hero)
|
||||
if(hero){
|
||||
this.load_hero(hero)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clear_heros(){
|
||||
let parent=this.node.getChildByName("main").getChildByName("view").getChildByName("heros")
|
||||
let children=parent.children
|
||||
console.log("[HeroPageComp]:clear_heros",children)
|
||||
for(let i=0;i<children.length;i++){
|
||||
children[i].destroy()
|
||||
}
|
||||
}
|
||||
load_hero(uuid:number){
|
||||
console.log("[HeroPageComp]:load_hero",uuid)
|
||||
let parent=this.node.getChildByName("main").getChildByName("view").getChildByName("heros")
|
||||
let path = "game/gui/hcard"
|
||||
const prefab = oops.res.get(path, Prefab);
|
||||
if (!prefab) {
|
||||
console.error("[Skill] 预制体加载失败:", path);
|
||||
return;
|
||||
}
|
||||
const node = instantiate(prefab);
|
||||
node.parent=parent
|
||||
let hcard=node.getComponent(HCardUICom)!
|
||||
hcard.update_data(uuid,{type:HeroConSet.SELECT,slot:this.slot})
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
close(){
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
assets/script/game/map/HeroSelectCom.ts.meta
Normal file
9
assets/script/game/map/HeroSelectCom.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0c9b9c74-9486-4b43-b797-f602d26f2f1a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user