private void _dispatcherTimer_Tick(object sender, EventArgs e)
        {
            if (TimeRemaining == TimeSpan.Zero)
            {
                TimerLockUIStop();
            }

            TimeRemaining = TimeRemaining.Add(TimeSpan.FromSeconds(-1));
        }
    public void Initialization()
    {
        _spawnObstacle = Object.FindObjectOfType <SpawnObstacle>();
        _spawnZombie   = Object.FindObjectOfType <SpawnZombie>();

        _timeToSpawn = new TimeRemaining(SpawnTarget, Random.Range(_minDelay, _maxDelay), true);

        _timeToSpawn.AddTimeRemaining();
    }
        async void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
            if (_timer != null)
            {
                _timer.Enabled = false;
            }

            DateTime      = TimeZoneInfo.ConvertTime(DateTime.Now, DateTimeService.CentralTimeZone);
            TimeRemaining = ShowTime.Subtract(DateTime);

            bool reenableTimer  = true;
            bool alreadyStarted = TimeRemaining.Ticks < 0;

            if (alreadyStarted)
            {
                // Show is over
                if (TimeRemaining.Duration() >= ShowDuration)
                {
                    reenableTimer = false;
                    StopTimerAndUnregisterHandler();
                    Navigation.NavigateTo("/", true);
                }
                else if (!_showStarted)
                {
                    ImminentClass = "";
                    await InvokeAsync(
                        async() => await ShowIsStarting.InvokeAsync(_showStarted = true));
                }
            }
            else
            {
                if (TimeRemaining <= TimeSpan.FromSeconds(30))
                {
                    // Starts in 30 seconds, show embedded Twitch stream
                    ImminentClass = "";
                    await InvokeAsync(
                        async() => await ShowIsStarting.InvokeAsync(_showStarted = true));
                }
                else if (TimeRemaining <= TimeSpan.FromSeconds(90))
                {
                    // Starts in 90 seconds, start blinking
                    ImminentClass = "blinking";
                    await InvokeAsync(() => StateHasChanged());
                }
                else
                {
                    // Show hasn't started, nor is it imminent, just keep ticking
                    await InvokeAsync(() => StateHasChanged());
                }
            }

            if (_timer != null)
            {
                _timer.Enabled = reenableTimer;
            }
        }
Esempio n. 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = TimeRemaining.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)State;
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ PercentComplete.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 5
0
 private void Tick(object sender, ElapsedEventArgs e)
 {
     if (TimeRemaining == null || TimeRemaining.TotalMilliseconds <= timer.Interval)
     {
         TimeRemaining = new TimeSpan();
     }
     else
     {
         TimeRemaining.Subtract(TimeSpan.FromMilliseconds(timer.Interval));
     }
 }
Esempio n. 6
0
        private void CountdownTimer_Tick(object sender, EventArgs e)
        {   //Countdown timer for image display in the beginning of the game
            int timer = Convert.ToInt32(label1.Text);

            timer      -= 1;
            label1.Text = Convert.ToString(timer);
            if (timer == 0)
            {
                CountdownTimer.Stop();
                TimeRemaining.Start();
            }
        }
Esempio n. 7
0
 public void OnStart()
 {
     wave      = new List <Wave>();
     countWave = MainController.Instance.WavesSatting.CountWave;
     for (int i = 0; i < countWave; i++)
     {
         wave.Add(new Wave());
         delayWave   += wave[i].DelayWave;
         spawnInvoker = new TimeRemaining(wave[i].CreateWave, delayWave);
         spawnInvoker.AddTimeRemaining();
         CountEnemy += wave[i].CountEnemy;
     }
 }
Esempio n. 8
0
 public void RestartGame()
 {
     foreach (KeyValuePair <int, Player> entry in PlayerIndex.ToArray())
     {
         entry.Value.Restart();
     }
     MobIndex.Clear();
     DropIndex.Clear();
     FallingBlockIndex.Clear();
     WorldMap.InitLevelFromRotation();
     TimeRemaining.Start(DEFAULT_TIME_REMAINING);
     RestartInterval.Reset();
     RedTent  = new Tent(true, WorldMap.RedTentPosition, ServerMode == GameMode.CaptureTheFlag, true);
     BlueTent = new Tent(false, WorldMap.BlueTentPosition, ServerMode == GameMode.CaptureTheFlag, true);
 }
