Esempio n. 1
0
    //void OnGUI()
    //{
    //    GUILayout.BeginArea(new Rect(400, 50, 400, 400), "", "box");
    //    GUILayout.BeginVertical();
    //    result = GUILayout.TextField(result);

    //    if (GUILayout.Button("Save"))
    //    {
    //        Save(result);
    //    }

    //    if (GUILayout.Button("Load"))
    //    {
    //        loadtext = Load();
    //    }

    //    GUILayout.Label(loadtext);
    //    GUILayout.EndVertical();
    //    GUILayout.EndArea();

    //}

    public static void Save(string _value)
    {
        #if !UNITY_WEBPLAYER
        if (!Common.IsRelease)
        {
            file = new FileInfo(Application.persistentDataPath + "\\" + "DebugLog" + DateTime.Now.Day +
                                "time" + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".txt");
        }
        else
        {
            file = new FileInfo(Application.persistentDataPath + "\\" + "DebugLog.txt");
        }
        StreamWriter writer;
        if (!file.Exists)
        {
            writer = file.CreateText();
        }
        else
        {
            file.Delete();
            writer = file.CreateText();
        }

        writer.WriteLine(_value);
        writer.Close();
        Debug.LogWarning(Application.persistentDataPath.ToString());
        StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, "");//Xóa luôn log sau khi đã lưu vào file
#endif
    }
Esempio n. 2
0
    void OnDestroy()
    {
                #if UNITY_IPHONE
        EtceteraManager.remoteNotificationReceivedAtLaunchEvent -= remoteNotificationAtLauch;
        EtceteraManager.remoteNotificationReceivedEvent         -= remoteNotification;
        EtceteraManager.remoteRegistrationSucceededEvent        -= remoteRegistrationSucceeded;
        EtceteraManager.remoteRegistrationFailedEvent           -= remoteRegistrationFailed;
                #elif UNITY_ANDROID
        GCMReceiver._onRegistered   -= remoteRegistrationSucceeded;
        GCMReceiver._onUnregistered -= remoteRegistrationFailed;
        GCMReceiver._onMessage      -= gcmReceiverMessage;
        if (GameObject.Find("GCMReceiver") != null)
        {
            GameObject.Destroy(GameObject.Find("GCMReceiver"));
        }
                #endif

        Debug.LogWarning(this.GetType().Name + ": OnDestroy");
        if (_mServer != null)
        {
            _mServer.OnDestroy();
        }
        //_mServer.DoLogOut();
        _instance = null;
        StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN);
    }
Esempio n. 3
0
 public static void ClearLog()
 {
     if (StoreGame.Contains(StoreGame.EType.DEBUG_LOG))
     {
         PlayerPrefs.SetString(GetKeyName(StoreGame.EType.DEBUG_LOG), "");
     }
 }
Esempio n. 4
0
    void OnAfterJoinRoom(JoinRoomEvent e)
    {
        if (cbSavePass.value)
        {
            if (IsClickButtonLogin)
            {
                StoreGame.SaveString(StoreGame.EType.SAVE_USERNAME, lableUsername.value);
                StoreGame.SaveString(StoreGame.EType.SAVE_PASSWORD, lablePassword.value);
            }
        }
        //else
        //{
        //    StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN);
        //    StoreGame.Remove(StoreGame.EType.SAVE_USERNAME);
        //    StoreGame.SaveString(StoreGame.EType.SAVE_PASSWORD, lablePassword.text);
        //}
        //OK Next Scene

        if (GameManager.Instance.selectedLobby.gameId != 0)
        {
            return;
        }
        WaitingView.Hide();
        NotificationView.Instance.HideMessageView();
        GameManager.LoadScene(ESceneName.HallSceen);
    }
Esempio n. 5
0
 private void OnClickSendMsg(GameObject targetObject)
 {
     StoreGame.SaveString(StoreGame.EType.SEND_FRIEND_MESSAGE, mUser.username);
     ProfileView.Instance.CheckWhenStart();
     //ProfileView profile = ProfileView.Instance.C;
     GameObject.Destroy(gameObject);
 }
