예제 #1
0
    void Start()
    {
        GameStatus = GameStatus.WAITING;
        if (PlayerPrefs.GetString("LastTimeOpenGift", "") == "")
        {
            PlayerPrefs.SetString("LastTimeOpenGift", DateTime.UtcNow.ToString());
        }
        TimeSpan diffTime = DateTime.Parse(PlayerPrefs.GetString("LastTimeOpenGift", "")).Subtract(DateTime.UtcNow);

        Debug.Log(diffTime.TotalSeconds);
        if (Math.Abs(diffTime.TotalSeconds) > 3600 && AdManager.Ins.rewardBasedVideo.IsLoaded())
        {
            GiftBoxPanel.SetActive(true);
        }
        ;
        txtTotalStar.text = PlayerPrefs.GetInt("totalStar", 0).ToString();
        txtLevel.text     = PlayerPrefs.GetInt("curLevel", 1).ToString();
        Instantiate(listLevel[PlayerPrefs.GetInt("curLevel", 1) - 1], transform);
        starSlider.setThreeStarLength(GetComponentInChildren <LevelInfo>().ThreeStarLength);
        if (showHint)
        {
            showHint = false;
            string[] allLine = new string[0];
#if UNITY_ANDROID
            var loadDb = new WWW("jar:file://" + Application.dataPath + "!/assets/hint" + PlayerPrefs.GetInt("curLevel", 1) + ".txt");  // this is the path to your StreamingAssets in android
            while (!loadDb.isDone)
            {
            }                           // CAREFUL here, for safety reasons you shouldn't let this while loop unattended, place a timer and error check
            if (string.IsNullOrEmpty(loadDb.error))
            {
                allLine = Regex.Split(loadDb.text, "\r\n");
            }
#endif
#if UNITY_EDITOR
            if (File.Exists(Application.streamingAssetsPath + "/hint" + PlayerPrefs.GetInt("curLevel", 1) + ".txt"))
            {
                allLine = File.ReadAllLines(Application.streamingAssetsPath + "/hint" + PlayerPrefs.GetInt("curLevel", 1) + ".txt");
            }
#endif
            for (int i = 0; i < allLine.Length; i++)
            {
                allLine[i] = allLine[i].Trim();
                string[]     arr      = allLine[i].Split(' ');
                LineRenderer hintLine = Instantiate(HintLine, Vector3.zero, Quaternion.identity).GetComponent <LineRenderer>();
                listHintLine.Add(hintLine);
                hintLine.positionCount = 0;
                for (int j = 0; j < arr.Length / 2; j++)
                {
                    hintLine.positionCount++;
                    hintLine.SetPosition(hintLine.positionCount - 1, new Vector2(float.Parse(arr[j * 2]), float.Parse(arr[j * 2 + 1])));
                }
            }
        }
        SceneTransition.Instance.Out();
        #if UNITY_EDITOR
        EditorButton.SetActive(true);
        #endif
    }
예제 #2
0
    IEnumerator cardClickIE(int idx)
    {
        if (idx == 0)
        {
            PlayerPrefs.SetInt("totalStar", PlayerPrefs.GetInt("totalStar", 0) + 1);
        }
        if (idx == 1)
        {
            PlayerPrefs.SetInt("totalStar", PlayerPrefs.GetInt("totalStar", 0) + 5);
        }
        if (idx == 2)
        {
            PlayerPrefs.SetInt("hintNum", PlayerPrefs.GetInt("hintNum", 5) + 1);
        }
        txtTotalStar.text = PlayerPrefs.GetInt("totalStar", 0).ToString();
        GiftBoxPanel.transform.GetChild(idx).GetComponent <Animator>().SetBool("isOpen", true);
        for (int i = 0; i < 3; i++)
        {
            if (idx != i)
            {
                GiftBoxPanel.transform.GetChild(i).GetComponent <Button>().interactable = false;
            }
        }
        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < 3; i++)
        {
            if (idx != i)
            {
                GiftBoxPanel.transform.GetChild(i).GetComponent <Animator>().SetBool("isOpen", true);
            }
        }
        yield return(new WaitForSeconds(1f));

        GiftBoxPanel.GetComponent <Image>().DOFade(0, 0.5f);
        GiftBoxPanel.transform.GetChild(3).DOScale(0, 0.5f);
        for (int i = 0; i < 3; i++)
        {
            GiftBoxPanel.transform.GetChild(i).GetComponent <CanvasGroup>().DOFade(0, 0.5f);
        }
        yield return(new WaitForSeconds(0.5f));

        GameStatus = GameStatus.WAITING;
        GiftBoxPanel.SetActive(false);
    }
예제 #3
0
    public IEnumerator giftBoxClickIEnumerator()
    {
        PlayerPrefs.SetString("LastTimeOpenGift", DateTime.UtcNow.ToString());
        GameStatus = GameStatus.PAUSE;
        DOTween.Kill(lineCreator.Pencil.GetComponent <SpriteRenderer>());
        lineCreator.Pencil.GetComponent <SpriteRenderer>().DOFade(0, 0.1f);
        lineCreator.activeLine = null;
        GiftBoxPanel.GetComponent <Image>().DOFade(1, 0.5f);
        List <Vector3> cardPos = new List <Vector3>();

        for (int i = 0; i < 3; i++)
        {
            GiftBoxPanel.transform.GetChild(i).gameObject.SetActive(true);
            GiftBoxPanel.transform.GetChild(i).GetComponent <Image>().DOFade(0, 0.5f).From();
            GiftBoxPanel.transform.GetChild(i).GetComponent <Button>().interactable = false;
            cardPos.Add(GiftBoxPanel.transform.GetChild(i).position);
            yield return(new WaitForSeconds(0.1f));
        }
        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < 3; i++)
        {
            GiftBoxPanel.transform.GetChild(i).GetComponent <Animator>().SetBool("isOpen", false);
            yield return(new WaitForSeconds(0.1f));
        }
        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < 3; i++)
        {
            GiftBoxPanel.transform.GetChild(i).DOMove(GiftBoxPanel.transform.GetChild(1).position, 0.5f);
        }
        yield return(new WaitForSeconds(1f));

        for (int i = 0; i < 3; i++)
        {
            int c = UnityEngine.Random.RandomRange(0, cardPos.Count);
            GiftBoxPanel.transform.GetChild(i).DOMove(cardPos[c], 0.5f);
            GiftBoxPanel.transform.GetChild(i).GetComponent <Button>().interactable = true;
            cardPos.RemoveAt(c);
        }
    }