Ejemplo n.º 1
0
    public void LoadFlight(string path)
    {
        string myLoadedItem = JsonFileReader.LoadJsonAsResource(path);
        Flight myFlights    = JsonUtility.FromJson <Flight>(myLoadedItem);

        flights.Add(myFlights);
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        CreateSingleton();

        if (PlayerPrefs.GetInt("level") == 4)
        {
            return;
        }

        FireList = new List <GameObject>();

        string levelData = JsonFileReader.LoadJsonAsResource("levels.json");

        LevelDataObj = JsonUtility.FromJson <LevelData>(levelData);

        List <Fire> FireData = LevelDataObj.levels[PlayerPrefs.GetInt("level") - 1].fires;

        spawnTimers = new List <float>();

        foreach (Fire data in FireData)
        {
            Vector3    position = new Vector3(data.x, data.y);
            GameObject newFire  = Instantiate(fireGameObj, position, Quaternion.identity);
            newFire.GetComponent <FireController>().Life        = data.life;
            newFire.GetComponent <FireController>().despawnTime = data.despawnTime;
            newFire.transform.localScale = new Vector3(data.scale, data.scale, 1);
            spawnTimers.Add(data.spawnTime);
            newFire.SetActive(false);
            FireList.Add(newFire);
        }
    }
Ejemplo n.º 3
0
    public void ResetMyContent()
    {
        allMobs     = new Dictionary <string, CharacterContent>();
        allItems    = new Dictionary <string, ItemContent>();
        allCounters = new Dictionary <string, CounterContent>();
        allEvents   = new Dictionary <string, TriggerContent>();

        // Load all mobs
        string       loadedItem = JsonFileReader.LoadJsonAsResource("Jsons/Mobs");
        MetaJsonMobs loadedMobs = JsonUtility.FromJson <MetaJsonMobs>(loadedItem);

        foreach (CharacterContent elt in loadedMobs.myMobs)
        {
            allMobs.Add(elt.myName, elt);
        }

        // Load all items
        loadedItem = JsonFileReader.LoadJsonAsResource("Jsons/Items");
        MetaJsonItems loadedItems = JsonUtility.FromJson <MetaJsonItems>(loadedItem);

        foreach (ItemContent elt in loadedItems.myItems)
        {
            allItems.Add(elt.myName, elt);
        }

        // Load all events
        ReadEventsFile();

        // Load all counters, create file if not exists
        if (!System.IO.File.Exists(Application.persistentDataPath + "/Counters.json"))
        {
            ResetCountersFile();
        }
        ReadCountersFile();
    }
Ejemplo n.º 4
0
    private void Awake()
    {
        string loadedQuestion = JsonFileReader.LoadJsonAsResource("Kvízy/Kvíz_1/1.json");

        Debug.Log(loadedQuestion);

        question = JsonUtility.FromJson <Question>(loadedQuestion);
    }
Ejemplo n.º 5
0
    public void LoadItem(string path)
    {
        string loadPlayerItem = JsonFileReader.LoadJsonAsResource(path);
        //Debug.Log(loadPlayerItem);
        Item item = JsonUtility.FromJson <Item>(loadPlayerItem);

        playerItems.Add(item);
    }
Ejemplo n.º 6
0
    void Awake()
    {
        flights = new List <Flight>();
        FlightDictionary dictionary = JsonUtility.FromJson <FlightDictionary>(JsonFileReader.LoadJsonAsResource("FlightDictionary.json"));

        foreach (string dictionaryItem in dictionary.flights)
        {
            LoadFlight(dictionaryItem);
        }
    }
Ejemplo n.º 7
0
    public void ReadEventsFile()
    {
        string           loadedItem     = JsonFileReader.LoadJsonAsResource("Jsons/Triggers");
        MetaJsonTriggers loadedTriggers = JsonUtility.FromJson <MetaJsonTriggers>(loadedItem);

        allEvents = new Dictionary <string, TriggerContent>();
        foreach (TriggerContent elt in loadedTriggers.myTriggers)
        {
            allEvents.Add(elt.ID, elt);
        }
    }
Ejemplo n.º 8
0
    public void LoadItem(string path)
    {
        string myLoadedItem = JsonFileReader.LoadJsonAsResource(path);
        Item   myItem       = JsonUtility.FromJson <Item>(myLoadedItem);

        if (items.ContainsKey(myItem.itemID))
        {
            Debug.Log("Item:" + myItem.itemName + " ||| Key already exists same as :" + items[myItem.itemID].itemName);
        }
        else
        {
            items.Add(myItem.itemID, myItem);
        }
    }
Ejemplo n.º 9
0
    private void Awake()
    {
        items = new Dictionary <int, Item>();
        ItemDictionary dictionary = JsonUtility.FromJson <ItemDictionary>(JsonFileReader.LoadJsonAsResource("Items/ItemDictionary.json"));

        foreach (string dictionaryItem in dictionary.items)
        {
            LoadItem(dictionaryItem);
        }

        foreach (KeyValuePair <int, Item> entry in items)
        {
            Item temp = entry.Value;
            itemList.Add(temp);
        }
    }
Ejemplo n.º 10
0
    void Start()
    {
        btnMenu.onClick.AddListener(() => { SceneController.instance.ChangeScene("Main Menu"); });
        btnReset.onClick.AddListener(() => { SceneController.instance.ChangeScene(SceneManager.GetActiveScene().name); });
        ResultPanel.SetActive(false);

        string WinQuotes = JsonFileReader.LoadJsonAsResource("win.json");

        winQuoteData = JsonUtility.FromJson <QuoteData>(WinQuotes);

        string LooseQuotes = JsonFileReader.LoadJsonAsResource("loose.json");

        looseQuoteData = JsonUtility.FromJson <QuoteData>(LooseQuotes);

        sentenceText     = SentencePanel.GetComponentInChildren <Text>();
        sentenceAnimator = SentencePanel.GetComponent <Animator>();
    }
Ejemplo n.º 11
0
    public void ResetCountersFile()
    {
        string loadedItem = JsonFileReader.LoadJsonAsResource("Jsons/Counters");

        JsonFileReader.WriteJsonToExternalResource("Counters.json", loadedItem);
    }
 public void LoadItem(string path)
 {
     string  myLoadedItem = JsonFileReader.LoadJsonAsResource(path);
     Element myElement    = JsonUtility.FromJson <Element>(myLoadedItem);
 }