Esempio n. 6
0
    IEnumerator DoRequest_AllHelp()
    {
        string reRequest = null;

        ServerWeb.StartThreadHttp(ServerWeb.URL_GETINFO_HELP, new object[] { "game_id", (int)GameManager.GAME, ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier }, delegate(bool isDone, WWW response, IDictionary json)
        {
            if (isDone)
            {
                if (string.IsNullOrEmpty(response.error))
                {
                    reRequest = "0";
                    if (json["code"].ToString() == "1")
                    {
                        string strSaveRule = JSON.JsonEncode(json["help"]);
                        StoreGame.SaveString(StoreGame.EType.CACHE_HELP, strSaveRule);
                        GameManager.Instance.StartCoroutine(onProcessGetInfoRule(strSaveRule, false));
                    }
                }
                else
                {
                    reRequest = "1";
                }
            }
        });
        while (string.IsNullOrEmpty(reRequest))
        {
            yield return(new WaitForEndOfFrame());
        }
        if (reRequest == "1")
        {
            yield return(new WaitForSeconds(2f));

            GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
        }
    }
    void Start()
    {
        if (GameManager.PlayGoldOrChip != GOLD && GameManager.PlayGoldOrChip != CHIP)
        {
            GameManager.PlayGoldOrChip = GOLD;
        }
        GameManager.Server.DoRequestCommand(Fields.REQUEST.REQUEST_FULL);
        if (GameManager.Setting.IsFirstLogin)
        {
            GameManager.Setting.IsFirstLogin = false;
            NotificationView.ShowConfirm(
                Fields.MESSAGE.FIRST_LOGIN_NOTE, Fields.MESSAGE.FIRST_LOGIN_MESSAGE,
                delegate()
            {
                StoreGame.SaveInt(StoreGame.EType.CHANGE_INFORMATION, 1);
                ProfileView.Instance.CheckWhenStart();
            }
                , null, "CẬP NHẬT", "ĐỂ SAU"
                );
        }
        GetDataUserInfo();
        SetIcon();

        HeaderMenu.Instance.OnClickButtonBackCallBack = delegate()
        {
            GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);
        };
    }
Esempio n. 8
0
    /// <summary>
    /// Lưu tin nhắn hệ thống vào cache của game
    /// </summary>
    /// <param name="_params">Danh sách các tin mới</param>
    public static void SaveCache(params Hashtable[] _params)
    {
        if (_params != null && _params.Length > 0)
        {
            foreach (Hashtable hash in _params)
            {
                Messages mess = new Messages(hash);
                if (GameManager.Instance.ListMessageSystem.Contains(mess) == false)
                {
                    GameManager.Instance.ListMessageSystem.Add(new Messages(hash));
                }
            }
        }

        GameManager.Instance.ListMessageSystem.Sort((x, y) => x.time_sent.CompareTo(y.time_sent));
        List <Messages> messageSystem = GameManager.Instance.ListMessageSystem;

        ArrayList cache = new ArrayList();

        foreach (Messages mess in messageSystem)
        {
            cache.Add(mess.ParseToHashtable);
        }

        StoreGame.SaveString(StoreGame.EType.CACHE_MESSAGE_SYSTEM, JSON.JsonEncode(cache));
    }
Esempio n. 9
0
    public void OnResponseMessageHandler()
    {
        string username = StoreGame.LoadString(StoreGame.EType.SEND_FRIEND_MESSAGE);

        if (StoreGame.Contains(StoreGame.EType.SEND_FRIEND_MESSAGE) && !string.IsNullOrEmpty(username) && GameManager.Instance.mInfo.messages.Find(m => m.receiver_name == username) == null)
        {
            Messages mess = new Messages();
            mess.sender_name     = GameManager.Instance.mInfo.username;
            mess.receiver_avatar = 0;
            mess.time_sent       = System.DateTime.Now;
            mess.receiver_name   = username;
            mess.content         = "";
            mess.read            = true;
            GameManager.Instance.mInfo.messages.Add(mess);
            createListMessageFriend(GameManager.Instance.mInfo.messages, controller.selectedIndex);
        }
        else
        {
            createListMessageFriend(GameManager.Instance.mInfo.messages, controller.selectedIndex);
        }
        if (!string.IsNullOrEmpty(username))
        {
            StartCoroutine(FindFriendWhenSelect(username));
        }

        if (GameManager.Instance.ListMessageSystem.Count > 0)
        {
            createListMessageSystem();
        }
    }
