public void LoadButtonState(BGSkin bgSkin) { if (PlayerPrefsManager.IsBGSkinUnblocked(bgSkin.index) == 1) { if (PlayerPrefsManager.GetCurrentBGSkin() == bgSkin.index) { stateText.text = "Using"; coin.SetActive(false); bgImage.sprite = greyBG; stateButton.interactable = false; GetCurrentBGSkin(bgSkin); } else { stateText.text = "Use"; coin.SetActive(false); bgImage.sprite = yellowBG; stateButton.interactable = true; GetCurrentBGSkin(bgSkin); } } else { stateText.text = bgSkin.price.ToString(); coin.SetActive(true); bgImage.sprite = greenBG; stateButton.interactable = true; GetCurrentBGSkin(bgSkin); } }
public void GetCurrentBGSkin(BGSkin bgSkin) { bgSkinAsset = ScriptableObject.CreateInstance <BGSkin>(); bgSkinAsset.name = bgSkin.name; bgSkinAsset.price = bgSkin.price; bgSkinAsset.index = bgSkin.index; bgSkinAsset.sprite = bgSkin.sprite; }
// Use this for initialization void Start() { stateButton = GetComponent <Button>(); //stateText = GetComponentInChildren<Text>(); //bgImage = GetComponent<Image>(); penAsset = ScriptableObject.CreateInstance <Pen>(); ballSkinAsset = ScriptableObject.CreateInstance <BallSkin>(); bgSkinAsset = ScriptableObject.CreateInstance <BGSkin>(); }
public void BuyOrUseBGSkin() { BGSkin bgSkin = bgSkinShop.bgSkinAsset; if (PlayerPrefsManager.IsBGSkinUnblocked(bgSkin.index) == 0) //buy ball then { if (bgSkin.price <= money) { Money -= bgSkin.price; PlayerPrefsManager.UnblockBGSkin(bgSkin.index); bgSkinShop.LoadButtonState(bgSkin); } } else if (PlayerPrefsManager.GetCurrentBGSkin() != bgSkin.index) //then use it; { PlayerPrefsManager.SetCurrentBGSkin(bgSkin.index); bgSkinShop.LoadButtonState(bgSkin); } }
void IdentifyTypeOfDisplayAndDisplayUI(int page) { PenDisplay[] penItems = gameObject.GetComponentsInChildren <PenDisplay>(); if (penItems.Length != 0) { Pen pen = penItems[page].pen; itemStateButton.GetComponent <ButtonState>().LoadButtonState(pen); return; } BallsDisplay[] ballsItem = gameObject.GetComponentsInChildren <BallsDisplay>(); if (ballsItem.Length != 0) { BallSkin ballskin = ballsItem[page].ballskin; itemStateButton.GetComponent <ButtonState>().LoadButtonState(ballskin); return; } BGSkinDisplay[] bgSkins = gameObject.GetComponentsInChildren <BGSkinDisplay>(); if (bgSkins.Length != 0) { BGSkin bgSkin = bgSkins[page].bgSkin; itemStateButton.GetComponent <ButtonState>().LoadButtonState(bgSkin); return; } }