void InitSliderData() { if (CurPet == null) { return; } int level = CurPet.GetProp((int)CreatureProp.Level); int petstate = CurPet.GetProp((int)PetProp.PetGuiYuanStatus); int curLife = CurPet.GetProp((int)PetProp.Life); int curExp = CurPet.GetProp((int)PetProp.LevelExp); uint totalExp = GameTableManager.Instance.GetTableItem <PetUpGradeDataBase>((uint)level, (int)CurPet.PetBaseID).upGradeExp; PetDataBase db = petDataManager.GetPetDataBase(CurPet.PetBaseID); if (db != null) { uint life = db.life; ShowSlider(m_slider_lifescorllbar, curLife, (int)life); } ShowSlider(m_slider_expscorllbar, curExp, (int)totalExp); int yinhunLv = CurPet.GetProp((int)PetProp.YinHunLevel); int yinhunExp = CurPet.GetProp((int)PetProp.YinHunExp); PetYinHunDataBase yhDb = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)yinhunLv); if (yhDb != null) { ShowSlider(m_slider_lingqizhi, yinhunExp, (int)yhDb.lingQiMax); } }
bool GetInheritXiuWeiLevel(out int level) { level = 0; IPet oldpet = petDataManager.GetInheritPet((int)PetInheritPos.Old); if (oldpet == null) { return(true); } IPet newpet = petDataManager.GetInheritPet((int)PetInheritPos.New); if (newpet == null) { return(true); } int oldPetLv = oldpet.GetProp((int)PetProp.YinHunLevel); uint oldExp = (uint)oldpet.GetProp((int)PetProp.YinHunExp); for (int i = 0; i < oldPetLv; i++) { PetYinHunDataBase udb = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)i); if (udb != null) { oldExp += udb.lingQiMax; } } int newPetLv = newpet.GetProp((int)PetProp.YinHunLevel); uint newExp = (uint)newpet.GetProp((int)PetProp.YinHunExp); newExp += oldExp; level = newPetLv; while (newExp > 0) { PetYinHunDataBase udb = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)level); if (udb != null) { if (newExp >= udb.lingQiMax) { level += 1; newExp -= udb.lingQiMax; } else { break; } } else { level -= 1; return(false); } } return(true); }
/// <summary> /// 通过[修为等级]二分快速查表 /// </summary> /// <param name="level">修为等级</param> /// <returns></returns> public static PetYinHunDataBase Query(this List <PetYinHunDataBase> sorted, uint level) { var key = new PetYinHunDataBase() { level = level }; var comparer = new Comparer1(); var index = sorted.BinarySearch(key, comparer); return(index >= 0 ? sorted[index] : default(PetYinHunDataBase)); }
void ShowNextXiuWei() { InitCurXiuWei(); int level = CurPet.GetProp((int)PetProp.YinHunLevel); int nextLv = level + 1; float factor = 10000;// 0.0001f; PetYinHunDataBase db = petDataManager.GetPetYinHunDataBase((uint)nextLv); if (db != null) { PetYinHunDataBase curdb = petDataManager.GetPetYinHunDataBase((uint)level); if (curdb != null) { uint jiacheng = db.jiaChengBi + 10000; uint lastFactor = curdb.jiaChengBi + 10000; int scale = Mathf.FloorToInt(db.jiaChengBi * 0.01f); string scaleStr = ColorManager.GetColorString(ColorType.Green, string.Format(" (+{0}%)", scale)); // lastFactor = 1 + db.jiaChengBi * 1.0f / 100; factor = jiacheng * 1.0f / lastFactor; m_label_xin_xiuwei.text = nextLv.ToString(); int liliang = CurPet.GetProp((int)PetProp.StrengthTalent); int nextll = Mathf.FloorToInt(liliang * factor); m_label_xin_liliangtianfu.text = nextll.ToString() + scaleStr; int minjie = CurPet.GetProp((int)PetProp.AgilityTalent); int nextmj = Mathf.FloorToInt(minjie * factor); m_label_xin_minjietianfu.text = nextmj.ToString() + scaleStr; int zhili = CurPet.GetProp((int)PetProp.IntelligenceTalent); int nextzhili = Mathf.FloorToInt(zhili * factor); m_label_xin_zhilitianfu.text = nextzhili.ToString() + scaleStr; int tili = CurPet.GetProp((int)PetProp.CorporeityTalent); int nexttili = Mathf.FloorToInt(tili * factor); m_label_xin_tilitianfu.text = nexttili.ToString() + scaleStr; int jingshen = CurPet.GetProp((int)PetProp.SpiritTalent); int nextjingshen = Mathf.FloorToInt(jingshen * factor); m_label_xin_jingshentianfu.text = nextjingshen.ToString() + scaleStr; int lingqiExp = CurPet.GetProp((int)PetProp.YinHunExp); uint totalExp = db.lingQiMax; } // ShowSlider(); } }
bool CheckItemNum() { if (CurPet != null) { int lv = CurPet.GetProp((int)Client.PetProp.YinHunLevel); PetYinHunDataBase db = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)lv); if (db != null) { uint jinbi = db.needMoney; if (!MainPlayerHelper.IsHasEnoughMoney(ClientMoneyType.Gold, jinbi)) { DataManager.Manager <Mall_HuangLingManager>().ShowExchange((uint)ErrorEnum.NotEnoughGold, ClientMoneyType.Gold, "提示", "去兑换", "取消"); return(false); } uint itemID = db.needItem; int itemCount = DataManager.Manager <ItemManager>().GetItemNumByBaseId(itemID); if (bAutoYinHunBuy) { if (!ShowYinHunColdLabel(itemID)) { TipsManager.Instance.ShowTipsById(5); return(false); } } else { if (itemCount <= 0) { TipsManager.Instance.ShowTipsById(6); return(false); } } } else { TipsManager.Instance.ShowTips(LocalTextType.Pet_YinHun_xiuweiyimanjibunengjixuyinhunle); //TipsManager.Instance.ShowTipsById( 108007 ); return(false); } } return(true); }
void InitCurXiuWei() { int level = CurPet.GetProp((int)PetProp.YinHunLevel); PetYinHunDataBase db = petDataManager.GetPetYinHunDataBase((uint)level); if (db != null) { int scale = Mathf.FloorToInt(db.jiaChengBi * 0.01f); string scaleStr = ColorManager.GetColorString(ColorType.Green, string.Format(" (+{0}%)", scale)); int liliang = CurPet.GetProp((int)PetProp.StrengthTalent); m_label_yuan_liliangtianfu.text = liliang.ToString() + scaleStr; int minjie = CurPet.GetProp((int)PetProp.AgilityTalent); m_label_yuan_minjietianfu.text = minjie.ToString() + scaleStr; int zhili = CurPet.GetProp((int)PetProp.IntelligenceTalent); m_label_yuan_zhilitianfu.text = zhili.ToString() + scaleStr; int tili = CurPet.GetProp((int)PetProp.CorporeityTalent); m_label_yuan_tilitianfu.text = tili.ToString() + scaleStr; int jingshen = CurPet.GetProp((int)PetProp.SpiritTalent); m_label_yuan_jingshentianfu.text = jingshen.ToString() + scaleStr; } }
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); } } }
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); } } }
void onClick_Yinhunshici_Btn(GameObject caster) { #region 十次发一次消息 /* * int lv = CurPet.GetProp((int)Client.PetProp.YinHunLevel); * PetYinHunDataBase db = GameTableManager.Instance.GetTableItem<PetYinHunDataBase>((uint)lv); * if (db != null) * { * int jinbi = (int)db.needMoney; * int totalNum = CommonData.GetMoneyNumByType(ClientMoneyType.Gold); * int jinbiUseNum = 10; * if (jinbi != 0) * { * jinbiUseNum = totalNum / jinbi; * } * if (jinbiUseNum == 0) * { * TipsManager.Instance.ShowTipsById(4); * return; * } * uint needCold = petDataManager.GetItemNeedColdNum(m_nYinHunNeedItemID); * int dianjuanTotalNum = CommonData.GetMoneyNumByType(ClientMoneyType.YuanBao); * int dianjuanUssNum = 10; * if (needCold != 0) * { * dianjuanUssNum = dianjuanTotalNum / (int)needCold; * } * if (dianjuanUssNum == 0) * { * TipsManager.Instance.ShowTipsById(5); * return; * } * int num = dianjuanUssNum < jinbiUseNum ? dianjuanUssNum : jinbiUseNum; * * uint itemID = db.needItem; * int itemCount = DataManager.Manager<ItemManager>().GetItemNumByBaseId(itemID); * * if (itemCount == 0) * { * if (!bAutoYinHunBuy) * { * TipsManager.Instance.ShowTipsById(6); * return; * } * } * else * { * num = num < itemCount ? num : itemCount; * * } * if (num > 10) * { * num = 10; * } * stYinHunPetUserCmd_CS cmd = new stYinHunPetUserCmd_CS(); * cmd.id = CurPet.GetID(); * cmd.yh_num = (uint)num; * cmd.auto_buy = bAutoYinHunBuy; * NetService.Instance.Send(cmd); * } * else * { * TipsManager.Instance.ShowTips(LocalTextType.Pet_YinHun_xiuweiyimanjibunengjixuyinhunle); * }*/ #endregion int lv = CurPet.GetProp((int)Client.PetProp.YinHunLevel); PetYinHunDataBase db = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)lv); if (db != null) { int jinbi = (int)db.needMoney; int totalNum = MainPlayerHelper.GetMoneyNumByType(ClientMoneyType.Gold); int jinbiUseNum = 10; if (jinbi != 0) { jinbiUseNum = totalNum / jinbi + 1; } uint needCold = petDataManager.GetItemNeedColdNum(m_nYinHunNeedItemID); int dianjuanTotalNum = MainPlayerHelper.GetMoneyNumByType(ClientMoneyType.YuanBao); int dianjuanUssNum = 10; if (needCold != 0) { dianjuanUssNum = dianjuanTotalNum / (int)needCold + 1; } int num = dianjuanUssNum < jinbiUseNum ? dianjuanUssNum : jinbiUseNum; if (num > 10) { num = 10; } for (int i = 0; i < num; i++) { if (!CheckItemNum()) { return; } SendYinHun(); } } }
void InitYinhunPaneel() { if (CurPet != null) { PetDataBase pdb = petDataManager.GetPetDataBase(CurPet.PetBaseID); if (pdb != null) { // DataManager.Manager<UIManager>().SetSpriteDynamicIcon(m_sprite_jinengpeticon, pdb.icon); UIManager.GetTextureAsyn(pdb.icon, ref m_yinhunJinengAsynSeed, () => { if (null != m__jinengpeticon) { m__jinengpeticon.mainTexture = null; } }, m__jinengpeticon, false); UIManager.GetTextureAsyn(pdb.icon, ref m_yinhunTopIconAsynSeed, () => { if (null != m__yinhuntopicon) { m__yinhuntopicon.mainTexture = null; } }, m__yinhuntopicon, false); // DataManager.Manager<UIManager>().SetSpriteDynamicIcon(m_sprite_yinhuntopicon, pdb.icon); //背景框品质 string bgSpriteName = ItemDefine.GetItemFangBorderIconByItemID(pdb.ItemID); Transform bgTrans = m__yinhuntopicon.transform.Find("pingzhi_box"); if (bgTrans) { UISprite bgSpr = bgTrans.GetComponent <UISprite>(); if (bgSpr) { UIManager.GetAtlasAsyn(bgSpriteName, ref m_yinhunBgIconAsynSeed, () => { if (null != bgSpr) { bgSpr.atlas = null; } }, bgSpr, false); // DataManager.Manager<UIManager>().SetSpriteDynamicIcon(bgSpr, bgSpriteName); } } UIManager.GetAtlasAsyn(bgSpriteName, ref m_yinhunPinzhiIconAsynSeed, () => { if (null != m_sprite_petpingzhi) { m_sprite_petpingzhi.atlas = null; } }, m_sprite_petpingzhi, false); // DataManager.Manager<UIManager>().SetSpriteDynamicIcon(m_sprite_petpingzhi, bgSpriteName); } int yLv = CurPet.GetProp((int)PetProp.YinHunLevel); PetYinHunDataBase db = GameTableManager.Instance.GetTableItem <PetYinHunDataBase>((uint)yLv); if (db != null) { uint itemID = db.needItem; m_nYinHunNeedItemID = itemID; int itemCount = DataManager.Manager <ItemManager>().GetItemNumByBaseId(itemID); UIItem.AttachParent(m__yinhun_icon.transform, itemID, (uint)itemCount, ShowYinhunGetWayCallBack); m_label_yinhun_xiaohaogold.text = db.needMoney.ToString(); m_label_yinhunshici_xiaohaogold.text = (10 * db.needMoney).ToString(); ItemDataBase itemDb = GameTableManager.Instance.GetTableItem <ItemDataBase>(itemID); if (itemDb != null) { int num = DataManager.Manager <ItemManager>().GetItemNumByBaseId(itemDb.itemID); ShowYinHunColdLabel(itemID); m_label_yinhun_xiaohaoname.text = itemDb.itemName; m_label_yinhun_xiaohaonumber.text = StringUtil.GetNumNeedString(num, 1); } } m_label_yinhunmanji.text = DataManager.Manager <TextManager>().GetLocalText(LocalTextType.Local_Txt_Pet_yinhunmanjineirong); if (yLv == 10) { m_widget_yinhun_nomax.gameObject.SetActive(false); m_trans_xinxiuweicontentparent.gameObject.SetActive(false); m_label_yinhunmanji.gameObject.SetActive(true); m_label_xin_xiuwei.text = CommonData.GetLocalString("满"); // m_widget_yinhun_nomax.gameObject.SetActive(false); // m_trans_yuanxiuwei.transform.localPosition = new Vector3(16, 122, 0); // m_label_yinhun_maxLabel.gameObject.SetActive(true); } else { m_widget_yinhun_nomax.gameObject.SetActive(true); m_trans_xinxiuweicontentparent.gameObject.SetActive(true); m_label_yinhunmanji.gameObject.SetActive(false); // m_widget_yinhun_nomax.gameObject.SetActive(true); // m_trans_yuanxiuwei.transform.localPosition = new Vector3(-180, 122, 0); // m_label_yinhun_maxLabel.gameObject.SetActive(false); } } }