Esempio n. 9
0
        private void TimeRemaining_Tick(object sender, EventArgs e)
        {   //Timer to show how much time is left to complete the level
            int timer = Convert.ToInt32(timeLeft.Text);

            timer        -= 1;
            timeLeft.Text = Convert.ToString(timer);
            if (timer == 0)
            {
                TimeRemaining.Stop();
                MessageBox.Show("You Scored " + ScoreCounter.Text + " at level : " + levelValue.Text);
                ScoreCounter.Text     = "0";
                resetButton.BackColor = Color.Red;
                resetButton.Text      = "Play Again?";
            }
        }
Esempio n. 10
0
 public void Draw()
 {
     SpriteBatch.Begin();
     MiniCoin.Draw(SpriteBatch);
     MiniAvatar.Draw(SpriteBatch);
     SpriteBatch.DrawString(TextFont, "PLAYER", TopLeft, Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, PlayerName, TopLeft + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, "SCORE", Top2ndRight, Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, Score.ToString(), Top2ndRight + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, "LIVES", TopCenter, Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, Lives.ToString(), TopCenter + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, "COINS", Top2ndLeft, Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, Coins.ToString(), Top2ndLeft + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, "TIME", TopRight, Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.DrawString(TextFont, TimeRemaining.ToString(), TopRight + new Vector2(Constants.ZERO, 25), Color.Lerp(Color.White, Color.Transparent, .05f));
     SpriteBatch.End();
 }
Esempio n. 11
0
 // Runs every frame
 void Update()
 {
     if (CountingDown)
     {
         if (CountdownRemaining > 0)
         {
             _timer          += Time.deltaTime;
             GOCountdown.text = CountdownRemaining.ToString();
         }
         else
         {
             _timer       = 0f;
             CountingDown = false;
             Ended        = false;
             GOCountdown.gameObject.transform.parent.gameObject.SetActive(false);
         }
     }
     else if (Lost)
     {
         if (!Ended)
         {
             EndGame();
         }
     }
     else
     {
         if (TimeRemaining > 0f && !Ended)
         {
             // Create platform after gapsize
             if (_prevPlatform.localPosition.x <= PlatformStartX - GapSize)
             {
                 CreatePlatform(PlatformStartX - GapSize - _prevPlatform.localPosition.x);
             }
             // Set UI variables
             _timer        += Time.deltaTime;
             GOTimeRem.text = TimeRemaining.ToString();
         }
         else if (_finalPlatform == null)
         {
             if (_prevPlatform.localPosition.x <= PlatformStartX - GapSize)
             {
                 _finalPlatform = CreatePlatform(PlatformStartX - GapSize - _prevPlatform.localPosition.x, true);
             }
         }
     }
 }
        public IHttpActionResult GetCountdown(
            [Metadata("Target Month", "Month part of the target date", VisibilityType.Important)]
            int month,
            [Metadata("Target Day", "Day part of the target date", VisibilityType.Important)]
            int day,
            [Metadata("Target Year", "Year part of the target date", VisibilityType.Advanced)]
            int year = 2038)
        {
            DateTime targetDate = DateTime.UtcNow;

            try
            {
                targetDate = new DateTime(year, month, day);
            }
            catch (Exception)
            {
                BadRequest("Failed to create target date/time based on inputs provided");
            }

            return(Ok(TimeRemaining.FromTimeSpan(targetDate - DateTime.UtcNow)));
        }
Esempio n. 13
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Code != global::Clarifai.Api.Status.StatusCode.Zero)
            {
                hash ^= Code.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (Details.Length != 0)
            {
                hash ^= Details.GetHashCode();
            }
            hash ^= stackTrace_.GetHashCode();
            if (PercentCompleted != 0)
            {
                hash ^= PercentCompleted.GetHashCode();
            }
            if (TimeRemaining != 0)
            {
                hash ^= TimeRemaining.GetHashCode();
            }
            if (ReqId.Length != 0)
            {
                hash ^= ReqId.GetHashCode();
            }
            if (InternalDetails.Length != 0)
            {
                hash ^= InternalDetails.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 14
0
 private void HandlePressUp()
 {
     Debug.LogFormat("[Mystery Widget #{0}] Released on: {1}.", id, (int)Math.Floor(Info.GetTime()));
     if (Ready && (pressedOn == (int)Math.Floor(Info.GetTime()) + 3 || pressedOn == (int)Math.Floor(Info.GetTime()) - 3))
     {
         Debug.LogFormat("[Mystery Widget #{0}] Correct! Solve.", id);
         isSolved = true;
         ActiveModule.HandlePass();
         StartCoroutine(UnCover());
         Ready = false;
     }
     else if (current != null && (pressedOn == (int)Math.Floor(Info.GetTime()) + 1 || pressedOn == (int)Math.Floor(Info.GetTime()) - 1))
     {
         Debug.LogFormat("[Mystery Widget #{0}] Failswitch! Taking off time.", id);
         TimeRemaining.FromModule(ActiveModule, Info.GetTime() * 0.8f);
         Displayed = false;
         valid.Remove(current);
     }
     else
     {
         Debug.LogFormat("[Mystery Widget #{0}] Wrong! Strike.", id); ActiveModule.HandleStrike();
     }
 }
Esempio n. 15
0
 public override string ToString()
 {
     return(IsRunning ? TimeRemaining.ToString() : "0.0f");
 }
Esempio n. 16
0
 private void RoundTimeRemainingUpToSecond()
 {
     TimeRemaining = TimeRemaining.Add(new TimeSpan(0, 0, 0, 0, 1000 - TimeRemaining.Milliseconds));
 }
    private void Start()
    {
        moduleId = moduleIdCounter++;
        Debug.LogFormat(@"[Mystery Module #{0}] Version: 4.0", moduleId);
        LED.range *= transform.lossyScale.x;

        NextModule.OnInteract += delegate
        {
            if (moduleSolved || strikeActive)
            {
                return(false);
            }
            NextModule.AddInteractionPunch();
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, NextModule.transform);
            if (FailswitchPressed)
            {
                FailswitchPressed = false;
                StartCoroutine(FailSwitchAborted());
                return(false);
            }
            if (!nextStage)
            {
                StartCoroutine(StrikeHandler());
                return(false);
            }

            if (failsolve)
            {
                StartCoroutine(UnlockMystery());
                return(false);
            }

            Debug.LogFormat(@"[Mystery Module #{0}] Advancing to the next stage after solving {1}", moduleId, keyModules[0].ModuleDisplayName);
            keyModules.RemoveAt(0);
            nextStage = false;
            SetLED(255, 0, 0);
            SetKey();
            return(false);
        };

        Failswitch.OnInteract += delegate
        {
            if (moduleSolved || strikeActive)
            {
                return(false);
            }
            Failswitch.AddInteractionPunch();
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Failswitch.transform);
            if (FailswitchPressed)
            {
                StartCoroutine(UnlockMystery());
                Debug.LogFormat(@"[Mystery Module #{0}] 'Failswitch' was pressed - Remaining time was cut by a quarter", moduleId);
                if (failsolve)
                {
                    setScreen("Why would you do that!?", 255, 0, 0);
                }
                TimeRemaining.FromModule(Module, Bomb.GetTime() * 0.75f);
                return(false);
            }
            FailswitchPressed = true;
            Debug.LogFormat(@"[Mystery Module #{0}] Defuser was asked if he really wants to press the Fail Switch", moduleId);
            setScreen("Are you sure?", 255, 0, 0);
            return(false);
        };

        StartCoroutine(Setup());
    }
