Esempio n. 1
0
        public void Initialize(PopSlotViewData arg)
        {
            if (background == null || pop == null)
            {
                throw new NullReferenceException();
            }

            _data = arg;

            if (arg.SlotGuid == Guid.Empty)
            {
                background.GetComponent <Image>().sprite = null;
                background.GetComponent <Image>().color  = new Color(255, 255, 255, 0);
            }
            else
            {
                background.GetComponent <Image>().sprite = _data.SlotBackgroundImage;
            }

            if (arg.WorkerGuid == Guid.Empty)
            {
                pop.GetComponent <Image>().sprite = null;
                pop.GetComponent <Image>().color  = new Color(255, 255, 255, 0);
            }
            else
            {
                pop.GetComponent <Image>().sprite = _data.WorkerImage;
            }
        }
        public void UpdatePop(PopSlotViewData data)
        {
            if (popFace == null || popName == null ||
                popProduct == null || popConsumption == null)
            {
                throw new NullReferenceException();
            }

            popFace.sprite      = data.WorkerImage;
            popName.text        = data.WorkerName;
            popProduct.text     = string.Join("\n", data.Produces.Select(x => $"{x.goodsName}:{x.amount.ToString(CultureInfo.CurrentCulture)}"));
            popConsumption.text = string.Join("\n", data.Consumptions.Select(x => $"{x.goodsName}:{x.amount.ToString(CultureInfo.CurrentCulture)}"));
        }
Esempio n. 3
0
        private void AddSlot(PopSlotViewData data)
        {
            var slot = Instantiate(popSlotPrefab, slotContainer, true)?.GetComponent <PopSlotView>();

            if (slot == null)
            {
                throw new NullReferenceException();
            }

            slot.Initialize(data);
            slot.OnSelected
            .Where(slotData => slotData.WorkerGuid != Guid.Empty)
            .Subscribe(slotData => _onPopSelectedSubject.OnNext(slotData))
            .AddTo(this);
        }