功能性卡牌功能继续

This commit is contained in:
2025-06-18 17:17:29 +08:00
parent b6a2ab2921
commit ab9ff70f77
4 changed files with 69 additions and 38 deletions

View File

@@ -16,18 +16,21 @@ export const cardType={
HERO:1,
SKILL:2,
EQUIP:3,
SPECIAL:4,
}
// 获取随机卡牌UUID
export function getRandomCardUUID(
heroRate: number = 1, // 伙伴出现概率修正系数
skillRate: number = 1, // 技能出现概率修正系数
equipRate: number = 1 // 装备出现概率修正系数
equipRate: number = 1, // 装备出现概率修正系数
specialRate: number = 1 // 功能卡牌出现概率修正系数
): { type: number; uuid: number } {
// 计算修正后的概率
const adjustedProbability = {
1: CardProbability[1] * heroRate,
2: CardProbability[2] * skillRate,
3: CardProbability[3] * equipRate
3: CardProbability[3] * equipRate,
4: CardProbability[4] * specialRate
};
// 计算总概率
@@ -38,47 +41,53 @@ export function getRandomCardUUID(
let cumulativeProbability = 0;
// 根据修正后的概率确定卡牌类型
let cardType = 1; // 默认类型为伙伴
let c_type = 1; // 默认类型为伙伴
for (const [type, probability] of Object.entries(adjustedProbability)) {
cumulativeProbability += probability;
if (random <= cumulativeProbability) {
cardType = parseInt(type);
c_type = parseInt(type);
break;
}
}
// 根据类型获取对应的卡牌列表
let cardList: number[] = [];
switch (cardType) {
case 1: // 伙伴
switch (c_type) {
case cardType.HERO: // 伙伴
cardList = HeroList;
break;
case 2: // 技能
case cardType.SKILL: // 技能
cardList = HeroSkillList;
break;
case 3: // 装备
case cardType.EQUIP: // 装备
cardList = equip_list;
break;
case cardType.SPECIAL: // 功能卡牌
cardList = SuperCardsList;
break;
}
// 从对应类型的卡牌列表中随机选择一个
const randomIndex = Math.floor(Math.random() * cardList.length);
return {type:cardType,uuid:cardList[randomIndex]};
return {type:c_type,uuid:cardList[randomIndex]};
}
// 获取指定类型的随机卡牌UUID
export function getRandomCardUUIDByType(type: number): number {
let cardList: number[] = [];
switch (type) {
case 1: // 伙伴
case cardType.HERO: // 伙伴
cardList = HeroList;
break;
case 2: // 技能
case cardType.SKILL: // 技能
cardList = HeroSkillList;
break;
case 3: // 装备
case cardType.EQUIP: // 装备
cardList = equip_list;
break;
case cardType.SPECIAL: // 功能卡牌
cardList = SuperCardsList;
break;
default:
throw new Error(`Invalid card type: ${type}`);
}
@@ -103,6 +112,9 @@ export function getRandomCardsByType(
case cardType.EQUIP:
cardList = equip_list;
break;
case cardType.SPECIAL:
cardList = SuperCardsList;
break;
default:
throw new Error(`Invalid card type: ${type}`);
}
@@ -125,6 +137,7 @@ export const SuperCardsType={
BUFF:3, //buff技能 范围buff
DEBUFF:4, //debuff技能 范围debuff
}
export const SuperCardsList=[3001,3002,3101,3201,3301];
export const SuperCards={
3001:{uuid:3001,name:"附魔宝典",path:"3001",type:SuperCardsType.SPECIAL,value1:1,value2:0,value3:0,tals:"你的提升英雄/伙伴属性的装备效果,额外添加+1攻击力"},
3002:{uuid:3002,name:"附魔宝典",path:"3002",type:SuperCardsType.SPECIAL,value1:0,value2:1,value3:0,tals:"你的提升英雄/伙伴属性的装备效果,额外添加+1生命值"},

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "9212372f-b316-41b5-8532-888e115c6e31",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -19,7 +19,7 @@ const { ccclass, property } = _decorator;
@ecs.register('Card', false)
export class CardComp extends CCComp {
c_uuid:number=0;
c_type:number=0; //0英雄,1 技能.2 装备
c_type:number=0; //1英雄,2 技能.3 装备 4.功能卡牌
is_used:boolean=false;
onLoad(){
@@ -37,7 +37,7 @@ export class CardComp extends CCComp {
this.node.getChildByName("show").active=false
}
hero_select(args: any){
this.c_type=0
this.c_type=cardType.HERO
this.c_uuid=args.uuid
console.log("card hero_select c_uuid:"+this.c_uuid)
this.show_hero(this.c_uuid)
@@ -49,7 +49,7 @@ export class CardComp extends CCComp {
}, 0.1);
}
hero_skill_select(args: any){
this.c_type=1
this.c_type=cardType.SKILL
console.log("card hero_skill_select",args)
this.c_uuid=args.uuid
this.node.getChildByName("show").active=false
@@ -61,7 +61,7 @@ export class CardComp extends CCComp {
}, 0.1);
}
equip_select(args: any){
this.c_type=2
this.c_type=cardType.EQUIP
this.c_uuid=args.uuid
this.node.getChildByName("show").active=false
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup')
@@ -73,7 +73,17 @@ export class CardComp extends CCComp {
}
func_select(args: any){
console.log("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);
}
random_select(){
let card =getRandomCardUUID() //随机获取卡牌类型
console.log("rad 开始请求卡牌",card)
@@ -87,8 +97,12 @@ export class CardComp extends CCComp {
case cardType.EQUIP:
this.equip_select(card)
break
case cardType.SPECIAL:
this.func_select(card)
break
}
}
show_skill(uuid:number){
let show=this.node.getChildByName("show")
show.getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
@@ -149,6 +163,15 @@ export class CardComp extends CCComp {
});
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
}
show_func(uuid:number){
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("s_bg").active=false
show.getChildByName("mask").getChildByName("equip").active=false
show.getChildByName("mask").getChildByName("e_bg").active=false
}
check_heros(){
// let heros=ecs.query(ecs.allOf(HeroModelComp))
// for(let hero of heros){

View File

@@ -49,7 +49,7 @@ export class CardsCompComp extends CCComp {
}
hero_select(){
let list=getRandomCardsByType(cardType.HERO,4)
console.log("英雄选择卡牌列表",list)
console.log("[CardsComp]:英雄选择卡牌列表",list)
this.card1c.hero_select(list[0])
this.card2c.hero_select(list[1])
this.card3c.hero_select(list[2])
@@ -57,9 +57,8 @@ export class CardsCompComp extends CCComp {
}
hero_skill_select(){
let list=getRandomCardsByType(cardType.SKILL,4)
console.log("技能选择卡牌列表",list)
console.log("[CardsComp]:技能选择卡牌列表",list)
this.card1c.hero_skill_select(list[0])
this.card2c.hero_skill_select(list[1])
this.card3c.hero_skill_select(list[2])
@@ -67,14 +66,19 @@ export class CardsCompComp extends CCComp {
}
equip_select(){
let list=getRandomCardsByType(cardType.EQUIP,4)
console.log("装备选择卡牌列表",list)
console.log("[CardsComp]:装备选择卡牌列表",list)
this.card1c.equip_select(list[0])
this.card2c.equip_select(list[1])
this.card3c.equip_select(list[2])
this.card4c.equip_select(list[3])
}
func_select(){
console.log("功能选择卡牌")
let list=getRandomCardsByType(cardType.SPECIAL,4)
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()
@@ -85,7 +89,7 @@ export class CardsCompComp extends CCComp {
/** 添加卡牌展示到队列 */
private addToQueue(e: GameEvent, data?: any) {
console.log("添加卡牌到队列", e);
console.log("[CardsComp]:添加卡牌到队列", e);
this.cardQueue.push({type: e, data: data});
this.processQueue();
}
@@ -105,15 +109,15 @@ export class CardsCompComp extends CCComp {
this.node.getChildByName("Button").active=false
switch(e){
case GameEvent.HeroSelect:
console.log("显示英雄选择卡牌")
console.log("[CardsComp]:显示英雄选择卡牌")
this.hero_select()
break
case GameEvent.HeroSkillSelect:
console.log("显示技能选择卡牌")
console.log("[CardsComp]:显示技能选择卡牌")
this.hero_skill_select()
break
case GameEvent.CardRefresh:
console.log("显示随机刷新卡牌")
console.log("[CardsComp]:显示随机刷新卡牌")
this.node.getChildByName("Button").active=true
this.random_select()
break
@@ -123,16 +127,16 @@ export class CardsCompComp extends CCComp {
close_cards(e:GameEvent,data:any){
switch(e){
case GameEvent.HeroSelect:
console.log("关闭英雄选择卡牌")
console.log("[CardsComp]:关闭英雄选择卡牌")
break
case GameEvent.HeroSkillSelect:
console.log("关闭技能选择卡牌")
console.log("[CardsComp]:关闭技能选择卡牌")
break
case GameEvent.CardRefresh:
console.log("关闭随机刷新卡牌")
console.log("[CardsComp]:关闭随机刷新卡牌")
break
case GameEvent.CardsClose:
console.log("关闭所有卡牌")
console.log("[CardsComp]:关闭所有卡牌")
break
}
this.hide()