Esempio n. 18
0
        internal async Task StartFarming()
        {
            if (NowFarming || Paused || !Bot.IsPlayingPossible)
            {
                return;
            }

            if (!Bot.CanReceiveSteamCards)
            {
                await Bot.OnFarmingFinished(false).ConfigureAwait(false);

                return;
            }

            await FarmingSemaphore.WaitAsync().ConfigureAwait(false);

            try {
                if (NowFarming || Paused || !Bot.IsPlayingPossible)
                {
                    return;
                }

                if (!await IsAnythingToFarm().ConfigureAwait(false))
                {
                    Bot.ArchiLogger.LogGenericInfo(Strings.NothingToIdle);
                    await Bot.OnFarmingFinished(false).ConfigureAwait(false);

                    return;
                }

                if (GamesToFarm.Count == 0)
                {
                    Bot.ArchiLogger.LogNullError(nameof(GamesToFarm));
                    return;
                }

                Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable()));

                // This is the last moment for final check if we can farm
                if (!Bot.IsPlayingPossible)
                {
                    Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable);
                    return;
                }

                if (Bot.PlayingWasBlocked)
                {
                    await Task.Delay(Bot.MinPlayingBlockedTTL * 1000).ConfigureAwait(false);

                    if (!Bot.IsPlayingPossible)
                    {
                        Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable);
                        return;
                    }
                }

                KeepFarming = NowFarming = true;
            } finally {
                FarmingSemaphore.Release();
            }

            do
            {
                // Now the algorithm used for farming depends on whether account is restricted or not
                if (Bot.BotConfig.CardDropsRestricted)                   // If we have restricted card drops, we use complex algorithm
                {
                    Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ChosenFarmingAlgorithm, "Complex"));
                    while (GamesToFarm.Count > 0)
                    {
                        HashSet <Game> gamesToFarmSolo = GamesToFarm.Count > 1 ? new HashSet <Game>(GamesToFarm.Where(game => game.HoursPlayed >= HoursToBump)) : new HashSet <Game>(GamesToFarm);
                        if (gamesToFarmSolo.Count > 0)
                        {
                            while (gamesToFarmSolo.Count > 0)
                            {
                                Game game = gamesToFarmSolo.First();
                                if (await FarmSolo(game).ConfigureAwait(false))
                                {
                                    gamesToFarmSolo.Remove(game);
                                }
                                else
                                {
                                    NowFarming = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (FarmMultiple(GamesToFarm.OrderByDescending(game => game.HoursPlayed).Take(ArchiHandler.MaxGamesPlayedConcurrently)))
                            {
                                Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.IdlingFinishedForGames, string.Join(", ", GamesToFarm.Select(game => game.AppID))));
                            }
                            else
                            {
                                NowFarming = false;
                                return;
                            }
                        }
                    }
                }
                else                     // If we have unrestricted card drops, we use simple algorithm
                {
                    Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ChosenFarmingAlgorithm, "Simple"));
                    while (GamesToFarm.Count > 0)
                    {
                        Game game = GamesToFarm.First();
                        if (await FarmSolo(game).ConfigureAwait(false))
                        {
                            continue;
                        }

                        NowFarming = false;
                        return;
                    }
                }
            } while (await IsAnythingToFarm().ConfigureAwait(false));

            CurrentGamesFarming.ClearAndTrim();
            NowFarming = false;

            Bot.ArchiLogger.LogGenericInfo(Strings.IdlingFinished);
            await Bot.OnFarmingFinished(true).ConfigureAwait(false);
        }
