Пример #1
0
        public PlayerStats()
        {
            PlayerInventory.FoodUsed  += PlayerInventoryOnFoodUsed;
            _sprintReductionMultiplier = this.Settings.GetValue <float>("stats", "sprint_reduction_multiplier", _sprintReductionMultiplier);
            _hungerReductionMultiplier = this.Settings.GetValue <float>("stats", "hunger_reduction_multiplier", _hungerReductionMultiplier);
            _thirstReductionMultiplier = this.Settings.GetValue <float>("stats", "thirst_reduction_multiplier", _thirstReductionMultiplier);
            _statDamageInterval        = this.Settings.GetValue <float>("stats", "stat_damage_interaval", _statDamageInterval);
            _statSustainLength         = this.Settings.GetValue <float>("stats", "stat_sustain_length", _statSustainLength);
            this.Settings.SetValue <bool>("stats", "use_stats", UseStats);
            this.Settings.SetValue <float>("stats", "sprint_reduction_multiplier", _sprintReductionMultiplier);
            this.Settings.SetValue <float>("stats", "hunger_reduction_multiplier", _hungerReductionMultiplier);
            this.Settings.SetValue <float>("stats", "thirst_reduction_multiplier", _thirstReductionMultiplier);
            this.Settings.SetValue <float>("stats", "stat_damage_interaval", _statDamageInterval);
            this.Settings.SetValue <float>("stats", "stat_sustain_length", _statSustainLength);
            this.Settings.Save();
            _statDisplay = new List <StatDisplayItem>();
            Stats stats = new Stats();

            foreach (Stat stat in stats.StatList)
            {
                StatDisplayItem statDisplayItem = new StatDisplayItem
                {
                    Stat = stat,
                    Bar  = new BarTimerBar(stat.Name.ToUpper())
                    {
                        ForegroundColor = Color.White,
                        BackgroundColor = Color.Gray
                    }
                };
                _statDisplay.Add(statDisplayItem);
                MenuConrtoller.BarPool.Add(statDisplayItem.Bar);
            }
            this.Tick    += (EventHandler)OnTick;
            this.Interval = 10;
        }
Пример #2
0
        private void UpdateStat(IFood item, string name, string notify, float valueOverride = 0f)
        {
            StatDisplayItem data = _statDisplay.Find((StatDisplayItem displayItem) => displayItem.Stat.Name == name);

            data.Stat.Value    += ((valueOverride <= 0f) ? item.RestorationAmount : valueOverride);
            data.Stat.Sustained = true;
            UI.Notify(notify, true);
            if (data.Stat.Value > data.Stat.MaxVal)
            {
                data.Stat.Value = data.Stat.MaxVal;
            }
        }
Пример #3
0
 private void OnTick(object sender, EventArgs e)
 {
     if (Database.PlayerIsDead)
     {
         foreach (StatDisplayItem item in _statDisplay)
         {
             item.Stat.Value = item.Stat.MaxVal;
         }
     }
     else if (!UseStats)
     {
         if (!_removedDisplay)
         {
             foreach (StatDisplayItem item2 in _statDisplay)
             {
                 MenuConrtoller.BarPool.Remove(item2.Bar);
             }
             _removedDisplay = true;
         }
     }
     else
     {
         if (_removedDisplay)
         {
             foreach (StatDisplayItem item3 in _statDisplay)
             {
                 MenuConrtoller.BarPool.Add(item3.Bar);
             }
             _removedDisplay = false;
         }
         int i = 0;
         for (int max = _statDisplay.Count; i < max; i++)
         {
             StatDisplayItem s    = _statDisplay[i];
             Stat            stat = s.Stat;
             s.Bar.Percentage = stat.Value;
             HandleReductionStat(stat, "Hunger", "You're ~r~starving~s~!", _hungerReductionMultiplier, ref _hungerDamageTimer, ref _hungerSustainTimer);
             HandleReductionStat(stat, "Thirst", "You're ~r~dehydrated~s~!", _thirstReductionMultiplier, ref _thirstDamageTimer, ref _thirstSustainTimer);
             HandleStamina(stat);
         }
     }
 }