Ejemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    public void PreviewItem(bl_ShopItemData info, Vector3 origin)
    {
        if (info.Type == ShopItemType.Weapon)
        {
            BuyIconImage.sprite = info.GunInfo.GunIcon;
        }
        else if (info.Type == ShopItemType.PlayerSkin)
        {
#if PSELECTOR
            BuyIconImage.sprite = info.PlayerSkinInfo.Preview;
#endif
        }
        else if (info.Type == ShopItemType.WeaponCamo)
        {
#if CUSTOMIZER
            BuyIconImage.sprite = info.camoInfo.spritePreview();
#endif
        }

        BuyNameText.text  = info.Name.ToUpper();
        BuyPriceText.text = string.Format("{0}{1}", bl_ShopData.Instance.PricePrefix, info.Price);
        previewData       = info;
#if SHOP
        CurrentPrice = info.Price;
#endif
        BuyWindow.SetActive(false);
        BuyWindow.SetActive(true);
        StopCoroutine("OpenBuyWindow");
        StartCoroutine("OpenBuyWindow", origin);
    }
Ejemplo n.º 2
0
    public void Preview(bl_ShopItemData info, bool isOwned)
    {
        foreach (Image i in PreviewIcons)
        {
            i.gameObject.SetActive(false);
        }
        InfoPanel.SetActive(true);
        infoPreviewData       = info;
        PreviewNameText.text  = info.Name.ToUpper();
        PreviewPriceText.text = string.Format("PRICE {0}{1}", bl_ShopData.Instance.PricePrefix, info.Price);
        if (info.Type == ShopItemType.Weapon)
        {
            PreviewIcons[0].gameObject.SetActive(true);
            PreviewIcons[0].sprite = info.GunInfo.GunIcon;
            PreviewBars[0].transform.parent.parent.GetComponentInChildren <Text>().text = "DAMAGE:";
            PreviewBars[0].fillAmount = (float)info.GunInfo.Damage / 100f;
            PreviewBars[1].transform.parent.parent.GetComponentInChildren <Text>().text = "FIRE RATE:";
            PreviewBars[1].fillAmount = info.GunInfo.FireRate / 1f;
            PreviewBars[2].transform.parent.parent.GetComponentInChildren <Text>().text = "ACCURACY:";
            PreviewBars[2].fillAmount = (float)info.GunInfo.Accuracy / 5f;
            PreviewBars[3].transform.parent.parent.GetComponentInChildren <Text>().text = "WEIGHT:";
            PreviewBars[3].fillAmount = (float)info.GunInfo.Weight / 4f;
        }
        else if (info.Type == ShopItemType.PlayerSkin)
        {
#if PSELECTOR
            PreviewIcons[1].gameObject.SetActive(true);
            PreviewIcons[1].sprite = info.PlayerSkinInfo.Preview;
            bl_PlayerHealthManager   pdm = info.PlayerSkinInfo.Prefab.GetComponent <bl_PlayerHealthManager>();
            bl_FirstPersonController fpc = info.PlayerSkinInfo.Prefab.GetComponent <bl_FirstPersonController>();
            PreviewBars[0].transform.parent.parent.GetComponentInChildren <Text>().text = "HEALTH:";
            PreviewBars[0].fillAmount = pdm.health / 125;
            PreviewBars[1].transform.parent.parent.GetComponentInChildren <Text>().text = "SPEED:";
            PreviewBars[1].fillAmount = fpc.WalkSpeed / 5;
            PreviewBars[2].transform.parent.parent.GetComponentInChildren <Text>().text = "REGENERATION:";
            PreviewBars[2].fillAmount = pdm.RegenerationSpeed / 5;
            PreviewBars[3].transform.parent.parent.GetComponentInChildren <Text>().text = "NOISE:";
            PreviewBars[3].fillAmount = 0.9f;
#endif
        }
        else if (info.Type == ShopItemType.WeaponCamo)
        {
#if CUSTOMIZER
            PreviewIcons[2].gameObject.SetActive(true);
            PreviewIcons[2].sprite = info.camoInfo.spritePreview();
            InfoPanel.SetActive(false);
#endif
        }
        BuyPreviewButton.SetActive(!isOwned);
    }
