Beispiel #1
0
        private async Task StartCountdown()
        {
            while (Info.Owner != null)
            {
                try
                {
                    LastCountdown = 0f;

                    await GameTask.DelaySeconds(Countdown);

                    if (Info.Owner != null)
                    {
                        OnCountdown();
                    }
                }
                catch (Exception e)
                {
                    if (e.Message.Trim() == "A task was canceled.")
                    {
                        return;
                    }

                    Log.Error($"[TASK] {e.Message}: {e.StackTrace}");
                }
            }
        }
Beispiel #2
0
        private async Task deletePanel(Panel panel, float seconds)
        {
            activePopups++;
            innerContainer.SetClass("populated", activePopups > 0);
            await GameTask.DelaySeconds(seconds);

            activePopups--;
            innerContainer.SetClass("populated", activePopups > 0);
            panel.Delete();
        }
Beispiel #3
0
        private async Task largeTextLogic()
        {
            await GameTask.DelaySeconds(0.25f);

            var container = screen.Add.Panel("gameover-container");
            var text      = container.Add.Label("Match Over", "gameover");
            await GameTask.DelaySeconds(2);

            text.Delete();
        }
Beispiel #4
0
        private async Task scoreboardLogic()
        {
            await GameTask.DelaySeconds(1f);             // Wait before making scoreboard visible

            scoreboard.OverrideClosed = false;
            scoreboard.OverrideOpen   = true;

            await GameTask.DelaySeconds(scoreboardTime);

            scoreboard.OverrideClosed = true;
        }
Beispiel #5
0
        protected async Task pulseIndicator()
        {
            await GameTask.Delay(100);

            while (!IsCollected)
            {
                using (Prediction.Off()) {
                    Particles.Create(indicator, Position + Vector3.Up * 0.5f);
                }
                await GameTask.DelaySeconds(timeBetweenIndicators);
            }
        }
Beispiel #6
0
        private async Task nextMapPreviewLogic()
        {
            await GameTask.DelaySeconds(1f);

            var preview = screen.Add.Panel("preview-container").Add.Panel("preview");
            var pack    = await Package.Fetch(nextMap, false);

            preview.Add.Label("Next Up:", "text");
            preview.Add.Panel("thumbnail").Style.Set("background-image", $"url({pack.Thumb})");
            prepareToChangeMap();
            while (true)
            {
                preview.Style.BackgroundColor = new Color(0.25f, 0.25f, 0.5f.LerpTo(0.75f, MathF.Sin(Time.Now * 2) * 0.5f + 0.5f));
                preview.Style.Dirty();
                await GameTask.NextPhysicsFrame();
            }
        }
Beispiel #7
0
        private async Task countDownMeter()           // Runs on the client who collected us
        {
            while (timeSinceCollected < duration)
            {
                if (clientCollector.LifeState != LifeState.Alive)
                {
                    break;
                }                                                                            // Stop updating if player died

                meterWidth.Value = initialMeterWidth.LerpTo(0, timeSinceCollected / duration, true).Clamp(0.01f, float.MaxValue);
                meter.ProgressBar.Style.Width = meterWidth;
                meter.ProgressBar.Style.Dirty();
                await GameTask.DelaySeconds(Time.Delta);
            }

            meter.Delete();
            meter = null;
        }
Beispiel #8
0
        private async Task podiumLogic()
        {
            await GameTask.DelaySeconds(1f);

            const string transition       = "all 0.5s ease-out";
            var          podium           = screen.Add.Panel("podium");
            float        transitionOffset = (scoreboard.Canvas.ChildCount.Clamp(0, 3) - 1) * podiumCardTiming;

            var secondContainer = podium.Add.Panel("card-container");
            var firstContainer  = podium.Add.Panel("card-container");
            var thirdContainer  = podium.Add.Panel("card-container");

            if (scoreboard.Canvas.ChildCount >= 2)
            {
                var second = secondContainer.Add.Panel("card");
                secondContainer.SetClass("second", true);
                second.SetClass("second", true);
                second.Style.Set("transition", $"{transition} {transitionOffset - podiumCardTiming}s");
                second.Style.Dirty();
                populateCard(second, 1);
            }
            if (scoreboard.Canvas.ChildCount >= 1)
            {
                var first = firstContainer.Add.Panel("card");
                firstContainer.SetClass("first", true);
                first.SetClass("first", true);
                first.Style.Set("transition", $"{transition} {transitionOffset}s");
                first.Style.Dirty();
                populateCard(first, 0);
            }
            if (scoreboard.Canvas.ChildCount >= 3)
            {
                var third = thirdContainer.Add.Panel("card");
                thirdContainer.SetClass("third", true);
                third.SetClass("third", true);
                third.Style.Set("transition", $"{transition} {transitionOffset - podiumCardTiming * 2}s");
                third.Style.Dirty();
                populateCard(third, 2);
            }

            await GameTask.DelaySeconds(podiumTime);

            podium.Delete();
        }
Beispiel #9
0
        private async void StartTimer()
        {
            IsArmed = true;

            int timeRemaining = CurrentPreset.Timer + 1;

            while (timeRemaining > 0 && IsArmed)
            {
                try
                {
                    if (timeRemaining <= 60)
                    {
                        Sound.FromEntity("c4-beep", this)
                        .SetVolume(0.05f);
                    }

                    timeRemaining -= 1;

                    TimeSpan span        = TimeSpan.FromSeconds(timeRemaining);
                    string   timerString = span.ToString("mm\\:ss");

                    ClientUpdateTimer(timerString);

                    await GameTask.DelaySeconds(1);
                }
                catch (Exception e)
                {
                    if (e.Message.Trim() == "A task was canceled.")
                    {
                        return;
                    }

                    Log.Error($"[TASK] {e.Message}: {e.StackTrace}");
                }
            }

            if (IsArmed)
            {
                await Explode();
            }
        }
Beispiel #10
0
        private static async void StartRespawnTimer(Player player)
        {
            try
            {
                await GameTask.DelaySeconds(1);

                if (player.IsValid() && Gamemode.Game.Instance.Round is WaitingRound)
                {
                    player.Respawn();
                }
            }
            catch (Exception e)
            {
                if (e.Message.Trim() == "A task was canceled.")
                {
                    return;
                }

                Log.Error($"[TASK] {e.Message}: {e.StackTrace}");
            }
        }
Beispiel #11
0
        private async Task deleteDelay()
        {
            await GameTask.DelaySeconds(4);

            Delete();
        }
Beispiel #12
0
        private async Task delayHudSpawn(Client cl, bool isEndGame)
        {
            await GameTask.DelaySeconds(0.25f);

            spawnInitialHud(To.Single(cl), isEndGame);
        }
Beispiel #13
0
        private static async Task changeMap()
        {
            await GameTask.DelaySeconds(6);

            ConsoleSystem.Run($"changelevel {nextMap}");
        }