public void Awake()
        {
            vendorUI         = InventoryManager.instance.vendor;
            animator         = GetComponent <Animator>();
            triggerer        = GetComponent <ObjectTriggerer>();
            triggerer.window = vendorUI.window;
            triggerer.handleWindowDirectly = false; // We're in charge now :)

            buyBackParent = new GameObject("Vendor_BuyBackContainer").transform;
            buyBackParent.SetParent(InventoryManager.instance.collectionObjectsParent);

            CreateGenerator();


            triggerer.OnTriggerUse += () =>
            {
                // Set items
                vendorUI.SetItems(forSale, false);
                vendorUI.currentVendor  = this;
                vendorUI.OnRemovedItem += vendorUI_OnRemovedItem;

                if (vendorUI.window.isVisible == false)
                {
                    vendorUI.window.Show();
                }
            };
            triggerer.OnTriggerUnUse += () =>
            {
                vendorUI.window.Hide();
                vendorUI.currentVendor  = null;
                vendorUI.OnRemovedItem -= vendorUI_OnRemovedItem;
            };
        }
        public override void Awake()
        {
            base.Awake();
            vendorUI = InventoryManager.instance.vendor;

            // Assuming we're using InventoryUIItemWrapperVendor here...
            for (int i = 0; i < items.Length; i++)
            {
                var s = ((InventoryUIItemWrapperVendor)items[i]);
                s.vendor      = vendorUI;
                s.isInBuyBack = true;
            }

            InventoryManager.instance.inventory.OnGoldChanged += (float amountAdded) =>
            {
                foreach (var item in items)
                {
                    item.Repaint();
                }
            };

            window.OnShow += () =>
            {
                UpdateItems();
            };

            vendorUI.OnSoldItemToVendor += (InventoryItemBase item, uint amount, VendorTriggerer vendor) =>
            {
                UpdateItems();
            };

            vendorUI.OnBoughtItemBackFromVendor += (InventoryItemBase item, uint amount, VendorTriggerer vendor) =>
            {
                UpdateItems();
            };
        }
        public override void Awake()
        {
            base.Awake();
            vendorUI = InventoryManager.instance.vendor;

            // Assuming we're using InventoryUIItemWrapperVendor here...
            for (int i = 0; i < items.Length; i++)
            {
                var s = ((InventoryUIItemWrapperVendor)items[i]);
                s.vendor = vendorUI;
                s.isInBuyBack = true;
            }

            InventoryManager.instance.inventory.OnGoldChanged += (float amountAdded) =>
            {
                foreach (var item in items)
                {
                    item.Repaint();
                }
            };

            window.OnShow += () =>
            {
                UpdateItems();
            };

            vendorUI.OnSoldItemToVendor += (InventoryItemBase item, uint amount, VendorTriggerer vendor) =>
            {
                UpdateItems();
            };

            vendorUI.OnBoughtItemBackFromVendor += (InventoryItemBase item, uint amount, VendorTriggerer vendor) =>
            {
                UpdateItems();
            };
        }
        public void Awake()
        {
            vendorUI = InventoryManager.instance.vendor;
            animator = GetComponent<Animator>();
            triggerer = GetComponent<ObjectTriggerer>();
            triggerer.window = vendorUI.window;
            triggerer.handleWindowDirectly = false; // We're in charge now :)

            buyBackParent = new GameObject("Vendor_BuyBackContainer").transform;
            buyBackParent.SetParent(InventoryManager.instance.collectionObjectsParent);

            CreateGenerator();

            triggerer.OnTriggerUse += () =>
            {
                // Set items
                vendorUI.SetItems(forSale, false);
                vendorUI.currentVendor = this;
                vendorUI.OnRemovedItem += vendorUI_OnRemovedItem;

                if (vendorUI.window.isVisible == false)
                {
                    vendorUI.window.Show();
                }
            };
            triggerer.OnTriggerUnUse += () =>
            {
                vendorUI.window.Hide();
                vendorUI.currentVendor = null;
                vendorUI.OnRemovedItem -= vendorUI_OnRemovedItem;
            };
        }
Пример #5
0
        public void Awake()
        {
            vendorUI = InventoryManager.instance.vendor;
            if (vendorUI == null)
            {
                Debug.LogWarning("No vendor UI found, yet there's a vendor in the scene.", transform);
                return;
            }

            animator = GetComponent<Animator>();
            triggerer = GetComponent<ObjectTriggerer>();
            triggerer.window = vendorUI.window;
            triggerer.handleWindowDirectly = false; // We're in charge now :)

            buyBackDict = new Dictionary<string, List<InventoryItemBase>>();

            buyBackParent = new GameObject("Vendor_BuyBackContainer").transform;
            buyBackParent.SetParent(InventoryManager.instance.collectionObjectsParent);


            triggerer.OnTriggerUse += Use;
            triggerer.OnTriggerUnUse += UnUse;
        }