feat(好友系统): 添加好友召唤功能及相关事件处理
- 在GameEvent枚举中添加ToCallFriend和CallFriend事件 - 在MissionHeroComp中添加好友召唤事件处理 - 在SingletonModuleComp中添加好友记录功能 - 更新icon.prefab界面以支持好友功能
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -65,4 +65,6 @@ export enum GameEvent {
|
||||
DIAMOND_UPDATE = "DIAMOND_UPDATE",
|
||||
MEAT_UPDATE = "MEAT_UPDATE",
|
||||
ReviveSuccess = "ReviveSuccess",
|
||||
ToCallFriend = "ToCallFriend",
|
||||
CallFriend = "CallFriend",
|
||||
}
|
||||
@@ -21,6 +21,7 @@ export class MissionHeroCompComp extends CCComp {
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
|
||||
this.on(GameEvent.MissionEnd,this.clear_heros,this)
|
||||
this.on(GameEvent.CallFriend,this.call_friend,this)
|
||||
}
|
||||
start() {
|
||||
// this.test_call()
|
||||
@@ -60,7 +61,10 @@ export class MissionHeroCompComp extends CCComp {
|
||||
// console.log("[MissionHeroComp]:zhaohuan",args)
|
||||
this.addHero(args.uuid,false)
|
||||
}
|
||||
|
||||
private call_friend(event: string, args: any){
|
||||
// console.log("[MissionHeroComp]:call_friend",args)
|
||||
this.addHero(args.uuid,false)
|
||||
}
|
||||
/** 添加英雄 */
|
||||
private addHero(uuid:number=1001,is_master:boolean=false) {
|
||||
// console.log("[MissionHeroComp]:addHero",uuid,is_zhaohuan)
|
||||
|
||||
Reference in New Issue
Block a user