// //-------------------------------------------------------- 
 | 
// //    [Author]:           第二世界 
 | 
// //    [  Date ]:           Monday, July 31, 2017 
 | 
// //-------------------------------------------------------- 
 | 
// using UnityEngine; 
 | 
// using System.Collections; 
 | 
// using UnityEngine.UI; 
 | 
// using System; 
 | 
  
 | 
// using vnxbqy.UI; 
 | 
  
 | 
// namespace vnxbqy.UI 
 | 
// { 
 | 
     
 | 
//     public class ItemBehaviour : MonoBehaviour 
 | 
//     { 
 | 
         
 | 
  
 | 
//         [SerializeField] ImageEx m_Icon; 
 | 
//         public ImageEx icon { get { return m_Icon; } } 
 | 
  
 | 
//         [SerializeField] ImageEx m_BackGround; 
 | 
//         public ImageEx backGround { get { return m_BackGround; } } 
 | 
  
 | 
//         [SerializeField] Transform m_CountContainer; 
 | 
//         public Transform countContainer { get { return m_CountContainer; } } 
 | 
  
 | 
//         [SerializeField] Text m_Count; 
 | 
//         public Text count { get { return m_Count; } } 
 | 
  
 | 
//         [SerializeField] Button m_ViewDetails; 
 | 
  
 | 
//         [SerializeField] ItemType m_ItemType = ItemType.Rewards; 
 | 
  
 | 
//         EquipSuitEffect m_EquipSuitEffect; 
 | 
//         EquipSuitEffect equipSuitEffect 
 | 
//         { 
 | 
//             get 
 | 
//             { 
 | 
//                 if (m_EquipSuitEffect == null) 
 | 
//                 { 
 | 
//                     m_EquipSuitEffect = EquipSuitEffect.Create(transform as RectTransform); 
 | 
//                 } 
 | 
//                 return m_EquipSuitEffect; 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         //物品基础特效(物品表) 
 | 
//         ItemBaseEffect m_ItemBaseEffect; 
 | 
//         ItemBaseEffect itemBaseEffect 
 | 
//         { 
 | 
//             get 
 | 
//             { 
 | 
//                 if (m_ItemBaseEffect == null) 
 | 
//                 { 
 | 
//                     m_ItemBaseEffect = ItemBaseEffect.Create(transform as RectTransform); 
 | 
//                 } 
 | 
//                 return m_ItemBaseEffect; 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         bool m_ShowCount = true; 
 | 
//         public bool showCount { 
 | 
//             get { 
 | 
//                 return m_ShowCount; 
 | 
//             } 
 | 
//             set { 
 | 
//                 if (m_ShowCount != value) 
 | 
//                 { 
 | 
//                     m_ShowCount = value; 
 | 
//                     DisplayCount(); 
 | 
//                 } 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         public int itemId { 
 | 
//             get; private set; 
 | 
//         } 
 | 
  
 | 
//         public int itemCount { 
 | 
//             get; private set; 
 | 
//         } 
 | 
  
 | 
//         public int itemQuality { get; private set; } 
 | 
  
 | 
//         private void Awake() 
 | 
//         { 
 | 
//             if (m_ViewDetails != null) 
 | 
//             { 
 | 
//                 m_ViewDetails.SetListener(ViewDetails); 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         public void SetItem(Item _item) 
 | 
//         { 
 | 
//             SetItem(_item.id, _item.count, _item.quality); 
 | 
//         } 
 | 
  
 | 
//         public void SetItem(int _id, int _count, int _quality = 0) 
 | 
//         { 
 | 
//             itemId = _id; 
 | 
//             itemCount = _count; 
 | 
//             itemQuality = _quality; 
 | 
//             DisplayBaseInfo(); 
 | 
//             DisplayCount(); 
 | 
//         } 
 | 
  
 | 
//         public void SetCount(int _count) 
 | 
//         { 
 | 
//             itemCount = _count; 
 | 
//             DisplayCount(); 
 | 
//         } 
 | 
  
 | 
//         public void DisplayEmpty() 
 | 
//         { 
 | 
//             try 
 | 
//             { 
 | 
//                 icon.SetActive(false); 
 | 
//                 backGround.SetActive(false); 
 | 
//                 if (countContainer != null) 
 | 
//                 { 
 | 
//                     countContainer.SetActive(false); 
 | 
//                 } 
 | 
//             } 
 | 
//             catch (System.Exception ex) 
 | 
//             { 
 | 
//                 Debug.Log(ex); 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         private void DisplayBaseInfo() 
 | 
//         { 
 | 
//             try 
 | 
//             { 
 | 
//                 var itemInfo = ItemConfig.Get(itemId); 
 | 
//                 if (icon != null) 
 | 
//                 { 
 | 
//                     icon.SetActive(true); 
 | 
//                     icon.SetSprite(itemInfo.IconKey); 
 | 
//                 } 
 | 
  
 | 
//                 if (backGround != null) 
 | 
//                 { 
 | 
//                     backGround.SetActive(true); 
 | 
//                     backGround.SetItemBackGround(itemQuality != 0 ? itemQuality : itemInfo.ItemColor, itemInfo.QualityEchoType); 
 | 
//                 } 
 | 
  
 | 
//                 equipSuitEffect.Display(itemId); 
 | 
//                 itemBaseEffect.Display(itemId); 
 | 
//             } 
 | 
//             catch (Exception e) 
 | 
//             { 
 | 
//                 Debug.Log(e); 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         private void DisplayCount() 
 | 
//         { 
 | 
//             if (countContainer == null) 
 | 
//             { 
 | 
//                 return; 
 | 
//             } 
 | 
//             switch (m_ItemType) 
 | 
//             { 
 | 
//                 case ItemType.Rewards: 
 | 
//                     if (showCount && itemCount > 1) 
 | 
//                     { 
 | 
//                         countContainer.SetActive(true); 
 | 
//                         count.text = UIHelper.ReplaceLargeNum((ulong)itemCount); 
 | 
//                     } 
 | 
//                     else 
 | 
//                     { 
 | 
//                         countContainer.SetActive(false); 
 | 
//                     } 
 | 
//                     break; 
 | 
//                 case ItemType.Use: 
 | 
//                     var _itemCnt = ModelCenter.Instance.GetModel<PackModel>().GetItemCountByID(PackType.Item, itemId); 
 | 
//                     count.text = StringUtility.Contact(_itemCnt >= itemCount ? "<color=#35e112>" : "<color=#ff0303>", _itemCnt, 
 | 
//                         "</color><color=#f7f7f7>/", itemCount, "</color>"); 
 | 
//                     break; 
 | 
//             } 
 | 
//         } 
 | 
  
 | 
//         private void ViewDetails() 
 | 
//         { 
 | 
//             ItemTipUtility.Show(itemId); 
 | 
//         } 
 | 
  
 | 
//         public enum ItemType 
 | 
//         { 
 | 
//             Rewards, 
 | 
//             Use, 
 | 
//         } 
 | 
//     } 
 | 
  
 | 
// } 
 |