Ejemplo n.º 3
0
    /// <summary>
    ///
    /// </summary>
    void BuildData()
    {
        Items.Clear();
        Weapons = bl_GameData.Instance.AllWeapons;
        for (int i = 0; i < Weapons.Count; i++)
        {
            bl_ShopItemData data = new bl_ShopItemData();
            data.ID      = i;
            data.Name    = Weapons[i].Name;
            data.Type    = ShopItemType.Weapon;
            data.GunInfo = Weapons[i];
#if SHOP
            data.Price = Weapons[i].Price;
#endif
            Items.Add(data);
        }

#if PSELECTOR
        var allPlayers = bl_PlayerSelector.Data.AllPlayers;
        for (int i = 0; i < allPlayers.Count; i++)
        {
            var             pinfo = allPlayers[i];
            bl_ShopItemData data  = new bl_ShopItemData();
            data.ID             = i;
            data.Name           = pinfo.Name;
            data.Type           = ShopItemType.PlayerSkin;
            data.PlayerSkinInfo = pinfo;
            data.Price          = pinfo.Price;
            Items.Add(data);
        }
#endif

#if CUSTOMIZER
        for (int i = 0; i < bl_CustomizerData.Instance.GlobalCamos.Count; i++)
        {
            if (i == 0)
            {
                continue;        //skip the default camo
            }
            var             gc   = bl_CustomizerData.Instance.GlobalCamos[i];
            bl_ShopItemData data = new bl_ShopItemData();
            data.ID       = i;
            data.Name     = gc.Name;
            data.Type     = ShopItemType.WeaponCamo;
            data.camoInfo = gc;
            data.Price    = gc.Price;
            Items.Add(data);
        }
#endif
    }
Ejemplo n.º 4
0
        public void Set(bl_ShopItemData _info)
        {
            foreach (Image i in Icons)
            {
                i.gameObject.SetActive(false);
            }
            Info = _info;
#if SHOP
            ID = _info.ID;
#endif
            TypeID        = _info.Type;
            NameText.text = Info.Name.ToUpper();
            string typeName = _info.Type.ToString();
            typeName      = string.Concat(typeName.Select(x => System.Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');
            typeText.text = typeName.Localized(_info.Type.ToString().ToLower()).ToUpper();
            LayoutRebuilder.ForceRebuildLayoutImmediate(NameText.transform.parent.GetComponent <RectTransform>());
            LayoutRebuilder.ForceRebuildLayoutImmediate(typeText.transform.parent.GetComponent <RectTransform>());
            //that's kinda dirty but it works :)
            foreach (MonoBehaviour b in oneTimeUsed)
            {
                Destroy(b);
            }
            if (Info.Price <= 0)
            {
                BuyUI.SetActive(false);
                isOwned = true;
                GetComponent <Selectable>().interactable = false;
                OwnedUI.SetActive(true);
            }
            else
            {
                //if this item has been purchase
#if ULSP && SHOP
                if (bl_DataBase.Instance != null && bl_DataBase.Instance.LocalUser.ShopData != null && bl_DataBase.Instance.LocalUser.ShopData.isItemPurchase(TypeID, ID))
                {
                    BuyUI.SetActive(false);
                    isOwned = true;
                    GetComponent <Selectable>().interactable = false;
                    OwnedUI.SetActive(true);
                }
                else
                {
                    PriceText.text = string.Format("{0}{1}", bl_ShopData.Instance.PricePrefix, Info.Price);
                    BuyUI.SetActive(true);
                    isOwned = false;
                    BuyButton.gameObject.SetActive(true);
                    OwnedUI.SetActive(false);
                }
#endif
            }
            if (_info.Type == ShopItemType.Weapon)
            {
                SetIcon(Info.GunInfo.GunIcon, 0);
            }
            else if (_info.Type == ShopItemType.PlayerSkin)
            {
#if PSELECTOR
                SetIcon(Info.PlayerSkinInfo.Preview, 1);
#endif
            }
            else if (Info.Type == ShopItemType.WeaponCamo)
            {
#if CUSTOMIZER
                SetIcon(Info.camoInfo.spritePreview(), 2);
#endif
            }
        }
Ejemplo n.º 5
0
 public bool isItemPurchase(bl_ShopItemData data)
 {
     return(ShopPurchases.Exists(x => x.TypeID == (int)data.Type && x.ID == data.ID));
 }