protected override void OnAwake() { Transform pivot = transform.Find("Pivot"); view1 = pivot.Find("View1").gameObject; view2 = pivot.Find("View2").gameObject; relicsName = pivot.Find("RelicsName").GetComponent <UILabel>(); relicsDesc = pivot.Find("RelicsDesc").GetComponent <UILabel>(); cardTrans = pivot.Find("View1/Cards"); cardTemp = pivot.Find("View1/Card").gameObject; cardTemp.SetActive(false); cardDrag = pivot.Find("Drag").gameObject; btnClose = pivot.Find("BtnClose").gameObject; btnUpgrade = pivot.Find("View2/Btn_Upgrade").gameObject; btnSkill = pivot.Find("View2/Btn_Skill").gameObject; btnUnload = pivot.Find("View2/Btn_Unload").gameObject; btnBattle = pivot.Find("View2/Btn_Battle").gameObject; Transform trans = view2.transform.Find("Items"); for (int i = 1; i <= 3; i++) { RelicsCharge tab = new RelicsCharge(); Transform item = trans.Find(i.ToString()); tab.itemQuality = item.Find("Quality").GetComponent <UISprite>(); tab.itemTexture = item.Find("Texture").GetComponent <UITexture>(); tab.itemNum = item.Find("Num").GetComponent <UILabel>(); tab.tip = item.Find("Tip").GetComponent <UILabel>(); tab.btn = item.Find("Btn").gameObject; tab.itemName = item.Find("Name").GetComponent <UILabel>(); tab.chargeProgressNum = item.Find("Progress/Num").GetComponent <UILabel>(); tab.chargeProgressValue = item.Find("Progress").GetComponent <UISlider>(); mRelicsCharges.Add(tab); } Transform propertyTrans = view2.transform.Find("RelicsProperty"); Transform tr1 = propertyTrans.Find("1"); nowAttr = tr1.gameObject; for (int i = 1; i <= 3; i++) { RelicsProperty tab = new RelicsProperty(); tab.propertyName = tr1.Find(i + "/Name").GetComponent <UILabel>(); tab.propertyNum = tr1.Find(i + "/Num").GetComponent <UILabel>(); mNowPropertys.Add(tab); } Transform tr2 = propertyTrans.Find("2"); nexAttr = tr2.gameObject; for (int i = 1; i <= 3; i++) { RelicsProperty tab = new RelicsProperty(); tab.propertyName = tr2.Find(i + "/Name").GetComponent <UILabel>(); tab.propertyNum = tr2.Find(i + "/Num").GetComponent <UILabel>(); mNexPropertys.Add(tab); } attrRow = propertyTrans.Find("Row").gameObject; mModelTexture = view2.transform.Find("RelicsTexture").GetComponent <UITexture>(); CreateItems(); }
private void ShowPropertyView() { DRelics db = ReadCfgRelics.GetDataById(centerID); XRelics relics = DataDBSRelics.GetDataById(centerID); for (int i = 0; i < 3; i++) { RelicsProperty tab1 = mNowPropertys[i]; RelicsProperty tab2 = mNexPropertys[i]; DProperty propertyDB = ReadCfgProperty.GetDataById(db.PropertyID[i]); tab1.propertyName.text = propertyDB.Name; tab2.propertyName.text = propertyDB.Name.ToString(); float ratio1 = 1; float ratio2 = ratio1 * (20 / 100f + 1); float num1 = 0; float num2 = 0; if (relics == null) { num1 = ratio1 * db.PropertyNum[i]; num2 = ratio2 * db.PropertyNum[i]; if (propertyDB.IsPercent) { tab1.propertyNum.text = "+" + (num1 / 100f).ToPercent(); tab2.propertyNum.text = "+" + (num2 / 100f).ToPercent(); } else { tab1.propertyNum.text = "+" + ((int)num1).ToString(); tab2.propertyNum.text = "+" + ((int)num2).ToString(); } } else { ratio1 = Mathf.Pow(20 / 100f + 1, relics.Level + 1); ratio2 = ratio1 * (20 / 100f + 1); num1 = (db.PropertyNum[i] * ratio1); num2 = (db.PropertyNum[i] * ratio2); if (relics.Level == db.LevelExp.Length) { if (propertyDB.IsPercent) { tab1.propertyNum.text = "+" + (num1 / 100f).ToPercent(); tab2.propertyNum.text = string.Empty; } else { tab1.propertyNum.text = "+" + ((int)num1).ToString(); tab2.propertyNum.text = string.Empty; } nowAttr.transform.localPosition = new Vector3(100, -50, 0); nexAttr.SetActive(false); attrRow.SetActive(false); } else { if (propertyDB.IsPercent) { tab1.propertyNum.text = "+" + (num1 / 100f).ToPercent(); tab2.propertyNum.text = "+" + (num2 / 100f).ToPercent(); } else { tab1.propertyNum.text = "+" + ((int)num1).ToString(); tab2.propertyNum.text = "+" + ((int)num2).ToString(); } nexAttr.SetActive(true); attrRow.SetActive(true); nowAttr.transform.localPosition = new Vector3(-20, -60, 0); nexAttr.transform.localPosition = new Vector3(200, -60, 0); } } } }