feat(好友系统): 添加好友召唤功能及相关事件处理
- 在GameEvent枚举中添加ToCallFriend和CallFriend事件 - 在MissionHeroComp中添加好友召唤事件处理 - 在SingletonModuleComp中添加好友记录功能 - 更新icon.prefab界面以支持好友功能
This commit is contained in:
@@ -26,19 +26,25 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 18
|
"__id__": 18
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 26
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 26
|
"__id__": 32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 28
|
"__id__": 34
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 36
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": {
|
"_prefab": {
|
||||||
"__id__": 30
|
"__id__": 39
|
||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
@@ -594,6 +600,165 @@
|
|||||||
"targetOverrides": null,
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "num",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 27
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 29
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 31
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 34.381,
|
||||||
|
"y": -27.61,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_lrot": {
|
||||||
|
"__type__": "cc.Quat",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_lscale": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 1,
|
||||||
|
"y": 1,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"_mobility": 0,
|
||||||
|
"_layer": 1073741824,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 26
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 28
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 17.90380859375,
|
||||||
|
"height": 54.4
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "bamuO27s5EHZhw2oKWl9jA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Label",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 26
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 30
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_string": "1",
|
||||||
|
"_horizontalAlign": 1,
|
||||||
|
"_verticalAlign": 1,
|
||||||
|
"_actualFontSize": 25,
|
||||||
|
"_fontSize": 25,
|
||||||
|
"_fontFamily": "Arial",
|
||||||
|
"_lineHeight": 40,
|
||||||
|
"_overflow": 0,
|
||||||
|
"_enableWrapText": true,
|
||||||
|
"_font": null,
|
||||||
|
"_isSystemFontUsed": true,
|
||||||
|
"_spacingX": 0,
|
||||||
|
"_isItalic": false,
|
||||||
|
"_isBold": true,
|
||||||
|
"_isUnderline": false,
|
||||||
|
"_underlineHeight": 2,
|
||||||
|
"_cacheMode": 0,
|
||||||
|
"_enableOutline": true,
|
||||||
|
"_outlineColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 0,
|
||||||
|
"g": 0,
|
||||||
|
"b": 0,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_outlineWidth": 2,
|
||||||
|
"_enableShadow": false,
|
||||||
|
"_shadowColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 0,
|
||||||
|
"g": 0,
|
||||||
|
"b": 0,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_shadowOffset": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 2,
|
||||||
|
"y": 2
|
||||||
|
},
|
||||||
|
"_shadowBlur": 2,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "91xb7dj5dBpoFxB6oNzuAs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "e0FG6b1MdParpWO5Eh10eo",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.UITransform",
|
"__type__": "cc.UITransform",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
@@ -604,7 +769,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 27
|
"__id__": 33
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
@@ -632,7 +797,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": false,
|
"_enabled": false,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 29
|
"__id__": 35
|
||||||
},
|
},
|
||||||
"_customMaterial": null,
|
"_customMaterial": null,
|
||||||
"_srcBlendFactor": 2,
|
"_srcBlendFactor": 2,
|
||||||
@@ -667,6 +832,74 @@
|
|||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
"fileId": "d43zVnYtNEa7gnqhcV0LD4"
|
"fileId": "d43zVnYtNEa7gnqhcV0LD4"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Button",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 37
|
||||||
|
},
|
||||||
|
"clickEvents": [
|
||||||
|
{
|
||||||
|
"__id__": 38
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_interactable": true,
|
||||||
|
"_transition": 0,
|
||||||
|
"_normalColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_hoverColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 211,
|
||||||
|
"g": 211,
|
||||||
|
"b": 211,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_pressedColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_disabledColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 124,
|
||||||
|
"g": 124,
|
||||||
|
"b": 124,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_normalSprite": null,
|
||||||
|
"_hoverSprite": null,
|
||||||
|
"_pressedSprite": null,
|
||||||
|
"_disabledSprite": null,
|
||||||
|
"_duration": 0.1,
|
||||||
|
"_zoomScale": 1.2,
|
||||||
|
"_target": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "94UHGas6VLi6OBaZrrGpOX"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.ClickEvent",
|
||||||
|
"target": null,
|
||||||
|
"component": "",
|
||||||
|
"_componentId": "",
|
||||||
|
"handler": "",
|
||||||
|
"customEventData": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.PrefabInfo",
|
"__type__": "cc.PrefabInfo",
|
||||||
"root": {
|
"root": {
|
||||||
@@ -676,7 +909,6 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "23znkFS6BDwoO5cjQxIEur",
|
"fileId": "23znkFS6BDwoO5cjQxIEur",
|
||||||
"instance": null,
|
"instance": null
|
||||||
"targetOverrides": null
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -8,7 +8,7 @@ import { GameEvent } from "./config/GameEvent";
|
|||||||
import * as exp from "constants";
|
import * as exp from "constants";
|
||||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||||
import { Attrs, GameScoreStats } from "./config/HeroAttrs";
|
import { Attrs, GameScoreStats } from "./config/HeroAttrs";
|
||||||
import { time } from "console";
|
import { count, time } from "console";
|
||||||
import { getLevelExp } from "../map/RogueConfig";
|
import { getLevelExp } from "../map/RogueConfig";
|
||||||
/**
|
/**
|
||||||
* 用远程数据覆盖本地数据(统一方法)
|
* 用远程数据覆盖本地数据(统一方法)
|
||||||
@@ -20,7 +20,8 @@ interface GameDate{
|
|||||||
fight_hero:number,
|
fight_hero:number,
|
||||||
collection?: {
|
collection?: {
|
||||||
talents: Record<number, number>,
|
talents: Record<number, number>,
|
||||||
skills: Record<number, number>
|
skills: {uuid:0,count:0},
|
||||||
|
friend:{uuid:0,count:0},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
interface CloudData {
|
interface CloudData {
|
||||||
@@ -129,7 +130,8 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
// 收集记录
|
// 收集记录
|
||||||
collection: {
|
collection: {
|
||||||
talents: {} as Record<number, number>,
|
talents: {} as Record<number, number>,
|
||||||
skills: {} as Record<number, number>,
|
skill: {uuid:0,count:0},
|
||||||
|
friend:{uuid:0,count:0},
|
||||||
},
|
},
|
||||||
gold: 200, // 金币数据(MVVM绑定字段)
|
gold: 200, // 金币数据(MVVM绑定字段)
|
||||||
};
|
};
|
||||||
@@ -184,13 +186,24 @@ export class SingletonModuleComp extends ecs.Comp {
|
|||||||
* @param id 技能ID
|
* @param id 技能ID
|
||||||
*/
|
*/
|
||||||
addSkillRecord(id: number) {
|
addSkillRecord(id: number) {
|
||||||
if (!this.vmdata.collection.skills[id]) {
|
if (!this.vmdata.collection.skill.uuid) {
|
||||||
this.vmdata.collection.skills[id] = 0;
|
this.vmdata.collection.skill.uuid = id;
|
||||||
}
|
}
|
||||||
this.vmdata.collection.skills[id]++;
|
this.vmdata.collection.skill.count++;
|
||||||
console.log(`[SMC] 记录技能获取: ID=${id}, 次数=${this.vmdata.collection.skills[id]}`);
|
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() {
|
vmAdd() {
|
||||||
VM.add(this.vmdata, "data");
|
VM.add(this.vmdata, "data");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,4 +65,6 @@ export enum GameEvent {
|
|||||||
DIAMOND_UPDATE = "DIAMOND_UPDATE",
|
DIAMOND_UPDATE = "DIAMOND_UPDATE",
|
||||||
MEAT_UPDATE = "MEAT_UPDATE",
|
MEAT_UPDATE = "MEAT_UPDATE",
|
||||||
ReviveSuccess = "ReviveSuccess",
|
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.FightReady,this.fight_ready,this)
|
||||||
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
|
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
|
||||||
this.on(GameEvent.MissionEnd,this.clear_heros,this)
|
this.on(GameEvent.MissionEnd,this.clear_heros,this)
|
||||||
|
this.on(GameEvent.CallFriend,this.call_friend,this)
|
||||||
}
|
}
|
||||||
start() {
|
start() {
|
||||||
// this.test_call()
|
// this.test_call()
|
||||||
@@ -60,7 +61,10 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
// console.log("[MissionHeroComp]:zhaohuan",args)
|
// console.log("[MissionHeroComp]:zhaohuan",args)
|
||||||
this.addHero(args.uuid,false)
|
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) {
|
private addHero(uuid:number=1001,is_master:boolean=false) {
|
||||||
// console.log("[MissionHeroComp]:addHero",uuid,is_zhaohuan)
|
// console.log("[MissionHeroComp]:addHero",uuid,is_zhaohuan)
|
||||||
|
|||||||
Reference in New Issue
Block a user