Esempio n. 1
0
    /*
     * public static void ReadNPCData()
     * {
     *      string dir = Directory.GetCurrentDirectory() + "\\NPCs";
     *      if (!Directory.Exists(dir))
     *              return;
     *      Map.MapList.Clear();
     *      foreach (string file in Directory.GetFiles(dir))
     *      {
     *              if (!file.ToLower().EndsWith(".json"))
     *                      continue;
     *              NPC.NPCList.Add(JsonUtility.FromJson<NPC>(File.ReadAllText(file)));
     *      }
     * }
     *
     * public static void ReadMapData()
     * {
     *      string dir = Directory.GetCurrentDirectory() + "\\Maps";
     *      if (!Directory.Exists(dir))
     *              return;
     *      Map.MapList.Clear();
     *      foreach (string file in Directory.GetFiles(dir))
     *      {
     *              if (!file.ToLower().EndsWith(".json"))
     *                      continue;
     *              Map.MapList.Add(JsonUtility.FromJson<Map>(File.ReadAllText(file)));
     *      }
     * }
     *
     * public static void ReadBuildingData()
     * {
     *      string dir = Directory.GetCurrentDirectory() + "\\Buildings";
     *      if (!Directory.Exists(dir))
     *              return;
     *      Building.BuildingList.Clear();
     *      foreach (string file in Directory.GetFiles(dir))
     *      {
     *              if (!file.ToLower().EndsWith(".json"))
     *                      continue;
     *              Building.BuildingList.Add(JsonUtility.FromJson<Building>(File.ReadAllText(file)));
     *      }
     * }
     */

    public static void ReadLocalData()
    {
        JSONData.InitLocal();

        if (!JSONData.InitializedLocal())
        {
            return;
        }

        NPC.NPCList.AddRange(JSONData.GetLocalNPCList());
        Map.MapList.AddRange(JSONData.GetLocalMapList());
        Building.BuildingList.AddRange(JSONData.GetLocalBuildingList());
    }