Esempio n. 1
0
        private void ProcessData()
        {
            switch (_xmlState)
            {
            case XmlLoadingState.Loading:
                if (_request.isDone)
                {
                    if (null != _request.error)
                    {
                        //Debug.Log("Error loading data: " + _request.error);
                        _xmlState = XmlLoadingState.Error;
                    }
                    else
                    {
                        string xml = _request.text;
                        //Debug.Log(xml);
                        //_xmlState = XmlLoadingState.Error;
                        ProcessXml(xml);
                        //_texture = _request.texture;
                        //_logoBounds = new Rect(0, 0, _texture.width, _texture.height);
                    }
                }
                break;

            case XmlLoadingState.LoadingLogo:
                if (_request.isDone)
                {
                    if (null != _request.error)
                    {
                        //Debug.Log("Error loading logo: " + _request.error);
                        _xmlState = XmlLoadingState.Error;
                    }
                    else
                    {
                        _texture = _request.texture;
                        //_texture = _request.texture;
                        //_logoBounds = new Rect(0, 0, _texture.width, _texture.height);
                        _xmlState        = XmlLoadingState.Finished;
                        _logoLoadingTime = Time.time;
                        //Alert.Show("Finished", "Finished!");
                    }
                }
                break;

            //case XmlLoadingState.Finished:
            //case XmlLoadingState.Error:
            default:
                // do nothing
                break;
            }
        }
Esempio n. 2
0
    private void ProcessXml(string xml)
    {
//        Debug.Log(@"UpdateCheck: Processing XML:
//" + xml);
        try
        {
            Configuration configuration = XmlSerializer <Configuration> .Deserialize(xml);

            if (null == configuration)
            {
                _xmlState = XmlLoadingState.Error;
                return;
            }

            _messages = configuration.Messages;
        }
        catch (Exception)
        {
            Debug.Log("Error loading data");
        }

        //Debug.Log("Processed: " + _messages.Count + " messages.");
        DataReady = true;
    }
Esempio n. 3
0
    private void ProcessXml(string xml)
    {
//        Debug.Log(@"UpdateCheck: Processing XML:
//" + xml);
        try
        {
            Configuration configuration = XmlSerializer<Configuration>.Deserialize(xml);

            if (null == configuration)
            {
                _xmlState = XmlLoadingState.Error;
                return;
            }

            _messages = configuration.Messages;
        }
        catch (Exception)
        {
            Debug.Log("Error loading data");
        }

        //Debug.Log("Processed: " + _messages.Count + " messages.");
        DataReady = true;
    }
Esempio n. 4
0
        private void ProcessXml(string xml)
        {
            try
            {
                Configuration configuration = XmlSerializer<Configuration>.Deserialize(xml);

                if (null == configuration)
                {
                    _xmlState = XmlLoadingState.Error;
                    return;
                }

                _settings = configuration.Settings;

                if (configuration.Blocked)
                {
                    //Alert.Show("Blocked", "The application is being blocked");
                    _timer = new Timer(10, 1);
                    _timer.Complete += OnTimerComplete;
                    _timer.Start();
                }

                if (null != configuration.InfoMessage)
                {
                    var info = configuration.InfoMessage;

                    bool shouldShow = info.Mode == MessageMode.Both;
                    if (Application.isEditor)
                    {
                        shouldShow = shouldShow || info.Mode == MessageMode.Editor;
                    }
                    else
                    {
                        shouldShow = shouldShow || info.Mode == MessageMode.Build;
                    }

                    if (shouldShow)
                    {
                        Alert.Show(
                            delegate(string action)
                            {
                                switch (action)
                                {
                                    case "dismiss":
                                        // do nothing
                                        break;
                                    case "more":
                                        Application.OpenURL(info.Url);
                                        break;
                                    default:
                                        break;
                                }

                            },
                            new AlertOption(AlertOptionType.Title, info.Title),
                            new AlertOption(AlertOptionType.Message, info.Message),
                            new AlertOption(AlertOptionType.Button, new AlertButtonDescriptor("dismiss", "Dismiss", true)),
                            new AlertOption(AlertOptionType.Button, new AlertButtonDescriptor("more", "More..."))
                            );
                    }
                }

                if (null != configuration.Messages)
                {
                    if (configuration.Messages.Count != 0)
                    {
                        List<string> msgs = new List<string>(_texts);

                        if (!configuration.AppendMessages)
                        {
                            msgs = new List<string>();
                            //if (configuration.Messages.Count == 1)
                            //    msgs.Add(_texts[0]);
                        }

                        foreach (InfoMessage message in configuration.Messages)
                        {
                            //Debug.Log("* " + message.Message);
                            msgs.Add(message.Message);
                        }
                        _texts = msgs.ToArray();
                    }
                }

                /**
             * 2. Load logo
             * */

                var logo = configuration.LogoInfo;
                if (null == logo)
                {
                    _xmlState = XmlLoadingState.Error;
                    return;
                }

                _logoInEditor = logo.ShowInEditor;
                _logoInBuild = logo.ShowInBuild;

                if (Application.isEditor)
                {
                    if (!_logoInEditor)
                    {
                        _xmlState = XmlLoadingState.Finished;
                        return;
                    }
                }
                else
                {
                    if (!_logoInBuild)
                    {
                        _xmlState = XmlLoadingState.Finished;
                        return;
                    }
                }

                string logoUrl = logo.Url;

                if (string.IsNullOrEmpty(logoUrl))
                    return;

                _logoAlpha = Mathf.Clamp(logo.Alpha, 0, 1);
                _logoColor = new Color(1, 1, 1, _logoAlpha);
                _logoPlacement = logo.Placement;
                _logoInterval = Mathf.Max(logo.Duration, LogoFadeInInterval + LogoFadeOutInterval);

                if (logo.CacheBuster)
                    logoUrl += string.Format("?{0}", (DateTime.Now - new DateTime(1970, 1, 1)).Ticks);

                _request = new WWW(logoUrl);
                _xmlState = XmlLoadingState.LoadingLogo;
            }
            catch (Exception)
            {
                Debug.Log("Error loading data");
            }
        }
