示例#1
0
    void Awake()
    {
        controller = transform.parent.GetComponentInChildren<Controller>();
        purchaseManager = transform.parent.FindChild("SOOMLA").GetComponent<PurchaseManager>();
        frogPackages = GetComponentInParent<FrogPackages>();
        variableManager = GetComponentInParent<VariableManager>();
        advertisingManager = GetComponentInParent<AdvertisingManager>();
        canvas = GetComponent<RectTransform>();
        titleTransform = canvas.FindChild("Title").GetComponent<RectTransform>();

        mainMenu = canvas.FindChild("MainMenu").GetComponent<CanvasGroup>();
        frogButton = mainMenu.transform.FindChild("FrogButton").GetComponent<RectTransform>();
        settingsButton = mainMenu.transform.FindChild("SettingsButton").GetComponent<RectTransform>();

        settingsMenu = canvas.FindChild("SettingsPanel").GetComponent<CanvasGroup>();
        musicToggle = settingsMenu.transform.GetChild(0).FindChild("MusicToggle").GetComponent<Toggle>();

        hud = transform.FindChild("HUD").GetComponent<HUD>();
        hudCanvas = hud.GetComponent<CanvasGroup>();
        hudRect = hud.GetComponent<RectTransform>();

        qualityCountPanelCG = canvas.FindChild("QualityCountPanel").GetComponent<CanvasGroup>();
        qualityCountPanel = qualityCountPanelCG.GetComponent<RectTransform>();
        perfectCount = qualityCountPanel.FindChild("PerfectCount").GetComponent<TextMeshProUGUI>();
        greatCount = qualityCountPanel.FindChild("GreatCount").GetComponent<TextMeshProUGUI>();;
        okCount = qualityCountPanel.FindChild("OKCount").GetComponent<TextMeshProUGUI>();;

        flyIconPosition = new Vector2(screenWidth, 50);
        flyButton = canvas.FindChild ("FlyPanel").GetComponent<Button>();
        flyPanelCG = flyButton.GetComponent<CanvasGroup>();
        flyTextAnimator = flyButton.transform.FindChild("FlyCount").GetComponent<Animator>();
        flyCount = flyButton.transform.FindChild("FlyCount").GetComponent<TextMeshProUGUI>();
        flyToGoText = flyButton.transform.FindChild("ToGoText").GetComponent<TextMeshProUGUI>();
        tameFlyNet = Instantiate(tameFlyNetPrefab, flyIconPosition, Quaternion.identity) as GameObject;

        arrowPanelCG = canvas.FindChild("ArrowPanel").GetComponent<CanvasGroup>();
        arrowPanel = arrowPanelCG.GetComponent<RectTransform>();
        frogName = arrowPanel.FindChild("FrogName").GetComponent<TextMeshProUGUI>();
        arrowPanelBuyButton = arrowPanel.FindChild("BuyButton").gameObject;

        returnPanel = canvas.FindChild("ReturnPanel").GetComponent<CanvasGroup>();
        returnButton = returnPanel.transform.FindChild("ReturnButton").GetComponent<RectTransform>();

        Transform endGameTransform = canvas.FindChild("EndGamePanel");
        endGamePanel = endGameTransform.GetComponent<CanvasGroup>();
        giftButton = endGameTransform.FindChild("GiftsButton").gameObject;
        adButton = endGameTransform.FindChild("AdsButton").gameObject;

        timeUntilGiftText = endGameTransform.FindChild("TimeUntilGift").GetComponent<TextMeshProUGUI>();

        buyButtonObject = endGameTransform.FindChild("BuyButton").gameObject;
        buyButton = buyButtonObject.GetComponent<Button>();
        buyButtonText = buyButton.transform.FindChild("Text").GetComponent<TextMeshProUGUI>();
        buyButtonImage = buyButton.transform.FindChild("Image").GetComponent<Image>();
    }
示例#2
0
        /// <summary>
        /// Fade menu in and out
        /// </summary>
        /// <param name="cg"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="close"></param>
        /// <returns></returns>
        protected virtual IEnumerator FadeMenu(CanvasGroup cg, float from, float to, bool close = false)
        {
            cg.alpha = from;
            float elapsedTime = 0f;
            Vector3 travelTo = Vector3.zero;
            Vector3 travelFrom = Vector3.zero;

            RectTransform rt = cg.GetComponent<RectTransform>();

            if(close)
            {
                travelTo = new Vector3(rt.localPosition.x, rt.localPosition.y - 15, rt.localPosition.z);
                travelFrom = new Vector3(rt.localPosition.x, rt.localPosition.y, rt.localPosition.z);
            }
            else
            {
                travelFrom = new Vector3(rt.localPosition.x, rt.localPosition.y - 15, rt.localPosition.z);
                travelTo = new Vector3(rt.localPosition.x, rt.localPosition.y, rt.localPosition.z);
            }

            while(elapsedTime < menuFadeTime)
            {
                rt.localPosition = Vector3.Lerp(travelFrom, travelTo, elapsedTime / menuFadeTime);
                cg.alpha = Mathf.Lerp(from, to, elapsedTime / menuFadeTime);

                elapsedTime += Time.deltaTime;
                yield return null;
            }

            cg.alpha = to;

            if(close)
            {
                rt.localPosition = Vector3.zero;
                isActive = false;
                root.SetActive(false);
                if (stopsMovement) OnMenuClose();
            }
        }
示例#3
0
    //
    void Start()
    {
        Player = GetComponentInParent<InputManager>().controller.gameObject.GetComponent<playerBase>();

        _inventoryPanel = transform.FindChild("inventoryPanel").GetComponent<CanvasGroup>();
        _containerPanel = transform.FindChild("containerPanel").GetComponent<CanvasGroup>();

        //StartCoRoutine(fadeOut(ContainerPanel);

        StartCoroutine(fadeOut(ContainerPanel));

        if (_inventoryPanel != null)
        //            Debug.Log("found inventory");

        inventoryHeader = _inventoryPanel.transform.FindChild("Details").FindChild("Header").GetComponent<Text>();

        inventoryHeader.text = "Inventory - " + Player.PlayerData.Name;

        //generate slots
        Player.PlayerData.Inventory.Slots = new slotScript[Player.PlayerData.Inventory.Cols, Player.PlayerData.Inventory.Rows];
        for (int r = 0; r < Player.PlayerData.Inventory.Rows; r++)
        {
            for (int c = 0; c < Player.PlayerData.Inventory.Cols; c++)
            {

                GameObject slot = (GameObject)Instantiate(Resources.Load("emptySlot"));

                slot.transform.SetParent(_inventoryPanel.transform.FindChild("SlotHolder"),false);
                slot.GetComponent<RectTransform>().anchoredPosition = new Vector2(64 * c, -64 * r);

                slot.name = "X" + c + "Y" + r;
                slot.GetComponent<slotScript>().x = c;
                slot.GetComponent<slotScript>().y = r;
                slot.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);

                slot.GetComponent<RectTransform>().localPosition =
         new Vector3(slot.GetComponent<RectTransform>().localPosition.x,
                 slot.GetComponent<RectTransform>().localPosition.y,
                 0);

                Player.PlayerData.Inventory.Slots[c, r] = slot.GetComponent<slotScript>();
                slot.GetComponent<slotScript>().slotNum = Player.PlayerData.Inventory.Slots[c, r].ToString();

            }
        }

        _inventoryPanel.GetComponent<RectTransform>().sizeDelta = new Vector2(64 * Player.PlayerData.Inventory.Cols, (64 * Player.PlayerData.Inventory.Rows) + 30);
    }