示例#1
0
        private IEnumerator CreateGuildRoutine(BasePlayerCharacterEntity playerCharacterEntity, string guildName)
        {
            FindGuildNameJob findGuildNameJob = new FindGuildNameJob(Database, guildName);

            findGuildNameJob.Start();
            yield return(StartCoroutine(findGuildNameJob.WaitFor()));

            if (findGuildNameJob.result > 0)
            {
                // Cannot create guild because guild name is already existed
                SendServerGameMessage(playerCharacterEntity.ConnectionId, GameMessage.Type.ExistedGuildName);
            }
            else
            {
                CreateGuildJob createGuildJob = new CreateGuildJob(Database, guildName, playerCharacterEntity.Id);
                createGuildJob.Start();
                yield return(StartCoroutine(createGuildJob.WaitFor()));

                int guildId = createGuildJob.result;
                // Create guild
                base.CreateGuild(playerCharacterEntity, guildName, guildId);
                // Save to database
                new SetCharacterGuildJob(Database, playerCharacterEntity.Id, guildId, guilds[guildId].GetMemberRole(playerCharacterEntity.Id)).Start();
                // Broadcast via chat server
                if (ChatNetworkManager.IsClientConnected)
                {
                    ChatNetworkManager.Client.SendCreateGuild(null, MMOMessageTypes.UpdateGuild, guildId, guildName, playerCharacterEntity.Id);
                    ChatNetworkManager.Client.SendAddSocialMember(null, MMOMessageTypes.UpdateGuildMember, guildId, playerCharacterEntity.Id, playerCharacterEntity.CharacterName, playerCharacterEntity.DataId, playerCharacterEntity.Level);
                }
            }
        }
        private IEnumerator CreateGuildRoutine(BasePlayerCharacterEntity playerCharacterEntity, string guildName)
        {
            var createGuildJob = new CreateGuildJob(Database, guildName, playerCharacterEntity.Id);

            createGuildJob.Start();
            yield return(StartCoroutine(createGuildJob.WaitFor()));

            var guildId = createGuildJob.result;

            // Create guild
            base.CreateGuild(playerCharacterEntity, guildName, guildId);
            // Save to database
            new SetCharacterGuildJob(Database, playerCharacterEntity.Id, guildId, guilds[guildId].GetMemberRole(playerCharacterEntity.Id)).Start();
            // Broadcast via chat server
            if (ChatNetworkManager.IsClientConnected)
            {
                ChatNetworkManager.Client.SendCreateGuild(null, MMOMessageTypes.UpdateGuild, guildId, guildName, playerCharacterEntity.Id);
                ChatNetworkManager.Client.SendAddSocialMember(null, MMOMessageTypes.UpdateGuildMember, guildId, playerCharacterEntity.Id, playerCharacterEntity.CharacterName, playerCharacterEntity.DataId, playerCharacterEntity.Level);
            }
        }