public virtual bool CanAddGuildMember(BasePlayerCharacterEntity inviteCharacterEntity, BasePlayerCharacterEntity acceptCharacterEntity, out int guildId, out GuildData guild) { guildId = 0; guild = null; if (inviteCharacterEntity == null || acceptCharacterEntity == null || !IsServer) { return(false); } if (acceptCharacterEntity.GuildId > 0) { SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.JoinedAnotherGuild); return(false); } guildId = inviteCharacterEntity.GuildId; if (guildId <= 0 || !guilds.TryGetValue(guildId, out guild)) { SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.CharacterNotJoinedGuild); return(false); } if (guild.CountMember() >= guild.MaxMember()) { SendServerGameMessage(acceptCharacterEntity.ConnectionId, GameMessage.Type.GuildMemberReachedLimit); return(false); } return(true); }
private void UpdateGuildUIs(GuildData guild) { if (guild == null) { return; } memberAmount = guild.CountMember(); UpdateUIs(); int selectedIdx = MemberSelectionManager.SelectedUI != null?MemberSelectionManager.IndexOf(MemberSelectionManager.SelectedUI) : -1; MemberSelectionManager.DeselectSelectedUI(); MemberSelectionManager.Clear(); SocialCharacterData[] members; byte[] memberRoles; guild.GetSortedMembers(out members, out memberRoles); MemberList.Generate(members, (index, guildMember, ui) => { SocialCharacterEntityTuple guildMemberEntity = new SocialCharacterEntityTuple(); guildMemberEntity.socialCharacter = guildMember; UIGuildCharacter uiGuildMember = ui.GetComponent <UIGuildCharacter>(); uiGuildMember.uiSocialGroup = this; uiGuildMember.Setup(guildMemberEntity, memberRoles[index], guild.GetRole(memberRoles[index])); uiGuildMember.Show(); MemberSelectionManager.Add(uiGuildMember); if (selectedIdx == index) { uiGuildMember.OnClickSelect(); } }); selectedIdx = RoleSelectionManager.SelectedUI != null?RoleSelectionManager.IndexOf(RoleSelectionManager.SelectedUI) : -1; RoleSelectionManager.DeselectSelectedUI(); RoleSelectionManager.Clear(); RoleList.Generate(guild.GetRoles(), (index, guildRole, ui) => { UIGuildRole uiGuildRole = ui.GetComponent <UIGuildRole>(); uiGuildRole.Data = guildRole; uiGuildRole.Show(); RoleSelectionManager.Add(uiGuildRole); if (selectedIdx == index) { uiGuildRole.OnClickSelect(); } }); selectedIdx = SkillSelectionManager.SelectedUI != null?SkillSelectionManager.IndexOf(SkillSelectionManager.SelectedUI) : -1; SkillSelectionManager.DeselectSelectedUI(); SkillSelectionManager.Clear(); SkillList.Generate(GameInstance.GuildSkills.Values, (index, guildSkill, ui) => { UIGuildSkill uiGuildSkill = ui.GetComponent <UIGuildSkill>(); uiGuildSkill.Data = new GuildSkillTuple(guildSkill, guild.GetSkillLevel(guildSkill.DataId)); uiGuildSkill.Show(); SkillSelectionManager.Add(uiGuildSkill); if (selectedIdx == index) { uiGuildSkill.OnClickSelect(); } }); }