コード例 #1
0
ファイル: Chaos.cs プロジェクト: udoprog/ChaosMod
        /// <summary>
        /// Setup a new timer.
        /// </summary>
        public Gauge Gauge(String what)
        {
            BarTimerBar bar = new BarTimerBar(what);

            timers.Add(bar);
            return(new Gauge(timers, bar));
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: theandrew61/Starman
        private void StartStarman()
        {
            string chosenTheme = starmanThemes[rnd.Next(1, starmanThemes.Length)];

            while (chosenTheme == previousTheme)
            {
                chosenTheme = starmanThemes[rnd.Next(1, starmanThemes.Length)];
            }
            previousTheme = chosenTheme;

            // get the settings when Starman is activated
            ScriptSettings tss = ScriptSettings.Load(@"scripts\Starman.ini");

            volume = float.Parse(tss.GetValue("Settings", "Volume", "0.4"));
            tss    = null;

            audioReader        = new AudioFileReader("scripts/starman/" + chosenTheme + ".mp3");
            audioReader.Volume = volume;
            DelayFadeOutSampleProvider fadeOut = new DelayFadeOutSampleProvider(audioReader);

            fadeOut.BeginFadeOut((starmanTime * 1000) - (fadeOutTime * 1000), fadeOutTime * 1000);
            waveOut = new WaveOutEvent();
            waveOut.PlaybackStopped += waveOut_PlaybackStopped;
            waveOut.Init(fadeOut);
            waveOut.Play();

            btb                 = new BarTimerBar("STARMAN POWER");
            btb.Percentage      = 1;
            btb.ForegroundColor = ExtendedColor.HSL2RGB(0, 1, 0.5);
            btb.BackgroundColor = ExtendedColor.HSL2RGB(0, 1, 0.3);
            tbPool.Add(btb);

            activated = true;
            SetInvulnerability(activated);
        }
コード例 #3
0
 public PlayerStats()
 {
     base.\u002Ector();
     PlayerInventory.FoodUsed       += new PlayerInventory.OnUsedFoodEvent(this.PlayerInventoryOnFoodUsed);
     this._sprintReductionMultiplier = (float)this.get_Settings().GetValue <float>("stats", "sprint_reduction_multiplier", (M0)(double)this._sprintReductionMultiplier);
     this._hungerReductionMultiplier = (float)this.get_Settings().GetValue <float>("stats", "hunger_reduction_multiplier", (M0)(double)this._hungerReductionMultiplier);
     this._thirstReductionMultiplier = (float)this.get_Settings().GetValue <float>("stats", "thirst_reduction_multiplier", (M0)(double)this._thirstReductionMultiplier);
     this._statDamageInterval        = (float)this.get_Settings().GetValue <float>("stats", "stat_damage_interaval", (M0)(double)this._statDamageInterval);
     this._statSustainLength         = (float)this.get_Settings().GetValue <float>("stats", "stat_sustain_length", (M0)(double)this._statSustainLength);
     this.get_Settings().SetValue <bool>("stats", "use_stats", (M0)(PlayerStats.UseStats ? 1 : 0));
     this.get_Settings().SetValue <float>("stats", "sprint_reduction_multiplier", (M0)(double)this._sprintReductionMultiplier);
     this.get_Settings().SetValue <float>("stats", "hunger_reduction_multiplier", (M0)(double)this._hungerReductionMultiplier);
     this.get_Settings().SetValue <float>("stats", "thirst_reduction_multiplier", (M0)(double)this._thirstReductionMultiplier);
     this.get_Settings().SetValue <float>("stats", "stat_damage_interaval", (M0)(double)this._statDamageInterval);
     this.get_Settings().SetValue <float>("stats", "stat_sustain_length", (M0)(double)this._statSustainLength);
     this.get_Settings().Save();
     this._statDisplay = new List <StatDisplayItem>();
     foreach (Stat stat in new Stats().StatList)
     {
         StatDisplayItem statDisplayItem1 = new StatDisplayItem();
         statDisplayItem1.Stat = stat;
         BarTimerBar barTimerBar = new BarTimerBar(stat.Name.ToUpper());
         barTimerBar.set_ForegroundColor(Color.White);
         barTimerBar.set_BackgroundColor(Color.Gray);
         statDisplayItem1.Bar = barTimerBar;
         StatDisplayItem statDisplayItem2 = statDisplayItem1;
         this._statDisplay.Add(statDisplayItem2);
         MenuConrtoller.BarPool.Add((TimerBarBase)statDisplayItem2.Bar);
     }
     this.add_Tick(new EventHandler(this.OnTick));
     this.set_Interval(10);
 }
コード例 #4
0
ファイル: Chaos.cs プロジェクト: udoprog/ChaosMod
 public PlayerTimer(TimerBarPool pool, BarTimerBar bar, float duration)
 {
     this.pool     = pool;
     this.bar      = bar;
     this.duration = duration;
     this.elapsed  = 0f;
 }
コード例 #5
0
ファイル: TimerBars.cs プロジェクト: Scaarus/RAGENativeUI
 private void CreateTimerBars()
 {
     tbPool      = new TimerBarPool();
     text        = new TextTimerBar("LABEL", "TEXT");
     progressBar = new BarTimerBar("PROGRESS");
     checkpoints = new CheckpointsTimerBar("CHECKPOINTS", 4);
     icons       = new IconsTimerBar("ICONS");
 }
コード例 #6
0
ファイル: Chaos.cs プロジェクト: udoprog/ChaosMod
        /// <summary>
        /// Setup a new timer.
        /// </summary>
        public PlayerTimer Timer(String what, float duration)
        {
            BarTimerBar bar = new BarTimerBar(what);

            bar.ForegroundColor = Color.White;
            bar.BackgroundColor = Color.DimGray;
            timers.Add(bar);
            return(new PlayerTimer(timers, bar, duration));
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: theandrew61/Starman
        private void EndStarman()
        {
            activated = false;
            SetInvulnerability(activated);

            if (btb != null)
            {
                tbPool.Remove(btb);
                btb = null;
            }

            dateTimeThatStarmanWasInitiated = janFirst1970;
        }
コード例 #8
0
        public DistanceRaceGui()
        {
            timerBarPool = new TimerBarPool();
            timeBar      = new TextTimerBar("Time", "0:00");
            timerBarPool.Add(timeBar);

            positionBar = new TextTimerBar("Position", "");
            timerBarPool.Add(positionBar);

            distanceBar = new BarTimerBar("Distance");
            distanceBar.BackgroundColor = Color.Black;
            distanceBar.ForegroundColor = Color.White;
            timerBarPool.Add(distanceBar);
        }
コード例 #9
0
 public Stats()
 {
     Tick     += OnTick;
     hudPool   = new TimerBarPool();
     hungerBar = new BarTimerBar("~y~HUNGER");
     thirstBar = new BarTimerBar("~b~THIRST");
     energyBar = new BarTimerBar("~g~ENERGY");
     hungerBar.BackgroundColor = Color.Gray;
     hungerBar.ForegroundColor = Color.Yellow;
     thirstBar.BackgroundColor = Color.Gray;
     thirstBar.ForegroundColor = Color.Blue;
     energyBar.BackgroundColor = Color.Gray;
     energyBar.ForegroundColor = Color.Green;
     hudPool.Add(energyBar);
     hudPool.Add(thirstBar);
     hudPool.Add(hungerBar);
 }
コード例 #10
0
 public Stats()
 {
     base.Tick     += new EventHandler(this.OnTick);
     this.hudPool   = new TimerBarPool();
     this.hungerBar = new BarTimerBar("~y~HUNGER");
     this.thirstBar = new BarTimerBar("~b~THIRST");
     this.energyBar = new BarTimerBar("~g~ENERGY");
     this.hungerBar.BackgroundColor = Color.Gray;
     this.hungerBar.ForegroundColor = Color.Yellow;
     this.thirstBar.BackgroundColor = Color.Gray;
     this.thirstBar.ForegroundColor = Color.Blue;
     this.energyBar.BackgroundColor = Color.Gray;
     this.energyBar.ForegroundColor = Color.Green;
     this.hudPool.Add(this.energyBar);
     this.hudPool.Add(this.thirstBar);
     this.hudPool.Add(this.hungerBar);
 }
コード例 #11
0
        public static void Main()
        {
            Game.FrameRender += Process;

            timerBarPool = new TimerBarPool();

            barTimerBar = new BarTimerBar("BAR");
            textTimerBar = new TextTimerBar("TIME", "00:00");
            textTimerBar2 = new TextTimerBar("SPEED", "0 km/h");

            timerBarPool.Add(barTimerBar);
            timerBarPool.Add(textTimerBar);
            timerBarPool.Add(textTimerBar2);

            while (true)
                GameFiber.Yield();
        }
コード例 #12
0
 public MerryweatherSurvivors(int timeout)
 {
     PedHash[] obj = new PedHash[3];
     obj[0]     = PedHash.Armoured01SMM;
     obj[1]     = PedHash.Armoured02SMM;
     obj[2]     = PedHash.Armymech01SMY;
     _pedHashes = (PedHash[])obj;
     WeaponHash[] obj2 = new WeaponHash[5];
     obj2[0]  = WeaponHash.AssaultRifle;
     obj2[1]  = WeaponHash.AssaultShotgun;
     obj2[2]  = WeaponHash.AssaultSMG;
     obj2[3]  = WeaponHash.MarksmanRifle;
     obj2[4]  = WeaponHash.SMG;
     _weapons = (WeaponHash[])obj2;
     //base._002Ector();
     _timerBar    = new BarTimerBar("TIME LEFT");
     _timeOut     = timeout;
     _currentTime = (float)_timeOut;
 }
コード例 #13
0
        public static void Main(Vector3 loc)
        {
            "Starting TimerBar Main".AddLog();
            _distance = Game.LocalPlayer.Character.TravelDistanceTo(loc);
            _loc      = loc;

            _timerBarPool = new TimerBarPool();

            _barTimerBar = new BarTimerBar("Distance Remaining");
            _barTimerBar.ForegroundColor = Color.Yellow;

            _timerBarPool.Add(_barTimerBar);

            "Starting TimerBar Process".AddLog();
            Game.FrameRender += Process;

            while (true)
            {
                GameFiber.Yield();
            }
        }
コード例 #14
0
        private static void Main()
        {
            // create the pool that handles drawing the timer bars
            pool = new TimerBarPool();

            // timer bar that shows the player health as a progress bar and is highlighted in red when the player is damaged
            BarTimerBar healthTB = new BarTimerBar("HEALTH");

            // timer bar that shows the player speed
            TextTimerBar speedTB = new TextTimerBar("SPEED", "0 km/h");

            // timer bar that shows the time of day
            TextTimerBar clockTB = new TextTimerBar("CLOCK", "00:00:00");

            // use monospace font for the time text
            clockTB.TextStyle = clockTB.TextStyle.With(font: TextFont.ChaletLondonFixedWidthNumbers);

            // timer bar that shows the player equipped weapon as an icon
            IconsTimerBar weaponTB = new IconsTimerBar("WEAPON");

            weaponTB.Icons.Add(new TimerBarIcon("commonmenu", "arrowleft")
            {
                Size    = new SizeF(TimerBarIcon.DefaultSize.Width * 0.825f, TimerBarIcon.DefaultSize.Height * 0.825f),
                Spacing = TimerBarIcon.DefaultSpacing * 2.75f
            });
            weaponTB.Icons.Add(new TimerBarIcon("mpkillquota", "weapon_unarmed"));

            // timer bar that shows the wanted level as checkpoints
            Color checkpointsColor            = HudColor.Gold.GetColor();
            CheckpointsTimerBar wantedLevelTB = new CheckpointsTimerBar("WANTED", 5)
            {
                Accent = checkpointsColor
            };

            foreach (TimerBarCheckpoint cp in wantedLevelTB.Checkpoints)
            {
                cp.Color = checkpointsColor;
            }

            // add all the timer bars to the pool
            pool.Add(healthTB, speedTB, clockTB, weaponTB, wantedLevelTB);

            // start the fiber which will handle drawing the timer bars
            GameFiber.StartNew(ProcessTimerBars);

            // continue with the plugin...
            Game.Console.Print($"  {healthTB.Label}: shows the player health.");
            Game.Console.Print($"  {speedTB.Label}: shows the player speed in kilometers per hour");
            Game.Console.Print($"  {clockTB.Label}: shows the current time of day");
            Game.Console.Print($"  {weaponTB.Label}: shows the type of the weapon currently equipped");
            Game.Console.Print($"  {wantedLevelTB.Label}: shows the player wanted level.");

            float       lastHealth   = 0.0f;
            float       healthDamage = 0.0f;
            const float HealthDamageIndicatorDuration = 2.0f; // seconds

            while (true)
            {
                GameFiber.Yield();

                Ped playerPed = Game.LocalPlayer.Character;

                // update speedometer timer bar
                {
                    int speed = MathHelper.ConvertMetersPerSecondToKilometersPerHourRounded(playerPed.Speed);
                    speedTB.Text = $"{speed} km/h";
                }

                // update clock timer bar
                {
                    clockTB.Text = World.TimeOfDay.ToString();
                }

                // update health timer bar
                {
                    float health             = (float)(playerPed.Health - 100) / (playerPed.MaxHealth - 100);
                    bool  hasReceivedDamaged = health < lastHealth;
                    lastHealth = health;

                    healthTB.Percentage = health;

                    healthTB.ForegroundColor = (health < 0.25 ? HudColor.RadarDamage : HudColor.RadarHealth).GetColor();
                    healthTB.BackgroundColor = Color.FromArgb(120, healthTB.ForegroundColor);


                    if (healthDamage > 0.0f)
                    {
                        // set highlight and fade it out
                        healthTB.Highlight = Color.FromArgb((int)(healthDamage * 255), HudColor.RadarDamage.GetColor());
                        healthDamage      -= (1.0f / HealthDamageIndicatorDuration) * Game.FrameTime;
                    }
                    else
                    {
                        healthTB.Highlight = null;

                        if (hasReceivedDamaged)
                        {
                            healthDamage = 1.0f;
                        }
                    }
                }

                // update weapon timer bar
                {
                    // choose a new texture based on the equipped weapon
                    var tex = playerPed.CurrentVehicle.Exists() ?
                              ("mpcarhud", "transport_car_icon", 1.1f, 1.1f) :
                              playerPed.Inventory.EquippedWeapon switch
                    {
                        null => ("mpkillquota", "weapon_unarmed", 2.75f, 1.25f),
                        var w => NativeFunction.Natives.GetWeapontypeGroup <uint>(w.Asset.Hash) switch
                        {
                            0x18D5FA97u /* group_pistol  */ => ("mpkillquota", "weapon_pistol", 2.75f, 1.25f),
                            0x33431399u /* group_shotgun */ => ("mpkillquota", "weapon_shotgun_pump", 2.7f, 1.3f),
                            _ => ("mpkillquota", "weapon_rifle_carbine", 2.75f, 1.25f)
                        }
                    };

                    var icon = weaponTB.Icons[1];
                    icon.TextureDictionary = tex.Item1;
                    icon.TextureName       = tex.Item2;
                    var s = TimerBarIcon.DefaultSize;
                    icon.Size = new SizeF(s.Width * tex.Item3, s.Height * tex.Item4);
                }

                // update wanted level timer bar
                {
                    int level = Game.LocalPlayer.WantedLevel;
                    for (int i = 0; i < wantedLevelTB.Checkpoints.Count; i++)
                    {
                        wantedLevelTB.Checkpoints[i].State        = i < level ? TimerBarCheckpointState.Completed : TimerBarCheckpointState.InProgress;
                        wantedLevelTB.Checkpoints[i].IsCrossedOut = i < level - 1;
                    }
                }
            }
        }
コード例 #15
0
        private static int GetNumberOfVehicleDoors(Vehicle veh) => NativeFunction.Natives.x92922A607497B14D <int>(veh); // _GET_NUMBER_OF_VEHICLE_DOORS

        private void SpeedBombRoutine()
        {
            var veh = CurrentVehicle;

            if (!veh)
            {
                return;
            }

            float maxSpeed = MathHelper.ConvertMetersPerSecondToKilometersPerHour(veh.TopSpeed - 5.0f); // kmph
            float minSpeed = maxSpeed - 50.0f;                                                          // kmph

            var timerBars = new TimerBarPool();
            var speedTB   = new BarTimerBar("SPEED");

            speedTB.Markers.Add(new TimerBarMarker(minSpeed / maxSpeed));
            var detonationTB = new BarTimerBar("DETONATION");
            var timeTB       = new TextTimerBar("TIME TO DISARM", "00:00");

            timeTB.TextStyle = timeTB.TextStyle.With(font: TextFont.ChaletLondonFixedWidthNumbers);

            timerBars.Add(speedTB, timeTB);

            const uint  DisarmTime     = 120_000; // ms
            const float DetonationTime = 10.0f;   // s

            bool  hasEnoughSpeed      = false;
            bool  isDetonationTBAdded = false;
            float detonation          = 0.0f;
            uint  endTime             = Game.GameTime + DisarmTime;

            while (veh)
            {
                float speed = MathHelper.ConvertMetersPerSecondToKilometersPerHour(veh.Speed);

                if (speed >= minSpeed)
                {
                    if (!hasEnoughSpeed)
                    {
                        speedTB.ForegroundColor = HudColor.Green.GetColor();
                        speedTB.BackgroundColor = Color.FromArgb(120, speedTB.ForegroundColor);
                        hasEnoughSpeed          = true;
                    }

                    detonation -= (1.0f / DetonationTime * 1.5f) * Game.FrameTime;
                }
                else
                {
                    if (hasEnoughSpeed)
                    {
                        speedTB.ForegroundColor = HudColor.Red.GetColor();
                        speedTB.BackgroundColor = Color.FromArgb(120, speedTB.ForegroundColor);
                        if (detonation < 0.0f)
                        {
                            detonation = 0.0f;
                        }
                        hasEnoughSpeed = false;
                    }

                    detonation += (1.0f / DetonationTime) * Game.FrameTime;

                    if (detonation >= 1.0f)
                    {
                        veh.Explode(makeExplosion: true);
                        break;
                    }
                }
                detonationTB.Percentage = detonation;

                if (isDetonationTBAdded)
                {
                    if (detonation <= 0.0f)
                    {
                        timerBars.Remove(detonationTB);
                        isDetonationTBAdded = false;
                    }
                }
                else
                {
                    if (detonation > 0.0f)
                    {
                        timerBars.Clear(); // note, there is no Insert at index
                        timerBars.Add(speedTB, detonationTB, timeTB);
                        isDetonationTBAdded = true;
                    }
                }

                speedTB.Percentage = speed / maxSpeed;

                uint currTime = Game.GameTime;
                if (currTime >= endTime)
                {
                    break;
                }
                else
                {
                    uint remaining = endTime - currTime;
                    timeTB.Text = TimeSpan.FromMilliseconds(remaining).ToString("mm\\:ss");
                }

                timerBars.Draw();

                GameFiber.Yield();
            }

            speedBomb.Enabled = CurrentVehicle;
            speedBombFiber    = null;
        }
コード例 #16
0
ファイル: Chaos.cs プロジェクト: udoprog/ChaosMod
 public Gauge(TimerBarPool pool, BarTimerBar bar)
 {
     this.pool    = pool;
     this.bar     = bar;
     this.visible = true;
 }