feat(好友系统): 添加好友召唤功能及相关事件处理

- 在GameEvent枚举中添加ToCallFriend和CallFriend事件
- 在MissionHeroComp中添加好友召唤事件处理
- 在SingletonModuleComp中添加好友记录功能
- 更新icon.prefab界面以支持好友功能
This commit is contained in:
walkpan
2026-01-05 19:25:44 +08:00
parent df7b3d0082
commit 1cfd74062d
4 changed files with 267 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ import { GameEvent } from "./config/GameEvent";
import * as exp from "constants";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { Attrs, GameScoreStats } from "./config/HeroAttrs";
import { time } from "console";
import { count, time } from "console";
import { getLevelExp } from "../map/RogueConfig";
/**
* 用远程数据覆盖本地数据(统一方法)
@@ -20,7 +20,8 @@ interface GameDate{
fight_hero:number,
collection?: {
talents: Record<number, number>,
skills: Record<number, number>
skills: {uuid:0,count:0},
friend:{uuid:0,count:0},
}
}
interface CloudData {
@@ -129,7 +130,8 @@ export class SingletonModuleComp extends ecs.Comp {
// 收集记录
collection: {
talents: {} as Record<number, number>,
skills: {} as Record<number, number>,
skill: {uuid:0,count:0},
friend:{uuid:0,count:0},
},
gold: 200, // 金币数据MVVM绑定字段
};
@@ -184,13 +186,24 @@ export class SingletonModuleComp extends ecs.Comp {
* @param id 技能ID
*/
addSkillRecord(id: number) {
if (!this.vmdata.collection.skills[id]) {
this.vmdata.collection.skills[id] = 0;
if (!this.vmdata.collection.skill.uuid) {
this.vmdata.collection.skill.uuid = id;
}
this.vmdata.collection.skills[id]++;
console.log(`[SMC] 记录技能获取: ID=${id}, 次数=${this.vmdata.collection.skills[id]}`);
this.vmdata.collection.skill.count++;
console.log(`[SMC] 记录技能获取: ID=${id}, 次数=${this.vmdata.collection.skill.count}`);
}
/**
* 记录好友获取
* @param id 好友ID
*/
addFriendHero(id: number) {
if (!this.vmdata.collection.friend.uuid) {
this.vmdata.collection.friend.uuid = id;
}
this.vmdata.collection.friend.count++;
console.log(`[SMC] 记录好友获取: ID=${id}, 次数=${this.vmdata.collection.friend.count}`);
}
vmAdd() {
VM.add(this.vmdata, "data");
}