예제 #1
0
 void onClick_Btn_right_Btn(GameObject caster)
 {
     if (m_dataManager.CurPet == null)
     {
         return;
     }
     GameCmd.stAttrPlanPetUserCmd_C cmd = new GameCmd.stAttrPlanPetUserCmd_C();
     GameCmd.PetTalent plan             = new GameCmd.PetTalent();
     plan.jingshen = (uint)m_dataManager.PlanAllocJingshen;
     plan.liliang  = (uint)m_dataManager.PlanAllocLiliang;
     plan.minjie   = (uint)m_dataManager.PlanAllocMinjie;
     plan.tizhi    = (uint)m_dataManager.PlanAlloTizhi;
     plan.zhili    = (uint)m_dataManager.PlanAllocZhili;
     cmd.attr_plan = plan;
     cmd.id        = m_dataManager.CurPet.GetID();
     cmd.ex_plan   = m_dataManager.PointType;
     NetService.Instance.Send(cmd);
 }
예제 #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);
            }
        }
    }