/// <summary> /// Converts amount to slider value. (0 - 1) /// </summary> /// <returns>Slider value. 0 - 1</returns> /// <param name="timeLeft">Time left to add one energy</param> public static float ConvertToSliderValue(TimeSpan timeLeft, TimeBasedValue timeBasedValue) { float result = 0f; long timeToAddDuration = timeBasedValue.GetTimeToAddEnergy(); long timeLeftDuration = (long)timeLeft.TotalSeconds; long percent = (100 * timeLeftDuration) / timeToAddDuration; result = percent / 100f; return(result); }
void OnAmountChanged(int amount, TimeBasedValue timeBasedValue) { string text = amount + "/" + timeBasedValue.MaxAmount; switch (timeBasedValue.Type) { case TimeValue.Life: CurrentLifeAmountText.text = text; break; case TimeValue.Key: CurrentKeyAmountText.text = text; break; default: break; } }
void OnTimeLeftChanged(TimeSpan timeLeft, TimeBasedValue timeBasedValue) { string formatString = string.Format("{0:00}:{1:00}", timeLeft.Minutes, timeLeft.Seconds); float sliderValue = EnergySuiteManager.ConvertToSliderValue(timeLeft, timeBasedValue); switch (timeBasedValue.Type) { case TimeValue.Life: LifeTimeLeftText.text = formatString; LifeTimeLeftSlider.value = sliderValue; break; case TimeValue.Key: KeyTimeLeftText.text = formatString; KeyTimeLeftSlider.value = sliderValue; break; default: break; } }
public void CustomInit(TimeBasedValue timeBasedValue) { TimeServHandler = new TimeServerHandler(this, timeBasedValue); TimeBasedValue = timeBasedValue; initialState = State.Init; }
public TimeServerHandler(EnergySuiteValueBehaviour energySuiteValueBehaviour, TimeBasedValue timeBasedValue) { _timeBasedValue = timeBasedValue; _energySuiteValueBehaviour = energySuiteValueBehaviour; }