Exemplo n.º 1
0
        private static void ShowMessage(Texture2D texture, ServerResponseData response)
        {
            MessageDisplayLogic.IncreaseTimesShown(response.MessageName);
            MessageDisplayLogic.SetLastMessageShownDate(response.MessageName);

            InfoMessage.ShowMessage(texture, response);
        }
Exemplo n.º 2
0
        private static void ProcessServerReply(WWW www, object args)
        {
            if (www.text.Contains("error"))
            {
                //			return;
                throw new InvalidOperationException("Received a error response from the server:\n" + www.text);
            }

            var responseData = ServerResponseData.DeserializeFromXML(www.text);

            if (null == responseData)
            {
                return;
            }
            //			throw new InvalidOperationException("Unable to deserialize XML response:\n" + www.text);

//			Debug.Log("Response:\n" +
//			          "MessageType: " + responseData.MessageType + "\n" +
//			          "ImageUrl: " + responseData.ImageUrl + "\n" +
//			          "TargetUrl: " + responseData.TargetUrl + "\n" +
//			          "TimesToShow: " + responseData.TimesToShow + "\n" +
//			          "IntervalInMinutes: " + responseData.IntervalInMinutes + "\n");
            MessageDisplayLogic.ResetIfShould(responseData);

            if (!MessageDisplayLogic.CanShowMessage(responseData))
            {
                return;
            }

            LoadTexture(responseData);
        }
Exemplo n.º 3
0
        void OnGUI()
        {
            if (GUILayout.Button(_texture))
            {
                if (null != _responseData && !string.IsNullOrEmpty(_responseData.TargetUrl))
                {
                    Application.OpenURL(_responseData.TargetUrl);
                    ServerGateway.ReportClick(_responseData.MessageType);

                    //Make sure to never show the message again if clicked on it
                    MessageDisplayLogic.SetTimesMessageWasShown(_responseData.MessageName, 100000);
                }
                this.Close();
            }
        }
Exemplo n.º 4
0
        public static void ResetIfShould(ServerResponseData response)
        {
            if (response.ResetToken < 0)
            {
                return;
            }

            var resetTokenKey = GetResetTokenKeyName(response);

            bool shouldReset = !EditorPrefs.HasKey(resetTokenKey) || (EditorPrefs.GetInt(resetTokenKey) != response.ResetToken);

            if (shouldReset)
            {
                                #if DEBUG_INFO_MESSAGE
                Debug.Log("Reset");
                                #endif
                //Reset mesage info
                MessageDisplayLogic.SetTimesMessageWasShown(response.MessageName, 0);
                MessageDisplayLogic.SetLastMessageShownDate(response.MessageName);
            }

            //Update reset token
            EditorPrefs.SetInt(resetTokenKey, response.ResetToken);
        }