示例#1
0
        private async UniTask LoadGuildRoutine(int id)
        {
            if (id > 0 && !loadingGuildIds.Contains(id))
            {
                loadingGuildIds.Add(id);
                GuildResp resp = await DbServiceClient.ReadGuildAsync(new ReadGuildReq()
                {
                    GuildId = id,
                });

                ServerGuildHandlers.SetGuild(id, resp.GuildData);
                loadingGuildIds.Remove(id);
            }
        }
 private async UniTask LoadGuildRoutine(int id)
 {
     if (id > 0 && !loadingGuildIds.Contains(id))
     {
         loadingGuildIds.Add(id);
         AsyncResponseData <GuildResp> resp;
         do
         {
             resp = await DbServiceClient.ReadGuildAsync(new ReadGuildReq()
             {
                 GuildId = id,
             });
         } while (!resp.IsSuccess);
         ServerGuildHandlers.SetGuild(id, resp.Response.GuildData);
         loadingGuildIds.Remove(id);
     }
 }
        public void OnUpdateMapUser(UpdateUserCharacterMessage message)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            int       socialId;
            PartyData party;
            GuildData guild;
            switch (message.type)
            {
            case UpdateUserCharacterMessage.UpdateType.Add:
                if (!usersById.ContainsKey(message.data.id))
                {
                    usersById.TryAdd(message.data.id, message.data);
                }
                break;

            case UpdateUserCharacterMessage.UpdateType.Remove:
                usersById.TryRemove(message.data.id, out _);
                break;

            case UpdateUserCharacterMessage.UpdateType.Online:
                if (usersById.ContainsKey(message.data.id))
                {
                    ServerCharacterHandlers.MarkOnlineCharacter(message.data.id);
                    socialId = message.data.partyId;
                    if (socialId > 0 && ServerPartyHandlers.TryGetParty(socialId, out party))
                    {
                        party.UpdateMember(message.data);
                        ServerPartyHandlers.SetParty(socialId, party);
                    }
                    socialId = message.data.guildId;
                    if (socialId > 0 && ServerGuildHandlers.TryGetGuild(socialId, out guild))
                    {
                        guild.UpdateMember(message.data);
                        ServerGuildHandlers.SetGuild(socialId, guild);
                    }
                    usersById[message.data.id] = message.data;
                }
                break;
            }
#endif
        }
        public void OnUpdateGuild(UpdateGuildMessage message)
        {
            BasePlayerCharacterEntity playerCharacterEntity;
            GuildData guild;

            if (ServerGuildHandlers.TryGetGuild(message.id, out guild))
            {
                switch (message.type)
                {
                case UpdateGuildMessage.UpdateType.ChangeLeader:
                    guild.SetLeader(message.characterId);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.characterId, out playerCharacterEntity))
                    {
                        playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                    }
                    ServerGameMessageHandlers.SendSetGuildLeaderToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.SetGuildMessage:
                    guild.guildMessage = message.guildMessage;
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildMessageToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.SetGuildRole:
                    guild.SetRole(message.guildRole, message.roleName, message.canInvite, message.canKick, message.shareExpPercentage);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    foreach (string memberId in guild.GetMemberIds())
                    {
                        if (ServerUserHandlers.TryGetPlayerCharacterById(memberId, out playerCharacterEntity))
                        {
                            playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                        }
                    }
                    ServerGameMessageHandlers.SendSetGuildRoleToMembers(guild, message.guildRole, message.roleName, message.canInvite, message.canKick, message.shareExpPercentage);
                    break;

                case UpdateGuildMessage.UpdateType.SetGuildMemberRole:
                    guild.SetMemberRole(message.characterId, message.guildRole);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    if (ServerUserHandlers.TryGetPlayerCharacterById(message.characterId, out playerCharacterEntity))
                    {
                        playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                    }
                    ServerGameMessageHandlers.SendSetGuildMemberRoleToMembers(guild, message.characterId, message.guildRole);
                    break;

                case UpdateGuildMessage.UpdateType.SetSkillLevel:
                    guild.SetSkillLevel(message.dataId, message.level);
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildSkillLevelToMembers(guild, message.dataId);
                    break;

                case UpdateGuildMessage.UpdateType.SetGold:
                    guild.gold = message.gold;
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildGoldToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.LevelExpSkillPoint:
                    guild.level      = message.level;
                    guild.exp        = message.exp;
                    guild.skillPoint = message.skillPoint;
                    ServerGuildHandlers.SetGuild(message.id, guild);
                    ServerGameMessageHandlers.SendSetGuildLevelExpSkillPointToMembers(guild);
                    break;

                case UpdateGuildMessage.UpdateType.Terminate:
                    foreach (string memberId in guild.GetMemberIds())
                    {
                        if (ServerUserHandlers.TryGetPlayerCharacterById(memberId, out playerCharacterEntity))
                        {
                            playerCharacterEntity.ClearGuild();
                            ServerGameMessageHandlers.SendClearGuildData(playerCharacterEntity.ConnectionId, message.id);
                        }
                    }
                    ServerGuildHandlers.RemoveGuild(message.id);
                    break;
                }
            }
        }