Ejemplo n.º 1
0
    private void Init()
    {
        //PlayerPrefs.DeleteAll();
        //JoaoResetData
        CSVReader.LoadLanguageCSV();
        //JoaoResetData
        if (!PlayerPrefs.GetString("PlayerSavedData").Equals(""))
        {
            //dbg += "from save";
            Debug.Log(PlayerPrefs.GetString("PlayerSavedData"));


            SaveLoadData.LoadPlayerData();
            if (GlobalData.SAVEDQUIZQUESTIONS.Count > 0)
            {
                //	dbg+="has loaded quiz questions from save";
                SaveLoadData.SavePlayerData();
            }
            else
            {
                //	dbg+="not loaded quiz questions from save";
                LoadQuiz(-1);
            }
        }
        else
        {
            //dbg += "loading_quiz\n";
            Debug.Log("loadquiz");
            LoadQuiz(-1);
        }
        SoundControl.PlayMusic(GlobalData.Music_Paths[0], true);
        this.transform.Find("OptionsMenu").GetComponent <OptionsMenu>().updateMusicSFXImages();
    }
Ejemplo n.º 2
0
    public void StartLevel(int level_n)
    {
        SoundControl.PlaySFX(GlobalData.SFX_Paths[1], false, true, true);

        Debug.Log(level_n);
        if (level_n <= 10)
        {
            GlobalData.current_level = level_n;
        }
        else
        {
            GlobalData.current_difficulty++;
            GlobalData.current_level = 1;
        }


        if (GlobalData.current_difficulty == 3)
        {
            GlobalData.current_difficulty = 2;
            GlobalData.current_level      = 10;
        }

        Debug.Log(PlayerData.lastunlockeddificulty + " difficulty compare " + GlobalData.current_difficulty);
        Debug.Log(PlayerData.lastunlockedlevel + " level compare " + GlobalData.current_level);
        if (PlayerData.lastunlockeddificulty < GlobalData.current_difficulty)
        {
            PlayerData.lastunlockeddificulty = GlobalData.current_difficulty;
            PlayerData.lastunlockedlevel     = GlobalData.current_level;
        }
        else if (PlayerData.lastunlockeddificulty == GlobalData.current_difficulty)
        {
            if (PlayerData.lastunlockedlevel < GlobalData.current_level)
            {
                PlayerData.lastunlockedlevel = GlobalData.current_level;
            }
        }
        if (GlobalData.current_level == 1 && GlobalData.current_difficulty == 0)
        {
            GlobalData.current_tutorial = -1;
        }
        else
        {
            GlobalData.current_tutorial = -2;
        }
        SaveLoadData.SavePlayerData();

        Debug.Log("PlayerData Unlocked level " + PlayerData.lastunlockedlevel);
        Debug.Log("level " + (GlobalData.current_level - 1) + " difficulty " + (GlobalData.current_difficulty));
        if (GlobalData.LevelsUnlocked[GlobalData.current_difficulty][GlobalData.current_level - 1])
        {
            GameObject quiz = (GameObject)Instantiate(Resources.Load("Prefabs/Quiz"));
            quiz.transform.parent = this.transform.parent;

            quiz.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width);
            quiz.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height);
            quiz.transform.position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
            quiz.GetComponent <QuizControl>().LoadQuiz(3);
        }
    }
Ejemplo n.º 3
0
    public static void ParseQuizFromJSON(string s)
    {
        SAVEDQUIZQUESTIONS.Clear();
        GlobalData.quiz_questions.Clear();
        JSONNode  json    = JSON.Parse(s);
        JSONArray jsonarr = json.AsArray;

        for (int i = 0; i < jsonarr.Count; i++)
        {
            int    d   = 0;
            string Q   = "";
            string RA  = "";
            string WA1 = "";
            string WA2 = "";
            string WA3 = "";
            string OW  = "";
            string OL  = "";

            if (jsonarr[i]["difficulty"] != null)
            {
                d = int.Parse(jsonarr[i]["difficulty"].Value);
            }


            if (jsonarr[i]["Q"] != null)
            {
                Q = jsonarr[i]["Q"].Value;
            }
            if (jsonarr[i]["RA"] != null)
            {
                RA = jsonarr[i]["RA"].Value;
            }
            if (jsonarr[i]["WA1"] != null)
            {
                WA1 = jsonarr[i]["WA1"].Value;
            }
            if (jsonarr[i]["WA2"] != null)
            {
                WA2 = jsonarr[i]["WA2"].Value;
            }
            if (jsonarr[i]["WA3"] != null)
            {
                WA3 = jsonarr[i]["WA3"].Value;
            }
            if (jsonarr[i]["OW"] != null)
            {
                OW = jsonarr[i]["OW"].Value;
            }
            if (jsonarr[i]["OL"] != null)
            {
                OL = jsonarr[i]["OL"].Value;
            }


            quiz_questions.Add(new QuizQuestion(d, Q, RA, WA1, WA2, WA3, OW, OL));

            //Joao2409

            if (SAVEDQUIZQUESTIONS.ContainsKey(d))
            {
                SAVEDQUIZQUESTIONS[d].Add(new QuizQuestion(d, Q, RA, WA1, WA2, WA3, OW, OL));
            }
            else
            {
                SAVEDQUIZQUESTIONS.Add(d, new List <QuizQuestion>()
                {
                    new QuizQuestion(d, Q, RA, WA1, WA2, WA3, OW, OL)
                });
            }
            //Joao2409
        }

        //Joao2409
        //string saveddata=JSONMaker.MakeSaveFile();
        SaveLoadData.SavePlayerData();
        //Joao2409
    }