public virtual void loadGameBaseData(ushort wKindID) { //if (HNMJGameScence::KIND_ID == wKindID) { DF.shared().init(wKindID, GameNet.GameScene.MAX_PLAYER, (int)GameScene.VERSION_CLIENT, Encoding.Default.GetBytes("Game")); } }
// 游客登陆 public void loginVisitor(CMD_GP_VisitorLogon VisitorAccount) { mVisitorAccount = VisitorAccount; mVisitorAccount.dwPlazaVersion = DF.shared().GetPlazaVersion(); mMissionType = MISSION_LOGIN_VISITOR; start(); }
public void RegisterAccount() { //lin: 微信第三方注册还未实现!! //m_kAccount = "Account_652595469"; //m_kUid = "Uid"; //m_kOpenid = "Openid"; //m_kPssword = "WeiXinPassword "; //m_kNickName = "慷慨阿姆斯特朗炮"; CMD_GP_RegisterAccounts kRegister = new CMD_GP_RegisterAccounts(); kRegister.Init(); kRegister.dwPlazaVersion = DF.shared().GetPlazaVersion(); kRegister.cbValidateFlags = MsgDefine.MB_VALIDATE_FLAGS | MsgDefine.LOW_VER_VALIDATE_FLAGS; kRegister.cbGender = (byte)(m_bMale ? 1 : 0); kRegister.wFaceID = 0; kRegister.wChannleId = m_ChannelID; var tempBuf = Encoding.Default.GetBytes(m_kAccount); Buffer.BlockCopy(tempBuf, 0, kRegister.szAccounts, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kUid); Buffer.BlockCopy(tempBuf, 0, kRegister.szUid, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kOpenid); Buffer.BlockCopy(tempBuf, 0, kRegister.szOpenid, 0, tempBuf.Length); tempBuf = Encoding.Default.GetBytes(m_kPssword); Buffer.BlockCopy(tempBuf, 0, kRegister.szLogonPass, 0, tempBuf.Length); tempBuf = Encoding.UTF8.GetBytes(m_kNickName); //不能使用GetEncoding(936),会导致数据库存的是乱码 在服务端进行UTF8转GB编码处理 Buffer.BlockCopy(tempBuf, 0, kRegister.szNickName, 0, tempBuf.Length); //kRegister.szAccounts = Encoding.Default.GetBytes (m_kAccount); //kRegister.szLogonPass = Encoding.Default.GetBytes(m_kPssword); //kRegister.szNickName = Encoding.Default.GetBytes(m_kNickName); //strncpy(kRegister.szAccounts, kAccounts.c_str(), kAccounts.size()); //strncpy(kRegister.szLogonPass, m_kPssword.c_str(), m_kPssword.size()); //std::string kNickName = (m_kWeiXinUserInfo.nickname); //strncpy(kRegister.szNickName, kNickName.c_str(), kNickName.size()); m_kLoginMission.registerServer(kRegister); if (HNGameManager.bWeChatLogonIn == false) { //游客登陆 Loom.QueueOnMainThread(() => { PlayerPrefs.SetString("UserName", m_kAccount); PlayerPrefs.SetString("Uid", m_kUid); PlayerPrefs.SetString("Openid", m_kOpenid); PlayerPrefs.SetString("Psd", m_kPssword); PlayerPrefs.SetString("NickName", m_kNickName); PlayerPrefs.SetInt("Sex", m_bMale ? 1 : 0); //PlayerPrefs.SetString("HeadURL", m_headURL); PlayerPrefs.Save(); }); } }
////////////////////////////////////////////////////////////////////////// // ISocketEngineSink public override void onEventTCPSocketLink() { //变量定义 GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); switch (mMissionType) { // 查询 case Type.MISSION_RAFFLE: { CMD_GP_RaffleDone kNetInfo = new CMD_GP_RaffleDone(); kNetInfo.Init(); kNetInfo.dwUserID = pGlobalUserData.dwUserID; kNetInfo.dwRaffleGold = m_dwRaffleGold; Buffer.BlockCopy(pGlobalUserData.szPassword, 0, kNetInfo.szPassword, 0, pGlobalUserData.szPassword.Length); ///strncpy(kNetInfo.szPassword, pGlobalUserData->szPassword, countarray(kNetInfo.szPassword)); var MachineID = DF.shared().GetMachineID(); if (MachineID != null) { Buffer.BlockCopy(MachineID, 0, kNetInfo.szMachineID, 0, MachineID.Length); } ///strncpy(kNetInfo.szMachineID, DF::shared()->GetMachineID(), countarray(kNetInfo.szMachineID)); var buf = StructConverterByteArray.StructToBytes(kNetInfo); send(MsgDefine.MDM_GP_USER_SERVICE, MsgDefine.SUB_GP_RAFFLE_DONE, buf, buf.Length); ///send(MDM_GP_USER_SERVICE, SUB_GP_RAFFLE_DONE, &kNetInfo, sizeof(CMD_GP_CheckInDone)); break; } default: stop(); break; } }
/*----------------IGPLoginMissionSink------------------------*/ //Login public void LogOn() { bool bHasAccount = false; if (HNGameManager.bWeChatLogonIn) { bHasAccount = PlayerPrefs.GetString("UserName_WX") == EventHandle.m_kAccount && PlayerPrefs.GetString("Uid_WX") == EventHandle.m_kUid; } else { bHasAccount = PlayerPrefs.HasKey("UserName"); } if (HNGameManager.bWeChatLogonIn) //SDK登录 { #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR Loom.QueueOnMainThread(() => { m_kAccount = EventHandle.m_kAccount; m_kUid = EventHandle.m_kUid; m_kNickName = CreateNickName.GetInstance.RandomName(); m_ChannelID = (ushort)EventHandle.m_channelID; PlayerPrefs.SetString("UserName_WX", m_kAccount); PlayerPrefs.SetString("Uid_WX", m_kUid); PlayerPrefs.SetString("Openid_WX", m_kOpenid); PlayerPrefs.SetString("Psd_WX", m_kPssword); PlayerPrefs.SetString("NickName_WX", m_kNickName); PlayerPrefs.SetInt("Sex_WX", m_bMale ? 1 : 0); PlayerPrefs.Save(); var loginAccount = new CMD_GP_LogonAccounts(); loginAccount.Init(); loginAccount.dwPlazaVersion = DF.shared().GetPlazaVersion(); loginAccount.cbValidateFlags = MsgDefine.MB_VALIDATE_FLAGS | MsgDefine.LOW_VER_VALIDATE_FLAGS; var tempBuf = System.Text.Encoding.Default.GetBytes(m_kAccount); Buffer.BlockCopy(tempBuf, 0, loginAccount.szAccounts, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kUid); Buffer.BlockCopy(tempBuf, 0, loginAccount.szUid, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kOpenid); Buffer.BlockCopy(tempBuf, 0, loginAccount.szOpenid, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kPssword); Buffer.BlockCopy(tempBuf, 0, loginAccount.szPassword, 0, tempBuf.Length); m_kLoginMission.loginAccount(loginAccount); }); #endif } else //PC游客登录,仅供测试 { //游客登陆,或者有历史账号信息 //GameManagerBaseNet pTemp = GameManagerBaseNet.InstanceBase(); if (bHasAccount) //存在PC账号记录 { m_kAccount = PlayerPrefs.GetString("UserName", m_kAccount); m_kUid = PlayerPrefs.GetString("Uid", m_kUid); m_kOpenid = PlayerPrefs.GetString("Openid", m_kOpenid); m_kPssword = PlayerPrefs.GetString("Psd", m_kPssword); m_kNickName = PlayerPrefs.GetString("NickName", m_kNickName); m_bMale = PlayerPrefs.GetInt("Sex", m_bMale ? 1 : 0) == 1; } var loginAccount = new CMD_GP_LogonAccounts(); loginAccount.Init(); loginAccount.dwPlazaVersion = DF.shared().GetPlazaVersion(); loginAccount.cbValidateFlags = MsgDefine.MB_VALIDATE_FLAGS | MsgDefine.LOW_VER_VALIDATE_FLAGS; var tempBuf = System.Text.Encoding.Default.GetBytes(m_kAccount); Buffer.BlockCopy(tempBuf, 0, loginAccount.szAccounts, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kUid); Buffer.BlockCopy(tempBuf, 0, loginAccount.szUid, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kOpenid); Buffer.BlockCopy(tempBuf, 0, loginAccount.szOpenid, 0, tempBuf.Length); tempBuf = System.Text.Encoding.Default.GetBytes(m_kPssword); Buffer.BlockCopy(tempBuf, 0, loginAccount.szPassword, 0, tempBuf.Length); m_kLoginMission.loginAccount(loginAccount); //// to set pGlobalUserData.szHeadHttp //GlobalUserInfo pGlobalUserInfo = GlobalUserInfo.GetInstance(); //tagGlobalUserData pGlobalUserData = pGlobalUserInfo.GetGlobalUserData(); /////string strHeadimgurl = "http:\\s1"; //var kHeadimgurl = Encoding.Default.GetBytes(m_headURL); //Buffer.BlockCopy(kHeadimgurl, 0, pGlobalUserData.szHeadHttp, 0, kHeadimgurl.Length); //pGlobalUserInfo.upPlayerInfo(); } }