Esempio n. 10
0
    void Start()
    {
        GameManager.Server.DoRequestCommand(Fields.REQUEST.REQUEST_FULL);

        if (GameManager.Setting.IsFirstLogin)
        {
            GameManager.Setting.IsFirstLogin = false;
            NotificationView.ShowConfirm(
                Fields.MESSAGE.FIRST_LOGIN_NOTE, Fields.MESSAGE.FIRST_LOGIN_MESSAGE,
                delegate()
            {
                StoreGame.SaveInt(StoreGame.EType.CHANGE_INFORMATION, 1);
                ProfileView.Instance.CheckWhenStart();
            }
                , null, "CẬP NHẬT", "ĐỂ SAU"
                );
        }

        listButton[0].GetComponentInChildren <NumberUserInChannel>().SetValue(2);
        SetIcon();
        HeaderMenu.Instance.OnClickButtonBackCallBack = delegate()
        {
            GameManager.Server.DoJoinRoom(GameManager.Instance.hallRoom.zoneId, GameManager.Instance.hallRoom.roomId);
        };
    }
Esempio n. 11
0
    public static void SendLogToServer()
    {
        StoreGame.ClearLog();
        for (int i = 0; i < entriesConsole.Count; i++)
        {
            StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, entriesConsole[i].message);
        }
        string  url  = ServerWeb.URL_REQUEST_ERROR;
        string  data = ConvertStringToJson(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG));
        WWWForm form = new WWWForm();

        form.AddField("app_id", GameManager.GAME.ToString());
        form.AddField("game_version", GameSettings.CurrentVersion);
        if (GameManager.CurrentScene != ESceneName.LoginScreen)
        {
            form.AddField("user_id", GameManager.Instance.mInfo.id);
            form.AddField("username", GameManager.Instance.mInfo.username);
        }
        form.AddField("scene", GameManager.CurrentScene.ToString());
        form.AddField("error", "");
        form.AddField("detail", "");
        form.AddField("environment", Common.GetDevice);
        form.AddField("debug_log", data);
        form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        ServerWeb.StartThread(url, form, null);
    }
Esempio n. 12
0
 void OnClickProfile(GameObject go)
 {
     //GameManager.Server.DoRequestPlugin(Utility.SetEsObject("getLevel", new object[]{
     //        "appId", GameManager.Instance.hallRoom.gameId
     //    }));
     StoreGame.Remove(StoreGame.EType.SEND_FRIEND_MESSAGE);
     ProfileView.Instance.CheckWhenStart();
     HideMenu();
 }
    public override void OnSelectTabbarAtIndex(int index)
    {
        if (tabbarPanel [index].gameObject.GetComponent <ProfileTabInfo> () != null)
        {
            tabbarPanel [index].gameObject.GetComponent <ProfileTabInfo> ().initUserInfo();
        }
        else if (tabbarPanel [index].gameObject.GetComponent <ProfileTabSettingView> () != null)
        {
            tabbarPanel [index].gameObject.GetComponent <ProfileTabSettingView> ().initInformation();
        }
        else if (tabbarPanel [index].gameObject.GetComponent <ProfileTabMessageView> () != null)
        {
            tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().gridMessageSystem.Reposition();
            tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().gridInvited.Reposition();
            tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().gridFriend.Reposition();

            if (!hadRequestMessage && GameManager.Instance.mInfo.messages.Count == 0)
            {
                WaitingView.Show("Đang tải dữ liệu");
                if (!hadRequestMessage)
                {
                    GameManager.Server.DoRequestCommand(Fields.REQUEST.GET_MESSAGE);
                    hadRequestMessage = true;
                }

                if (!hadRequestBuddies)
                {
                    hadRequestBuddies = true;
                    GameManager.Server.DoRequestCommand(Fields.REQUEST.GET_BUDDIES);
                }
            }
            else
            {
                if (StoreGame.Contains(StoreGame.EType.SEND_FRIEND_MESSAGE))
                {
                    tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().OnResponseMessageHandler();
                }
                else
                {
                    tabbarPanel[index].gameObject.GetComponent <ProfileTabMessageView>().reLoadListMessageFriendWhenSelectTabMessage();
                }
            }

            numberTabMessage.gameObject.SetActive(index != 1);
        }
        else if (tabbarPanel [index].gameObject.GetComponent <ProfileTabFriend> () != null)
        {
            tabbarPanel[index].gameObject.GetComponent <ProfileTabFriend>().tableFriend.Reposition();
            if (!hadRequestBuddies && GameManager.Instance.mInfo.buddies.Count == 0)
            {
                WaitingView.Show("Đang tải dữ liệu");
                hadRequestBuddies = true;
                GameManager.Server.DoRequestCommand(Fields.REQUEST.GET_BUDDIES);
            }
        }
    }
