コード例 #1
0
 private void Init()
 {
     foreach (var ia in itemAgents)
     {
         ia.Empty();
     }
     while (itemAgents.Count < slotCount)
     {
         ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
         ia.Init(ItemAgentType.Loot);
         itemAgents.Add(ia);
     }
     while (itemAgents.Count > slotCount)
     {
         itemAgents[itemAgents.Count - 1].Clear(true);
         itemAgents.RemoveAt(itemAgents.Count - 1);
     }
     if (LootAgent)
     {
         foreach (ItemInfo li in LootAgent.lootItems)
         {
             foreach (ItemAgent ia in itemAgents)
             {
                 if (ia.IsEmpty)
                 {
                     ia.SetItem(li);
                     break;
                 }
             }
         }
     }
 }
コード例 #2
0
 public void Init()
 {
     if (!UI || !UI.gameObject)
     {
         return;
     }
     if (Backpack != null)
     {
         foreach (ItemAgent ia in itemAgents)
         {
             ia.Empty();
         }
         while (Backpack.size.Max > itemAgents.Count)
         {
             ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
             itemAgents.Add(ia);
             ia.Init(ItemAgentType.Backpack, itemAgents.Count - 1, UI.gridScrollRect);
         }
         while (Backpack.size.Max < itemAgents.Count)
         {
             itemAgents[itemAgents.Count - 1].Clear(true);
             itemAgents.RemoveAt(itemAgents.Count - 1);
         }
         UpdateUI();
     }
     UI.pageSelector.SetValueWithoutNotify(0);
 }
コード例 #3
0
ファイル: PlantUI.cs プロジェクト: pengeel/Project-ZT
 protected override void Awake()
 {
     base.Awake();
     icon.Init();
     closeButton.onClick.AddListener(PlantManager.Instance.CloseWindow);
     pageSelector.onValueChanged.AddListener(PlantManager.Instance.SetPage);
 }
コード例 #4
0
ファイル: MakingUI.cs プロジェクト: pengeel/Project-ZT
 protected override void Awake()
 {
     base.Awake();
     icon.Init(ItemAgentType.Making);
     closeButton.onClick.AddListener(MakingManager.Instance.CloseWindow);
     makeButton.onClick.AddListener(MakingManager.Instance.MakeCurrent);
     DIYButton.onClick.AddListener(MakingManager.Instance.DIY);
     pageSelector.onValueChanged.AddListener(MakingManager.Instance.SetPage);
 }
コード例 #5
0
 public void Init(MerchandiseInfo info, MerchandiseType type)
 {
     if (info == null || !info.Item)
     {
         return;
     }
     merchandiseInfo = info;
     merchandiseType = type;
     if (type == MerchandiseType.SellToPlayer)
     {
         itemAgentSon.Init(ItemAgentType.Selling);
     }
     else
     {
         itemAgentSon.Init(ItemAgentType.Purchasing);
     }
     itemAgentSon.SetItem(new ItemInfo(info.Item));
     UpdateInfo();
 }
コード例 #6
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);
 }
コード例 #7
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);
     }
 }
コード例 #8
0
ファイル: DialogueManager.cs プロジェクト: pengeel/Project-ZT
    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;
    }
コード例 #9
0
    /// <summary>
    /// 扩展容量
    /// </summary>
    /// <param name="size">扩展数量</param>
    /// <returns>是否成功扩展</returns>
    public bool ExpandSize(int size)
    {
        if (size < 1)
        {
            return(false);
        }
        if (Backpack.size.Max >= 192)
        {
            MessageManager.Instance.New(GameManager.BackpackName + "已经达到最大容量了");
            return(false);
        }
        int finallyExpand = Backpack.size.Max + size > 192 ? 192 - Backpack.size.Max : size;

        Backpack.size.Max += finallyExpand;
        for (int i = 0; i < finallyExpand; i++)
        {
            ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
            itemAgents.Add(ia);
            ia.Init(ItemAgentType.Backpack, itemAgents.Count - 1, UI.gridScrollRect);
        }
        MessageManager.Instance.New(GameManager.BackpackName + "空间增加了");
        return(true);
    }
コード例 #10
0
 public bool Place(ItemInfo info)
 {
     if (info == null || info.item == null || info.Amount < 0)
     {
         return(false);
     }
     if (info.item.StackAble)
     {
         if (SelectionType == ItemSelectionType.Discard)
         {
             if (info.item.DiscardAble && BackpackManager.Instance.TryLoseItem_Boolean(info))
             {
                 if (itemAgents.Exists(x => x.MItemInfo == info))
                 {
                     MessageManager.Instance.New("已选择该道具");
                     return(false);
                 }
                 ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
                 ia.Init(ItemAgentType.Selection, -1, UI.gridScrollRect);
                 itemAgents.Add(ia);
                 ia.SetItem(info);
                 if (itemAgents.Count > 0)
                 {
                     ZetanUtility.SetActive(UI.tips, false);
                 }
                 return(true);
             }
         }
         else
         {
             if (SelectionType == ItemSelectionType.Making && info.item.MaterialType == MaterialType.None)
             {
                 return(false);
             }
             if (info.Amount < 2)
             {
                 if (BackpackManager.Instance.TryLoseItem_Boolean(info))
                 {
                     if (itemAgents.Exists(x => x.MItemInfo == info || x.MItemInfo.item == info.item))
                     {
                         MessageManager.Instance.New("已选择该道具");
                         return(false);
                     }
                     ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
                     ia.Init(ItemAgentType.Selection, -1, UI.gridScrollRect);
                     itemAgents.Add(ia);
                     ia.SetItem(info);
                     if (itemAgents.Count > 0)
                     {
                         ZetanUtility.SetActive(UI.tips, false);
                     }
                     return(true);
                 }
             }
             else
             {
                 if (itemAgents.Exists(x => x.MItemInfo == info || x.MItemInfo.item == info.item))
                 {
                     MessageManager.Instance.New("已选择该道具");
                     return(false);
                 }
                 AmountManager.Instance.New(delegate
                 {
                     if (BackpackManager.Instance.TryLoseItem_Boolean(info, (int)AmountManager.Instance.Amount))
                     {
                         ItemAgent ia = itemAgents.Find(x => x.MItemInfo.item == info.item);
                         if (ia)
                         {
                             ia.MItemInfo.Amount = (int)AmountManager.Instance.Amount;
                         }
                         else
                         {
                             ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
                             ia.Init(ItemAgentType.Selection, -1, UI.gridScrollRect);
                             itemAgents.Add(ia);
                             ia.SetItem(new ItemInfo(info.item, (int)AmountManager.Instance.Amount));
                         }
                         if (itemAgents.Count > 0)
                         {
                             ZetanUtility.SetActive(UI.tips, false);
                         }
                     }
                 }, info.Amount);
                 return(true);
             }
         }
     }
     else if ((SelectionType != ItemSelectionType.Discard || SelectionType == ItemSelectionType.Discard && info.item.DiscardAble) &&
              BackpackManager.Instance.TryLoseItem_Boolean(info))
     {
         if (itemAgents.Exists(x => x.MItemInfo == info))
         {
             MessageManager.Instance.New("已选择该道具");
             return(false);
         }
         ItemAgent ia = ObjectPool.Get(UI.itemCellPrefab, UI.itemCellsParent).GetComponent <ItemAgent>();
         ia.Init(ItemAgentType.Selection, -1, UI.gridScrollRect);
         itemAgents.Add(ia);
         ia.SetItem(info);
         if (itemAgents.Count > 0)
         {
             ZetanUtility.SetActive(UI.tips, false);
         }
         return(true);
     }
     return(false);
 }