Set() публичный Метод

Update the visible slider.
public Set ( float input, bool force ) : void
input float
force bool
Результат void
Пример #1
0
 public void UpdateHpValue()
 {
     if (AssignedHpBarSlider != null)
     {
         AssignedHpBarSlider.Set((float)Health.Current / Health.Max);
         Health.Percent = AssignedHpBarSlider.value;
     }
 }
Пример #2
0
        public void UpdateValue()
        {
            int      cur      = attr == null ? 0 : attr.CurValue;
            int      max      = attr == null ? 0 : attr.MaxValue;
            int      addValue = attr == null ? 0 : attr.BuffValue;
            UISlider bar      = trans.GetComponent <UISlider>();

            bar.Set((float)cur / max);
            UILabel label = trans.Find("cur").GetComponent <UILabel>();

            label.text  = cur.ToString() + (addValue > 0 ? ("(" + addValue.ToString() + ")") : "");
            label.color = addValue == 0 ? Color.white : (addValue < 0 ? Color.red : Color.green);
            label       = trans.Find("max").GetComponent <UILabel>();
            label.text  = max.ToString();
        }
Пример #3
0
    void ShowSlider(UISlider slider, int curValue, int totalValue)
    {
        UILabel label = slider.transform.Find("Percent").GetComponent <UILabel>();
        string  str   = "" + curValue + "/" + totalValue;

        label.text = str;
        if (totalValue == 0)
        {
            curValue   = 0;
            totalValue = 10000;
            Log.Info("total value is 0");
        }
        float precent = (float)(curValue * 1.0f / totalValue * 1.0f);

        slider.Set(precent);
    }
Пример #4
0
    void InitSliderData()
    {
        if (CurPet == null)
        {
            return;
        }
        int level    = CurPet.GetProp((int)CreatureProp.Level);
        int petstate = CurPet.GetProp((int)PetProp.PetGuiYuanStatus);
        //PetUpGradeDataBase db = GetPetUpGradeDataBase( (uint)level , petstate );
        PetDataBase       db       = petDataManager.GetPetDataBase(CurPet.PetBaseID);
        int               yinhunLv = CurPet.GetProp((int)PetProp.YinHunLevel);
        PetYinHunDataBase ydb      = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)yinhunLv);
        uint              jiacheng = 0;

        if (ydb != null)
        {
            jiacheng = ydb.jiaChengBi;
        }
        float factor = 1 + (float)(jiacheng * 1.0f / 10000);

        if (db != null)
        {
            string   talent     = db.PetTalent;
            string[] zizhiArray = talent.Split(';');
            var      iter       = sliderDic.GetEnumerator();
            while (iter.MoveNext())
            {
                var sliderPair = iter.Current;
                int curValue   = petDataManager.GetPropByString(sliderPair.Key);
                if (m_type == PetSliderGroupType.GuiYuan)
                {
                    curValue = Mathf.RoundToInt(curValue * 1.0f / factor);
                }
                m_nCurValue = curValue;
                uint   totalValue = 0;
                int    maxValue   = 0;
                string tempStr    = "";
                int    low        = 0;
                if (sliderPair.Key == PetProp.LevelExp.ToString())
                {
                    // totalValue = db.upGradeExp;
                }
                else if (sliderPair.Key == PetProp.StrengthTalent.ToString())
                {
                    if (zizhiArray.Length > 0)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[0], ref tempStr, ref low, ref maxValue);
                    }
                }
                else if (sliderPair.Key == PetProp.AgilityTalent.ToString())
                {
                    if (zizhiArray.Length > 1)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[1], ref tempStr, ref low, ref maxValue);
                    }
                }
                else if (sliderPair.Key == PetProp.IntelligenceTalent.ToString())
                {
                    if (zizhiArray.Length > 2)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[2], ref tempStr, ref low, ref maxValue);
                    }
                }
                else if (sliderPair.Key == PetProp.CorporeityTalent.ToString())
                {
                    if (zizhiArray.Length > 3)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[3], ref tempStr, ref low, ref maxValue);
                    }
                }
                else if (sliderPair.Key == PetProp.SpiritTalent.ToString())
                {
                    if (zizhiArray.Length > 4)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[4], ref tempStr, ref low, ref maxValue);
                    }
                }
                UISlider slider = sliderPair.Value;
                UILabel  label  = slider.transform.Find("Percent").GetComponent <UILabel>();
                string   str    = string.Format("{0}/{1}", curValue, maxValue);
                //string str = curValue.ToString();// +"" + tempStr;
                label.text = str;
                if (totalValue == 0)
                {
                    totalValue = (uint)curValue;
                    if (totalValue == 0)
                    {
                        totalValue = 10000;
                    }
                    Log.Info("total value is 0");
                }
                curValue = curValue - low;
                float precent = (float)(curValue * 1.0f / totalValue * 1.0f);
                slider.Set(precent);
            }
        }
    }
