Example #1
0
        IEnumerator startRegisterCoroutine(string name, string pass)
        {
            Debug.Log("LoginInit::startRegisterCoroutine: ");
            //var name = loginUI.nameInput.text;
            //var pass = loginUI.passwordInput.text;

            PacketHolder packet = new PacketHolder();

            CGRegisterAccount.Builder reg = CGRegisterAccount.CreateBuilder();
            reg.Username = name;
            reg.Password = pass;

            yield return(StartCoroutine(Bundle.sendSimple(this, reg, packet)));

            if (packet.packet.responseFlag == 0)
            {
                SaveGame.saveGame.AddNewAccount(name, pass);

                SaveGame.saveGame.SaveFile();
                //Login Game Auto

                yield return(StartCoroutine(loginCoroutine()));
            }
            else
            {
                //loginUI.showLog(Util.GetString("autoRegError"));
            }
        }
Example #2
0
        public IEnumerator regAndLog()
        {
            Debug.Log("LoginInit::regAndlog: start Register");
            PacketHolder packet = new PacketHolder();

            {
                CGAutoRegisterAccount.Builder auto = CGAutoRegisterAccount.CreateBuilder();
                var    data   = auto.Build();
                Bundle bundle = new Bundle();
                bundle.newMessage(typeof(CGAutoRegisterAccount));
                uint fid = bundle.writePB(data);
                yield return(StartCoroutine(bundle.sendCoroutine(KBEngineApp.app.networkInterface(), fid, packet)));
            }

            {
                var newAccount = packet.packet.protoBody as GCAutoRegisterAccount;
                CGRegisterAccount.Builder reg = CGRegisterAccount.CreateBuilder();
                reg.Username = newAccount.Username;
                reg.Password = "******";

                var data = reg.BuildPartial();
                Debug.Log("LoginInit::regAndLog: " + newAccount + " : " + data);
                Debug.Log("LoginInit::regAndLog:  username pass " + newAccount.Username + " " + data.Password);
                Bundle bundle = new Bundle();
                bundle.newMessage(data.GetType());
                var fid = bundle.writePB(data);
                yield return(StartCoroutine(bundle.sendCoroutine(KBEngineApp.app.networkInterface(), fid, packet)));

                if (packet.packet.responseFlag == 0)
                {
                    SaveGame.saveGame.AddNewAccount(newAccount.Username, data.Password);
                    SaveGame.saveGame.SaveFile();
                }
                else
                {
                    Log.Sys(Util.GetString("autoRegError"));
                }
            }

            yield return(StartCoroutine(loginCoroutine()));

            Debug.Log("LoginInit::regAndlog: finish register");
        }