using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
public class SliderLerp : MonoBehaviour {
///
///
///
private Slider mOwner = null;
///
///
///
private float mRate = 0;
///
///
///
private float mCurt = 0;
///
/// 耗时(毫秒)
///
private float mTime = 0;
///
/// 速度1500毫秒
///
private float mSpeed = 0.2f;
///
/// 发光条
///
private Transform mGlow = null;
///
/// 下面的计数框
///
private Transform mHandle = null;
///
/// 是否十连
///
public bool mBoolTen = false;
///
/// 是否结束
///
public bool mBoolOver = true;
///
///
///
public void InitComponents()
{
// Handle Slide Area
this.mOwner = GetComponent();
mGlow = transform.Find("Fill Area/Fill/glow");
if (mGlow != null)
{
mGlow.gameObject.SetActive(false);
}
mHandle = transform.Find("Handle Slide Area/Handle");
}
///
///
///
public void SetData(float _rate)
{
this.mCurt = _rate;
this.mRate = _rate;
}
///
///
///
/// 值
public void SetValueLerp(float _rate)
{
this.mRate = _rate;
this.mBoolOver = false;
if (mGlow != null)
{
mGlow.gameObject.SetActive(true);
}
if (mHandle != null && mBoolTen )
{
mHandle.GetComponent().Play("LuckSilder");
}
}
///
///
///
void Update()
{
if (this.mOwner == null)
{
return;
}
this.mCurt = Mathf.Lerp(this.mCurt, this.mRate, mSpeed);
this.mOwner.value = this.mCurt;
if (mHandle != null)
{
Transform temptxt = null;
temptxt = mHandle.Find("NumText");
// LogHelper.Log(temptxt);
if (temptxt != null)
{
// LogHelper.Log(((int)this.mOwner.value * 100).ToString());
temptxt.GetComponent().text = (Math.Round(this.mOwner.value * 100, 0)).ToString();
}
}
if (mRate == 0)
{
if (mGlow != null)
{
mGlow.gameObject.SetActive(false);
}
if (mHandle != null && mBoolTen && !mBoolOver)
{
mHandle.GetComponent().Play("LuckSliderStop");
}
this.mBoolOver = true;
}
else if ((mCurt / mRate )> 0.98f )
{
if (mGlow != null)
{
mGlow.gameObject.SetActive(false);
}
if (mHandle != null && mBoolTen && !mBoolOver)
{
mHandle.GetComponent().Play("LuckSliderStop");
}
this.mBoolOver = true;
}
}
}