Example #1
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));

        if (window == 1)
        {
            if (GUI.Button(new Rect(0, 0, Screen.width, height), "Сұрақтар қосу"))
            {
                window = 2;
            }
            // if (GUI.Button (new Rect (0, height, Screen.width, height), "Привязать картинки")) {
            //  window = 3;
            // }
        }

        if (window == 2)
        {
            //GUI.Label (new Rect (0, 0, width, height), "Выбери крч 3-еун біреун");

            if (GUI.Button(new Rect(0, height, Screen.width, height), "Сұрақтар"))
            {
                window = 4;
            }
            if (GUI.Button(new Rect(0, height * 2, Screen.width, height), "Жауаптар"))
            {
                window = 5;
            }
            if (GUI.Button(new Rect(0, height * 3, Screen.width, height), "Суреттер"))
            {
                window = 6;
            }
            if (GUI.Button(new Rect(0, height * 5, Screen.width, height), "Артқа"))
            {
                window = 1;
            }
        }

        // QUESTIONS
        if (window == 4)
        {
            GUI.Label(new Rect(0, 0, Screen.width, height), "Сұрақтың аты");
            txt = GUI.TextField(new Rect(0, height, Screen.width, height), txt, 1024);
            if (GUI.Button(new Rect(0, height * 2, Screen.width, height), "қосу"))
            {
                jsonManager.AddQuestion(txt);
                txt = "";
            }
            if (GUI.Button(new Rect(0, height * 3, Screen.width, height), "Барлық сұрақтарды жою"))
            {
                jsonManager.Clear("Q");
            }
            back(2, 5);
        }

        // ANSWEEEEEEEEEEEEEEEEEEEEEEEEEEEEERRRSSS
        if (window == 5)
        {
            GUI.Label(new Rect(0, 0, Screen.width / 2, height), "Сурақ ID");
            GUI.Label(new Rect(Screen.width / 2, 0, Screen.width / 2, height), "Жауап аты");
            string[]     qlist  = jsonManager.GetQuestions(start);
            GUIContent[] strgui = new GUIContent[qlist.Length];
            for (int i = 0; i < qlist.Length; i++)
            {
                strgui[i] = new GUIContent(qlist[i]);
            }
            int picked = popup.List(new Rect(0, height, Screen.width / 2, height), strgui, GUIStyle.none, GUIStyle.none);
            txt  = GUI.TextField(new Rect(Screen.width / 2, height, Screen.width / 2, height), txt, 1024);
            toog = GUI.Toggle(new Rect(Screen.width / 2, height * 2, Screen.width / 2, height), toog, "Дұрыс жауап?");

            if (GUI.Button(new Rect(Screen.width / 2, height * 3, Screen.width / 2, height), "қосу"))
            {
                jsonManager.AddAnswer(txt, picked, toog);
                txt  = "";
                qID  = "";
                toog = false;
            }
            if (GUI.Button(new Rect(Screen.width / 2, height * 4, Screen.width / 2, height), "Барлық жауаптарды жою"))
            {
                jsonManager.Clear("A");
            }

            GUI.Label(new Rect(Screen.width / 2, height * 6, Screen.width / 2, height), "Бастау");

            strstart = GUI.TextField(new Rect(Screen.width / 2, height * 7, Screen.width / 2, height), strstart, 50);
            start    = Int32.Parse(strstart);

            back(2, 9);
        }

        // PICTUREEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSS
        if (window == 6)
        {
            int picked;
            if (!toog)
            {
                GUI.Label(new Rect(0, 0, Screen.width / 2, height), "Сұрақ ID");
                string[]     qlist  = jsonManager.GetQuestions(start);
                GUIContent[] strgui = new GUIContent[qlist.Length];
                for (int i = 0; i < qlist.Length; i++)
                {
                    strgui[i] = new GUIContent(qlist[i]);
                }
                picked = popup.List(new Rect(0, height, Screen.width / 2, height), strgui, GUIStyle.none, GUIStyle.none);
            }
            else
            {
                GUI.Label(new Rect(0, 0, Screen.width / 2, height), "жауап ID");
                string[]     alist  = jsonManager.GetAnswers(start);
                GUIContent[] strgui = new GUIContent[alist.Length];
                for (int i = 0; i < alist.Length; i++)
                {
                    strgui[i] = new GUIContent(alist[i]);
                }
                picked = popup.List(new Rect(0, height, Screen.width / 2, height), strgui, GUIStyle.none, GUIStyle.none);
            }

            GUI.Label(new Rect(Screen.width / 2, 0, Screen.width / 2, height), "Сурет ID");

            pIDstr = GUI.TextField(new Rect(Screen.width / 2, height, Screen.width / 2, height), pIDstr, 50);

            Texture tex = Resources.Load("Суреттер/" + Int32.Parse(pIDstr), typeof(Texture)) as Texture;

            toog = GUI.Toggle(new Rect(Screen.width / 2, height * 2, Screen.width / 2, height), toog, "Жауап?");
            GUI.DrawTexture(new Rect(Screen.width / 2, height * 3, height * 3, height * 3), tex);

            if (GUI.Button(new Rect(Screen.width / 2, height * 6, Screen.width / 2, height), "Қосу"))
            {
                jsonManager.AddPicture(Int32.Parse(pIDstr), toog, picked, picked);
                txt  = "";
                qID  = "";
                aID  = "";
                toog = false;
            }
            if (GUI.Button(new Rect(Screen.width / 2, height * 7, Screen.width / 2, height), "Барлық суреттерді жою"))
            {
                jsonManager.Clear("P");
            }

            GUI.Label(new Rect(Screen.width / 2, height * 9, Screen.width / 2, height), "Бастау");
            strstart = GUI.TextField(new Rect(Screen.width / 2, height * 10, Screen.width / 2, height), strstart, 50);
            start    = Int32.Parse(strstart);

            back(2, 12);
        }

        GUI.EndGroup();
    }
    /* SAVE SECTION */
    public void Save(bool allData)
    {
        JsonManager.Clear();
        Dictionary <string, object> playerData = new Dictionary <string, object>();

        if (allData)
        {
            JsonManager.UpdateJsonArray("scene", UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
            JsonManager.UpdateJsonArray("dateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            playerData.Add("playerPosition", Camera.main.transform.root.position);
            playerData.Add("cameraRotation", Camera.main.transform.parent.parent.GetComponent <MouseLook>().GetRotation());
        }

        playerData.Add("playerHealth", Camera.main.transform.root.GetComponent <HealthManager>().Health);
        JsonManager.UpdateJsonArray("playerData", playerData);

        Dictionary <string, object> switcherData = new Dictionary <string, object>
        {
            { "switcherActiveItem", switcher.currentItem }, //Save Item Switcher Current Item
            { "switcherLightObject", switcher.currentLightObject },
            { "switcherWeaponItem", switcher.weaponItem }
        };

        //Save Item Switcher Item Data
        for (int i = 0; i < switcher.ItemList.Count; i++)
        {
            if (switcher.ItemList[i].GetComponent <SaveHelper>())
            {
                switcher.ItemList[i].GetComponent <SaveHelper>().CallScriptGetValues();
                switcherData.Add("switcheritem_" + switcher.ItemList[i].name, switcher.ItemList[i].GetComponent <SaveHelper>().GetArray());
            }
        }

        JsonManager.UpdateJsonArray("itemSwitcherData", switcherData);

        Dictionary <string, object> inventoryData = new Dictionary <string, object>
        {
            //Save Inventory Slots Count
            { "inv_slots_count", GetComponent <Inventory>().slots.Count }
        };

        Dictionary <string, object> slotData = new Dictionary <string, object>();

        //Save Inventory Data
        for (int i = 0; i < GetComponent <Inventory>().slots.Count; i++)
        {
            if (GetComponent <Inventory>().slots[i].transform.childCount > 1)
            {
                Dictionary <string, object> itemDataArray = new Dictionary <string, object>();
                InventoryItemData           itemData      = GetComponent <Inventory>().slots[i].transform.GetChild(1).GetComponent <InventoryItemData>();
                itemDataArray.Clear();

                itemDataArray.Add("slotID", itemData.slotID);
                itemDataArray.Add("itemID", itemData.item.ID);
                itemDataArray.Add("itemAmount", itemData.m_amount);

                slotData.Add("inv_slot_" + i, itemDataArray);
            }
            else
            {
                slotData.Add("inv_slot_" + i, "null");
            }
        }

        inventoryData.Add("slotsData", slotData);

        //InventoryData Serialize
        JsonManager.UpdateJsonArray("inventoryData", inventoryData);

        if (allData)
        {
            //Save objects with SaveObject.cs script
            for (int i = 0; i < saveableObjects.Length; i++)
            {
                foreach (KeyValuePair <string, object> data in saveableObjects[i].GetObjectData())
                {
                    JsonManager.UpdateJsonArray(data.Key, data.Value);
                }
            }
        }

        SaveGame(!allData);
    }
 public void SaveNextSceneData()
 {
     JsonManager.Clear();
     Save(false);
 }
Example #4
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height));

        if (window == 1)
        {
            if (GUI.Button(new Rect(0, 0, Screen.width, height), "Добавить вопросы"))
            {
                window = 2;
            }
            if (GUI.Button(new Rect(0, height, Screen.width, height), "Привязать картинки"))
            {
                window = 3;
            }
        }

        if (window == 2)
        {
            GUI.Label(new Rect(0, 0, width, height), "Выбери крч 3-еун біреун");

            if (GUI.Button(new Rect(0, height, Screen.width, height), "Questions"))
            {
                window = 4;
            }
            if (GUI.Button(new Rect(0, height * 2, Screen.width, height), "Answers"))
            {
                window = 5;
            }
            if (GUI.Button(new Rect(0, height * 3, Screen.width, height), "Pictures"))
            {
                window = 6;
            }
            if (GUI.Button(new Rect(0, height * 5, Screen.width, height), "Назад"))
            {
                window = 1;
            }
        }

        // QUESTIONS
        if (window == 4)
        {
            GUI.Label(new Rect(0, 0, Screen.width, height), "QUESTION NAME");
            txt = GUI.TextField(new Rect(0, height, Screen.width, height), txt, 1024);
            if (GUI.Button(new Rect(0, height * 2, Screen.width, height), "add"))
            {
                jsonManager.AddQuestion(txt);
                txt = "";
            }
            if (GUI.Button(new Rect(0, height * 3, Screen.width, height), "clear all questions"))
            {
                jsonManager.Clear("Q");
            }
            back(2, 5);
        }

        // ANSWEEEEEEEEEEEEEEEEEEEEEEEEEEEEERRRSSS
        if (window == 5)
        {
            GUI.Label(new Rect(0, 0, Screen.width / 2, height), "QUESTION ID");
            GUI.Label(new Rect(Screen.width / 2, 0, Screen.width / 2, height), "ANSWER NAME");
            string[]     qlist  = jsonManager.GetQuestions(start);
            GUIContent[] strgui = new GUIContent[qlist.Length];
            for (int i = 0; i < qlist.Length; i++)
            {
                strgui[i] = new GUIContent(qlist[i]);
            }
            int picked = popup.List(new Rect(0, height, Screen.width / 2, height), strgui, GUIStyle.none, GUIStyle.none);
            txt  = GUI.TextField(new Rect(Screen.width / 2, height, Screen.width / 2, height), txt, 1024);
            toog = GUI.Toggle(new Rect(Screen.width / 2, height * 2, Screen.width / 2, height), toog, "Right answer?");

            if (GUI.Button(new Rect(Screen.width / 2, height * 3, Screen.width / 2, height), "add"))
            {
                jsonManager.AddAnswer(txt, picked, toog);
                txt  = "";
                qID  = "";
                toog = false;
            }
            if (GUI.Button(new Rect(Screen.width / 2, height * 4, Screen.width / 2, height), "clear all answers"))
            {
                jsonManager.Clear("A");
            }

            GUI.Label(new Rect(Screen.width / 2, height * 6, Screen.width / 2, height), "START FROM");

            strstart = GUI.TextField(new Rect(Screen.width / 2, height * 7, Screen.width / 2, height), strstart, 50);
            start    = Int32.Parse(strstart);

            back(2, 9);
        }

        // PICTUREEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSSS
        if (window == 6)
        {
            int picked;
            if (!toog)
            {
                GUI.Label(new Rect(0, 0, Screen.width / 2, height), "QUESTION ID");
                string[]     qlist  = jsonManager.GetQuestions(start);
                GUIContent[] strgui = new GUIContent[qlist.Length];
                for (int i = 0; i < qlist.Length; i++)
                {
                    strgui[i] = new GUIContent(qlist[i]);
                }
                picked = popup.List(new Rect(0, height, Screen.width / 2, height), strgui, GUIStyle.none, GUIStyle.none);
            }
            else
            {
                GUI.Label(new Rect(0, 0, Screen.width / 2, height), "ANSWER ID");
                string[]     alist  = jsonManager.GetAnswers(start);
                GUIContent[] strgui = new GUIContent[alist.Length];
                for (int i = 0; i < alist.Length; i++)
                {
                    strgui[i] = new GUIContent(alist[i]);
                }
                picked = popup.List(new Rect(0, height, Screen.width / 2, height), strgui, GUIStyle.none, GUIStyle.none);
            }

            GUI.Label(new Rect(Screen.width / 2, 0, Screen.width / 2, height), "PICTURE ID");

            pIDstr = GUI.TextField(new Rect(Screen.width / 2, height, Screen.width / 2, height), pIDstr, 50);

            Texture tex = Resources.Load("Pictures/" + Int32.Parse(pIDstr), typeof(Texture)) as Texture;

            toog = GUI.Toggle(new Rect(Screen.width / 2, height * 2, Screen.width / 2, height), toog, "ANSWER?");
            GUI.DrawTexture(new Rect(Screen.width / 2, height * 3, height * 3, height * 3), tex);

            if (GUI.Button(new Rect(Screen.width / 2, height * 6, Screen.width / 2, height), "add"))
            {
                jsonManager.AddPicture(Int32.Parse(pIDstr), toog, picked, picked);
                txt  = "";
                qID  = "";
                aID  = "";
                toog = false;
            }
            if (GUI.Button(new Rect(Screen.width / 2, height * 7, Screen.width / 2, height), "clear all pictures"))
            {
                jsonManager.Clear("P");
            }

            GUI.Label(new Rect(Screen.width / 2, height * 9, Screen.width / 2, height), "START FROM");
            strstart = GUI.TextField(new Rect(Screen.width / 2, height * 10, Screen.width / 2, height), strstart, 50);
            start    = Int32.Parse(strstart);

            back(2, 12);
        }

        GUI.EndGroup();
    }