コード例 #1
0
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                if (playerAvatar.IsInAlliance())
                {
                    if (playerAvatar.GetAllianceId().Equals(this.m_allianceId))
                    {
                        playerAvatar.SetAllianceId(null);
                        playerAvatar.SetAllianceName(null);
                        playerAvatar.SetAllianceBadgeId(-1);
                        playerAvatar.SetAllianceLevel(-1);
                        playerAvatar.GetChangeListener().AllianceLeft();
                    }
                }

                level.GetGameListener().AllianceLeft();

                return(0);
            }

            return(-1);
        }
コード例 #2
0
        public void StateChangeConfirmed()
        {
            switch (this.m_data.GetMissionType())
            {
            case 1:
                if (this.m_progress == 0)
                {
                    this.m_level.GetGameMode().StartDefendState(LogicNpcAvatar.GetNpcAvatar(this.m_data.GetDefendNpcData()));
                    this.m_progress = 1;
                }

                break;

            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 20:
            case 21:
                this.m_progress = 1;
                this.Finished();

                break;

            case 16:
                if (this.m_progress == 0)
                {
                    // ?
                }

                this.m_progress += 1;
                break;

            case 19:
                if (this.m_progress == 1)
                {
                    LogicClientAvatar playerAvatar = this.m_level.GetPlayerAvatar();
                    int duelScoreGain = LogicDataTables.GetGlobals().GetVillage2FirstVictoryTrophies();

                    playerAvatar.AddDuelReward(LogicDataTables.GetGlobals().GetVillage2FirstVictoryGold(), LogicDataTables.GetGlobals().GetVillage2FirstVictoryElixir(), 0, 0,
                                               null);
                    playerAvatar.SetDuelScore(playerAvatar.GetDuelScore() + LogicDataTables.GetGlobals().GetVillage2FirstVictoryTrophies());
                    playerAvatar.GetChangeListener().DuelScoreChanged(playerAvatar.GetAllianceId(), duelScoreGain, -1, false);

                    this.m_progress = 2;
                    this.Finished();
                }

                break;
            }
        }
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                if (LogicLong.Equals(playerAvatar.GetAllianceId(), this.m_allianceId))
                {
                    playerAvatar.SetAllianceBadgeId(this.m_allianceBadgeId);
                    level.GetGameListener().AllianceSettingsChanged();
                }

                return(0);
            }

            return(-1);
        }
コード例 #4
0
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                if (this.m_allianceCreate)
                {
                    LogicGlobals      globals  = LogicDataTables.GetGlobals();
                    LogicResourceData resource = globals.GetAllianceCreateResourceData();

                    int removeCount = LogicMath.Min(globals.GetAllianceCreateCost(), playerAvatar.GetResourceCount(resource));

                    playerAvatar.CommodityCountChangeHelper(0, resource, -removeCount);
                }

                playerAvatar.SetAllianceId(this.m_allianceId.Clone());
                playerAvatar.SetAllianceName(this.m_allianceName);
                playerAvatar.SetAllianceBadgeId(this.m_allianceBadgeId);
                playerAvatar.SetAllianceLevel(this.m_allianceExpLevel);
                playerAvatar.SetAllianceRole(this.m_allianceCreate ? LogicAvatarAllianceRole.LEADER : LogicAvatarAllianceRole.MEMBER);
                playerAvatar.GetChangeListener().AllianceJoined(playerAvatar.GetAllianceId(), this.m_allianceName, this.m_allianceBadgeId, this.m_allianceExpLevel,
                                                                playerAvatar.GetAllianceRole());

                LogicGameListener gameListener = level.GetGameListener();

                if (gameListener != null)
                {
                    if (this.m_allianceCreate)
                    {
                        gameListener.AllianceCreated();
                    }
                    else
                    {
                        gameListener.AllianceJoined();
                    }
                }

                return(0);
            }

            return(-1);
        }
