示例#1
0
    public void SetCharSelected(int index, Sprite img)
    {
        daScript.Pop();

        charSelected.enabled = true;
        charSprite           = img;
        charSelected.sprite  = charSprite;
        charIndex            = index;

        currentName.text     = "" + pScript.GetCharName(index);
        currentJump.text     = "" + pScript.GetCharJumpTimes(index).ToString();
        currentDistance.text = "" + pScript.GetCharDistance(index).ToString();
        currentLevel.text    = "" + pScript.GetCharLevel(index).ToString();
    }
示例#2
0
    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);
            }
        }
    }