Exemple #1
0
 /// <summary>
 /// Don't need SaveSystemAlt.StartWork(); and SaveSystemAlt.StopWorkAndClose();
 /// Loading array with key, use only English
 /// Don't use this on Update or FixedUpdate
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key">Name to save</param>
 /// <param name="array">Any array to save</param>
 public static T[] GetArray <T>(string key)
 {
     if (FilesSet.CheckFile("SaveSystemSL/Arrays/", "Array_" + key, "slsave", true))
     {
         if (useDebug)
         {
             Debug.LogError("Key not exist");
         }
         return(null);
     }
     else
     {
         return(JsonHelper.FromJson <T>(EasyDo.GetWWWString(Application.persistentDataPath + "/SaveSystemSL/Arrays/Array_" + key + ".slsave")));
     }
 }
Exemple #2
0
        /// <summary>
        /// Getting ip from url (default jsontest)
        /// Dont use on Update or FixedUpdate
        /// </summary>
        /// <param name="from">To specify another url, !WARNING! JSON must has "ip" as string</param>
        public static string getIp(string from = "http://ip.jsontest.com/")
        {
            string ip = "";

            ip = EasyDo.GetWWWString(from, true);
            try
            {
                if (string.IsNullOrEmpty(ip))
                {
                    return(null);
                }
                IpCallback ipc = JsonUtility.FromJson <IpCallback>(ip);
                ip = ipc.ip;
                return(ip);
            } catch (Exception ex) { return(null); }
        }
Exemple #3
0
        /// <summary>
        /// Getting time or date from url (default jsontest)
        /// Dont use on Update or FixedUpdate
        /// </summary>
        /// <param name="type">The return type, pmam returns 0 if AM and 1 if PM</param>
        /// <param name="pmam">Whether to use the AM PM system</param>
        /// <param name="from">To specify another url, !WARNING! JSON must has "time" as string, "milliseconds_since_epoch" as int and "date" as string</param>
        public static DateTime getTime(string from = "http://date.jsontest.com/")
        {
            string getting = EasyDo.GetWWWString(from, true);

            if (string.IsNullOrEmpty(getting))
            {
                return(DateTime.Today);
            }
            RealTimeCallback rt = new RealTimeCallback();

            try
            {
                rt = JsonUtility.FromJson <RealTimeCallback>(getting);

                return(DateTime.Parse(rt.date + " " + rt.time));
            } catch (Exception ex) { return(DateTime.Today); }
        }
Exemple #4
0
        /// <summary>
        /// Getting time or date from url (default jsontest)
        /// Dont use on Update or FixedUpdate
        /// </summary>
        /// <param name="type">The return type, pmam returns 0 if AM and 1 if PM</param>
        /// <param name="pmam">Whether to use the AM PM system</param>
        /// <param name="from">To specify another url, !WARNING! JSON must has "time" as string, "milliseconds_since_epoch" as int and "date" as string</param>
        public static int getTime(TimeType type, bool pmam = false, string from = "http://date.jsontest.com/")
        {
            string getting = "";

            getting = EasyDo.GetWWWString(from, true);
            if (string.IsNullOrEmpty(getting))
            {
                return(0);
            }
            RealTimeCallback rt = new RealTimeCallback();

            rt = JsonUtility.FromJson <RealTimeCallback>(getting);

            DateTime date = DateTime.Parse(rt.date + " " + rt.time);

            if (type == TimeType.day)
            {
                return(date.Day);
            }
            if (type == TimeType.mounth)
            {
                return(date.Month);
            }
            if (type == TimeType.year)
            {
                return(date.Year);
            }

            if (type == TimeType.sec)
            {
                return(date.Second);
            }
            if (type == TimeType.min)
            {
                return(date.Minute);
            }
            if (type == TimeType.hour)
            {
                if (rt.time[9].ToString() + rt.time[10].ToString() == "PM" && !pmam)
                {
                    return(int.Parse(rt.time[0].ToString() + rt.time[1].ToString()) + 12);
                }
                else
                {
                    return(int.Parse(rt.time[0].ToString() + rt.time[1].ToString()));
                }
            }

            if (type == TimeType.pmam)
            {
                if (rt.time[9].ToString() + rt.time[10].ToString() == "PM")
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }

            return(0);
        }