Beispiel #1
0
        /// <summary>
        ///     Destructs this instance.
        /// </summary>
        public void Destruct()
        {
            if (this._level != null)
            {
                this._level.Destruct();
                this._level = null;
            }

            if (this._commandManager != null)
            {
                this._commandManager.Destruct();
                this._commandManager = null;
            }

            if (this._calendar != null)
            {
                this._calendar.Destruct();
                this._calendar = null;
            }

            if (this._battleTimer != null)
            {
                this._battleTimer.Destruct();
                this._battleTimer = null;
            }

            if (this._replay != null)
            {
                this._replay.Destruct();
                this._replay = null;
            }

            this._configuration = null;
        }
Beispiel #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="LogicGameMode" /> class.
 /// </summary>
 public LogicGameMode()
 {
     this._level            = new LogicLevel(this);
     this._commandManager   = new LogicCommandManager(this._level);
     this._calendar         = new LogicCalendar();
     this._configuration    = new LogicConfiguration();
     this._currentTimestamp = -1;
 }
Beispiel #3
0
        public override int Execute(LogicLevel level)
        {
            LogicClientAvatar playerAvatar = level.GetPlayerAvatar();

            if (playerAvatar != null)
            {
                int lootLimitCooldown = playerAvatar.GetVariableByName("LootLimitCooldown");

                if (lootLimitCooldown == 1)
                {
                    LogicConfiguration configuration = level.GetGameMode().GetConfiguration();

                    if (configuration != null)
                    {
                        LogicCalendar calendar = level.GetGameMode().GetCalendar();

                        if (calendar != null)
                        {
                            int remainingSecs          = playerAvatar.GetRemainingLootLimitTime();
                            int totalSecs              = LogicCalendar.GetDuelLootLimitCooldownInMinutes(calendar, configuration) * 60;
                            int maxDiamondsCostPercent = LogicCalendar.GetDuelBonusMaxDiamondCostPercent(calendar, configuration);

                            int speedUpCost = LogicMath.Max(
                                LogicGamePlayUtil.GetLeagueVillage2(playerAvatar.GetDuelScore()).GetMaxDiamondCost() * maxDiamondsCostPercent * remainingSecs / totalSecs / 100, 1);

                            if (playerAvatar.HasEnoughDiamonds(speedUpCost, true, level))
                            {
                                playerAvatar.UseDiamonds(speedUpCost);
                                playerAvatar.GetChangeListener().DiamondPurchaseMade(18, 0, remainingSecs, speedUpCost, level.GetVillageType());
                                playerAvatar.FastForwardLootLimit(remainingSecs);

                                return(0);
                            }

                            return(-3);
                        }

                        return(-5);
                    }

                    return(-4);
                }

                return(-3);
            }

            return(-2);
        }
Beispiel #4
0
        public static int GetDuelBonusPercentLose(LogicCalendar instance, LogicConfiguration configuration)
        {
            if (instance == null)
            {
                Debugger.Warning("LogicCalender is NULL for getDuelBonusPercentLose call");

                if (configuration != null)
                {
                    return(configuration.GetDuelBonusPercentLose());
                }

                return(100);
            }

            int percent = -1;

            for (int i = 0; i < instance.m_activeCalendarEvents.Size(); i++)
            {
                LogicCalendarEvent calendarEvent = instance.m_activeCalendarEvents[i];

                if (calendarEvent.GetCalendarEventType() == LogicCalendarEvent.EVENT_TYPE_DUEL_LOOT_LIMIT)
                {
                    LogicDuelLootLimitCalendarEvent duelLootLimitCalendarEvent = (LogicDuelLootLimitCalendarEvent)calendarEvent;

                    if (percent == -1 || duelLootLimitCalendarEvent.GetDuelBonusPercentLose() <= percent)
                    {
                        percent = duelLootLimitCalendarEvent.GetDuelBonusPercentLose();
                    }
                }
            }

            if (percent == -1)
            {
                if (configuration != null)
                {
                    return(configuration.GetDuelBonusPercentLose());
                }

                return(100);
            }

            return(0);
        }