//请求登陆 public void SendLogin(TempLogRegDataVO data) { //不论成功失败都会添加用户Id数据 UserInfoProxy userInfoProxy = AppFacade.getInstance.RetrieveProxy(UserInfoProxy.NAME) as UserInfoProxy; DbAccess dbAccess = new DbAccess(); string userName = data.UserName; string password = data.Password; string query = string.Format("SELECT id FROM info_users WHERE playername='{0}' AND passwd='{1}'", userName, password); SqliteDataReader reader = dbAccess.ExecuteQuery(query); if (reader.Read()) { int id = Utils.GetInt(reader["id"]); userInfoProxy.UsertData.Id = id; tempData = new TempLogRegDataVO(); tempData.status = ErrorCode.SUCCESS; LocalSaveData.LoginUserName = userName; LocalSaveData.LoginPassword = password; } else { tempData = new TempLogRegDataVO(); userInfoProxy.UsertData.Id = -1; tempData.status = ErrorCode.INVALID_LOGIN_INFO; } dbAccess.CloseSqlConnection(); SendNotification(LoginViewMediator.LOGIN_RESPONSE, tempData); }
public void Login() { tempData = new TempLogRegDataVO(); tempData.UserName = UserName.value; tempData.Password = PassWord.value; AppFacade.GetInstance().SendNotification(NotiConst.LOGIN_REQUEST, tempData); }
public void ReceiveRegisterMessage(TempLogRegDataVO vo) { //JsonData data = vo as JsonData; //if ((int)data[JsonConst.ErrorCode] == ErrorCode.SUCCESS) if (vo.status == ErrorCode.SUCCESS) { Debug.Log("注册成功"); ChangeState(LoginViewMediator.ELoginViewState.LOGIN); } else { Debug.Log("注册失败"); } }
public void ReceiveLoginMessage(TempLogRegDataVO vo) { //JsonData data = vo as JsonData; Message.text = ""; //if ((int)data[JsonConst.ErrorCode] == ErrorCode.SUCCESS) if (vo.status == ErrorCode.SUCCESS) { Debug.Log("登陆成功"); (AppFacade.getInstance.RetrieveMediator(SceneMediator.NAME) as SceneMediator).LoadScene(SceneConst.GameScene); //AppFacade.GetInstance().SendNotification(SceneMediator.LOAD_SCENE, SceneConst.GameScene); } else { Message.text = "Failed login UserName or password error"; Debug.Log("登陆失败"); } }
public void SendRegister(TempLogRegDataVO data) { /********** * 需要改成Json与服务器通讯 **********/ DbAccess dbAccess = new DbAccess(); string userName = data.UserName; //string.Format("'{0}'",data.UserName); string passWord = data.Password; //string.Format("'{0}'", data.Password); dbAccess.InsertIntoSpecific("info_users", new string[] { "type", "playername", "passwd", "lv", "vip", "gold", "diamond", "exp" }, new string[] { "1", userName, passWord, "0", "0", "100", "5", "0" }); //dbAccess.CloseSqlConnection(); int id = -1; SqliteDataReader reader = dbAccess.SelectWhere("info_users", new string[] { "id" }, new string[] { "playername", "passwd" }, new string[] { " = ", " = " }, new string[] { userName, passWord }); if (reader.Read()) { id = Utils.GetInt(reader["id"]); } dbAccess.InsertIntoSpecific("info_spheres", new string[] { "userid", "customer_current" }, new string[] { id.ToString(), "0" }); dbAccess.CloseSqlConnection(); tempData = new TempLogRegDataVO(); tempData.status = ErrorCode.SUCCESS; SendNotification(LoginViewMediator.REGISTER_RESPONSE, tempData); }
public void OnBtnClick(GameObject go) { if (go == LoginBtn) { Login(); } else if (go == RegisterBtn) { // 清空密码输入框 需要重新输入密码 PassWord.value = ""; ConfirmPassWord.value = ""; ChangeState(LoginViewMediator.ELoginViewState.REGISTER); } else if (go == OKBtn) { Message.text = ""; string errorInfo = "Registration error"; if (string.IsNullOrEmpty(UserName.value)) { errorInfo = "The user name cannot be empty"; } else if (string.IsNullOrEmpty(PassWord.value)) { errorInfo = "Password cannot be empty"; } else if (PassWord.value.Length < 6) { errorInfo = "Password length cannot be less than 6"; } else if (string.IsNullOrEmpty(ConfirmPassWord.value)) { errorInfo = "Please input the password again"; } else if (PassWord.value != ConfirmPassWord.value) { errorInfo = "Two entered passwords do not match"; } else { tempData = new TempLogRegDataVO(); tempData.UserName = UserName.value; tempData.Password = PassWord.value; AppFacade.GetInstance().SendNotification(NotiConst.REGISTER_REQUEST, tempData); return; } Message.text = errorInfo; // JsonData data2 = new JsonData(); // data2[MessageView.MessageType] = MessageView.TwoParameters; // data2[MessageView.OneParameters] = errorInfo; // data2[MessageView.TwoParameters] = gameObject.GetComponent<UIPanel>().depth; // AppFacade.GetInstance().SendNotification(NotiConst.MessageMediator, data2); // Debug.LogError("注册信息有误!"); } else if (go == ReturnBtn) { // 清空密码输入框 需要重新输入密码 PassWord.value = ""; ConfirmPassWord.value = ""; ChangeState(LoginViewMediator.ELoginViewState.LOGIN); } else if (go == QuitBtn) { //退出游戏 Application.Quit(); } }