Add unclaim button
This commit is contained in:
@@ -171,49 +171,43 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
|||||||
GameObject newIcon = Instantiate(sample, content.transform);
|
GameObject newIcon = Instantiate(sample, content.transform);
|
||||||
newIcon.name = "IconEntry";
|
newIcon.name = "IconEntry";
|
||||||
Tools.RenderFromBase64(entry.Data, newIcon.transform.GetChild(0).GetChild(0).GetComponent<Image>());
|
Tools.RenderFromBase64(entry.Data, newIcon.transform.GetChild(0).GetChild(0).GetComponent<Image>());
|
||||||
newIcon.transform.GetChild(1).GetComponent<TMP_Text>().text = "Bird Name: " + entry.Name;
|
newIcon.transform.GetChild(1).GetComponent<TMP_Text>().text = "Icon Name: " + entry.Name;
|
||||||
newIcon.transform.GetChild(2).GetComponent<TMP_Text>().text = "Price " + Tools.FormatWithCommas(entry.Price) + " coins";
|
newIcon.transform.GetChild(2).GetComponent<TMP_Text>().text = "Price " + Tools.FormatWithCommas(entry.Price) + " coins";
|
||||||
newIcon.transform.GetChild(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.CreatorUsername;
|
newIcon.transform.GetChild(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.CreatorUsername;
|
||||||
|
|
||||||
var btnGrid = newIcon.transform.GetChild(4);
|
var BtnGrid = newIcon.transform.GetChild(4);
|
||||||
var buybtn = btnGrid.transform.GetChild(0).GetComponent<Button>();
|
var buyBtn = BtnGrid.transform.GetChild(0).GetComponent<Button>();
|
||||||
var sellbtn = btnGrid.transform.GetChild(1).GetComponent<Button>();
|
var buyBtnText = buyBtn.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||||
var buyttnText = buybtn.transform.GetChild(0).GetComponent<TMP_Text>();
|
var sellBtn = BtnGrid.transform.GetChild(1).GetComponent<Button>();
|
||||||
|
var sellBtnText = sellBtn.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||||
|
|
||||||
sellbtn.onClick.AddListener(() =>
|
sellBtn.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
HandleSell(entry, buybtn, buyttnText, sellbtn, localUserID);
|
HandleSell(entry, buyBtn, buyBtnText, sellBtn, localUserID);
|
||||||
Tools.RefreshHierarchy(newIcon);
|
Tools.RefreshHierarchy(newIcon);
|
||||||
});
|
});
|
||||||
buybtn.onClick.AddListener(() =>
|
buyBtn.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
HandlePurchase(entry, buybtn, sellbtn, localUserID);
|
HandlePurchase(entry, buyBtn, sellBtn, localUserID);
|
||||||
Tools.RefreshHierarchy(newIcon);
|
Tools.RefreshHierarchy(newIcon);
|
||||||
});
|
});
|
||||||
bool alreadyBought = BazookaManager.Instance.GetCustomBirdIconData().Purchased.Any(d => d == entry.ID);
|
bool alreadyBought = BazookaManager.Instance.GetCustomBirdIconData().Purchased.Any(d => d == entry.ID);
|
||||||
if (alreadyBought)
|
if (alreadyBought)
|
||||||
{
|
{
|
||||||
buybtn.interactable = false;
|
buyBtn.interactable = false;
|
||||||
|
sellBtn.gameObject.SetActive(true);
|
||||||
if (localUserID != entry.CreatorUserID)
|
if (localUserID != entry.CreatorUserID)
|
||||||
{
|
buyBtnText.text = "Purchased";
|
||||||
buyttnText.text = "Purchased";
|
|
||||||
sellbtn.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buyttnText.text = "Claimed";
|
buyBtnText.text = "Claimed";
|
||||||
|
sellBtnText.text = "Unclaim";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (localUserID != entry.CreatorUserID)
|
if (localUserID != entry.CreatorUserID) buyBtnText.text = "Purchase";
|
||||||
{
|
else buyBtnText.text = "Claim";
|
||||||
buyttnText.text = "Purchase";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buyttnText.text = "Claim";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newIcon.SetActive(true);
|
newIcon.SetActive(true);
|
||||||
@@ -241,20 +235,21 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
|||||||
iconPurchaseSound.Play();
|
iconPurchaseSound.Play();
|
||||||
}
|
}
|
||||||
marketplaceIconStorage.Purchased.Add(data.ID);
|
marketplaceIconStorage.Purchased.Add(data.ID);
|
||||||
|
sellButton.gameObject.SetActive(true);
|
||||||
if (localUserID != data.CreatorUserID)
|
if (localUserID != data.CreatorUserID)
|
||||||
{
|
{
|
||||||
button.transform.GetChild(0).GetComponent<TMP_Text>().text = "Purchased";
|
button.transform.GetChild(0).GetComponent<TMP_Text>().text = "Purchased";
|
||||||
sellButton.gameObject.SetActive(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
button.transform.GetChild(0).GetComponent<TMP_Text>().text = "Claimed";
|
button.transform.GetChild(0).GetComponent<TMP_Text>().text = "Claimed";
|
||||||
|
sellButton.transform.GetChild(0).GetComponent<TMP_Text>().text = "Unclaim";
|
||||||
}
|
}
|
||||||
balanceText.text = Tools.FormatWithCommas(marketplaceIconStorage.Balance);
|
balanceText.text = Tools.FormatWithCommas(marketplaceIconStorage.Balance);
|
||||||
BazookaManager.Instance.SetCustomBirdIconData(marketplaceIconStorage);
|
BazookaManager.Instance.SetCustomBirdIconData(marketplaceIconStorage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleSell(MarketplaceTempIcon data, Button buyBtn, TMP_Text buyttnText, Button sellButton, BigInteger? localUserID)
|
void HandleSell(MarketplaceTempIcon data, Button buyBtn, TMP_Text buyBtnText, Button sellButton, BigInteger? localUserID)
|
||||||
{
|
{
|
||||||
MarketplaceIconStorageType marketplaceIconStorage = BazookaManager.Instance.GetCustomBirdIconData();
|
MarketplaceIconStorageType marketplaceIconStorage = BazookaManager.Instance.GetCustomBirdIconData();
|
||||||
var owned = marketplaceIconStorage.Purchased.Contains(data.ID);
|
var owned = marketplaceIconStorage.Purchased.Contains(data.ID);
|
||||||
@@ -267,8 +262,12 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
|||||||
iconPurchaseSound.Play();
|
iconPurchaseSound.Play();
|
||||||
balanceText.text = Tools.FormatWithCommas(marketplaceIconStorage.Balance);
|
balanceText.text = Tools.FormatWithCommas(marketplaceIconStorage.Balance);
|
||||||
BazookaManager.Instance.SetCustomBirdIconData(marketplaceIconStorage);
|
BazookaManager.Instance.SetCustomBirdIconData(marketplaceIconStorage);
|
||||||
if (localUserID != data.CreatorUserID) buyttnText.text = "Purchase";
|
if (localUserID != data.CreatorUserID) buyBtnText.text = "Purchase";
|
||||||
else buyttnText.text = "Claim";
|
else
|
||||||
|
{
|
||||||
|
buyBtnText.text = "Claim";
|
||||||
|
buyBtnText.text = "Claim";
|
||||||
|
}
|
||||||
buyBtn.interactable = true;
|
buyBtn.interactable = true;
|
||||||
sellButton.gameObject.SetActive(false);
|
sellButton.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user