Ejemplo n.º 1
0
    public void Update_To_Infor()
    {
        List <BallInfor> list = JsonUtility.FromJson <ListInfoBall>(PlayerPrefs.GetString(key_List_Ball)).list;

        for (int i = 0; i < list.Count; i++)
        {
            list[i].isBuing          = card[i].isBuying;
            list[i].isUse            = card[i].isUse;
            list[i].isUsing          = card[i].isUsing;
            list[i].TimeGetRewardAds = card[i].TimeAdsToGetBall;
        }
        ListInfoBall listInfo = new ListInfoBall(list);
        string       key      = JsonUtility.ToJson(listInfo);

        PlayerPrefs.SetString(key_List_Ball, key);
        PlayerPrefs.Save();
    }
Ejemplo n.º 2
0
    private void Awake()



    {
        Application.targetFrameRate = 60;
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
        }


        listplayer = Load();

        Debug.Log("SO LUONG PLAYER :  " + Load().Count);
        DontDestroyOnLoad(gameObject);

        GameStart = false;
        GamePause = false;
        // PlayerPrefs.DeleteKey(firstTime);
        if (PlayerPrefs.HasKey(firstTime))
        {
            firstPlay = false;
        }
        else
        {
            PlayerPrefs.SetInt(firstTime, 0);
            firstPlay = true;
            Debug.Log("Ko co Key");
        }


        if (firstPlay)
        {
            if (PlayerPrefs.HasKey(Key_Star_Golbal))
            {
                PlayerPrefs.DeleteKey(Key_Star_Golbal);
            }
            else
            {
                PlayerPrefs.SetInt(Key_Star_Golbal, 0);
            }
            Set_Time_Last();
            Save_Star(50);
            SaveScore(0);
            for (int i = 0; i < card.Length; i++)
            {
                card[i].isBuying         = true;
                card[i].isUsing          = false;
                card[i].isUse            = false;
                card[i].TimeAdsToGetBall = 0;
            }
            card[0].isBuying = false;
            card[0].isUsing  = true;
            card[0].isUse    = true;
            for (int i = 0; i < ChallengesCard.Length; i++)
            {
                ChallengesCard[i].isCompleQuest = false;
                ChallengesCard[i].levelCurr     = 0;
                ChallengesCard[i].isTake        = 0;
                for (int j = 0; j < 5; j++)
                {
                    //   if (j == 0)
                    //    {
                    //       ChallengesCard[j].TakeRewardGame[j] = true;
                    //   }
                    //  else
                    {
                        ChallengesCard[i].TakeRewardGame[j] = false;
                    }
                }
            }
            List <BallInfor> List = new List <BallInfor>();
            for (int i = 0; i < card.Length; i++)
            {
                BallInfor infor = new BallInfor();
                if (i == 0)
                {
                    infor.isBuing = false;
                    infor.isUse   = true;
                    infor.isUsing = true;
                }
                else
                {
                    infor.isBuing = true;
                    infor.isUse   = false;
                    infor.isUsing = false;
                }
                List.Add(infor);
            }
            ListInfoBall listInfo = new ListInfoBall(List);
            string       key      = JsonUtility.ToJson(listInfo);
            PlayerPrefs.SetString(key_List_Ball, key);
            PlayerPrefs.Save();


            List <AchievementInfor> list = new List <AchievementInfor>();
            for (int i = 0; i < ChallengesCard.Length; i++)
            {
                AchievementInfor infor = new AchievementInfor();
                infor.level      = ChallengesCard[i].levelCurr;
                infor.isTake     = ChallengesCard[i].isTake;
                infor.isComplete = ChallengesCard[i].isComplete;
                for (int j = 0; j < 5; j++)
                {
                    infor.reward[j] = ChallengesCard[i].TakeRewardGame[j];
                }
                list.Add(infor);
                ListAchievement achievement = new ListAchievement(list);
                string          key_1       = JsonUtility.ToJson(achievement);
                PlayerPrefs.SetString(key_List_Achie, key_1);
                PlayerPrefs.Save();
            }
        }
        else
        {
            UpdateInforBall_To_Game();
            Update_InforAchieve_ToGame();
        }


        width = Camera.main.pixelWidth;

        height = Camera.main.pixelHeight;

        Debug.Log(width + "  " + height);
        leftbottom = Vector2.zero;

        rightbottom = new Vector2(width, 0);

        rightup = new Vector2(width, height);

        leftup = new Vector2(0, height);

        leftBottomReal = Camera.main.ScreenToWorldPoint(leftbottom);
        //    Debug.Log(leftBottomReal);
        rightBottomReal = Camera.main.ScreenToWorldPoint(rightbottom);
        leftUpRead      = Camera.main.ScreenToWorldPoint(leftup);
        rightUpReal     = Camera.main.ScreenToWorldPoint(rightup);

        widthReal = Vector2.Distance(leftBottomReal, rightBottomReal);

        heightReal = Vector2.Distance(leftBottomReal, leftUpRead);
    }