Price.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class Price : MonoBehaviour {
  5. public GameObject[] gameObjArr;
  6. public Text[] textArr;
  7. public void SetPrice(BuyUtil.Currency currency, int price, BuyUtil.ItemState state = BuyUtil.ItemState.Sell)
  8. {
  9. for(int i=0; i<gameObjArr.Length; i++)
  10. {
  11. if(state == BuyUtil.ItemState.Bought)
  12. {
  13. if(i == BuyUtil.Currency.Money.GetHashCode())
  14. {
  15. gameObjArr[i].SetActive(true);
  16. textArr[i].text = Language.GetStr("Shop", "bought");
  17. }
  18. else
  19. {
  20. gameObjArr[i].SetActive(false);
  21. }
  22. }
  23. else if(state == BuyUtil.ItemState.Equiped)
  24. {
  25. if(i == BuyUtil.Currency.Money.GetHashCode())
  26. {
  27. gameObjArr[i].SetActive(true);
  28. textArr[i].text = Language.GetStr("Shop", "equiped");
  29. }
  30. else
  31. {
  32. gameObjArr[i].SetActive(false);
  33. }
  34. }
  35. else
  36. {
  37. if(i == currency.GetHashCode())
  38. {
  39. gameObjArr[i].SetActive(true);
  40. if(currency == BuyUtil.Currency.Money)
  41. textArr[i].text = Language.GetStr("Shop", "RMB") + ((float)price/100f).ToString();
  42. else
  43. textArr[i].text = NumberUtil.AddThousandSplit(price);
  44. }
  45. else
  46. {
  47. gameObjArr[i].SetActive(false);
  48. }
  49. }
  50. }
  51. }
  52. }