summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/PurchaseButton.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/PurchaseButton.cs')
-rw-r--r--Client/Assembly-CSharp/PurchaseButton.cs90
1 files changed, 90 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/PurchaseButton.cs b/Client/Assembly-CSharp/PurchaseButton.cs
new file mode 100644
index 0000000..56c3171
--- /dev/null
+++ b/Client/Assembly-CSharp/PurchaseButton.cs
@@ -0,0 +1,90 @@
+using System;
+using UnityEngine;
+
+public class PurchaseButton : MonoBehaviour
+{
+ public StoreMenu Parent { get; set; }
+
+ public SpriteRenderer PurchasedIcon;
+
+ public TextRenderer NameText;
+
+ public SpriteRenderer HatImage;
+
+ public Sprite MannequinFrame;
+
+ public SpriteRenderer Background;
+
+ public IBuyable Product;
+
+ public bool Purchased;
+
+ public string Name;
+
+ public string Price;
+
+ public string ProductId;
+
+ public void SetItem(IBuyable product, string productId, string name, string price, bool purchased)
+ {
+ this.Product = product;
+ this.Purchased = purchased;
+ this.Name = name;
+ this.Price = price;
+ this.ProductId = productId;
+ this.PurchasedIcon.enabled = this.Purchased;
+ if (this.Product is HatBehaviour)
+ {
+ HatBehaviour hat = (HatBehaviour)this.Product;
+ this.NameText.gameObject.SetActive(false);
+ this.HatImage.transform.parent.gameObject.SetActive(true);
+ PlayerControl.SetHatImage(hat, this.HatImage);
+ this.SetSquare();
+ return;
+ }
+ if (this.Product is SkinData)
+ {
+ SkinData skin = (SkinData)this.Product;
+ this.NameText.gameObject.SetActive(false);
+ this.HatImage.transform.parent.gameObject.SetActive(true);
+ this.HatImage.transform.parent.GetComponent<SpriteRenderer>().sprite = this.MannequinFrame;
+ this.HatImage.transform.parent.localPosition = new Vector3(0f, 0f, -0.01f);
+ this.HatImage.transform.parent.localScale = Vector3.one * 0.3f;
+ this.HatImage.transform.localPosition = new Vector3(0f, 0f, -0.01f);
+ this.HatImage.transform.localScale = Vector3.one * 2f;
+ PlayerControl.SetSkinImage(skin, this.HatImage);
+ this.SetSquare();
+ return;
+ }
+ if (this.Product is PetBehaviour)
+ {
+ PetBehaviour petBehaviour = (PetBehaviour)this.Product;
+ this.NameText.gameObject.SetActive(false);
+ this.HatImage.transform.parent.gameObject.SetActive(true);
+ this.HatImage.transform.parent.GetComponent<SpriteRenderer>().enabled = false;
+ this.HatImage.material = new Material(petBehaviour.rend.sharedMaterial);
+ PlayerControl.SetPetImage(petBehaviour, (int)SaveManager.BodyColor, this.HatImage);
+ this.SetSquare();
+ return;
+ }
+ this.NameText.Text = this.Name;
+ }
+
+ private void SetSquare()
+ {
+ this.Background.size = new Vector2(0.7f, 0.7f);
+ this.Background.GetComponent<BoxCollider2D>().size = new Vector2(0.7f, 0.7f);
+ this.PurchasedIcon.transform.localPosition = new Vector3(0f, 0f, -1f);
+ }
+
+ internal void SetPurchased()
+ {
+ this.Purchased = true;
+ this.PurchasedIcon.enabled = true;
+ }
+
+ public void DoPurchase()
+ {
+ this.Parent.SetProduct(this);
+ }
+}