Esempio n. 19
0
 public void Decrement()
 {
     TimeRemaining =
         TimeRemaining.Subtract(TimeSpan.FromSeconds(1));
 }
Esempio n. 20
0
        private async Task Farm()
        {
            do
            {
                Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable()));

                // Now the algorithm used for farming depends on whether account is restricted or not
                if (Bot.BotConfig.HoursUntilCardDrops > 0)
                {
                    // If we have restricted card drops, we use complex algorithm
                    Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ChosenFarmingAlgorithm, "Complex"));

                    while (GamesToFarm.Count > 0)
                    {
                        // Initially we're going to farm games that passed our HoursUntilCardDrops
                        // This block is almost identical to Simple algorithm, we just copy appropriate items from GamesToFarm into innerGamesToFarm
                        HashSet <Game> innerGamesToFarm = GamesToFarm.Where(game => game.HoursPlayed >= Bot.BotConfig.HoursUntilCardDrops).ToHashSet();

                        while (innerGamesToFarm.Count > 0)
                        {
                            Game game = innerGamesToFarm.First();

                            if (!await IsPlayableGame(game).ConfigureAwait(false))
                            {
                                GamesToFarm.Remove(game);
                                innerGamesToFarm.Remove(game);
                                continue;
                            }

                            if (await FarmSolo(game).ConfigureAwait(false))
                            {
                                innerGamesToFarm.Remove(game);
                                continue;
                            }

                            NowFarming = false;
                            return;
                        }

                        // At this point we have no games past HoursUntilCardDrops anymore, so we're going to farm all other ones
                        // In order to maximize efficiency, we'll take games that are closest to our HoursPlayed first

                        // We must call ToList() here as we can't remove items while enumerating
                        foreach (Game game in GamesToFarm.OrderByDescending(game => game.HoursPlayed).ToList())
                        {
                            if (!await IsPlayableGame(game).ConfigureAwait(false))
                            {
                                GamesToFarm.Remove(game);
                                continue;
                            }

                            innerGamesToFarm.Add(game);

                            // There is no need to check all games at once, allow maximum of MaxGamesPlayedConcurrently in this batch
                            if (innerGamesToFarm.Count >= ArchiHandler.MaxGamesPlayedConcurrently)
                            {
                                break;
                            }
                        }

                        // If we have no playable games to farm, we're done
                        if (innerGamesToFarm.Count == 0)
                        {
                            break;
                        }

                        // Otherwise, we farm our innerGamesToFarm batch until any game hits HoursUntilCardDrops
                        if (await FarmMultiple(innerGamesToFarm).ConfigureAwait(false))
                        {
                            Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.IdlingFinishedForGames, string.Join(", ", innerGamesToFarm.Select(game => game.AppID))));
                        }
                        else
                        {
                            NowFarming = false;
                            return;
                        }
                    }
                }
                else
                {
                    // If we have unrestricted card drops, we use simple algorithm
                    Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.ChosenFarmingAlgorithm, "Simple"));

                    while (GamesToFarm.Count > 0)
                    {
                        // In simple algorithm we're going to farm anything that is playable, regardless of hours
                        Game game = GamesToFarm.First();

                        if (!await IsPlayableGame(game).ConfigureAwait(false))
                        {
                            GamesToFarm.Remove(game);
                            continue;
                        }

                        if (await FarmSolo(game).ConfigureAwait(false))
                        {
                            continue;
                        }

                        NowFarming = false;
                        return;
                    }
                }
            } while ((await IsAnythingToFarm().ConfigureAwait(false)).GetValueOrDefault());

            NowFarming = false;

            Bot.ArchiLogger.LogGenericInfo(Strings.IdlingFinished);
            await Bot.OnFarmingFinished(true).ConfigureAwait(false);
        }
