예제 #1
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;
        }
예제 #2
0
        private void startClientMeter()           // Set up the meter and start it counting down locally
        {
            clientCollector    = Local.Pawn as TankPlayer;
            timeSinceCollected = 0;

            meter = GameHud.Current.RootPanel.ChildrenOfType <PowerUpFeed>().First().RegisterPowerUp();
            meter.Icon.Style.BackgroundColor = iconColor;
            meter.Icon.Style.Dirty();
            if (!string.IsNullOrEmpty(iconImage))
            {
                meter.Icon.SetTexture(iconImage);
            }
            meter.ProgressBar.Style.BackgroundColor = meterColor;
            meter.ProgressBar.Style.Dirty();

            meterWidth.Unit = LengthUnit.Pixels;
            _ = countDownMeter();
        }