Exemplo n.º 1
0
        protected override int GetWarningTimer()
        {
            int num1 = 0;

            if (this.IsRoundInProgress)
            {
                float num2 = 180f;
                if (this.GameType == MissionLobbyComponent.MultiplayerGameType.Skirmish)
                {
                    num2 = 120f;
                }
                float num3 = (float)MultiplayerOptions.OptionType.RoundTimeLimit.GetIntValue() - num2;
                float num4 = num3 + 30f;
                if ((double)this.RoundComponent.RemainingRoundTime <= (double)num4 && (double)this.RoundComponent.RemainingRoundTime > (double)num3)
                {
                    num1 = MBMath.Ceiling((float)(30.0 - ((double)num4 - (double)this.RoundComponent.RemainingRoundTime)));
                    if (!this._informedAboutFlagRemoval)
                    {
                        this._informedAboutFlagRemoval = true;
                        this.NotificationsComponent.FlagsWillBeRemovedInXSeconds(30);
                    }
                }
            }
            return(num1);
        }
        public bool CheckTimer(out int remainingTime, out int remainingWarningTime, bool forceUpdate = false)
        {
            bool  flag = false;
            float f    = 0.0f;

            if (this.WarmupComponent != null && this.MissionLobbyComponent.CurrentMultiplayerState == MissionLobbyComponent.MultiplayerGameState.WaitingFirstPlayers)
            {
                flag = !this.WarmupComponent.IsInWarmup;
            }
            else if (this.RoundComponent != null)
            {
                flag = !this.RoundComponent.CurrentRoundState.StateHasVisualTimer();
                f    = this.RoundComponent.LastRoundEndRemainingTime;
            }
            if (forceUpdate || !flag)
            {
                remainingTime = !flag?MBMath.Ceiling(this.RemainingTime) : MBMath.Ceiling(f);

                remainingWarningTime = MBMath.Ceiling((float)this.GetWarningTimer());
                return(true);
            }
            remainingTime        = 0;
            remainingWarningTime = 0;
            return(false);
        }
Exemplo n.º 3
0
        public void Init(bool spawnDefenders, bool spawnAttackers, float defenderAdvantageFactor = 1f)
        {
            foreach (IEnumerable <MissionAgentSpawnLogic.SpawnPhase> phase in this._phases)
            {
                if (!phase.Any <MissionAgentSpawnLogic.SpawnPhase>())
                {
                    throw new Exception("There must be at least 1 phase (initial phase) on each side before Init was called.");
                }
            }
            int[] numArray1 = new int[2]
            {
                this._phases[0].Sum <MissionAgentSpawnLogic.SpawnPhase>((Func <MissionAgentSpawnLogic.SpawnPhase, int>)(p => p.TotalSpawnNumber)),
                this._phases[1].Sum <MissionAgentSpawnLogic.SpawnPhase>((Func <MissionAgentSpawnLogic.SpawnPhase, int>)(p => p.TotalSpawnNumber))
            };
            int num1 = ((IEnumerable <int>)numArray1).Sum();

            float[] numArray2 = new float[2]
            {
                (float)numArray1[0] / (float)num1,
                (float)numArray1[1] / (float)num1
            };
            if ((double)numArray2[0] < 0.600000023841858)
            {
                numArray2[0] *= defenderAdvantageFactor;
                if ((double)numArray2[0] > 0.600000023841858)
                {
                    numArray2[0] = 0.6f;
                }
                numArray2[1] = 1f - numArray2[0];
            }
            BattleSideEnum side         = (double)numArray2[0] < (double)numArray2[1] ? BattleSideEnum.Defender : BattleSideEnum.Attacker;
            BattleSideEnum oppositeSide = side.GetOppositeSide();

            int[] numArray3 = new int[2];
            numArray3[(int)side]         = MBMath.Ceiling(numArray2[(int)side] * (float)this._battleSize);
            numArray3[(int)oppositeSide] = this._battleSize - numArray3[(int)side];
            for (int index = 0; index < 2; ++index)
            {
                foreach (MissionAgentSpawnLogic.SpawnPhase spawnPhase in this._phases[index])
                {
                    if (spawnPhase.InitialSpawnNumber > numArray3[index])
                    {
                        int num2 = numArray3[index];
                        int num3 = spawnPhase.InitialSpawnNumber - num2;
                        spawnPhase.InitialSpawnNumber    = num2;
                        spawnPhase.RemainingSpawnNumber += num3;
                    }
                }
            }
            Mission.Current.SetBattleAgentCount(Math.Min(this.DefenderActivePhase.InitialSpawnNumber, this.AttackerActivePhase.InitialSpawnNumber));
            this._missionSides[0].SetSpawnTroops(spawnDefenders);
            this._missionSides[1].SetSpawnTroops(spawnAttackers);
        }