Esempio n. 14
0
    void EnterLogin()
    {
        btLogin.StopImpact(1f);

        if (!string.IsNullOrEmpty(GameManager.Setting.IsMustUpdate))
        {
            Common.MustUpdateGame();
            return;
        }

        if (!Common.IsRelease)
        {
            string testUsername = "******";
            string testPassword = "******";

#if UNITY_STANDALONE_WIN
            testUsername = "******";
#elif UNITY_ANDROID
            testUsername = "******";
#else
            testUsername = "******";
#endif
            if (Application.isEditor)
            {
                testUsername = "******";
                testPassword = "******";
            }

            if (string.IsNullOrEmpty(lableUsername.value) && string.IsNullOrEmpty(lablePassword.value))
            {
                lableUsername.value = testUsername;
                lablePassword.value = testPassword;
            }
        }

        if (string.IsNullOrEmpty(lableUsername.value))
        {
            NotificationView.ShowMessage("Tên truy cập không được phép để trống");
            return;
        }
        if (string.IsNullOrEmpty(lablePassword.value))
        {
            NotificationView.ShowMessage("Mật khẩu không được phép để trống.");
            return;
        }

        IsClickButtonLogin = true;
        GameManager.Instance.userNameLogin = lableUsername.value;
        GameManager.Instance.passwordLogin = lablePassword.value;
        GameManager.Server.DoLogin();

        if (!Common.IsRelease)
        {
            StoreGame.SaveString(StoreGame.EType.SAVE_SERVER, CServer.HOST_NAME);
        }
    }
Esempio n. 15
0
    IEnumerator onProcessGetInfoRule(string textJson, bool isCache)
    {
        string reRequest = null;

        ArrayList list = (ArrayList)JSON.JsonDecode(textJson);

        foreach (Hashtable obj in list)
        {
            GameManager.Instance.ListHelp.Add(obj);
        }

        if (list.Count > 0)
        {
            //GameManager.Instance.ListHelp.Sort((x, y) => DateTime.Parse(x["time"].ToString()).CompareTo(DateTime.Parse(y["time"].ToString())));
            GameManager.Instance.ListHelp.Sort((x, y) => int.Parse(x["id"].ToString()).CompareTo(int.Parse(y["id"].ToString())));

            if (isCache)
            {
                WWWForm form = new WWWForm();
                string  time = string.Format("{0:yyyy-MM-dd HH:mm:ss}", GameManager.Instance.ListHelp[list.Count - 1]["time"].ToString());
                form.AddField("time", time);
                form.AddField("game_id", (int)GameManager.GAME);
                form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
                ServerWeb.StartThreadHttp(ServerWeb.URL_GETINFO_HELP, form, delegate(bool isDone, WWW response, IDictionary json)
                {
                    if (isDone)
                    {
                        if (string.IsNullOrEmpty(response.error))
                        {
                            reRequest = "0";
                            if (json["code"].ToString() == "1")
                            {
                                StoreGame.Remove(StoreGame.EType.CACHE_HELP);
                                GameManager.Instance.ListHelp.Clear();
                                GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
                            }
                        }
                        else
                        {
                            reRequest = "1";
                        }
                    }
                });
                while (string.IsNullOrEmpty(reRequest))
                {
                    yield return(new WaitForEndOfFrame());
                }
                if (reRequest == "1")
                {
                    yield return(new WaitForSeconds(2f));

                    GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
                }
            }
        }
    }
Esempio n. 16
0
    string GetAccessToken(IDictionary json)
    {
        string accessToken = json["accessToken"].ToString();

        if (isSaveAccessToken)
        {
            StoreGame.SaveString(StoreGame.EType.SAVE_ACCESSTOKEN, accessToken);
        }
        return(accessToken);
    }
