Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
        private void UpdateStat(IFood item, string name, string notify, float valueOverride = 0.0f)
        {
            StatDisplayItem statDisplayItem = this._statDisplay.Find((Predicate <StatDisplayItem>)(displayItem => displayItem.Stat.Name == name));

            statDisplayItem.Stat.Value    += (double)valueOverride <= 0.0 ? item.RestorationAmount : valueOverride;
            statDisplayItem.Stat.Sustained = true;
            UI.Notify(notify, true);
            if ((double)statDisplayItem.Stat.Value <= (double)statDisplayItem.Stat.MaxVal)
            {
                return;
            }
            statDisplayItem.Stat.Value = statDisplayItem.Stat.MaxVal;
        }
Exemplo n.º 3
0
 private void OnTick(object sender, EventArgs e)
 {
     if (Database.PlayerIsDead)
     {
         foreach (StatDisplayItem statDisplayItem in this._statDisplay)
         {
             statDisplayItem.Stat.Value = statDisplayItem.Stat.MaxVal;
         }
     }
     else if (!PlayerStats.UseStats)
     {
         if (this._removedDisplay)
         {
             return;
         }
         foreach (StatDisplayItem statDisplayItem in this._statDisplay)
         {
             MenuConrtoller.BarPool.Remove((TimerBarBase)statDisplayItem.Bar);
         }
         this._removedDisplay = true;
     }
     else
     {
         if (this._removedDisplay)
         {
             foreach (StatDisplayItem statDisplayItem in this._statDisplay)
             {
                 MenuConrtoller.BarPool.Add((TimerBarBase)statDisplayItem.Bar);
             }
             this._removedDisplay = false;
         }
         int index = 0;
         for (int count = this._statDisplay.Count; index < count; ++index)
         {
             StatDisplayItem statDisplayItem = this._statDisplay[index];
             Stat            stat            = statDisplayItem.Stat;
             statDisplayItem.Bar.set_Percentage(stat.Value);
             this.HandleReductionStat(stat, "Hunger", "You're ~r~starving~s~!", this._hungerReductionMultiplier, ref this._hungerDamageTimer, ref this._hungerSustainTimer);
             this.HandleReductionStat(stat, "Thirst", "You're ~r~dehydrated~s~!", this._thirstReductionMultiplier, ref this._thirstDamageTimer, ref this._thirstSustainTimer);
             this.HandleStamina(stat);
         }
     }
 }