예제 #1
0
    public void Load()
    {
        /*if (File.Exists(Application.persistentDataPath + "/flickrValues.txt"))
         * {
         *  BinaryFormatter bf = new BinaryFormatter();
         *  FileStream file = File.Open(Application.persistentDataPath + "/flickrValues.txt", FileMode.Open);
         *  FlickrValues values = (FlickrValues)bf.Deserialize(file);
         *  file.Close();
         *
         * }*/
        FlickrValues values = gameObject.AddComponent <FlickrValues>();
        TextReader   tr     = new StreamReader("SavedFirstDate.txt");
        TextReader   tr1    = new StreamReader("SavedLastDate.txt");
        TextReader   tr2    = new StreamReader("SavedYears.txt");
        string       a      = tr.ReadLine();
        string       b      = tr1.ReadLine();
        string       c      = tr2.ReadLine();

        Debug.Log("THIS IS LOADING AND READING FROM FILE: ALL " + a + b + c);
        Debug.Log("THIS IS LOADING AND READING FROM FILE   A: " + a);
        Debug.Log("THIS IS LOADING AND READING FROM FILE:  B: " + b);
        Debug.Log("THIS IS LOADING AND READING FROM FILE:  C: " + c);
        tr.Close();
        tr1.Close();
        tr2.Close();
        apiStartTakenDay = c + a;
        apiEndTakenDay   = c + b;
    }
예제 #2
0
    public void SaveDate()
    {
        TextWriter tw  = new StreamWriter("SavedFirstDate.txt");
        TextWriter tw1 = new StreamWriter("SavedLastDate.txt");

        //saving to text files because so easy. sorry for inconvinience.
        //BinaryFormatter bf = new BinaryFormatter();
        //FileStream file = File.Create(Application.persistentDataPath + "/flickrValues.txt");
        Debug.Log("SAVING VALUES SM EM: " + startMonthValue + endMonthValue);

        //FlickrValues values = new FlickrValues();
        FlickrValues values = gameObject.AddComponent <FlickrValues>();

        values.startMonthValue = startMonthValue;
        values.endMonthValue   = endMonthValue;
        // values.yearValue = yearValue;
        Debug.Log("SAVING VALUES TTOOOO SM EM: " + values.startMonthValue + values.endMonthValue);
        tw.WriteLine(values.startMonthValue);
        tw1.WriteLine(values.endMonthValue);

        //values.apiStartTakenDay = startMonthValue + yearValue;
        //values.apiEndTakenDay = endMonthValue + yearValue;
        //Debug.Log("SAVING VALUES valuesapistart + apiend: " + values.apiStartTakenDay + values.apiEndTakenDay );
        //bf.Serialize(file, values);
        //file.Close();
        tw.Close();
        tw1.Close();
    }
예제 #3
0
    public void SaveYear()
    {
        //BinaryFormatter bf = new BinaryFormatter();

        TextWriter tw = new StreamWriter("SavedYears.txt");

        //if (!tw.Exists(Application.persistentDataPath + "/flickrValues.txt"))
        //file = File.Create(Application.persistentDataPath + "/flickrValues.txt");

        Debug.Log("SAVING VALUES Y: " + yearValue);

        //FlickrValues values = new FlickrValues();
        FlickrValues values = gameObject.AddComponent <FlickrValues>();

        values.yearValue = yearValue;
        tw.WriteLine(values.yearValue);

        //values.apiStartTakenDay = startMonthValue + yearValue;
        //values.apiEndTakenDay = endMonthValue + yearValue;
        //Debug.Log("SAVING VALUES valuesapistart + apiend: " + values.apiStartTakenDay + values.apiEndTakenDay );
        //bf.Serialize(file, values);
        //file.Close();
        tw.Close();
    }