Esempio n. 17
0
    /// <summary>
    /// Logged messages are sent through this callback function.
    /// </summary>
    /// <param name="message">The message itself.</param>
    /// <param name="stackTrace">A trace of where the message came from.</param>
    /// <param name="type">The type of message: error/exception, warning, or assert.</param>
    void HandleLog(string message, string stackTrace, LogType type)
    {
        ConsoleMessage entry = new ConsoleMessage(message, stackTrace, type);

        entries.Add(entry);
        if (entries.Count > LIMIT_LINE)
        {
            entries.RemoveAt(0);
        }

        if (GameManager.CurrentScene == ESceneName.GameplayChan && type == LogType.Exception)
        {
            WaitingView.Show("Có l?i x?y ra. Vui lòng d?i!");
            GameManager.Server.DoRequestGameCommand("refreshGame");
        }


        entriesConsole.Add(entry);
        if (entriesConsole.Count > LIMIT_LINE_CONSOLE)
        {
            entriesConsole.RemoveAt(0);
        }

        if (type == LogType.Error && !message.StartsWith("Coroutine couldn't be started because the the game object"))
        {
            StoreGame.ClearLog();
            for (int i = 0; i < entries.Count; i++)
            {
                StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, entries[i].message);
            }
            //SaveLogToFile(); //for test
            string  url  = ServerWeb.URL_REQUEST_ERROR;
            string  data = ConvertStringToJson(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG));
            WWWForm form = new WWWForm();
            form.AddField("app_id", GameManager.GAME.ToString());
            form.AddField("game_version", GameSettings.CurrentVersion);
            if (GameManager.CurrentScene != ESceneName.LoginScreen)
            {
                form.AddField("user_id", GameManager.Instance.mInfo.id);
                form.AddField("username", GameManager.Instance.mInfo.username);
            }
            form.AddField("scene", GameManager.CurrentScene.ToString());
            form.AddField("error", "");
            form.AddField("detail", "");
            form.AddField("environment", Common.GetDevice);
            form.AddField("debug_log", data);
            form.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
            if (!listSendError.Contains(form))
            {
                listSendError.Add(form);
                ServerWeb.StartThread(url, form, null);
            }
        }
    }
Esempio n. 18
0
 public static void SaveLog(EType _type, string _value)
 {
     if (_type == EType.DEBUG_LOG)
     {
         if (StoreGame.Contains(StoreGame.EType.DEBUG_LOG))
         {
             _value = StoreGame.LoadString(StoreGame.EType.DEBUG_LOG) + "\n\n" + _value;
             PlayerPrefs.SetString(GetKeyName(_type), _value);
         }
     }
 }
Esempio n. 19
0
 public static void SaveLogToFile()
 {
     StoreGame.ClearLog();
     for (int i = 0; i < entriesConsole.Count; i++)
     {
         StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, entriesConsole[i].message);
     }
     if (StoreGame.Contains(StoreGame.EType.DEBUG_LOG))
     {
         SaveAndLoadFile.Save(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG));
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Khởi tạo thông tin cài đặt
        /// </summary>
        public void Init()
        {
            Platform = new PlatformSetting();

            if (StoreGame.Contains(StoreGame.EType.FULL_SCREEN))
            {
                IsFullScreen = StoreGame.LoadInt(StoreGame.EType.FULL_SCREEN) == (int)StoreGame.EToggle.ON;
            }
            if (StoreGame.Contains(StoreGame.EType.LOCK_SCREEN))
            {
                AllowLockScreen = StoreGame.LoadInt(StoreGame.EType.LOCK_SCREEN) == (int)StoreGame.EToggle.ON;
            }
        }
Esempio n. 21
0
    public static void SaveDeviceWhenJoinGame()
    {
        string str = "";

        if (StoreGame.Contains(StoreGame.EType.PLAY_THE_SAME_DEVICE))
        {
            str = StoreGame.LoadString(StoreGame.EType.PLAY_THE_SAME_DEVICE) + DATA_ROW;
        }
        str += GameManager.Instance.mInfo.username + DATA_SAPCE + GameManager.Instance.selectedLobby.gameId;

        Debug.LogWarning("IsCanJoinGameplay SAVED: " + str);

        StoreGame.SaveString(StoreGame.EType.PLAY_THE_SAME_DEVICE, str);
        StoreGame.Save();
    }
Esempio n. 22
0
    System.Collections.IEnumerator _CheckWhenStart()
    {
        if (StoreGame.Contains(StoreGame.EType.SEND_FRIEND_MESSAGE))
        {
            yield return(new WaitForEndOfFrame());

            controller.OnSelectTabbar(1);
        }
        else if (StoreGame.Contains(StoreGame.EType.CHANGE_INFORMATION))
        {
            controller.OnSelectTabbar(5);
            panelSettings.ShowEditGeneral();
            StoreGame.Remove(StoreGame.EType.CHANGE_INFORMATION);
        }
    }
