ResultDropItem.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class ResultDropItem : ItemRenderer
  5. {
  6. public RectTransform container;
  7. public Image border;
  8. public Image icon;
  9. public Text label;
  10. public GameObject priceObj;
  11. public Text priceTxt;
  12. private bool shaking;
  13. void Awake()
  14. {
  15. label.text = Language.GetStr ("ResultPanel", "open");
  16. }
  17. public override object data {
  18. get {
  19. return base.data;
  20. }
  21. set {
  22. base.data = value;
  23. int id = (int)value;
  24. if (id > 0) {
  25. EquipData equip = EquipManager.GetInstance ().GetData (id);
  26. border.color = equip.GetBorderColor ();
  27. icon.sprite = equip.GetIconSprite ();
  28. } else {
  29. border.color = UpgradeUtil.GetCommonBorderColor ();
  30. icon.sprite = EquipData.GetUnknowIconSprite ();
  31. }
  32. }
  33. }
  34. void FixedUpdate()
  35. {
  36. if(shaking)
  37. {
  38. Vector2 pos = container.anchoredPosition;
  39. pos.x = Random.Range (0, 5f);
  40. pos.y = Random.Range (0, 5f);
  41. container.anchoredPosition = pos;
  42. }
  43. }
  44. public void Shake(bool value)
  45. {
  46. if (value) {
  47. shaking = true;
  48. }
  49. else {
  50. shaking = false;
  51. container.anchoredPosition = Vector2.zero;
  52. }
  53. }
  54. public void ShowOpen(int price)
  55. {
  56. label.enabled = true;
  57. if (price > 0) {
  58. priceTxt.text = price.ToString ();
  59. priceObj.SetActive (true);
  60. } else {
  61. priceObj.SetActive (false);
  62. }
  63. }
  64. public void HideOpen()
  65. {
  66. label.enabled = false;
  67. priceObj.SetActive (false);
  68. }
  69. }