예제 #4
0
    void OnTriggerEnter(Collider collider)

    //add this script to colliders and finish years and build final apiqueue string with stringbuilder

    {
        //FlickrValues flickrValues = new FlickrValues();
        FlickrValues flickrValues = gameObject.AddComponent <FlickrValues>();

        Debug.Log("HIT WITH " + collider);
        //if (collider.gameObject.tag == "cube1") changing this
        if (collider.gameObject.tag == "Jan")
        {
            Debug.Log("okok you hit with cube1 aka January!!");
            startMonthValue = "1-1";
            endMonthValue   = "1-31";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Feb")
        {
            startMonthValue = "2-1";
            endMonthValue   = "2-28";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Mar")
        {
            startMonthValue = "3-1";
            endMonthValue   = "3-31";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Apr")
        {
            startMonthValue = "4-1";
            endMonthValue   = "4-30";
            SaveDate();
        }
        else if (collider.gameObject.tag == "May")
        {
            startMonthValue = "5-1";
            endMonthValue   = "5-31";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Jun")
        {
            startMonthValue = "6-1";
            endMonthValue   = "6-30";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Jul")
        {
            startMonthValue = "7-1";
            endMonthValue   = "7-31";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Aug")
        {
            startMonthValue = "8-1";
            endMonthValue   = "8-31";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Sep")
        {
            startMonthValue = "9-1";
            endMonthValue   = "9-30";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Oct")
        {
            startMonthValue = "10-1";
            endMonthValue   = "10-31";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Nov")
        {
            startMonthValue = "11-1.";
            endMonthValue   = "11-30";
            SaveDate();
        }
        else if (collider.gameObject.tag == "Dec")
        {
            startMonthValue = "12-1";
            endMonthValue   = "12-31";
            SaveDate();
        }
        //now for the years
        //else if (collider.gameObject.tag == "Des2012")  temp....
        else if (collider.gameObject.name == "Collider2012")
        {
            yearValue = "2012-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2013")
        {
            yearValue = "2013-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2014")
        {
            yearValue = "2014-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2015")
        {
            yearValue = "2015-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2016")
        {
            yearValue = "2016-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2017")
        {
            yearValue = "2017-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2018")
        {
            yearValue = "2018-";
            SaveYear();
        }
        else if (collider.gameObject.name == "Collider2019")
        {
            yearValue = "2019-";
            SaveYear();
        }
    }
예제 #5
0
    public IEnumerator OnCollisionEnter(Collision collision)
    {
        Texture2D tex;

        tex = new Texture2D(4, 4, TextureFormat.DXT1, false);

        //api call example
        //https://api.flickr.com/services/rest/?method=flickr.people.getPhotos&api_key=0579d5b4256b91929f80cea37fb63f8c&user_id=134653989%40N07&min_upload_date=1.1.2018&max_upload_date=31.12.2018&min_taken_date=&max_taken_date=&content_type=&format=json&nojsoncallback=1&auth_token=72157702486478861-fa74bb8610aa766e&api_sig=4122e3678f6107dc4ad280c07952b2f3
        var noSignUrl = "https://api.flickr.com/services/rest/" +
                        "?method=flickr.people.getPhotos" +
                        "&api_key=0579d5b4256b91929f80cea37fb63f8c" +
                        "&user_id=134653989%40N07" +
                        "&min_upload_date=1.1.2018=" +
                        "&max_upload_date=31.12.2018" +
                        "&min_taken_date=" +
                        "&max_taken_date=" +
                        "&content_type=" +
                        "&format=json" +
                        "&nojsoncallback=1" +
                        "&auth_token=72157702486478861-fa74bb8610aa766e" +
                        "&api_sig=f7b42ae3f1fc127d93bc0f141bdbf590";


        //this one we use, values binded to get flexible usage
        url = "https://api.flickr.com/services/rest/" +
              "?method=flickr.people.getPhotos" +
              "&api_key={0}" +
              "&user_id={1}" +
              "&min_upload_date=" +
              "&max_upload_date=" +
              "&min_taken_date={2}" +
              "&max_taken_date={3}" +
              "&content_type=" +
              "&format=json" +
              "&nojsoncallback=1";


        //use taken dates instead of upload dates for easier modification. done beforehand on flickr pics.
        // minTakenDate = "2017-8-1";    yyyy-mm-dd
        //maxTakenDate = "2017-8-16";

        //access other script like this
        MonthYearValues myv = gameObject.AddComponent <MonthYearValues>();
        FlickrValues    fv  = gameObject.AddComponent <FlickrValues>();

        myv.Load();
        //dont run it again, just access values like this.
        MonthYearValues myv1 = gameObject.GetComponent <MonthYearValues>();

        //get values from files
        minTakenDate = myv1.apiStartTakenDay;
        maxTakenDate = myv1.apiEndTakenDay;

        Debug.Log("monthyearvalues apistarttakenday...: " + minTakenDate + maxTakenDate);
        var baseUrl = string.Format(url, myApiKey, userid, minTakenDate, maxTakenDate);

        Debug.Log("this is the api url request BASEURL " + baseUrl);

        //ok so httpwebreq cant handle SHA256 Certificate, use unitywebrequest or www instead.
        using (WWW www = new WWW(baseUrl))
        {
            yield return(www);

            Debug.Log("this is WWW call " + www);

            string flickrResult = www.text;
            Debug.Log("this is supposed to be the json from server: " + flickrResult);
            FlickrData apiData = JsonConvert.DeserializeObject <FlickrData>(flickrResult);

            foreach (Photo data in apiData.photos.photo)
            {
                //retrieve one photo:
                // http://farm{farmid}.staticflickr.com/{server-id}/{id}_{secret}{size}.jpg

                string photoUrl = "http://farm{0}.staticflickr.com/{1}/{2}_{3}_n.jpg";

                string baseFlickrUrl = string.Format(photoUrl,
                                                     data.farm,
                                                     data.server,
                                                     data.id,
                                                     data.secret);

                Debug.Log("this is  image url for one image.. hopefully: " + baseFlickrUrl);
                // yield return baseFlickrUrl;
                //add picture's address to list..
                flickrpicturelist.Add(baseFlickrUrl);
            }
            //access list of pictures with certain api request like this
            //ATM accessing only 1st picture of the list... modify the way to see them all before changing this!
            using (WWW xxx = new WWW(flickrpicturelist[apiTracker.apiCount % flickrpicturelist.Count]))
            {
                yield return(xxx);

                xxx.LoadImageIntoTexture(tex);
                GetComponent <Renderer>().material.mainTexture = tex;
            }
        }
    }