Esempio n. 5
0
 private void ProcessData()
 {
     switch (_xmlState)
     {
         case XmlLoadingState.Loading:
             if (_request.isDone)
             {
                 if (null != _request.error)
                 {
                     //Debug.Log("Error loading data: " + _request.error);
                     _xmlState = XmlLoadingState.Error;
                 }
                 else
                 {
                     string xml = _request.text;
                     //Debug.Log(xml);
                     //_xmlState = XmlLoadingState.Error;
                     ProcessXml(xml);
                     //_texture = _request.texture;
                     //_logoBounds = new Rect(0, 0, _texture.width, _texture.height);
                 }
             }
             break;
         case XmlLoadingState.LoadingLogo:
             if (_request.isDone)
             {
                 if (null != _request.error)
                 {
                     //Debug.Log("Error loading logo: " + _request.error);
                     _xmlState = XmlLoadingState.Error;
                 }
                 else
                 {
                     _texture = _request.texture;
                     //_texture = _request.texture;
                     //_logoBounds = new Rect(0, 0, _texture.width, _texture.height);
                     _xmlState = XmlLoadingState.Finished;
                     _logoLoadingTime = Time.time;
                     //Alert.Show("Finished", "Finished!");
                 }
             }
             break;
             //case XmlLoadingState.Finished:
             //case XmlLoadingState.Error:
         default:
             // do nothing
             break;
     }
 }
Esempio n. 6
0
        private void ProcessXml(string xml)
        {
            try
            {
                Configuration configuration = XmlSerializer <Configuration> .Deserialize(xml);

                if (null == configuration)
                {
                    _xmlState = XmlLoadingState.Error;
                    return;
                }

                _settings = configuration.Settings;

                if (configuration.Blocked)
                {
                    //Alert.Show("Blocked", "The application is being blocked");
                    _timer           = new Timer(10, 1);
                    _timer.Complete += OnTimerComplete;
                    _timer.Start();
                }

                if (null != configuration.InfoMessage)
                {
                    var info = configuration.InfoMessage;

                    bool shouldShow = info.Mode == MessageMode.Both;
                    if (Application.isEditor)
                    {
                        shouldShow = shouldShow || info.Mode == MessageMode.Editor;
                    }
                    else
                    {
                        shouldShow = shouldShow || info.Mode == MessageMode.Build;
                    }

                    if (shouldShow)
                    {
                        Alert.Show(
                            delegate(string action)
                        {
                            switch (action)
                            {
                            case "dismiss":
                                // do nothing
                                break;

                            case "more":
                                Application.OpenURL(info.Url);
                                break;

                            default:
                                break;
                            }
                        },
                            new AlertOption(AlertOptionType.Title, info.Title),
                            new AlertOption(AlertOptionType.Message, info.Message),
                            new AlertOption(AlertOptionType.Button, new AlertButtonDescriptor("dismiss", "Dismiss", true)),
                            new AlertOption(AlertOptionType.Button, new AlertButtonDescriptor("more", "More..."))
                            );
                    }
                }

                if (null != configuration.Messages)
                {
                    if (configuration.Messages.Count != 0)
                    {
                        List <string> msgs = new List <string>(_texts);

                        if (!configuration.AppendMessages)
                        {
                            msgs = new List <string>();
                            //if (configuration.Messages.Count == 1)
                            //    msgs.Add(_texts[0]);
                        }

                        foreach (InfoMessage message in configuration.Messages)
                        {
                            //Debug.Log("* " + message.Message);
                            msgs.Add(message.Message);
                        }
                        _texts = msgs.ToArray();
                    }
                }

                /**
                 * 2. Load logo
                 * */

                var logo = configuration.LogoInfo;
                if (null == logo)
                {
                    _xmlState = XmlLoadingState.Error;
                    return;
                }

                _logoInEditor = logo.ShowInEditor;
                _logoInBuild  = logo.ShowInBuild;

                if (Application.isEditor)
                {
                    if (!_logoInEditor)
                    {
                        _xmlState = XmlLoadingState.Finished;
                        return;
                    }
                }
                else
                {
                    if (!_logoInBuild)
                    {
                        _xmlState = XmlLoadingState.Finished;
                        return;
                    }
                }

                string logoUrl = logo.Url;

                if (string.IsNullOrEmpty(logoUrl))
                {
                    return;
                }

                _logoAlpha     = Mathf.Clamp(logo.Alpha, 0, 1);
                _logoColor     = new Color(1, 1, 1, _logoAlpha);
                _logoPlacement = logo.Placement;
                _logoInterval  = Mathf.Max(logo.Duration, LogoFadeInInterval + LogoFadeOutInterval);

                if (logo.CacheBuster)
                {
                    logoUrl += string.Format("?{0}", (DateTime.Now - new DateTime(1970, 1, 1)).Ticks);
                }

                _request  = new WWW(logoUrl);
                _xmlState = XmlLoadingState.LoadingLogo;
            }
            catch (Exception)
            {
                Debug.Log("Error loading data");
            }
        }