public void SelectChar() { if (bPanel.IsPanelMovedIn()) { watchAdsBut = GameObject.FindGameObjectWithTag("uiWatchAds").GetComponent <WatchAdsButton>(); if (watchAdsBut == null) { Debug.Log("Character Button script couldnt get reference to the watch ads button."); } watchAdsBut.SetWiggle(false); if (!IsInCenter()) { ForceToCenter(); charSelectHighLight.SetActive(true); //playSound = false; } else { playSound = true; } // save the scroll position to saved data GameSaver.gSaver.scrollViewPosition = scrollRect.horizontalNormalizedPosition; if (!pScript.GetCharPurchased(charIndex)) { Button btn = buyButton.GetComponent <Button>(); if (btn == null) { Debug.Log("Character Button couldnt get a reference to the Buy Button Button Script"); } btn.enabled = true; BuyButton bbtn = buyButton.GetComponent <BuyButton>(); if (btn == null) { Debug.Log("Menu Button couldnt get a reference to the Buy Button Button component."); } else { bbtn.SetWiggle(true); Sprite img = gameObject.GetComponent <Image>().sprite; bbtn.SetCharIndex(charIndex, img); } audioOut.PlayOneShot(acClickSelect, 0.9f); //get rid of arrow daScript.UnPop(); menuButton.ShowCharFields(); charCost.text = "" + pScript.GetCharCost(charIndex).ToString(); charDist.text = "" + pScript.GetCharDistance(charIndex).ToString(); charJump.text = "" + pScript.GetCharJumpTimes(charIndex).ToString(); } else { Button btn = buyButton.GetComponent <Button>(); if (btn == null) { Debug.Log("Character Button couldnt get a reference to the Buy Button"); } btn.enabled = false; BuyButton bbtn = buyButton.GetComponent <BuyButton>(); if (btn == null) { Debug.Log("Menu Button couldnt get a reference to the Buy Button Button component."); } else { bbtn.SetWiggle(false); } audioOut.PlayOneShot(acClickOn, 0.8f); //make the arrow pop daScript.Pop(); menuButton.ClearCharFields(); charCost.text = ""; charDist.text = ""; charJump.text = ""; Sprite img = gameObject.GetComponentInChildren <Image>().sprite; menuButton.SetCharSelected(charIndex, img); } } }
public void OpenMenu() { if (scrollView != null && !gScript.IsRoundNewTime()) { if (disableMenuButton == false) { if (scrollIsActive == false) { gScript.PauseGame(true); buyPanelActive = true; panel.SetActive(true); audioOut.PlayOneShot(acClickOn, 0.8f); backGroundFade.SetActive(true); buyButton.SetActive(true); BackButton blarg = backButton.GetComponentInParent <BackButton>(); if (roundOver == true) { backButton.enabled = false; if (blarg != null) { blarg.SetAlpha(0f); } } else { backButton.enabled = true; if (blarg != null) { blarg.SetAlpha(255f); } } // move the canvas in bPanel.SetMovePanelIn(); watchAdsBut = GameObject.FindGameObjectWithTag("uiWatchAds").GetComponent <WatchAdsButton>(); if (watchAdsBut == null) { Debug.Log("Menu Button script couldnt get reference to the watch ads button."); } watchAdsBut.SetWiggle(false); Button btn = buyButton.GetComponent <Button>(); if (btn == null) { Debug.Log("Menu Button couldnt get a reference to the Buy Button Button component."); } else { btn.enabled = false; } BuyButton bbtn = buyButton.GetComponent <BuyButton>(); if (btn == null) { Debug.Log("Menu Button couldnt get a reference to the Buy Button Button component."); } else { bbtn.SetWiggle(false); } // get reference to the text that shows the coin bank and update Text coinB = GameObject.FindGameObjectWithTag("uiTotalCoins").GetComponent <Text>(); if (coinB != null) { string str = "" + gScript.GetBigCoinBank().ToString(); coinB.text = str; } // update current lerper character fields currentName.text = "" + pScript.GetCharName(charIndex); currentJump.text = "" + pScript.GetCharJumpTimes(charIndex).ToString(); currentDistance.text = "" + pScript.GetCharDistance(charIndex).ToString(); currentLevel.text = "" + pScript.GetCharLevel(charIndex).ToString(); // close the winpanel //winPanel.SetActive(false); playButton.enabled = true; scrollView.SetActive(true); scrollIsActive = true; GameSaver.gSaver.SaveData(); Debug.Log("bugger"); } else { if (roundOver == false) { CloseMenu(); } } } } }
// Use this for initialization void Start() { menuButton = GameObject.FindGameObjectWithTag("MenuButton").GetComponent <MenuButton>(); if (menuButton == null) { Debug.Log("BuyButton couldnt get a reference to the Menu Button"); } button = GetComponent <Button>(); if (button == null) { Debug.Log("Menu Button script could not get a reference to the button sript."); } else { button.onClick.AddListener(BuyItem); } gScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <LerpGameController>(); if (gScript == null) { Debug.Log("Buy Button script could not get a reference to the game controller."); } pScript = GameObject.FindGameObjectWithTag("PlayerController").GetComponent <PlayerController>(); if (pScript == null) { Debug.Log("Buy Button script could not get a reference to the player controller."); } audioOut = GetComponent <AudioSource>(); if (audioOut == null) { Debug.Log("Buy Button couldnt get its Audio Source component."); } charCostText = GameObject.FindGameObjectWithTag("uiCharCostField").GetComponent <Text>(); if (charCostText == null) { Debug.Log("Buy button script could not get a reference to the Character Cost Text component."); } totCoinsField = GameObject.FindGameObjectWithTag("uiTotalCoins").GetComponent <Text>(); if (totCoinsField == null) { Debug.Log("Buy button script couldnt get a reference to the Panels Total Coins Field"); } anim = GetComponent <Animator>(); if (anim == null) { Debug.Log("Buy Button couldnt get reference to its animator component"); } img = GetComponent <Image>(); if (img == null) { Debug.Log("Buy Button couldnt get reference to its Image component"); } buyButText = GetComponentInChildren <Text>(); if (buyButText == null) { Debug.Log("Buy Button Script couldnt get reference to the Text child component."); } watchAdsBut = GameObject.FindGameObjectWithTag("uiWatchAds").GetComponent <WatchAdsButton>(); if (watchAdsBut == null) { Debug.Log("Buy Button script couldnt get reference to the watch ads button."); } charIndex = 0; charSprite = null; }