Ejemplo n.º 1
0
        public void Setup(string npcName, List <TradeObjectRef> buyList, List <TradeObjectRef> sellList)
        {
            // setup window title
            string title;

            if (npcName != null)
            {
                title = string.Format(TextResources.WINDOWTITLE_NPCTRADE_WITH_NAME, npcName);
            }
            else
            {
                title = TextResources.WINDOWTITLE_NPCTRADE_NO_NAME;
            }

            _title.text = title;

            _currentTradeItem = null;

            // setup objects
            _buyTradeItems = new List <NPCTradeItem>();
            foreach (var tradeObject in buyList)
            {
                var tradeItem = CreateTradeItem(tradeObject);
                tradeItem.gameObject.SetActive(true);
                _buyTradeItems.Add(tradeItem);
            }

            _sellTradeItems = new List <NPCTradeItem>();
            foreach (var tradeObject in sellList)
            {
                var tradeItem = CreateTradeItem(tradeObject);
                tradeItem.gameObject.SetActive(false);
                _sellTradeItems.Add(tradeItem);
            }

            _forceDontUpdateTradeItems = true;
            OnPlayerMoneyChange(0, OpenTibiaUnity.ContainerStorage.PlayerMoney);
            OnPlayerGoodsChange(OpenTibiaUnity.ContainerStorage.PlayerGoods);
            _forceDontUpdateTradeItems = false;

            InternalUpdateOffers();
            ShowBuyOffers();
        }
Ejemplo n.º 2
0
        private void ShowSellOffers()
        {
            if (_changingCurrentOffers || _buyTradeItems == null || _sellTradeItems == null)
            {
                return;
            }

            _changingCurrentOffers = true;
            _sellToggle.isOn       = true;

            foreach (var tradeItem in _buyTradeItems)
            {
                if (tradeItem.gameObject.activeSelf)
                {
                    tradeItem.gameObject.SetActive(false);
                }
            }

            foreach (var tradeItem in _sellTradeItems)
            {
                if (!tradeItem.gameObject.activeSelf)
                {
                    tradeItem.gameObject.SetActive(true);
                }
            }

            if (_sellTradeItems.Count > 0)
            {
                _sellTradeItems[0].toggle.isOn = true;
            }
            else
            {
                _currentTradeItem = null;
            }

            _changingCurrentOffers = false;
        }
Ejemplo n.º 3
0
        private void OnTradeItemValueChanged(NPCTradeItem tradeItem, bool value)
        {
            if (!value)
            {
                return;
            }

            _currentTradeItem = tradeItem;
            var tradeObject = _currentTradeItem.tradeObject;

            if (tradeObject.Amount == 0)
            {
                _amountSlider.minValue = 0;
                _amountSlider.maxValue = 0;
            }
            else
            {
                _amountSlider.minValue = 1;
                _amountSlider.maxValue = tradeObject.Amount;
            }

            _amountSlider.handleRect.gameObject.SetActive(_amountSlider.maxValue != 0);
            UpdateTradeAmount((int)_amountSlider.value);
        }