Ejemplo n.º 1
0
 /// <summary>
 ///     更新玩家血量
 /// </summary>
 /// <param name="curHp">当前血量</param>
 /// <param name="hp">总血量</param>
 public void UpdateHealth(int curHp, int hp)
 {
     if (curHp < 0)
     {
         curHp = 0;
     }
     _healthLabel.text = curHp + "/" + hp;
     TweenSlider.Begin(_sldHp.gameObject, 0.5f, (float)curHp / hp);
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     更新玩家魔法
 /// </summary>
 /// <param name="curMp">当前魔法</param>
 /// <param name="mp">总魔法</param>
 public void UpdateMagic(int curMp, int mp)
 {
     if (curMp < 0)
     {
         curMp = 0;
     }
     _magicLabel.text = curMp + "/" + mp;
     TweenSlider.Begin(_sldMagic.gameObject, 0.5f, (float)curMp / mp);
 }
Ejemplo n.º 3
0
    public static TweenSlider Begin(GameObject go, float duration, float fill)
    {
        TweenSlider tweenSlider = UITweener.Begin <TweenSlider>(go, duration);

        tweenSlider.from = tweenSlider.value;
        tweenSlider.to   = fill;
        if (duration <= 0f)
        {
            tweenSlider.Sample(1f, true);
            tweenSlider.enabled = false;
        }
        return(tweenSlider);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenSlider Begin(GameObject go, float duration, float value)
    {
        TweenSlider comp = UITweener.Begin <TweenSlider>(go, duration);

        comp.from = comp.value;
        comp.to   = value;

        if (duration <= 0.0f)
        {
            comp.Sample(1.0f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 5
0
        private void StepTo(int idx_)
        {
            if (1 == idx_)
            {
                this.m_title_root.Visible = true;
                this.m_lvl_root.Visible   = false;
                this.m_grid.Visible       = false;
                this.m_ok_btn.Visible     = false;

                m_title_effect.Visible = true;


                float pending_time = 1.5f;

                TimeModule.Instance.SetTimeout(() => StepTo(++m_idx), pending_time);
            }
            else if (2 == idx_)
            {
                this.m_title_root.Visible = true;
                this.m_lvl_root.Visible   = true;
                this.m_grid.Visible       = false;
                this.m_ok_btn.Visible     = false;

                m_lvl_effect.Visible     = true;
                m_lvl_bar_effect.Visible = true;

                float pending_time = 0.5f;

                m_lvl_bar_effect.Visible = true;

                m_lvl_slider.Value = 0;
                TweenSlider.BeginTween(m_lvl_slider.gameObject, 1.0f, pending_time);
                m_cur_vit_txt.Text = "0";
                DOTween.To(() => float.Parse(m_cur_vit_txt.Text), (value) => m_cur_vit_txt.Text = value.ToString(), m_max_vit, pending_time);
                //TweenText.Begin(m_cur_vit_txt.Label, pending_time, 0f, 0f, m_max_vit);
                TimeModule.Instance.SetTimeInterval(StartRefreshExpUIEffect, 0.0001f);

                EngineCoreEvents.AudioEvents.PlayAudio.SafeInvoke(Audio.AudioType.UISound, GameCustomAudioKey.vit_full.ToString());

                TimeModule.Instance.SetTimeout(() => StepTo(++m_idx), pending_time);
            }
            else if (3 == idx_)
            {
                this.m_title_root.Visible = true;
                this.m_lvl_root.Visible   = true;
                this.m_grid.Visible       = true;
                this.m_ok_btn.Visible     = true;
            }
        }
Ejemplo n.º 6
0
    public static TweenSlider Begin(Slider slider, float duration, float delay, float from, float to)
    {
        TweenSlider comp = UITweener.Begin <TweenSlider>(slider.gameObject, duration);

        comp.from  = from;
        comp.to    = to;
        comp.delay = delay;

        if (duration <= 0)
        {
            comp.Sample(1, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 7
0
    static public TweenSlider Begin(UISlider slider, float duration, float value)
    {
        TweenSlider comp = UITweener.Begin <TweenSlider>(slider.gameObject, duration);

        if (comp != null)
        {
            comp.from   = comp.Value;
            comp.to     = value;
            comp.slider = slider;
            if (duration <= 0.0f)
            {
                comp.Sample(1.0f, true);
                comp.enabled = false;
            }
        }
        return(comp);
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public TweenSlider Begin(GameObject go, float duration, float number)
    {
                #if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return(null);
        }
                #endif
        TweenSlider comp = UITweener.Begin <TweenSlider>(go, duration);
        comp.from = comp.number;
        comp.to   = number;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
Ejemplo n.º 9
0
    static public TweenSlider Begin(UISlider slider, float value, float speed, float maxDuration)
    {
        TweenSlider comp = UITweener.Begin <TweenSlider>(slider.gameObject, 1f);

        if (comp != null)
        {
            comp.from   = comp.Value;
            comp.to     = value;
            comp.slider = slider;

            comp.duration = Mathf.Max(0.1f, Mathf.Min(Mathf.Abs(comp.to = comp.from) / speed, maxDuration));

            if (speed < 0.0f)
            {
                comp.Sample(1.0f, true);
                comp.enabled = false;
            }
        }
        return(comp);
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 设置精炼成功UI
    /// </summary>
    /// <param name="data"></param>
    private void SetRefineSuccessProbability(int percent, bool showPercent = true)
    {
        if (null != m_slider_RefineSuccessSlider && m_bool_playRefAnim)
        {
            m_bool_playRefAnim = false;
            TweenSlider ts = m_slider_RefineSuccessSlider.GetComponent <TweenSlider>();
            if (null != ts)
            {
                ts.from = 0;
                ts.to   = percent / 100f;
                ts.ResetToBeginning();
                ts.enabled = true;
            }
        }

        if (null != m_label_RefineSuccessProp && m_label_RefineSuccessProp.gameObject.activeSelf != showPercent)
        {
            m_label_RefineSuccessProp.gameObject.SetActive(showPercent);
        }
    }
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6.0f);
        NGUIEditorTools.SetLabelWidth(120f);

        TweenSlider tw = target as TweenSlider;

        GUI.changed = false;

        float from = EditorGUILayout.FloatField("From", tw.from);
        float to   = EditorGUILayout.FloatField("To", tw.to);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Tween Change", tw);
            tw.from = Mathf.Clamp(from, 0.0f, 1.0f);
            tw.to   = Mathf.Clamp(to, 0.0f, 1.0f);
            UnityEditor.EditorUtility.SetDirty(tw);
        }

        DrawCommonProperties();
    }