コード例 #1
0
        public void ChangeMemberRole(AllianceMemberEntry allianceMemberEntry, LogicAvatarAllianceRole allianceRole, LogicLong eventAvatarId, string eventAvatarName)
        {
            if (allianceMemberEntry.GetAllianceRole() != allianceRole)
            {
                bool isPromoted = allianceMemberEntry.HasLowerRoleThan(allianceRole);

                allianceMemberEntry.SetAllianceRole(allianceRole);

                LogicChangeAllianceRoleCommand logicChangeAllianceRoleCommand = new LogicChangeAllianceRoleCommand();
                logicChangeAllianceRoleCommand.SetData(this.Id, allianceRole);
                ServerMessageManager.SendMessage(new GameAllowServerCommandMessage
                {
                    AccountId     = allianceMemberEntry.GetAvatarId(),
                    ServerCommand = logicChangeAllianceRoleCommand
                }, 9);

                AllianceEventStreamEntry allianceEventStreamEntry = new AllianceEventStreamEntry();
                AllianceStreamEntryUtil.SetSenderInfo(allianceEventStreamEntry, allianceMemberEntry);

                allianceEventStreamEntry.SetEventAvatarId(eventAvatarId);
                allianceEventStreamEntry.SetEventAvatarName(eventAvatarName);
                allianceEventStreamEntry.SetEventType(isPromoted ? AllianceEventStreamEntryType.PROMOTED : AllianceEventStreamEntryType.DEMOTED);

                StreamManager.Create(this.Id, allianceEventStreamEntry);

                this.AddStreamEntry(allianceEventStreamEntry);
            }
        }
コード例 #2
0
        private void OnChangeAllianceMemberRoleMessageReceived(ChangeAllianceMemberRoleMessage message)
        {
            if (this.m_session.Alliance != null)
            {
                LogicLong memberId = message.RemoveMemberId();

                if (!this.m_session.Alliance.Members.TryGetValue(memberId, out AllianceMemberEntry memberEntry))
                {
                    return;
                }

                AllianceMemberEntry eventMemberEntry = this.m_session.Alliance.Members[this.m_session.AccountId];

                if (message.GetMemberRole() == LogicAvatarAllianceRole.MEMBER ||
                    message.GetMemberRole() == LogicAvatarAllianceRole.LEADER ||
                    message.GetMemberRole() == LogicAvatarAllianceRole.ELDER ||
                    message.GetMemberRole() == LogicAvatarAllianceRole.CO_LEADER)
                {
                    if (memberEntry.HasLowerRoleThan(eventMemberEntry.GetAllianceRole()) &&
                        !eventMemberEntry.HasLowerRoleThan(message.GetMemberRole()))
                    {
                        if (message.GetMemberRole() == LogicAvatarAllianceRole.LEADER)
                        {
                            this.m_session.Alliance.ChangeMemberRole(eventMemberEntry, LogicAvatarAllianceRole.CO_LEADER, eventMemberEntry.GetAvatarId(), eventMemberEntry.GetName());
                        }
                        this.m_session.Alliance.ChangeMemberRole(memberEntry, message.GetMemberRole(), memberEntry.GetAvatarId(), memberEntry.GetName());

                        AllianceManager.Save(this.m_session.Alliance);
                    }
                }
            }
        }