Esempio n. 21
0
        public void Update(float msElapsed)
        {
            if (RestartInterval.Left > 1 || !RestartInterval.IsRunning)
            {
                foreach (KeyValuePair <int, Player> entry in PlayerIndex.ToArray())
                {
                    Player player = entry.Value;
                    player.Update(msElapsed, WorldMap, RedTent.Position, BlueTent.Position);
                    if (player.Y >= WorldMap.Height * Universal.TILE_SIZE - Universal.TILE_SIZE * 3)
                    {
                        network.SendKilledPlayer(-1, entry.Key, player);
                        player.DeathAction(false);
                        network.SendServerMove(entry.Key, player);
                        player.RespondMove = false;
                        network.CheckWinCondition();
                    }
                }
                foreach (KeyValuePair <int, Mob> entry in MobIndex.ToArray())
                {
                    if (entry.Value.Dead)
                    {
                        foreach (ItemDrop drop in entry.Value.Drops)
                        {
                            int id = 0;
                            foreach (KeyValuePair <int, ItemDrop> dropEntry in DropIndex.ToArray())
                            {
                                if (dropEntry.Key == id)
                                {
                                    id++;
                                }
                            }
                            DropIndex.TryAdd(id, drop);
                        }
                        network.SendRemoveMob(entry.Key, entry.Value.Drops);
                        Universal.TryDictRemove(MobIndex, entry.Key);
                    }
                    else
                    {
                        entry.Value.Update(msElapsed, WorldMap);
                    }
                }
                foreach (KeyValuePair <int, ItemDrop> entry in DropIndex.ToArray())
                {
                    entry.Value.Update(msElapsed, WorldMap);
                }
                foreach (KeyValuePair <int, FallingBlock> entry in FallingBlockIndex.ToArray())
                {
                    FallingBlock fallingBlock = entry.Value;
                    fallingBlock.Update(msElapsed, WorldMap);
                    if (Math.Abs(fallingBlock.DY) > 70)
                    {
                        foreach (KeyValuePair <int, Mob> mobEntry in MobIndex.ToArray())
                        {
                            Mob mob = mobEntry.Value;
                            if (fallingBlock.CollideBox.Intersects(mob.CollideBox))
                            {
                                mob.Damage(2);
                                network.SendHitMob(mobEntry.Key, 2);
                            }
                        }
                        foreach (KeyValuePair <int, Player> playerEntry in PlayerIndex.ToArray())
                        {
                            Player targetPlayer = playerEntry.Value;
                            if (fallingBlock.CollideBox.Intersects(targetPlayer.CollideBox))
                            {
                                targetPlayer.Damage(2);
                                network.SendHitPlayer(playerEntry.Key, 2, targetPlayer.DX, targetPlayer.DY);
                                if (targetPlayer.HP <= 0)
                                {
                                    Player killer;
                                    if (fallingBlock.PlayerID != playerEntry.Key &&
                                        PlayerIndex.TryGetValue(fallingBlock.PlayerID, out killer) &&
                                        (targetPlayer.PlayerTeam.Name == "No Team" || killer.PlayerTeam.Name != targetPlayer.PlayerTeam.Name))
                                    {
                                        killer.Kills++;
                                        network.SendKilledPlayer(fallingBlock.PlayerID, playerEntry.Key, targetPlayer);
                                    }
                                    else
                                    {
                                        network.SendKilledPlayer(-1, playerEntry.Key, targetPlayer);
                                    }
                                    targetPlayer.DeathAction(false);
                                    network.SendServerMove(playerEntry.Key, targetPlayer);
                                    targetPlayer.RespondMove = false;
                                    network.CheckWinCondition();
                                }
                            }
                        }
                    }
                    if (fallingBlock.CanDestroy)
                    {
                        network.SendRemoveFallingBlock(entry.Key);
                        Universal.TryDictRemove(FallingBlockIndex, entry.Key);
                    }
                }
                if (ServerMode == GameMode.TeamDeathmatch || ServerMode == GameMode.CaptureTheFlag)
                {
                    RedTent.Update(msElapsed, WorldMap);
                    BlueTent.Update(msElapsed, WorldMap);
                }
            }

            TimeRemaining.Update(msElapsed);
            RestartInterval.Update(msElapsed);
        }
