public void OnSendMessageFromInscriptionButton(InscriptionButton inscriptionButton) { inscripptionId = inscriptionButton.inscription; inscriptionSprite.sprite = inscriptionButton.inscriptionSprite.sprite; inscriptionName.text = inscriptionButton.inscriptionName.text; outherAttibute.text = inscriptionButton.otherJieShao.text; for (int i = 0; i < attibuteList.Count; i++) { attibuteList[i].text = inscriptionButton.inscriptionAttribute[i].text; } string text1 = ""; string text2 = ""; switch (inscriptionButton.level) { case 1: text1 = "10"; text2 = "10"; break; case 2: text1 = "25"; text2 = "20"; break; case 3: text1 = "100"; text2 = "80"; break; case 4: text1 = "400"; text2 = "320"; break; case 5: text1 = "1600"; text2 = "800"; break; } buyText.text = text1; SellText.text = text2; }
/// <summary> /// 根据选择的等级和类型筛选出合适的符文 /// </summary> private void ChooseDeal() { List <Inscription> resultList = GetInScription(); Transform[] transformList = contentObj.GetComponentsInChildren <Transform>(); foreach (Transform ta in transformList) { if (ta.tag == "Inscription") { Destroy(ta.gameObject); } } int number = resultList.Count / 3; if (resultList.Count % 3 > 0) { number = resultList.Count / 3 + 1; } float height = number * buttonheight + number; if (height < rectHeight) { height = rectHeight; } contentTransform.sizeDelta = new Vector2(0, height); float y = -(buttonwidth / 4 + 1); int count = 0; for (int i = 0; i < number; i++) { float x = (buttonwidth + 1) / 2; for (int j = 0; j < 3; j++) { count++; if (count <= resultList.Count) { GameObject ga = Instantiate(instance); ga.GetComponent <RectTransform>().SetParent(contentObj.transform); ga.GetComponent <RectTransform>().sizeDelta = new Vector2(-(rectWidth - buttonwidth), buttonheight); ga.GetComponent <RectTransform>().localPosition = new Vector2(j * (buttonwidth + 1) + x, -i * (buttonheight + 1) + y); InscriptionButton inscriptionButton = ga.GetComponent <InscriptionButton>(); Inscription inscription = resultList[count - 1]; inscriptionButton.inscription = inscription._inscriptionID; inscriptionButton.level = inscription._inscriptionLevel; inscriptionButton.inscriptionName.text = inscription.inscriptionLevel.ToString() + "级铭文:" + inscription.inscriptionName; inscriptionButton.inscriptionSprite.sprite = inscription._inscriptionIcon; if (PlayerInscriptionMessage.InscriptionList.ContainsKey(inscription.inscriptionID)) { inscriptionButton.otherJieShao.text = "X" + PlayerInscriptionMessage.InscriptionList[inscription.inscriptionID].inscriptionNumber; } else { inscriptionButton.otherJieShao.text = "未获得"; } inscriptionButton.inscriptionbuy = buyOrSellPanel; int temp = 0; foreach (InscriptionAttribute item in inscription.inscriptionAttribute) { string value = ""; if (item.valueType == AttributeValue.NUMBER) { value = item.attribueValue.ToString(); } else { value = System.Math.Round(item._attributeValue * 100, 1).ToString() + "%"; } inscriptionButton.inscriptionAttribute[temp].text = item.attributeName + ":+" + value; temp++; } } } } }