Exemplo n.º 1
0
        /// <summary>
        /// utility routine: read a place info record from a BinaryReader
        /// </summary>
        /// <param name="br">Binary reader to read data from</param>
        /// <param name="pn">Where to write data</param>
        /// <param name="metaDataAction">What to do with metadata, read, skip, omit. The difference between skip and omit is that
        /// the latter is faster, while the former correctly positions to the next record if needed</param>
        static public void ReadPlaceName(BinaryReader br, ref WorldWindPlacename pn, MetaDataAction metaDataAction)
        {
            pn.Name = br.ReadString();      // get place name
            pn.Lat  = br.ReadSingle();      // and latitude
            pn.Lon  = br.ReadSingle();      // and longitude

            int metaCount = br.ReadInt32(); // number of metadata (key/value pairs)

            if (metaDataAction == MetaDataAction.Store)
            {
                pn.metaData = new Hashtable();
            }
            else
            {
                pn.metaData = null;
            }
            if (metaDataAction == MetaDataAction.Omit)
            {
                return;
            }

            for (int j = 0; j < metaCount; j++)
            {
                string strKey   = br.ReadString();
                string strValue = br.ReadString();
                // add the metadata pair if so requested
                if (metaDataAction == MetaDataAction.Store)
                {
                    pn.metaData.Add(strKey, strValue);
                }
            }
        }
Exemplo n.º 2
0
    public IEnumerator updateLevels()
    {
        Debug.Log("Welcome to Levels Getter");
        UnityWebRequest allLevelsRequest = _webRequester.Get("https://immense-lake-57494.herokuapp.com/levels", null);

        yield return(new WaitUntil(() => allLevelsRequest.isDone)); // To replace with personnal levels

        MetaData currentMetaData;

        if (MetaDataAction.metadataExists())
        {
            currentMetaData = MetaDataAction.readMetaData();
        }
        else
        {
            currentMetaData        = new MetaData();
            currentMetaData.levels = new List <level>();
        }


        Debug.Log("Finish downloading...");

        if (allLevelsRequest.responseCode != 200)
        {
            yield return(null);
        }

        Debug.Log("Start parsing... " + allLevelsRequest.downloadHandler.text);

        Levels allLevels = JsonUtility.FromJson <Levels>("{\"all\":" + allLevelsRequest.downloadHandler.text + "}");

        foreach (Level level in allLevels.all)
        {
            Debug.Log("OBJET LEVEL : " + JsonUtility.ToJson(level));
            if (!currentMetaData.levels.Exists(x => x.id == Convert.ToInt64(level.id)))
            {
                string filePath = Path.Combine(Application.persistentDataPath, "Levels/" + level.name);
                File.WriteAllText(filePath, JsonUtility.ToJson(level.json));
                currentMetaData.levels.Add(MetaDataAction.LevelToMetaDataLevel(level));
            }
        }

        Debug.Log("Current Meta Data... " + JsonUtility.ToJson(currentMetaData));

        yield return(MetaDataAction.modifyMetaData(currentMetaData));

        menuManager.StartMenu();
    }
Exemplo n.º 3
0
        // given an index descriptor, seek to and return place information
        PlaceItem GetPlaceItemFromIndexEntry(WplIndexEntry ie, MetaDataAction metaDataAction)
        {
            using (BinaryReader brWwp = OpenWwpReader(ie.fileNumber))
            {
                // seek to the relevant info
                brWwp.BaseStream.Seek(ie.seekOffset, SeekOrigin.Begin);

                // create a new PlaceItem
                PlaceItem pi = new PlaceItem();

                pi.pn = new WorldWindPlacename();

                // set placeNameSet info
                pi.placeDescriptor = this.m_placeNameSet;

                // now read the rest from the WWP file
                ReadPlaceName(brWwp, ref pi.pn, metaDataAction);
                return(pi);
            }
        }
Exemplo n.º 4
0
      /// <summary>
      /// utility routine: read a place info record from a BinaryReader
      /// </summary>
      /// <param name="br">Binary reader to read data from</param>
      /// <param name="pn">Where to write data</param>
      /// <param name="metaDataAction">What to do with metadata, read, skip, omit. The difference between skip and omit is that
      /// the latter is faster, while the former correctly positions to the next record if needed</param>
      static public void ReadPlaceName(BinaryReader br, ref WorldWindPlacename pn, MetaDataAction metaDataAction) 
      {
         pn.Name = br.ReadString(); // get place name
         pn.Lat = br.ReadSingle(); // and latitude
         pn.Lon = br.ReadSingle(); // and longitude

         int metaCount = br.ReadInt32(); // number of metadata (key/value pairs)

         if(metaDataAction == MetaDataAction.Store) 
         {
            pn.metaData = new Hashtable();
         }
         else 
         {
            pn.metaData = null;
         }
         if(metaDataAction == MetaDataAction.Omit) 
         {
            return;
         }

         for(int j = 0; j < metaCount; j++) 
         {
            string strKey = br.ReadString();
            string strValue = br.ReadString();
            // add the metadata pair if so requested
            if(metaDataAction == MetaDataAction.Store) pn.metaData.Add(strKey, strValue);
         }
      }
Exemplo n.º 5
0
      // given an index descriptor, seek to and return place information
      PlaceItem GetPlaceItemFromIndexEntry(WplIndexEntry ie, MetaDataAction metaDataAction) 
      {
			using( BinaryReader brWwp = OpenWwpReader(ie.fileNumber) )
			{
				// seek to the relevant info
				brWwp.BaseStream.Seek(ie.seekOffset, SeekOrigin.Begin);

				// create a new PlaceItem
				PlaceItem pi = new PlaceItem();
         
				pi.pn = new WorldWindPlacename();

				// set placeNameSet info
				pi.placeDescriptor = this.m_placeNameSet;

				// now read the rest from the WWP file
				ReadPlaceName(brWwp, ref pi.pn, metaDataAction);
				return pi;
			}
      }