Пример #5
0
    void InitSliderData()
    {
        if (CurPet == null)
        {
            return;
        }
        int level    = CurPet.GetProp((int)CreatureProp.Level);
        int petstate = CurPet.GetProp((int)PetProp.PetGuiYuanStatus);
        //PetUpGradeDataBase db = GetPetUpGradeDataBase( (uint)level , petstate );
        PetDataBase db = petDataManager.GetPetDataBase(CurPet.PetBaseID);

        int yinhunLv          = CurPet.GetProp((int)PetProp.YinHunLevel);
        PetYinHunDataBase ydb = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)yinhunLv);
        uint jiacheng         = 0;

        if (ydb != null)
        {
            jiacheng = ydb.jiaChengBi;
        }
        float factor = 1 + (float)(jiacheng * 1.0f / 10000);

        if (db != null)
        {
            string            talent        = db.PetTalent;
            string[]          zizhiArray    = talent.Split(';');
            GameCmd.PetTalent replaceTalent = CurPet.GetReplaceTalent();
            foreach (var sliderPair in sliderDic)
            {
                uint   curValue   = 0;
                uint   totalValue = 0;
                string tempStr    = "";
                int    low        = 0;
                if (sliderPair.Key == PetProp.LevelExp.ToString())
                {
                    // totalValue = db.upGradeExp;
                }
                else if (sliderPair.Key == PetProp.StrengthTalent.ToString())
                {
                    curValue = replaceTalent.liliang;
                    if (zizhiArray.Length > 0)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[0], ref tempStr, ref low);
                    }
                }
                else if (sliderPair.Key == PetProp.AgilityTalent.ToString())
                {
                    curValue = replaceTalent.minjie;
                    if (zizhiArray.Length > 1)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[1], ref tempStr, ref low);
                    }
                }
                else if (sliderPair.Key == PetProp.IntelligenceTalent.ToString())
                {
                    curValue = replaceTalent.zhili;
                    if (zizhiArray.Length > 2)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[2], ref tempStr, ref low);
                    }
                }
                else if (sliderPair.Key == PetProp.CorporeityTalent.ToString())
                {
                    curValue = replaceTalent.tizhi;
                    if (zizhiArray.Length > 3)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[3], ref tempStr, ref low);
                    }
                }
                else if (sliderPair.Key == PetProp.SpiritTalent.ToString())
                {
                    curValue = replaceTalent.jingshen;
                    if (zizhiArray.Length > 4)
                    {
                        totalValue = GetTotalValue(petstate, zizhiArray[4], ref tempStr, ref low);
                    }
                }

                UISlider slider    = sliderPair.Value;
                UILabel  label     = slider.transform.Find("Percent").GetComponent <UILabel>();
                int      oldTelant = petDataManager.GetPropByString(sliderPair.Key);
                oldTelant = Mathf.RoundToInt((int)oldTelant * 1.0f / factor);
                curValue  = (uint)Mathf.RoundToInt((int)curValue * 1.0f / factor);
                int       delta = (int)curValue - oldTelant;
                ColorType c     = ColorType.Green;
                string    sign  = "+";
                if (delta >= 0)
                {
                    c = ColorType.Green;
                    if (delta == 0)
                    {
                        sign = "";
                        c    = ColorType.White;
                    }
                }
                else
                {
                    sign = "";
                    c    = ColorType.Red;
                }

                string str = curValue + " " + ColorManager.GetColorString(c, "(" + sign + delta + ")");
                label.text = str;
                if (totalValue == 0)
                {
                    totalValue = (uint)curValue;
                    if (totalValue == 0)
                    {
                        totalValue = 10000;
                    }
                    Log.Info("total value is 0");
                }
                curValue = curValue - (uint)low;
                float precent = (float)(curValue * 1.0f / totalValue * 1.0f);
                slider.Set(precent);
            }
        }
    }
Пример #6
0
 public override void SetValue(float value)
 {
     Slider.Set(value, false);
 }