Example #1
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);
            }
        }
    }
Example #2
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);
            }
        }
    }