Esempio n. 23
0
    /// <summary>
    /// Load tin nhắn hệ thống từ cache của game và kiểm tra tin nhắn mới từ database
    /// </summary>
    public static void DownloadOrLoadCache()
    {
        GameManager.Instance.ListMessageSystem.Clear();
        if (StoreGame.Contains(StoreGame.EType.CACHE_MESSAGE_SYSTEM))
        {
            ArrayList cacheMessageSystem = (ArrayList)JSON.JsonDecode(StoreGame.LoadString(StoreGame.EType.CACHE_MESSAGE_SYSTEM));

            foreach (Hashtable hash in cacheMessageSystem)
            {
                GameManager.Instance.ListMessageSystem.Add(new Messages(hash));
            }

            GameManager.Instance.ListMessageSystem.Sort((x, y) => x.time_sent.CompareTo(y.time_sent));
        }

        #region DOWNLOAD
        WWWForm formMessageSystem = new WWWForm();
        formMessageSystem.AddField("sender", 0);
        formMessageSystem.AddField("receiver", GameManager.Instance.mInfo.id);
        formMessageSystem.AddField(ServerWeb.PARAM_PARTNER_ID, GameSettings.Instance.ParnerCodeIdentifier);
        if (GameManager.Instance.ListMessageSystem.Count > 0)
        {
            DateTime time_send = GameManager.Instance.ListMessageSystem[GameManager.Instance.ListMessageSystem.Count - 1].time_sent;
            formMessageSystem.AddField("time", string.Format("{0:yyyy-MM-dd HH:mm:ss}", time_send));
            //Debug.Log(ServerWeb.URL_GETINFO_MESSAGE + "?sender=0&receiver=" + GameManager.Instance.mInfo.id + "&time=" + string.Format("{0:yyyy-MM-dd HH:mm:ss}", time_send));
        }

        ServerWeb.StartThread(ServerWeb.URL_GETINFO_MESSAGE, formMessageSystem, delegate(bool isDone, WWW response, IDictionary json)
        {
            var x = json;
            if (isDone && json["code"].ToString() == "1")
            {
                ArrayList downloadMessageSystem = (ArrayList)json["item"];
                List <Hashtable> lst            = new List <Hashtable>();
                foreach (Hashtable hash in downloadMessageSystem)
                {
                    lst.Add(hash);
                }
                SaveCache(lst.ToArray());
                if (EventResponseMessageSystem != null)
                {
                    EventResponseMessageSystem();
                }
            }
        });
        #endregion
    }
Esempio n. 24
0
    void Start()
    {
        //disable checkbox full screen on mobile
#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY
        cbFullScreen.GetComponent <BoxCollider>().enabled      = false;
        cbFullScreen.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 90 / 255f);
#endif
        //chưa có âm thanh nền nên không cho người chơi tương tác
        cbSoundBackground.GetComponent <BoxCollider>().enabled      = false;
        cbSoundBackground.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 90 / 255f);

        cbSoundEffect.value     = StoreGame.LoadInt(StoreGame.EType.SOUND_EFFECT, (int)StoreGame.EToggle.ON) == (int)StoreGame.EToggle.ON;
        cbSoundBackground.value = StoreGame.LoadInt(StoreGame.EType.SOUND_BACKGROUND, (int)StoreGame.EToggle.ON) == (int)StoreGame.EToggle.ON;
        cbFullScreen.value      = GameManager.Setting.IsFullScreen;
        cbLockScreen.value      = GameManager.Setting.AllowLockScreen;
        wasStart = true;
    }
Esempio n. 25
0
 private void Download(string file, ListStore list)
 {
     try
     {
         WebClient wc      = new WebClient();
         string    rawjson = wc.DownloadString("http://" + ftpServerIP.Replace("ftp.", "") + "/" + remoteDir + "/" + file);
         StoreGame game    = Newtonsoft.Json.JsonConvert.DeserializeObject <StoreGame>(rawjson);
         list.AppendValues(game.Name, game);
     }
     catch (WebException wEx)
     {
         ShowError("An error occurred while downloading data for the Shifted Store." + wEx.Message);
     }
     catch (Exception ex)
     {
         ShowError("A C# exception has occurred while downloading data for the Shifted Store. " + ex.Message);
     }
 }
