public void ShowSliderTime(float start, float max, float zeroToMaxTime, System.Action callback) { if (start >= max) { if (hudSliderTime != null) { hudSliderTime.Hide(); } if (callback != null) { callback(); } } else { if (hudSliderTime == null) { string _path = "prefabs/uis/p_hud_time_slider"; hudSliderTime = UIMgr.instance.CreateHud(_path, Camera.main, hudAnchor, SLIDER_OFFSET) as HudSlider; UIMgr.instance.SetHudVisible(true, false); hudGos.Add(hudSliderTime.gameObject); } hudSliderTime.SetValue(start / max); float delta = max - start; float totalTime = zeroToMaxTime * delta / max; sliderTimeAction = Scheduler.Create(this, (sche, t, s) => { if (hudSliderTime == null) { return; } if (t >= s) { hudSliderTime.Hide(); if (callback != null) { callback(); } } else { hudSliderTime.SetValue((start + t / s * delta) / max); } }, 0f, totalTime, 0f).actionId; } }
public void ShowSliderEnergy(float start, float max) { if (hudSliderEnergy == null) { string _path = "prefabs/uis/p_hud_energy_slider"; hudSliderEnergy = UIMgr.instance.CreateHud(_path, Camera.main, hudAnchor, ENERGY_OFFSET) as HudSlider; UIMgr.instance.SetHudVisible(true, false); hudGos.Add(hudSliderEnergy.gameObject); } hudSliderEnergy.SetValue(start / max); }
public void UpdateValue(float max, float current) { text.text = string.Format("{0}/{1}", current, max); slider.SetValue(current / max); }