Beispiel #1
0
        public void Activate()
        {
            if (GameManager.IsScreenResolutionGreaterOrEqualThanFHD)
            {
                Resize();
            }

            if (renderTexture != null)
            {
                Debug.Log("Render texture not null!!", Debug.LogType.Warning);
            }
            else
            {
                renderTexture = new RenderTexture((int)itemRenderer.rectTransform.sizeDelta.x,
                                                  (int)itemRenderer.rectTransform.sizeDelta.y, 16, RenderTextureFormat.ARGBHalf);
            }

            var product = TradeMenu.Mid.ItemProduct;

            costText.text = UI_Shop.Instance.TradeType == TradeType.Buy ? product.PriceBuyString : product.PriceSellString;

            itemRenderer.texture = renderTexture;
            itemPreview          = Item_Preview.InstantiateItemPrefab(product.Product, Vector2.zero);
            itemPreview.enabled  = true;
            UI_ItemRenderer.ResetCameraPositionAndRotation(product.Product, itemPreview.transform);
            UI_ItemRenderer.SetTexture(renderTexture);

            UpdateAsync();
        }
Beispiel #2
0
        public void Deactivate()
        {
            if (UI_Shop.Instance.TradeType == TradeType.Buy)
            {
                Right.Shop.Left.Buy.ItemParent.OnSelectedItemChanged.RemoveListener(OnSelectedItemChanged);
            }
            else
            {
                Right.Shop.Left.Sell.ItemParent.OnSelectedItemChanged.RemoveListener(OnSelectedItemChanged);
            }

            if (itemRenderer.texture != null)
            {
                Destroy(itemRenderer.texture);
            }

            Effect.Deactivate();

            itemRenderer.texture = null;
            UI_ItemRenderer.SetTexture(null);
            Destroy(renderTexture);
            renderTexture = null;

            if (itemPreview != null)
            {
                Destroy(itemPreview);
                itemPreview = null;
            }
        }
Beispiel #3
0
        private void OnSelectedItemChanged(Item_Product itemProduct)
        {
            if (itemProduct == null)
            {
                Destroy(itemPreview);
                itemPreview = null;

                itemRenderer.enabled = false;
                itemName.text        = null;
                itemDesription.text  = null;

                Effect.Deactivate();
            }

            else
            {
                itemPreview          = Item_Preview.InstantiateItemPrefab(itemProduct.Product, Vector2.zero);
                itemPreview.enabled  = true;
                itemRenderer.enabled = true;
                itemName.text        = itemProduct.Product.ItemName;
                itemDesription.text  = itemProduct.Product.ItemDescription;
                Effect.Activate(itemProduct);

                UI_ItemRenderer.ResetCameraPositionAndRotation(itemProduct.Product, itemPreview.transform);
                UI_ItemRenderer.SetTexture(renderTexture);
                UI_ItemRenderer.Render();

                UpdateAsync();
            }
        }
Beispiel #4
0
        private async void UpdateAsync()
        {
            while (renderTexture != null)
            {
                await AsyncManager.WaitForFrame(1);

                UI_ItemRenderer.Render();
            }
        }
Beispiel #5
0
        private void CleanItem()
        {
            UI_ItemRenderer.SetTexture(null);

            foreach (var itemIcon in itemIconsList)
            {
                itemIcon.ReturnToPool();
            }

            instantiatedPrefabDic.Clear();
            itemIconsList.Clear();
            itemIconsPool.Clear();

            UI_Menu_Inventory_Left_EquippedItemIcon.SetToNull();
        }
Beispiel #6
0
        private async void UpdateAsync()
        {
            var instanceID = itemPreview.GetInstanceID();

            while (itemPreview != null && instanceID == itemPreview.GetInstanceID())
            {
                await AsyncManager.WaitForFrame(1);

                if (itemPreview != null)
                {
                    UI_ItemRenderer.ResetCameraPositionAndRotation(itemPreview.ItemBase, itemPreview.transform);
                    UI_ItemRenderer.SetTexture(renderTexture);
                    UI_ItemRenderer.Render();
                }
            }
        }