Esempio n. 22
0
        internal async Task StartFarming()
        {
            if (NowFarming || Paused || !Bot.IsPlayingPossible)
            {
                return;
            }

            if (!Bot.CanReceiveSteamCards)
            {
                await Bot.OnFarmingFinished(false).ConfigureAwait(false);

                return;
            }

            await FarmingSemaphore.WaitAsync().ConfigureAwait(false);

            try {
                if (NowFarming || Paused || !Bot.IsPlayingPossible)
                {
                    return;
                }

                if (!await IsAnythingToFarm().ConfigureAwait(false))
                {
                    Bot.ArchiLogger.LogGenericInfo(Strings.NothingToIdle);
                    await Bot.OnFarmingFinished(false).ConfigureAwait(false);

                    return;
                }

                if (GamesToFarm.Count == 0)
                {
                    Bot.ArchiLogger.LogNullError(nameof(GamesToFarm));
                    return;
                }

                Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable()));

                // This is the last moment for final check if we can farm
                if (!Bot.IsPlayingPossible)
                {
                    Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable);
                    return;
                }

                if (Bot.PlayingWasBlocked)
                {
                    await Task.Delay(Bot.MinPlayingBlockedTTL * 1000).ConfigureAwait(false);

                    if (!Bot.IsPlayingPossible)
                    {
                        Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable);
                        return;
                    }
                }

                KeepFarming = NowFarming = true;
                Farm().Forget();                 // Farm() will end when we're done farming, so don't wait for it
            } finally {
                FarmingSemaphore.Release();
            }
        }
Esempio n. 23
0
        internal async Task StartFarming()
        {
            if (NowFarming || Paused || !Bot.IsPlayingPossible)
            {
                return;
            }

            if (!Bot.CanReceiveSteamCards)
            {
                await Bot.OnFarmingFinished(false).ConfigureAwait(false);

                return;
            }

            await FarmingInitializationSemaphore.WaitAsync().ConfigureAwait(false);

            try {
                if (NowFarming || Paused || !Bot.IsPlayingPossible)
                {
                    return;
                }

                bool?isAnythingToFarm = await IsAnythingToFarm().ConfigureAwait(false);

                if (isAnythingToFarm == null)
                {
                    return;
                }

                if (!isAnythingToFarm.Value)
                {
                    Bot.ArchiLogger.LogGenericInfo(Strings.NothingToIdle);
                    await Bot.OnFarmingFinished(false).ConfigureAwait(false);

                    return;
                }

                if (GamesToFarm.Count == 0)
                {
                    Bot.ArchiLogger.LogNullError(nameof(GamesToFarm));
                    return;
                }

                Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable()));

                // This is the last moment for final check if we can farm
                if (!Bot.IsPlayingPossible)
                {
                    Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable);
                    return;
                }

                if (Bot.PlayingWasBlocked)
                {
                    for (byte i = 0; (i < Bot.MinPlayingBlockedTTL) && Bot.IsPlayingPossible; i++)
                    {
                        await Task.Delay(1000).ConfigureAwait(false);
                    }

                    if (!Bot.IsPlayingPossible)
                    {
                        Bot.ArchiLogger.LogGenericInfo(Strings.PlayingNotAvailable);
                        return;
                    }
                }

                KeepFarming = NowFarming = true;
                Utilities.InBackground(Farm, true);
            } finally {
                FarmingInitializationSemaphore.Release();
            }
        }
Esempio n. 24
0
 public virtual string ToString(string format)
 {
     return(TimeRemaining.ToString(format));
 }