コード例 #5
0
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                if (playerAvatar.IsInAlliance())
                {
                    if (LogicLong.Equals(playerAvatar.GetAllianceId(), this.m_allianceId))
                    {
                        playerAvatar.SetAllianceRole(this.m_allianceRole);
                    }
                }

                return(0);
            }

            return(-1);
        }
コード例 #6
0
ファイル: AvatarEntry.cs プロジェクト: NotHuza/Cerberus-v4
        /// <summary>
        ///     Sets the data.
        /// </summary>
        public void SetData(LogicClientAvatar avatar)
        {
            this._avatarId        = avatar.GetId();
            this._homeId          = avatar.GetCurrentHomeId();
            this._avatarName      = avatar.GetName();
            this._facebookId      = avatar.GetFacebookId();
            this._expLevel        = avatar.GetExpLevel();
            this._leagueType      = avatar.GetLeagueType();
            this._nameChangeState = avatar.GetNameChangeState();
            this._nameSetByUser   = avatar.GetNameSetByUser();

            if (avatar.IsInAlliance())
            {
                this._allianceId       = avatar.GetAllianceId();
                this._allianceName     = avatar.GetAllianceName();
                this._allianceExpLevel = avatar.GetAllianceExpLevel();
                this._allianceRole     = avatar.GetAllianceRole();
                this._badgeId          = avatar.GetAllianceBadge();
            }
        }
コード例 #7
0
        private static GameAvatar FindEnemy(MatchmakingEntry entry, Dictionary <long, GameAvatar> documents)
        {
            GameAvatar        document      = entry.Session.GameAvatar;
            LogicClientAvatar playerAvatar1 = document.LogicClientAvatar;

            int totalSecs       = TimeUtil.GetTimestamp() - entry.Timestamp;
            int strength1       = GameMatchmakingManager.CalculateStrength(playerAvatar1);
            int maxStrengthDiff = 50 + LogicMath.Clamp(totalSecs * 150 / 60, 0, 150);

            foreach (GameAvatar enemy in documents.Values)
            {
                LogicClientAvatar playerAvatar2 = enemy.LogicClientAvatar;

#if DEBUG
                if (ServerCore.Random.Rand(100) <= 95)
                {
                    continue;
                }
#else
                if (playerAvatar1.IsInAlliance() && playerAvatar2.IsInAlliance() && playerAvatar1.GetAllianceId().Equals(playerAvatar2.GetAllianceId()))
                {
                    continue;
                }

                int strength2 = GameMatchmakingManager.CalculateStrength(playerAvatar2);

                if (LogicMath.Abs(strength1 - strength2) >= maxStrengthDiff)
                {
                    continue;
                }
                if (document.HasRecentlyMatchedWithEnemy(enemy.Id))
                {
                    continue;
                }
#endif
                return(enemy);
            }

            return(null);
        }
コード例 #8
0
        public void PublishMessage(LogicClientAvatar logicClientAvatar, string message)
        {
            GlobalChatLineMessage globalChatLineMessage = new GlobalChatLineMessage();

            globalChatLineMessage.SetMessage(message);
            globalChatLineMessage.SetAvatarName(logicClientAvatar.GetName());
            globalChatLineMessage.SetAvatarExpLevel(logicClientAvatar.GetExpLevel());
            globalChatLineMessage.SetAvatarLeagueType(logicClientAvatar.GetLeagueType());
            globalChatLineMessage.SetAvatarId(logicClientAvatar.GetId());
            globalChatLineMessage.SetHomeId(logicClientAvatar.GetCurrentHomeId());

            if (logicClientAvatar.IsInAlliance())
            {
                globalChatLineMessage.SetAllianceId(logicClientAvatar.GetAllianceId());
                globalChatLineMessage.SetAllianceName(logicClientAvatar.GetAllianceName());
                globalChatLineMessage.SetAllianceBadgeId(logicClientAvatar.GetAllianceBadgeId());
            }

            foreach (ChatSession session in this.m_sessions.Values)
            {
                session.SendPiranhaMessage(globalChatLineMessage, 1);
            }
        }