Ejemplo n.º 1
0
 public void Clear(bool recycle = false)
 {
     nameText.text   = string.Empty;
     priceText.text  = string.Empty;
     amountText.text = string.Empty;
     merchandiseInfo = null;
     if (recycle)
     {
         itemAgentSon.Empty();
         ObjectPool.Put(gameObject);
     }
 }
Ejemplo n.º 2
0
 public void Init(Warehouse warehouse)
 {
     if (warehouse != null)
     {
         MWarehouse = warehouse;
         foreach (ItemAgent ia in itemAgents)
         {
             ia.Empty();
         }
         while (itemAgents.Count < MWarehouse.size.Max)//格子不够用,新建
         {
             ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
             itemAgents.Add(ia);
             ia.Empty();
             ia.Init(ItemAgentType.Warehouse, itemAgents.Count - 1, UI.gridRect);
         }
         int originalSize = itemAgents.Count;
         for (int i = MWarehouse.size.Max; i < originalSize - MWarehouse.size.Max; i++)//用不到的格子隐藏
         {
             itemAgents[i].Hide();
         }
         for (int i = 0; i < MWarehouse.size.Max; i++)//用得到的格子显示
         {
             itemAgents[i].Show();
         }
         foreach (ItemInfo info in MWarehouse.Items)
         {
             if (info.indexInGrid > 0 && info.indexInGrid < itemAgents.Count)
             {
                 itemAgents[info.indexInGrid].SetItem(info);
             }
             else
             {
                 for (int i = 0; i < MWarehouse.size.Max; i++)
                 {
                     if (itemAgents[i].IsEmpty)
                     {
                         itemAgents[i].SetItem(info);
                         break;
                     }
                 }
             }
         }
         UpdateUI();
     }
     UI.pageSelector.SetValueWithoutNotify(0);
     SetPage(0);
 }
Ejemplo n.º 3
0
 private new void Awake()
 {
     if (!UI || !UI.gameObject)
     {
         return;
     }
     base.Awake();
     for (int i = 0; i < 100; i++)
     {
         ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
         itemAgents.Add(ia);
         ia.Init(ItemAgentType.Warehouse, itemAgents.Count - 1, UI.gridRect);
         ia.Empty();
         ZetanUtility.SetActive(ia.gameObject, false);
     }
 }
Ejemplo n.º 4
0
    public void ShowQuestDescription(Quest quest)
    {
        if (quest == null)
        {
            return;
        }
        CurrentQuest            = quest;
        UI.descriptionText.text = new StringBuilder().AppendFormat("<b>{0}</b>\n[委托人: {1}]\n{2}",
                                                                   CurrentQuest.Title,
                                                                   CurrentQuest.originalQuestHolder.TalkerName,
                                                                   CurrentQuest.Description).ToString();
        UI.moneyText.text = CurrentQuest.RewardMoney > 0 ? CurrentQuest.RewardMoney.ToString() : "无";
        UI.EXPText.text   = CurrentQuest.RewardEXP > 0 ? CurrentQuest.RewardEXP.ToString() : "无";
        int befCount = rewardCells.Count;

        for (int i = 0; i < 10 - befCount; i++)
        {
            ItemAgent rwc = ObjectPool.Get(UI.rewardCellPrefab, UI.rewardCellsParent).GetComponent <ItemAgent>();
            rwc.Init();
            rewardCells.Add(rwc);
        }
        foreach (ItemAgent rwc in rewardCells)
        {
            if (rwc)
            {
                rwc.Empty();
            }
        }
        foreach (ItemInfo info in quest.RewardItems)
        {
            foreach (ItemAgent rw in rewardCells)
            {
                if (rw.IsEmpty)
                {
                    rw.SetItem(info);
                    break;
                }
            }
        }
        UI.descriptionWindow.alpha          = 1;
        UI.descriptionWindow.blocksRaycasts = true;
    }