清理 ui1 ui2 精简到ui3 和ui4
This commit is contained in:
@@ -1,376 +0,0 @@
|
||||
import { _decorator, Animation, Label, resources, SpriteAtlas,Sprite, Skeleton, SkinnedMeshRenderer, sp } 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 { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroInfo} from "../common/config/heroSet";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroSkillList, SkillSet } from "../common/config/SkillSet";
|
||||
import { cardType, getRandomCardUUID, SuperCards } from "../common/config/CardSet";
|
||||
import { EquipInfo, EquipType } from "../common/config/Equips";
|
||||
import { FightSet } from "../common/config/Mission";
|
||||
import { EnhancementOptions } from "../common/config/LevelUp";
|
||||
import { TalentList } from "../common/config/TalentSet";
|
||||
import { QualitySet } from "../common/config/BoxSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('CardComp')
|
||||
@ecs.register('Card', false)
|
||||
export class CardComp extends CCComp {
|
||||
c_uuid:number=0;
|
||||
c_type:number=0; //1英雄,2 技能.3 装备 4.功能卡牌
|
||||
is_used:boolean=false;
|
||||
cost_gold:number=0;
|
||||
skill_slot:string="skill1"
|
||||
equip_slot:string="weapon"
|
||||
talent_slot:string="tal1"
|
||||
enhancement_data:any=null;
|
||||
onLoad(){
|
||||
// this.on(GameEvent.HeroSelect,this.hero_select,this)
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
init_card(){
|
||||
this.node.getChildByName("Button").active=false
|
||||
this.node.getChildByName("show").active=false
|
||||
}
|
||||
talent_select(args: any,data:any){
|
||||
this.c_type=cardType.TALENT
|
||||
this.c_uuid=args.uuid
|
||||
// this.talent_slot=data.slot
|
||||
this.show_talent(this.c_uuid)
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
hero_select(args: any){
|
||||
this.c_type=cardType.HERO
|
||||
this.c_uuid=args.uuid
|
||||
this.show_hero(this.c_uuid)
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
hero_skill_select(args: any,data:any){
|
||||
this.c_type=cardType.SKILL
|
||||
// console.log("[cardcomp]:card hero_skill_select",args)
|
||||
this.c_uuid=args.uuid
|
||||
this.skill_slot=data.slot
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_skill(this.c_uuid)
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
equip_select(args: any,slot:string="weapon"){
|
||||
this.c_type=cardType.EQUIP
|
||||
this.c_uuid=args.uuid
|
||||
this.equip_slot=slot
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_equip(this.c_uuid)
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
func_select(args: any){
|
||||
// console.log("[cardcomp]:card func_select",args)
|
||||
this.c_type=cardType.SPECIAL
|
||||
this.c_uuid=args.uuid
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_func(this.c_uuid)
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
enhancement_select(args: any){
|
||||
this.c_type=cardType.ENHANCEMENT
|
||||
this.enhancement_data=args
|
||||
this.node.getChildByName("show").active=false
|
||||
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
|
||||
this.show_enhancement(args)
|
||||
this.scheduleOnce(() => {
|
||||
this.node.getChildByName("show").active=true
|
||||
this.node.getChildByName("Button").active=true
|
||||
}, 0.1);
|
||||
}
|
||||
|
||||
random_select(){
|
||||
let card =getRandomCardUUID() //随机获取卡牌类型
|
||||
// console.log("[cardcomp]:rad 开始请求卡牌",card)
|
||||
switch(card.type){
|
||||
case cardType.EQUIP:
|
||||
this.equip_select(card)
|
||||
break
|
||||
case cardType.SPECIAL:
|
||||
this.func_select(card)
|
||||
break
|
||||
}
|
||||
}
|
||||
show_talent(uuid:number,){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=TalentList[uuid].name
|
||||
this.do_card_bg_show(TalentList[uuid].quality)
|
||||
this.node.getChildByName("show").getChildByName("coins").active=false
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("tal").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(TalentList[uuid].path);
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=TalentList[uuid].info
|
||||
// console.log("[cardcomp]:show_talent",TalentList[uuid],show)
|
||||
}
|
||||
show_skill(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
|
||||
this.do_card_bg_show(SkillSet[uuid].quality)
|
||||
this.node.getChildByName("show").getChildByName("coins").active=false
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=SkillSet[uuid].info
|
||||
}
|
||||
/* 英雄 直接加载骨骼动画 */ //注意 动画名称为Idle
|
||||
show_hero(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
|
||||
this.do_card_bg_show(HeroInfo[uuid].quality)
|
||||
show.getChildByName("coins").active=false
|
||||
var icon_path = "game/heros/heros/"+HeroInfo[uuid].path
|
||||
// resources.load(icon_path, sp.SkeletonData, (err, skeleton) => {
|
||||
// if (err) {
|
||||
// console.error("[CardComp]: 加载骨骼数据失败:", err);
|
||||
// return;
|
||||
// }
|
||||
// // console.log("[CardComp]: 加载骨骼数据成功:", skeleton)
|
||||
// // 检查节点是否仍然存在
|
||||
// const maskNode = show.getChildByName("mask");
|
||||
// if (!maskNode) {
|
||||
// console.error("[CardComp]: mask节点不存在");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const heroNode = maskNode.getChildByName("hero");
|
||||
// if (!heroNode) {
|
||||
// console.error("[CardComp]: hero节点不存在");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const spine = heroNode.getComponent(sp.Skeleton);
|
||||
// if (!spine) {
|
||||
// console.error("[CardComp]: hero节点上没有找到SkinnedMeshRenderer组件");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (spine) {
|
||||
// spine.skeletonData = skeleton;
|
||||
// spine.setAnimation(0, "Idle", true);
|
||||
// }
|
||||
// });
|
||||
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
// const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
|
||||
// sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
|
||||
// });
|
||||
show.getChildByName("info").getComponent(Label).string=HeroInfo[uuid].info
|
||||
|
||||
}
|
||||
|
||||
show_equip(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=EquipInfo[uuid].name
|
||||
this.do_card_bg_show(EquipInfo[uuid].quality)
|
||||
var icon_path = "game/heros/equips2"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("equip").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(EquipInfo[uuid].path);
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=EquipInfo[uuid].info
|
||||
}
|
||||
|
||||
show_func(uuid:number){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=SuperCards[uuid].name
|
||||
this.do_card_bg_show(SuperCards[uuid].quality)
|
||||
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("func").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(SuperCards[uuid].path);
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=SuperCards[uuid].info
|
||||
}
|
||||
|
||||
show_enhancement(data:any){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("name").getChildByName("name").getComponent(Label).string=data.name
|
||||
this.do_card_bg_show(data.rarity)
|
||||
var icon_path = "game/heros/cards"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = show.getChildByName("mask").getChildByName("func").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(data.icon);
|
||||
});
|
||||
show.getChildByName("info").getComponent(Label).string=data.description
|
||||
}
|
||||
|
||||
do_card_bg_show(q:number=QualitySet.GREEN){
|
||||
let show=this.node.getChildByName("show")
|
||||
show.getChildByName("ap").active=false
|
||||
show.getChildByName("hp").active=false
|
||||
show.getChildByName("mask").getChildByName("skill").active=false
|
||||
show.getChildByName("mask").getChildByName("equip").active=false
|
||||
show.getChildByName("mask").getChildByName("hero").active=false
|
||||
show.getChildByName("mask").getChildByName("func").active=false
|
||||
show.getChildByName("mask").getChildByName("tal").active=false
|
||||
show.getChildByName("mask").getChildByName("lv1").active=false
|
||||
show.getChildByName("mask").getChildByName("lv2").active=false
|
||||
show.getChildByName("mask").getChildByName("lv3").active=false
|
||||
show.getChildByName("mask").getChildByName("lv4").active=false
|
||||
show.getChildByName("mask").getChildByName("lv5").active=false
|
||||
switch(this.c_type){
|
||||
case cardType.HERO:
|
||||
show.getChildByName("mask").getChildByName("hero").active=true
|
||||
break
|
||||
case cardType.SKILL:
|
||||
show.getChildByName("mask").getChildByName("skill").active=true
|
||||
break
|
||||
case cardType.TALENT:
|
||||
show.getChildByName("mask").getChildByName("tal").active=true
|
||||
break
|
||||
case cardType.EQUIP:
|
||||
show.getChildByName("mask").getChildByName("equip").active=true
|
||||
switch(EquipInfo[this.c_uuid].type){
|
||||
case EquipType.ARMOR:
|
||||
show.getChildByName("mask").getChildByName("abg").active=true
|
||||
break
|
||||
case EquipType.WEAPON:
|
||||
show.getChildByName("mask").getChildByName("wbg").active=true
|
||||
break
|
||||
case EquipType.ACCESSORY:
|
||||
// console.log("[cardcomp]:装备卡 饰品")
|
||||
break
|
||||
}
|
||||
|
||||
break
|
||||
case cardType.SPECIAL:
|
||||
show.getChildByName("mask").getChildByName("func").active=true
|
||||
break
|
||||
}
|
||||
show.getChildByName("q2").active=q==QualitySet.GREEN
|
||||
show.getChildByName("q3").active=q==QualitySet.BLUE
|
||||
show.getChildByName("q4").active=q==QualitySet.PURPLE
|
||||
show.getChildByName("q5").active=q==QualitySet.ORANGE
|
||||
show.getChildByName("fq2").active=q==QualitySet.GREEN
|
||||
show.getChildByName("fq3").active=q==QualitySet.BLUE
|
||||
show.getChildByName("fq4").active=q==QualitySet.PURPLE
|
||||
show.getChildByName("fq5").active=q==QualitySet.ORANGE
|
||||
// this.node.getChildByName("show").getChildByName("coins").active=false
|
||||
// this.node.getChildByName("show").getChildByName("coins").getChildByName("num").getComponent(Label).string=this.get_cost_gold(q).toString()
|
||||
}
|
||||
|
||||
get_cost_gold(quality:number){
|
||||
switch(quality){
|
||||
case QualitySet.GREEN:
|
||||
return FightSet.GREEN_GOLD
|
||||
|
||||
case QualitySet.BLUE:
|
||||
return FightSet.BLUE_GOLD
|
||||
|
||||
case QualitySet.PURPLE:
|
||||
return FightSet.PURPLE_GOLD
|
||||
|
||||
case QualitySet.ORANGE:
|
||||
return FightSet.ORANGE_GOLD
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
check_heros(){
|
||||
// let heros=ecs.query(ecs.allOf(HeroModelComp))
|
||||
// for(let hero of heros){
|
||||
// if(hero.get(HeroViewComp).hero_uuid == this.c_uuid){
|
||||
// return "升级"
|
||||
// }
|
||||
// if(hero.get(HeroViewComp).type==HeroInfo[this.c_uuid].type){
|
||||
// return "替换"
|
||||
// }
|
||||
// }
|
||||
return "获取"
|
||||
}
|
||||
reset_card(){
|
||||
this.cost_gold=0
|
||||
this.c_type=0
|
||||
this.c_uuid=0
|
||||
this.is_used=false
|
||||
}
|
||||
use_card(){
|
||||
switch(this.c_type){
|
||||
case cardType.HERO:
|
||||
oops.message.dispatchEvent(GameEvent.UseHeroCard,{uuid:this.c_uuid})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.SKILL:
|
||||
// console.log("[cardcomp]:use_card 技能卡")
|
||||
oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid,slot:this.skill_slot})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
this.skill_slot="skill1"
|
||||
break
|
||||
case cardType.EQUIP:
|
||||
// console.log("[cardcomp]:use_card 装备卡")
|
||||
// if(!this.cost_gold_check()) return
|
||||
oops.message.dispatchEvent(GameEvent.EquipAdd,{uuid:this.c_uuid,type:EquipInfo[this.c_uuid].type,slot:this.equip_slot})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.SPECIAL:
|
||||
// console.log("[cardcomp]:use_card 功能卡")
|
||||
// if(!this.cost_gold_check()) return
|
||||
oops.message.dispatchEvent(GameEvent.UseSpecialCard,{uuid:this.c_uuid})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.ENHANCEMENT:
|
||||
// console.log("[cardcomp]:use_card 强化卡",this.enhancement_data,smc.enhancements)
|
||||
oops.message.dispatchEvent(GameEvent.UseEnhancement,this.enhancement_data)
|
||||
smc.enhancements[this.enhancement_data.type]=this.enhancement_data.lv
|
||||
// console.log("[cardcomp]:use_card 强化卡",this.enhancement_data,smc.enhancements)
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
case cardType.TALENT:
|
||||
// console.log("[cardcomp]:use_card 天赋卡",this.c_uuid)
|
||||
oops.message.dispatchEvent(GameEvent.UseTalentCard,{uuid:this.c_uuid,slot:this.talent_slot})
|
||||
oops.message.dispatchEvent(GameEvent.CardsClose)
|
||||
break
|
||||
}
|
||||
this.reset_card()
|
||||
}
|
||||
cost_gold_check(){
|
||||
if(smc.data.gold< this.cost_gold){
|
||||
oops.gui.toast("[cardcomp]:金币不足", false);
|
||||
return false
|
||||
}
|
||||
smc.data.gold-=this.cost_gold
|
||||
return true
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "e06b1406-878e-482d-99dd-46eb7ed2c7a8",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
import { _decorator, Label, tween, 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 { GameEvent } from "../common/config/GameEvent";
|
||||
import { CardComp } from "./CardComp";
|
||||
import { cardType, getRandomCardsByType } from "../common/config/CardSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { RandomManager } from "db://oops-framework/core/common/random/RandomManager";
|
||||
import { EquipType } from "../common/config/Equips";
|
||||
import { getSkills } from "../common/config/SkillSet";
|
||||
import { getEnhancement } from "../common/config/LevelUp";
|
||||
import { FightSet } from "../common/config/Mission";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { getHeroList } from "../common/config/heroSet";
|
||||
import { QualitySet } from "../common/config/BoxSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('CardsCompComp')
|
||||
@ecs.register('CardsComp', false)
|
||||
export class CardsCompComp extends CCComp {
|
||||
card1:any=null
|
||||
card2:any=null
|
||||
card3:any=null
|
||||
// card4:any=null
|
||||
card1c:CardComp=null
|
||||
card2c:CardComp=null
|
||||
card3c:CardComp=null
|
||||
// card4c:CardComp=null
|
||||
more_btn:any=null
|
||||
refresh_btn:any=null
|
||||
cancel_btn:any=null
|
||||
/** 卡牌展示队列 */
|
||||
private cardQueue: Array<{type: GameEvent, data?: any}> = [];
|
||||
/** 是否正在展示卡牌 */
|
||||
private isShowing: boolean = false;
|
||||
//**当前卡组 */
|
||||
private now_card:any=null;
|
||||
//**是否正在倒计时 */
|
||||
private is_countdown:boolean=false;
|
||||
//**倒计时时间 */
|
||||
private countdown_time:number=10;
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.on(GameEvent.HeroSkillSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.HeroSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.CardRefresh, this.addToQueue, this);
|
||||
this.on(GameEvent.FuncSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.MissionEnd, this.clear_cards, this);
|
||||
this.on(GameEvent.HeroSkillSelectEnd, this.close_cards, this);
|
||||
this.on(GameEvent.CardsClose, this.close_cards, this);
|
||||
this.on(GameEvent.EquipSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.EnhancementSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.TalentSelect, this.addToQueue, this);
|
||||
this.on(GameEvent.AD_BACK_TRUE,this.ad_back_true,this)
|
||||
this.on(GameEvent.AD_BACK_FALSE,this.ad_back_false,this)
|
||||
this.card1=this.node.getChildByName("cards").getChildByName("card1")
|
||||
this.card2=this.node.getChildByName("cards").getChildByName("card2")
|
||||
this.card3=this.node.getChildByName("cards").getChildByName("card3")
|
||||
// this.card4=this.node.getChildByName("card4")
|
||||
this.card1c=this.card1.getComponent(CardComp)
|
||||
this.card2c=this.card2.getComponent(CardComp)
|
||||
this.card3c=this.card3.getComponent(CardComp)
|
||||
// this.card4c=this.card4.getComponent(CardComp)
|
||||
this.more_btn=this.node.getChildByName("btns").getChildByName("more")
|
||||
this.refresh_btn=this.node.getChildByName("btns").getChildByName("new")
|
||||
this.cancel_btn=this.node.getChildByName("btns").getChildByName("cancel")
|
||||
}
|
||||
|
||||
show_cards(e:GameEvent,data:any,is_refresh:boolean=false){
|
||||
this.cancel_btn.active=false
|
||||
switch(e){
|
||||
case GameEvent.HeroSelect:
|
||||
// console.log("[CardsComp]:显示英雄选择卡牌",data)
|
||||
let title="选择英雄"
|
||||
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string=title
|
||||
this.hero_select(data)
|
||||
break
|
||||
case GameEvent.HeroSkillSelect:
|
||||
// console.log("[CardsComp]:显示技能选择卡牌")
|
||||
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择技能"
|
||||
this.hero_skill_select(data)
|
||||
break
|
||||
case GameEvent.FuncSelect:
|
||||
// console.log("[CardsComp]:显示功能卡牌")
|
||||
this.cancel_btn.active=true
|
||||
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择卡牌"
|
||||
this.func_select()
|
||||
break
|
||||
case GameEvent.EquipSelect:
|
||||
// console.log("[CardsComp]:显示装备选择卡牌")
|
||||
this.cancel_btn.active=true
|
||||
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择装备"
|
||||
this.equip_select(data)
|
||||
break
|
||||
case GameEvent.EnhancementSelect:
|
||||
// console.log("[CardsComp]:显示强化选择卡牌")
|
||||
this.cancel_btn.active=true
|
||||
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择强化"
|
||||
this.enhancement_select()
|
||||
break
|
||||
case GameEvent.TalentSelect:
|
||||
// console.log("[CardsComp]:显示天赋选择卡牌")
|
||||
this.cancel_btn.active=true
|
||||
this.node.getChildByName("top").getChildByName("title").getChildByName("Label").getComponent(Label).string="选择天赋"
|
||||
this.talent_select(data)
|
||||
break
|
||||
}
|
||||
|
||||
if(!is_refresh) this.show()
|
||||
|
||||
}
|
||||
talent_select(data:any){
|
||||
let list=getRandomCardsByType(cardType.TALENT,3,QualitySet.GREEN)
|
||||
// console.log("[CardsComp]:天赋选择卡牌列表",list)
|
||||
this.card1c.talent_select(list[0],data)
|
||||
this.card2c.talent_select(list[1],data)
|
||||
this.card3c.talent_select(list[2],data)
|
||||
}
|
||||
enhancement_select(){
|
||||
let list=getEnhancement(smc.enhancements,3)
|
||||
// console.log("[CardsComp]:强化选择卡牌列表",smc.enhancements,list)
|
||||
this.card1c.enhancement_select(list[0])
|
||||
this.card2c.enhancement_select(list[1])
|
||||
this.card3c.enhancement_select(list[2])
|
||||
}
|
||||
hero_select(data:any){
|
||||
|
||||
let list=getHeroList(data.called)
|
||||
// console.log("[CardsComp]:英雄选择卡牌列表",list)
|
||||
this.card1c.hero_select(list[0])
|
||||
this.card2c.hero_select(list[1])
|
||||
this.card3c.hero_select(list[2])
|
||||
// this.card4c.hero_select(list[3])
|
||||
}
|
||||
|
||||
hero_skill_select(data:any){
|
||||
let list=[]
|
||||
if(data.slot=="skill1"){
|
||||
list =getRandomCardsByType(cardType.SKILL,3,QualitySet.GREEN)
|
||||
}else if(data.slot=="skill2"){
|
||||
list=getRandomCardsByType(cardType.SKILL,3,QualitySet.BLUE)
|
||||
}else if(data.slot=="skill3"){
|
||||
list=getRandomCardsByType(cardType.SKILL,3,QualitySet.PURPLE)
|
||||
}
|
||||
// console.log("[CardsComp]:技能选择卡牌列表",list)
|
||||
this.card1c.hero_skill_select(list[0],data)
|
||||
this.card2c.hero_skill_select(list[1],data)
|
||||
this.card3c.hero_skill_select(list[2],data)
|
||||
// this.card4c.hero_skill_select(list[3])
|
||||
}
|
||||
equip_select(data:any){
|
||||
let list=[]
|
||||
switch(data.slot){
|
||||
case "weapon":
|
||||
list=getRandomCardsByType(cardType.EQUIP,3,EquipType.WEAPON,data.lv)
|
||||
break
|
||||
case "armor":
|
||||
list=getRandomCardsByType(cardType.EQUIP,3,EquipType.ARMOR,data.lv)
|
||||
break
|
||||
case "accessory":
|
||||
list=getRandomCardsByType(cardType.EQUIP,3,EquipType.ACCESSORY,data.lv)
|
||||
break
|
||||
}
|
||||
// console.log("[CardsComp]:装备选择卡牌列表",list)
|
||||
this.card1c.equip_select(list[0],data)
|
||||
this.card2c.equip_select(list[1],data)
|
||||
this.card3c.equip_select(list[2],data)
|
||||
// this.card4c.equip_select(list[3])
|
||||
}
|
||||
func_select(){
|
||||
let list=getRandomCardsByType(cardType.SPECIAL,3)
|
||||
// console.log("[CardsComp]:功能选择卡牌列表",list)
|
||||
this.card1c.func_select(list[0])
|
||||
this.card2c.func_select(list[1])
|
||||
this.card3c.func_select(list[2])
|
||||
// this.card4c.func_select(list[3])
|
||||
}
|
||||
random_select(){
|
||||
this.card1c.random_select()
|
||||
this.card2c.random_select()
|
||||
this.card3c.random_select()
|
||||
// this.card4c.random_select()
|
||||
}
|
||||
|
||||
/** 添加卡牌展示到队列 */
|
||||
private addToQueue(e: GameEvent, data?: any) {
|
||||
// console.log("[CardsComp]:添加卡牌到队列", e,data);
|
||||
this.cardQueue.push({type: e, data: data});
|
||||
this.processQueue();
|
||||
}
|
||||
|
||||
/** 处理卡牌队列 */
|
||||
private processQueue() {
|
||||
if (this.isShowing || this.cardQueue.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextCard = this.cardQueue.shift();
|
||||
this.isShowing = true;
|
||||
this.now_card=nextCard
|
||||
this.show_cards(nextCard.type, nextCard.data);
|
||||
}
|
||||
|
||||
|
||||
close_cards(e:GameEvent,data:any){
|
||||
switch(e){
|
||||
case GameEvent.HeroSelect:
|
||||
// console.log("[CardsComp]:关闭英雄选择卡牌")
|
||||
break
|
||||
case GameEvent.HeroSkillSelect:
|
||||
// console.log("[CardsComp]:关闭技能选择卡牌")
|
||||
break
|
||||
case GameEvent.CardRefresh:
|
||||
// console.log("[CardsComp]:关闭随机刷新卡牌")
|
||||
break
|
||||
case GameEvent.CardsClose:
|
||||
// console.log("[CardsComp]:关闭所有卡牌")
|
||||
break
|
||||
}
|
||||
this.hide()
|
||||
}
|
||||
|
||||
show(){
|
||||
// 设置初始状态
|
||||
smc.mission.pause=true
|
||||
// this.node.getChildByName("btns").getChildByName("cancel").setPosition(v3(0, this.node.getChildByName("btns").getChildByName("cancel").getPosition().y, 0))
|
||||
// this.node.getChildByName("top").setPosition(v3(0, this.node.getChildByName("top").getPosition().y, 0))
|
||||
this.node.setPosition(v3(0, 0, 0));
|
||||
this.node.setScale(v3(0, 0, 1));
|
||||
|
||||
// 使用缓动动画放大和移动
|
||||
tween(this.node)
|
||||
.parallel(
|
||||
tween().to(0.3, { scale: v3(1, 1, 1) }, { easing: 'backOut' }),
|
||||
tween().to(0.3, { position: v3(0, 640, 0) }, { easing: 'backOut' })
|
||||
)
|
||||
.start();
|
||||
this.is_countdown=true
|
||||
this.countdown_time=10
|
||||
|
||||
}
|
||||
|
||||
hide(){
|
||||
smc.mission.pause=false
|
||||
tween(this.node)
|
||||
.parallel(
|
||||
tween().to(0.3, { scale: v3(0, 0, 1) }, { easing: 'backIn' }),
|
||||
tween().to(0.3, { position: v3(0, 0, 0) }, { easing: 'backIn' })
|
||||
)
|
||||
.call(()=>{
|
||||
this.node.setPosition(v3(1500, 640, 0));
|
||||
this.isShowing = false;
|
||||
this.processQueue(); // 处理队列中的下一个卡牌
|
||||
})
|
||||
.start();
|
||||
}
|
||||
clear_cards(){
|
||||
// console.log("[CardsComp]:清除卡牌队列")
|
||||
this.cardQueue = [];
|
||||
this.close_cards(GameEvent.CardsClose,null)
|
||||
}
|
||||
refresh_card(){
|
||||
if(smc.vmdata.mission_data.refresh_count>0){
|
||||
smc.vmdata.mission_data.refresh_count--
|
||||
this.show_cards(this.now_card.type,this.now_card.data,true)
|
||||
if(smc.vmdata.mission_data.refresh_count==0){
|
||||
this.more_btn.active=true
|
||||
this.refresh_btn.active=false
|
||||
}
|
||||
}else{
|
||||
this.more_btn.active=true
|
||||
this.refresh_btn.active=false
|
||||
}
|
||||
}
|
||||
|
||||
ad_callback(){
|
||||
oops.message.dispatchEvent(GameEvent.DO_AD_BACK)
|
||||
}
|
||||
|
||||
ad_back_true(){
|
||||
this.more_btn.active=false
|
||||
this.refresh_btn.active=true
|
||||
}
|
||||
ad_back_false(){
|
||||
this.more_btn.active=true
|
||||
this.refresh_btn.active=false
|
||||
}
|
||||
//检测广告是否成功观看
|
||||
checkout_ad_back(){
|
||||
return true
|
||||
}
|
||||
//放弃选择
|
||||
give_up_select(){
|
||||
this.hide()
|
||||
// let mission_data=smc.vmdata.mission_data
|
||||
// mission_data.gold+=(mission_data.back_gold+mission_data.buff_back_gold) //返还金币
|
||||
}
|
||||
|
||||
update(dt: number) {
|
||||
if(this.is_countdown){
|
||||
this.countdown_time-=dt
|
||||
if(this.countdown_time<=0){
|
||||
this.is_countdown=false
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.cardQueue = [];
|
||||
this.isShowing = false;
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "3d183133-c60d-44c0-933f-a629bea43331",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -122,7 +122,6 @@ export class GuideConComp extends CCComp {
|
||||
/** 步骤完成回调 */
|
||||
private onStepCompleted(step: IGuideStep) {
|
||||
console.log(`[Tutorial] 步骤完成: ${step.id}`);
|
||||
finishCurrGuide(step.key)
|
||||
// 检查是否有下一个引导
|
||||
if (step.nextStep && step.nextStep.trim() !== "") {
|
||||
const nextGuide = findGuideById(step.nextStep);
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
|
||||
import { HeroInfo, 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, QualitySet } from '../common/config/BoxSet';
|
||||
import { HttpReturn } from 'db://oops-framework/libs/network/HttpRequest';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
|
||||
import { CCComp } from 'db://oops-framework/module/common/CCComp';
|
||||
import { finishCurrGuide, startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HCardUICom')
|
||||
@ecs.register('HCardUICom', false)
|
||||
export class HCardUICom extends CCComp {
|
||||
h_uuid:number=0
|
||||
type:number=0
|
||||
slot:number=0
|
||||
start() {
|
||||
// console.log("[HCardUICom]:start")
|
||||
}
|
||||
protected onLoad(): void {
|
||||
this.on(GameEvent.UpdateHero,this.to_update_hero,this)
|
||||
this.on(GameEvent.HeroUnlock,this.to_update_hero,this)
|
||||
this.on(GameEvent.HeroLvUp,this.to_update_hero,this)
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
to_update_hero(event:any,args:any){
|
||||
if(args.uuid==this.h_uuid){
|
||||
console.log("[HCardUICom]:是我诶:",HeroInfo[args.uuid].name+args.uuid,this.h_uuid)
|
||||
this.update_data(this.h_uuid,{type:this.type})
|
||||
}
|
||||
}
|
||||
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.node)
|
||||
this.h_uuid=uuid
|
||||
this.node.getChildByName("in_fight").active=this.check_in_fight()
|
||||
let hero_data = HeroInfo[uuid]
|
||||
let hero= this.node.getChildByName("hero")
|
||||
let anm_path=hero_data.path
|
||||
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
||||
hero.getComponent(Animation).addClip(clip);
|
||||
hero.getComponent(Animation).play("idle");
|
||||
});
|
||||
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
|
||||
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
|
||||
// this.node.getChildByName("slv").getChildByName("lv4").active=smc.heros[uuid].slv>=4
|
||||
// this.node.getChildByName("slv").getChildByName("lv5").active=smc.heros[uuid].slv>=5
|
||||
this.node.getChildByName("g").active=hero_data.quality==QualitySet.GREEN
|
||||
this.node.getChildByName("gg").active=hero_data.quality==QualitySet.GREEN
|
||||
this.node.getChildByName("b").active=hero_data.quality==QualitySet.BLUE
|
||||
this.node.getChildByName("bg").active=hero_data.quality==QualitySet.BLUE
|
||||
this.node.getChildByName("p").active=hero_data.quality==QualitySet.PURPLE
|
||||
this.node.getChildByName("pg").active=hero_data.quality==QualitySet.PURPLE
|
||||
this.node.getChildByName("y").active=hero_data.quality==QualitySet.ORANGE
|
||||
this.node.getChildByName("yg").active=hero_data.quality==QualitySet.ORANGE
|
||||
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
|
||||
|
||||
}
|
||||
do_click(){
|
||||
switch(this.type){
|
||||
case HeroConSet.INFO:
|
||||
oops.gui.open(UIID.HeroInfo,this.h_uuid)
|
||||
break
|
||||
case HeroConSet.SELECT:
|
||||
finishCurrGuide(9)
|
||||
startGuide(10)
|
||||
if(oops.gui.has(UIID.HeroSelect)) {
|
||||
this.check_in_slot()
|
||||
smc.setFightHero(this.slot,this.h_uuid,true)
|
||||
oops.message.dispatchEvent(GameEvent.UpdateFightHero)
|
||||
oops.gui.remove(UIID.HeroSelect)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
check_in_slot(){ //如果英雄在出战位,则移除久的出战位
|
||||
let heros=smc.fight_heros
|
||||
for(let i=0;i<GameSet.HERO_NUM;i++){
|
||||
if(heros[i]==this.h_uuid) {
|
||||
smc.setFightHero(i,0,true)
|
||||
}
|
||||
}
|
||||
}
|
||||
check_in_fight(){
|
||||
let heros=smc.fight_heros
|
||||
for(let i=0;i<GameSet.HERO_NUM;i++){
|
||||
if(heros[i]==this.h_uuid) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "d625f285-3706-4f2e-bf30-e03e34f16650",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import { smc } from '../common/SingletonModuleComp';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
import { NumberFormatter } from '../common/config/BoxSet';
|
||||
import { Items } from '../common/config/Items';
|
||||
import { finishCurrGuide, GuideConfig, startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HInfoComp')
|
||||
@@ -61,8 +60,6 @@ export class HInfoComp extends Component {
|
||||
this.update_data(prevHero)
|
||||
}
|
||||
close(){
|
||||
finishCurrGuide(6)
|
||||
startGuide(7)
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
reset() {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
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';
|
||||
import { finishCurrGuide, startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroPageComp')
|
||||
@@ -18,7 +16,6 @@ export class HeroPageComp extends Component {
|
||||
}
|
||||
onEnable(){
|
||||
this.update_heros()
|
||||
startGuide(3)
|
||||
|
||||
}
|
||||
update_heros(){
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import { _decorator, Animation, AnimationClip, CCInteger, Component, instantiate, Label, Node, Prefab, resources, v3 } from 'cc';
|
||||
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';
|
||||
import { finishCurrGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroReadyCom')
|
||||
export class HeroReadyCom extends Component {
|
||||
@property(CCInteger)
|
||||
slot: number=0;
|
||||
@property(Prefab)
|
||||
hero_prefab: Prefab = null!;
|
||||
protected onLoad(): void {
|
||||
|
||||
}
|
||||
start() {
|
||||
this.add_heros()
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
add_heros(){
|
||||
let heros=smc.heros
|
||||
let x=0
|
||||
for(let key in heros){
|
||||
this.add_hero(heros[key].uuid,x)
|
||||
console.log("[HeroReadyCom]:add_hero",heros[key],x)
|
||||
x++
|
||||
}
|
||||
}
|
||||
add_hero(hero:any,pos:number){
|
||||
let hero_data = HeroInfo[hero]
|
||||
if(!this.hero_prefab) return
|
||||
const node = instantiate(this.hero_prefab) as unknown as Node;
|
||||
let anm_path=hero_data.path
|
||||
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
||||
node.getChildByName("hero").getComponent(Animation).addClip(clip);
|
||||
node.getChildByName("hero").getComponent(Animation).play("idle");
|
||||
});
|
||||
node.parent = this.node;
|
||||
node.setPosition(v3(-pos*100,0,0))
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.node.destroy()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "11781c25-08d5-41fc-af3e-b2dfd46dc5d7",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
import { _decorator, Component, instantiate, Node, Prefab, UITransform, Vec3 } 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';
|
||||
import { startGuide } from '../common/config/Guide';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroSelectCom')
|
||||
export class HeroSelectCom extends Component {
|
||||
slot:number=0
|
||||
start() {
|
||||
console.log("[HeroSelectCom]:start",this.node)
|
||||
}
|
||||
onAdded(args: any) {
|
||||
// console.log("[HeroSelectCom]:onAdded",args)
|
||||
this.slot=args.slot
|
||||
startGuide(9)
|
||||
this.update_heros()
|
||||
}
|
||||
protected onDisable(): void {
|
||||
// console.log("[HeroSelectCom]:onDisable")
|
||||
this.clear_heros()
|
||||
}
|
||||
update_heros(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
let width= heros.length*230+20
|
||||
this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform).setContentSize(width,320)
|
||||
// console.log("[HeroPageComp]:UITransform width",this.node.getChildByName("main").getChildByName("view").getChildByName("heros").getComponent(UITransform))
|
||||
for(let i=0;i<heros.length;i++){
|
||||
let hero=heros[i]
|
||||
// console.log("[HeroPageComp]:hero",hero)
|
||||
if(hero){
|
||||
this.load_hero(hero,i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,index: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) as unknown as Node;
|
||||
node.name="hero"+index.toString()
|
||||
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)
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "0c9b9c74-9486-4b43-b797-f602d26f2f1a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
import { _decorator, Component, Node, Label, Sprite, resources, SpriteFrame, input, Input, EventTouch, EventMouse, Vec3, Vec2, UITransform, Color } from 'cc';
|
||||
import { Items } from '../common/config/Items';
|
||||
import { QualitySet } from '../common/config/BoxSet';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ItemInfoComp')
|
||||
export class ItemInfoComp extends Component {
|
||||
item_uuid: number = 0;
|
||||
item_count: number = 1;
|
||||
|
||||
// 触摸监听相关
|
||||
private touchListener: any = null;
|
||||
private isListening: boolean = false;
|
||||
|
||||
start() {
|
||||
// console.log("[ItemInfoComp]:start");
|
||||
}
|
||||
|
||||
onAdded(args: any) {
|
||||
// console.log("[ItemInfoComp]:onAdded", args);
|
||||
this.setupTouchListener();
|
||||
this.update_data(args);
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.removeTouchListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置触摸监听
|
||||
*/
|
||||
private setupTouchListener() {
|
||||
if (this.isListening) return;
|
||||
// 监听触摸开始事件
|
||||
this.touchListener = input.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.isListening = true;
|
||||
|
||||
// console.log("[ItemInfoComp]: Touch listener setup");
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除触摸监听
|
||||
*/
|
||||
private removeTouchListener() {
|
||||
if (this.touchListener && this.isListening) {
|
||||
input.off(Input.EventType.TOUCH_START, this.onTouchStart, this);
|
||||
this.isListening = false;
|
||||
this.touchListener = null;
|
||||
|
||||
// console.log("[ItemInfoComp]: Touch listener removed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触摸开始事件处理
|
||||
* @param event 触摸事件
|
||||
*/
|
||||
private onTouchStart(event: EventTouch) {
|
||||
const touchPos = event.getLocation();
|
||||
const nodePos = this.node.getWorldPosition();
|
||||
|
||||
// 检查触摸点是否在弹窗范围内
|
||||
if (!this.isTouchInNodeBounds(touchPos, nodePos)) {
|
||||
// console.log("[ItemInfoComp]: Touch outside bounds, closing popup");
|
||||
this.closeItemInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查触摸点是否在节点范围内
|
||||
* @param touchPos 触摸点世界坐标
|
||||
* @param nodePos 节点世界坐标
|
||||
* @returns 是否在范围内
|
||||
*/
|
||||
private isTouchInNodeBounds(touchPos: Vec2, nodePos: Vec3): boolean {
|
||||
const nodeSize = this.node.getComponent(UITransform)?.contentSize;
|
||||
if (!nodeSize) return false;
|
||||
|
||||
// 计算节点的边界
|
||||
const halfWidth = nodeSize.width * 0.5;
|
||||
const halfHeight = nodeSize.height * 0.5;
|
||||
|
||||
// 检查触摸点是否在节点范围内
|
||||
const inX = Math.abs(touchPos.x - nodePos.x) <= halfWidth;
|
||||
const inY = Math.abs(touchPos.y - nodePos.y) <= halfHeight;
|
||||
|
||||
return inX && inY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新物品数据
|
||||
* @param args 物品参数 {item_uuid: number, count?: number}
|
||||
*/
|
||||
update_data(args: any) {
|
||||
// console.log("[ItemInfoComp]:update_data", args);
|
||||
|
||||
if (!args || !args.item_uuid) {
|
||||
console.error("[ItemInfoComp]: Invalid args", args);
|
||||
return;
|
||||
}
|
||||
|
||||
this.item_uuid = args.item_uuid;
|
||||
this.item_count = args.count || 1;
|
||||
|
||||
// 获取物品配置
|
||||
const itemData = Items[this.item_uuid];
|
||||
if (!itemData) {
|
||||
console.error("[ItemInfoComp]: Item not found", this.item_uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置物品图标
|
||||
this.setItemIcon(itemData.path);
|
||||
|
||||
// 设置品质边框
|
||||
this.setQualityFrame(itemData.quality);
|
||||
|
||||
// 设置品质文字描述
|
||||
this.setQualityText(itemData.quality);
|
||||
|
||||
// 设置数量显示
|
||||
this.setItemCount(this.item_count);
|
||||
|
||||
// 设置物品名称
|
||||
this.setItemName(itemData.name);
|
||||
|
||||
// 设置物品描述
|
||||
this.setItemInfo(itemData.info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置物品图标
|
||||
* @param iconPath 图标路径
|
||||
*/
|
||||
private setItemIcon(iconPath: string) {
|
||||
let path=`gui/items/${iconPath}`
|
||||
// console.log("[ItemComp]: setItemIcon", path);
|
||||
resources.load(path, SpriteFrame, (err, spriteFrame) => {
|
||||
if (err) {
|
||||
console.error("[ItemComp]: Failed to load item icon", iconPath, err);
|
||||
return;
|
||||
}
|
||||
// console.log("[ItemComp]: setItemIcon", iconPath, spriteFrame);
|
||||
this.node.getChildByName("item").getChildByName("icon").getComponent(Sprite)!.spriteFrame = spriteFrame;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置品质边框
|
||||
* @param quality 品质类型
|
||||
*/
|
||||
private setQualityFrame(quality: QualitySet) {
|
||||
// 隐藏所有品质边框
|
||||
this.hideAllQualityFrames();
|
||||
|
||||
// 根据品质显示对应边框
|
||||
switch (quality) {
|
||||
case QualitySet.GREEN:
|
||||
this.node.getChildByName("item").getChildByName("q1").active = true;
|
||||
break;
|
||||
case QualitySet.BLUE:
|
||||
this.node.getChildByName("item").getChildByName("q2").active = true;
|
||||
break;
|
||||
case QualitySet.PURPLE:
|
||||
this.node.getChildByName("item").getChildByName("q3").active = true;
|
||||
break;
|
||||
case QualitySet.ORANGE:
|
||||
this.node.getChildByName("item").getChildByName("q4").active = true;
|
||||
break;
|
||||
default:
|
||||
// 默认使用绿色边框
|
||||
this.node.getChildByName("item").getChildByName("q").active = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏所有品质边框
|
||||
*/
|
||||
private hideAllQualityFrames() {
|
||||
this.node.getChildByName("item").getChildByName("q").active = false;
|
||||
this.node.getChildByName("item").getChildByName("q1").active = false;
|
||||
this.node.getChildByName("item").getChildByName("q2").active = false;
|
||||
this.node.getChildByName("item").getChildByName("q3").active = false;
|
||||
this.node.getChildByName("item").getChildByName("q4").active = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置物品数量
|
||||
* @param count 数量
|
||||
*/
|
||||
private setItemCount(count: number) {
|
||||
if (count > 1) {
|
||||
this.node.getChildByName("item").getChildByName("num").getComponent(Label)!.string = count.toString();
|
||||
this.node.getChildByName("item").getChildByName("num").active = true;
|
||||
} else {
|
||||
this.node.getChildByName("item").getChildByName("num").active = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置物品名称
|
||||
* @param name 物品名称
|
||||
*/
|
||||
private setItemName(name: string) {
|
||||
this.node.getChildByName("name").getComponent(Label)!.string = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置物品描述
|
||||
* @param info 物品描述
|
||||
*/
|
||||
private setItemInfo(info: string) {
|
||||
this.node.getChildByName("info").getComponent(Label)!.string = info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置品质文字描述
|
||||
* @param quality 品质类型
|
||||
*/
|
||||
private setQualityText(quality: QualitySet) {
|
||||
|
||||
switch (quality) {
|
||||
case QualitySet.GREEN:
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.string = "优秀";
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.color = new Color(76, 175, 80, 255); // 现代绿色
|
||||
break;
|
||||
case QualitySet.BLUE:
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.string = "精良";
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.color = new Color(33, 150, 243, 255); // 现代蓝色
|
||||
break;
|
||||
case QualitySet.PURPLE:
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.string = "史诗";
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.color = new Color(156, 39, 176, 255); // 现代紫色
|
||||
break;
|
||||
case QualitySet.ORANGE:
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.string = "传说";
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.color = new Color(255, 87, 34, 255); // 现代橙色
|
||||
break;
|
||||
default:
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.string = "普通";
|
||||
this.node.getChildByName("quality").getChildByName("Label").getComponent(Label)!.color = new Color(158, 158, 158, 255); // 现代灰色
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物品UUID
|
||||
*/
|
||||
getItemUUID(): number {
|
||||
return this.item_uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物品数量
|
||||
*/
|
||||
getItemCount(): number {
|
||||
return this.item_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭物品信息弹窗
|
||||
*/
|
||||
closeItemInfo() {
|
||||
// console.log("[ItemInfoComp]: Close item info");
|
||||
this.removeTouchListener();
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用物品
|
||||
*/
|
||||
useItem() {
|
||||
// console.log("[ItemInfoComp]: Use item", this.item_uuid);
|
||||
// 这里可以添加使用物品的逻辑
|
||||
// 比如消耗物品、触发效果等
|
||||
}
|
||||
|
||||
/**
|
||||
* 丢弃物品
|
||||
*/
|
||||
dropItem() {
|
||||
// console.log("[ItemInfoComp]: Drop item", this.item_uuid);
|
||||
// 这里可以添加丢弃物品的逻辑
|
||||
// 比如从背包中移除、显示确认对话框等
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "627ed4fe-6a6c-4591-96fb-df08a6ebed95",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
@@ -86,7 +86,6 @@ export class MissionComp extends CCComp {
|
||||
|
||||
async mission_start(){
|
||||
// console.log("[MissionComp] ** 1 ** mission_start")
|
||||
this.node.getChildByName("ending").getComponent(Animation).play("startFight")
|
||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||
this.node.active=true
|
||||
this.data_init()
|
||||
@@ -125,7 +124,6 @@ export class MissionComp extends CCComp {
|
||||
|
||||
mission_end(){
|
||||
// console.log("[MissionComp] mission_end")
|
||||
this.node.getChildByName("ending").active=false
|
||||
this.node.active=false
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroPageComp } from "./HeroPageComp";
|
||||
import { finishCurrGuide, GuideConfig, startGuide } from "../common/config/Guide";
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { randomSpeek, Speeks } from "../common/config/Tasks";
|
||||
|
||||
@@ -25,9 +24,6 @@ export class MissionHomeComp extends CCComp {
|
||||
this.home_active()
|
||||
}
|
||||
onEnable(){
|
||||
this.startNextGuide(); // 启动第一个引导
|
||||
startGuide(1)
|
||||
startGuide(2)
|
||||
}
|
||||
update(dt:number){
|
||||
if(this.speek_cd.update(dt)){
|
||||
@@ -37,18 +33,10 @@ export class MissionHomeComp extends CCComp {
|
||||
console.log("[MissionHomeComp]:speek",speek,slot)
|
||||
}
|
||||
}
|
||||
/** 启动下一个引导 */
|
||||
private startNextGuide() {
|
||||
// 检查是否还有未完成的引导
|
||||
if(smc.guides[GuideConfig[0].key]==0){
|
||||
oops.message.dispatchEvent(GameEvent.GuideStart,0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
start_mission() {
|
||||
finishCurrGuide(1)
|
||||
finishCurrGuide(10)
|
||||
|
||||
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
||||
this.node.active=false;
|
||||
}
|
||||
@@ -69,50 +57,6 @@ export class MissionHomeComp extends CCComp {
|
||||
}
|
||||
btn_func(e:string,data:any){
|
||||
|
||||
// // console.log("[MissionHomeComp]:btn_func",e,data)
|
||||
// let page_heros=this.node.getChildByName("heros_page")
|
||||
// let page_shop=this.node.getChildByName("shop_page")
|
||||
// // let page_fight=this.node.getChildByName("fight_page")
|
||||
// // let page_skill=this.node.getChildByName("skill_page")
|
||||
// // let page_set=this.node.getChildByName("set_page")
|
||||
// let btns=this.node.getChildByName("btns")
|
||||
// let btn_shop =btns.getChildByName("shop")
|
||||
// let btn_heros =btns.getChildByName("heros")
|
||||
// let btn_fight =btns.getChildByName("fight")
|
||||
// let btn_skill =btns.getChildByName("skill")
|
||||
// let btn_set =btns.getChildByName("set")
|
||||
// btn_shop.getChildByName("act").active=false
|
||||
// btn_heros.getChildByName("act").active=false
|
||||
// btn_fight.getChildByName("act").active=false
|
||||
// btn_skill.getChildByName("act").active=false
|
||||
// btn_set.getChildByName("act").active=false
|
||||
// page_heros.active=false
|
||||
// page_shop.active=false
|
||||
// switch(data){
|
||||
// case "shop":
|
||||
// page_shop.active=true
|
||||
// btn_shop.getChildByName("act").active=true
|
||||
// break
|
||||
// case "heros":
|
||||
// finishCurrGuide(2)
|
||||
// page_heros.active=true
|
||||
// btn_heros.getChildByName("act").active=true
|
||||
// break
|
||||
// case "fight":
|
||||
// finishCurrGuide(7)
|
||||
// startGuide(8)
|
||||
// btn_fight.getChildByName("act").active=true
|
||||
// break
|
||||
// case "skill":
|
||||
// btn_skill.getChildByName("act").active=true
|
||||
// break
|
||||
// case "set":
|
||||
// btn_set.getChildByName("act").active=true
|
||||
// break
|
||||
// default:
|
||||
// btn_fight.getChildByName("act").active=true
|
||||
// break
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,28 +24,20 @@ export class topComp extends Component {
|
||||
.start()
|
||||
}
|
||||
onDiamondUpdate(event:string,data:any){
|
||||
this.update_diamond(smc.data.diamond)
|
||||
tween(this.node.getChildByName("bar").getChildByName("diamond").getChildByName("num").getComponent(Label).node)
|
||||
.to(0.1,{scale:v3(1.2,1.2,1)})
|
||||
.to(0.1,{scale:v3(1,1,1)})
|
||||
.start()
|
||||
|
||||
}
|
||||
onMeatUpdate(event:string,data:any){
|
||||
this.update_meat(smc.data.meat)
|
||||
tween(this.node.getChildByName("bar").getChildByName("meat").getChildByName("num").getComponent(Label).node)
|
||||
.to(0.1,{scale:v3(1.2,1.2,1)})
|
||||
.to(0.1,{scale:v3(1,1,1)})
|
||||
.start()
|
||||
|
||||
}
|
||||
|
||||
update_gold(gold:number){
|
||||
this.node.getChildByName("bar").getChildByName("gold").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(gold);
|
||||
}
|
||||
update_diamond(diamond:number){
|
||||
this.node.getChildByName("bar").getChildByName("diamond").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(diamond);
|
||||
|
||||
}
|
||||
update_meat(meat:number){
|
||||
this.node.getChildByName("bar").getChildByName("meat").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(meat);
|
||||
|
||||
}
|
||||
update_all(){
|
||||
this.update_gold(smc.data.gold)
|
||||
|
||||
@@ -66,7 +66,6 @@ export class VictoryComp extends CCComp {
|
||||
}
|
||||
victory_end(){
|
||||
this.clear_data()
|
||||
// startGuide(2)
|
||||
oops.message.dispatchEvent(GameEvent.MissionEnd)
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user