1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class ResultDropItem : ItemRenderer
- {
- public RectTransform container;
- public Image border;
- public Image icon;
- public Text label;
- public GameObject priceObj;
- public Text priceTxt;
- private bool shaking;
- void Awake()
- {
- label.text = Language.GetStr ("ResultPanel", "open");
- }
- public override object data {
- get {
- return base.data;
- }
- set {
- base.data = value;
- int id = (int)value;
- if (id > 0) {
- EquipData equip = EquipManager.GetInstance ().GetData (id);
- border.color = equip.GetBorderColor ();
- icon.sprite = equip.GetIconSprite ();
- } else {
- border.color = UpgradeUtil.GetCommonBorderColor ();
- icon.sprite = EquipData.GetUnknowIconSprite ();
- }
- }
- }
- void FixedUpdate()
- {
- if(shaking)
- {
- Vector2 pos = container.anchoredPosition;
- pos.x = Random.Range (0, 5f);
- pos.y = Random.Range (0, 5f);
- container.anchoredPosition = pos;
- }
- }
- public void Shake(bool value)
- {
- if (value) {
- shaking = true;
- }
- else {
- shaking = false;
- container.anchoredPosition = Vector2.zero;
- }
- }
- public void ShowOpen(int price)
- {
- label.enabled = true;
- if (price > 0) {
- priceTxt.text = price.ToString ();
- priceObj.SetActive (true);
- } else {
- priceObj.SetActive (false);
- }
- }
- public void HideOpen()
- {
- label.enabled = false;
- priceObj.SetActive (false);
- }
- }
|