Beispiel #7
0
        public void Deactivate()
        {
            if (renderTexture != null)
            {
                Destroy(renderTexture);
                renderTexture = null;
            }

            if (itemPreview != null)
            {
                Destroy(itemPreview);
                itemPreview = null;
            }

            itemRenderer.texture = null;
            UI_ItemRenderer.SetTexture(null);
        }
Beispiel #8
0
        private async void RenderCameraForTheFirstTime()
        {
            await AsyncManager.WaitForFrame(2);

            foreach (var t in itemIconsList)
            {
                UI_ItemRenderer.SetPosition(t.ItemRenderer.ItemPreview.transform.position - new Vector3(0, 0, 1));
                UI_ItemRenderer.SetTexture(t.ItemRenderer.RawImage.texture as RenderTexture);
                UI_ItemRenderer.ResetCameraPositionAndRotation(t.Item, t.ItemRenderer.ItemPreview.transform);

                t.ItemRenderer.ItemPreview.ResetRotation();
                t.ItemRenderer.ItemPreview.UpdateMaterial();
                UI_ItemRenderer.Render();

                t.ItemRenderer.gameObject.SetActive(true);
            }
        }
Beispiel #9
0
        private async void InstantiateItem()
        {
            var products       = Buy.Left.Shop.Products;
            var position       = new Vector3(RectTransform.position.x, RectTransform.position.y + (RectTransform.sizeDelta.y * 0.5f));
            var spacingPerItem = 10.0f;

            position.y -= itemPrefab.RectTransform.sizeDelta.y * 0.5f;

            items = new UI_Shop_Left_Buy_ItemChild[maxVisibleItem];
            for (int i = startIndex; i < startIndex + maxVisibleItem; i++)
            {
                if (i > products.Count - 1)
                {
                    break;
                }

                var product = Instantiate(itemPrefab, RectTransform);
                product.Initialize(products.ElementAt(i), this, position);
                items[i - startIndex] = product;

                position.y -= itemPrefab.RectTransform.sizeDelta.y + spacingPerItem;
            }

            await AsyncManager.WaitForFrame(1);

            int index = startIndex;

            foreach (var item in items)
            {
                if (index > products.Count - 1)
                {
                    break;
                }

                UI_ItemRenderer.ResetCameraPositionAndRotation(products.ElementAt(index).Product, item.ItemPreview.transform);
                UI_ItemRenderer.SetTexture(item.ItemRenderer.texture as RenderTexture);
                UI_ItemRenderer.Render();

                index++;
            }

            UI_ItemRenderer.SetTexture(null);
        }
Beispiel #10
0
        private void OnItemTypeChanged(ItemType itemType)
        {
            UI_ItemRenderer.Deactivate();
            UI_ItemRenderer.SetTexture(null);

            foreach (var i in itemIconsList)
            {
                i.ItemRenderer.DestroyItemPreview();
                i.ItemRenderer.gameObject.SetActive(false);
                i.gameObject.SetActive(false);
                itemIconsPool.Push(i);
            }

            instantiatedPrefabDic.Clear();
            itemIconsList.Clear();

            InstantiateItemIconBackground();

            UI_ItemRenderer.Activate();
        }
Beispiel #11
0
 public void UpdateMaterial()
 {
     material.SetVector("_CamDir", UI_ItemRenderer.GetCameraTransform().forward);
 }
Beispiel #12
0
 private void RenderCamera()
 {
     UI_ItemRenderer.SetTexture(RawImage.texture as RenderTexture);
     UI_ItemRenderer.Render();
 }
Beispiel #13
0
 public void ResetCameraPositionAndRotation()
 {
     UI_ItemRenderer.ResetCameraPositionAndRotation(ItemPreview.ItemBase, ItemPreview.transform);
 }