Esempio n. 26
0
    public static void ClearCache()
    {
        if (!Application.isWebPlayer)
        {
            return;
        }

        if (GameManager.CurrentScene == ESceneName.GameplayChan)
        {
            return;
        }

        if (StoreGame.Contains(StoreGame.EType.PLAY_THE_SAME_DEVICE))
        {
            string   newValue = "";
            string[] arrays   = StoreGame.LoadString(StoreGame.EType.PLAY_THE_SAME_DEVICE).Split(DATA_ROW.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            Debug.LogWarning(StoreGame.LoadString(StoreGame.EType.PLAY_THE_SAME_DEVICE) + "\n" + arrays.Length);

            foreach (string str in arrays)
            {
                string[] arr = str.Split(DATA_SAPCE.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arr[0] == GameManager.Instance.mInfo.username)
                {
                    Debug.LogWarning("IsCanJoinGameplay Remove: " + str);
                    continue;
                }
                newValue += str + DATA_ROW;
            }

            if (newValue != StoreGame.LoadString(StoreGame.EType.PLAY_THE_SAME_DEVICE))
            {
                if (string.IsNullOrEmpty(newValue))
                {
                    StoreGame.Remove(StoreGame.EType.PLAY_THE_SAME_DEVICE);
                }
                else
                {
                    StoreGame.SaveString(StoreGame.EType.PLAY_THE_SAME_DEVICE, newValue);
                }
                StoreGame.Save();
            }
        }
    }
Esempio n. 27
0
    public ApplicationStart()
    {
        #region CLEAR CACHE WITH OLD VERSION
        if (!StoreGame.Contains(StoreGame.EType.VERSION) || (StoreGame.LoadString(StoreGame.EType.VERSION) != GameSettings.CurrentVersion))
        {
            StoreGame.ClearCache();
            StoreGame.SaveString(StoreGame.EType.VERSION, GameSettings.CurrentVersion);
        }
        #endregion

        #region KIỂM TRA CẤU HÌNH CÁC CONFIGURATION CỦA SERVER
        GameManager.Instance.StartCoroutine(DoRequestAllConfiguration("Kiểm tra kết nối đến server"));
        #endregion

        #region KIỂM TRA THÔNG TIN HỖ TRỢ (1)
        if (!StoreGame.Contains(StoreGame.EType.CACHE_HELP))
        {
            GameManager.Instance.StartCoroutine(DoRequest_AllHelp());
        }
        else
        {
            GameManager.Instance.StartCoroutine(onProcessGetInfoRule(StoreGame.LoadString(StoreGame.EType.CACHE_HELP), true));
        }
        #endregion

        #region KIỂM TRA THÔNG TIN ĐIỀU KHOẢN SỬ DỤNG (1)
        //if (!StoreGame.Contains(StoreGame.EType.CACHE_POLICY))
        //    GameManager.Instance.StartCoroutine(DoRequest_Policy());
        //else
        //    GameManager.Instance.StartCoroutine(onProcessGetInfoRule(StoreGame.LoadString(StoreGame.EType.CACHE_POLICY), true));
        #endregion

        #region REQUEST CHECK VERSION
        GameManager.Instance.StartCoroutine(DoRequestVersion());
        #endregion

        #region REQUEST GET ADS
        GameManager.Instance.StartCoroutine(DoRequestAds());
        #endregion

        #region REQUEST RECHARGE
        GameManager.Instance.StartCoroutine(DoRequestRecharge());
        #endregion
    }
Esempio n. 28
0
    protected virtual void OnLoginResponse(LoginResponse e)
    {
        isLogged = true;
        if (e.Successful)
        {
            EsObject param = new EsObject();

            if (!string.IsNullOrEmpty(GameManager.Instance.userNameLogin) && !string.IsNullOrEmpty(GameManager.Instance.passwordLogin))
            {
                param.setString("userName", GameManager.Instance.userNameLogin);
                param.setString("password", GameManager.Instance.passwordLogin);
                param.setInteger(Fields.REQUEST.APP_ID, (int)GameManager.GAME);
                param.setString("environment", Common.GetDevice);
                param.setString("version", GameSettings.CurrentVersion);
                param.setString("platform", PlatformSetting.GetSamplePlatform.ToString());
                param.setString("deviceToken", GameManager.Instance.deviceToken);
            }
            else if (!string.IsNullOrEmpty(GameManager.Instance.accessToken))
            {
                param.setString("accessToken", GameManager.Instance.accessToken);
                param.setInteger(Fields.REQUEST.APP_ID, (int)GameManager.GAME);
                param.setString("environment", Common.GetDevice);
                param.setString("version", GameSettings.CurrentVersion);
                param.setString("platform", PlatformSetting.GetSamplePlatform.ToString());
                param.setString("deviceToken", GameManager.Instance.deviceToken);
            }

            GameManager.Server.DoRequestPluginLogin(Utility.SetEsObject(Fields.REQUEST.COMMAND_LOGIN, new object[] { "loginInfo", param }));
        }
        else
        {
            WaitingView.Instance.Close();
            StoreGame.Remove(StoreGame.EType.SAVE_USERNAME);
            StoreGame.Remove(StoreGame.EType.SAVE_PASSWORD);
            StoreGame.Remove(StoreGame.EType.SAVE_ACCESSTOKEN);
            string message = "Thông tin đăng nhập không hợp lệ. Yêu cầu nhập lại thông tin truy cập.";
            if (e.EsObject.variableExists("reason"))
            {
                message = e.EsObject.getString("reason");
            }
            NotificationView.ShowMessage(message);
        }
    }
Esempio n. 29
0
    IEnumerator checkConnection(string ipAddress)
    {
        pinger = new Ping(ipAddress);
        //Debug.LogWarning("pos: " + this.transform.localPosition);
        yield return(new WaitForSeconds(5f));

        //Debug.LogWarning(pinger.time);
        if (!pinger.isDone)
        {
            statusWifi.spriteName = WIFI_DISCONNECT;
            StoreGame.SaveLog(StoreGame.EType.DEBUG_LOG, "==========================[Ping time out]================================");
            //if (!Common.IsRelease)
            //{
            //    if (IsSaveFileLog == false)
            //        SaveAndLoadFile.Save(StoreGame.LoadString(StoreGame.EType.DEBUG_LOG));//SAVE DEBUG_LOG TO FILE
            //}
            //else
            //{
            //    StoreGame.SaveString(StoreGame.EType.BOOL_SEND_LOG_TO_SERVER, "true");
            //}

            StartCoroutine(checkConnection(ipAddress));
            IsSaveFileLog = true;
        }
        else
        {
            if (pinger.time < 40)
            {
                statusWifi.spriteName = WIFI_EXCELLENT;
            }
            if (pinger.time > 40 && pinger.time < 100)
            {
                statusWifi.spriteName = WIFI_NORMAL;
            }
            if (pinger.time > 100)
            {
                statusWifi.spriteName = WIFI_LOW;
            }
            StartCoroutine(checkConnection(ipAddress));
        }
    }
Esempio n. 30
0
    IEnumerator _LoginInWebPlayer()
    {
        Debug.Log("===> Call Login web");
        string accessToken = "";

        while (cookie.Length == 0)
        {
            yield return(new WaitForEndOfFrame());
        }
        Debug.Log("===> End Call Login web cookie:" + cookie);
        string[] array = cookie.Split(';');

        Array.ForEach(array, c => { if (c.Contains("accessToken"))
                                    {
                                        accessToken = c;
                                    }
                      });

        if (accessToken.Length > 0)
        {
            while (string.IsNullOrEmpty(CServer.HOST_NAME))
            {
                yield return(new WaitForEndOfFrame());
            }
            string[] arrayAccessToken = accessToken.Split('=');
            hasAccessToken = true;

            GameManager.Server.DoLogin(arrayAccessToken[1], GameManager.Instance.deviceToken);
            if (cbSavePass.value)
            {
                StoreGame.SaveString(StoreGame.EType.SAVE_ACCESSTOKEN, arrayAccessToken[1]);
            }
        }
        else
        {
            //NotificationView.ShowConfirm("Lỗi", "Bạn chưa đăng nhập vào hệ thống , vui lòng vào trang chủ đăng nhập sau đó quay lại chơi game", delegate() { Application.OpenURL(ServerWeb.URL_BASE); }, delegate() { Application.OpenURL(ServerWeb.URL_BASE); });
        }
    }