Exemplo n.º 1
0
    public int waitSeconds = 3 * 60;      // Interval for free gift: 3 minutes.

    void OnGUI()
    {
        if (textStyle == null)
        {
            SetUpStyles();
        }

        GUILayout.BeginHorizontal(GUI.skin.label, GUILayout.Width(Screen.width));
        GUILayout.Label("FreeGift:", textStyle);
        // Main routine: Control Free Gift.
        if (FreeGiftTimer.IsValid())
        {
            if (FreeGiftTimer.CanSend())
            {
                // Can get a free gift.
                if (GUILayout.Button("Get", buttonStyle))
                {
                    FreeGiftTimer.SetNextWait(waitSeconds);
                }
            }
            else
            {
                // Cannot get a free gift because the time has not yet come.
                GUILayout.Label("Next: " + FreeGiftTimer.GetRemainingTime() + " sec later", textStyle);
            }
        }
        else
        {
            // Cannot get a free gift because the clock is invalid.
            GUILayout.Label("Unavailable", textStyle);
        }
        GUILayout.EndHorizontal();
    }
Exemplo n.º 2
0
    public void OnGetButtonPressed()
    {
        FreeGiftTimer.SetNextWait(waitSeconds);

        // Hide all UIs.
        invalidNode.SetActive(false);
        waitingNode.SetActive(false);
        canSendNode.SetActive(false);

        gameObject.SetActive(false);         // Pause self action until coin demo will be finished.
        //var coin = FREE_GIFT_COIN_TABLE[Random.Range(0, FREE_GIFT_COIN_TABLE.Length)];
        gameObject.SetActive(true);          // Resume.
        CollectStars();
    }