Example #1
0
 void CancelConnection()
 {
     popup.Hide();
     sfs.KillConnection();
 }
Example #2
0
        void OnResponse(BaseEvent eventParam)
        {
            if (false)
            {
                Console.WriteLine("OnResponse : " + eventParam.Type);
                foreach (var kvp in eventParam.Params)
                {
                    Console.WriteLine("\t" + kvp.Key + " : " + kvp.Value);
                }
            }
            var varst = (SFSObject)eventParam.Params["params"];

            //Console.WriteLine(varst.GetDump());

            Task.Run(() =>
            {
                var vars  = (SFSObject)eventParam.Params["params"];
                var array = eventParam.Params["cmd"].ToString().Split('.');
                var text  = array[0];
                if (text == "Chat")
                {
                    Console.WriteLine(text);
                }
                else if (text == "TemtemWelfare")
                {
                    Console.WriteLine(text);
                }
                else if (text == "PA")
                {
                    Console.WriteLine(text);
                }
                else if (text == "GameStart")
                {
                    if (vars.ContainsKey("inbattle"))
                    {
                        InBattle = vars.GetBool("inbattle");
                    }
                    GameStarted = true;
                    X           = vars.GetFloat("x");
                    Y           = vars.GetFloat("z");
                    //Thread.Sleep(700);
                    SFClient.Send(new LogoutRequest());
                    //Task.Run(() => { SFClient.Send(new LogoutRequest()); });
                }
                else if (text == "Monsters")
                {
                    Console.WriteLine(text);
                }
                else if (text == "PickAndBan")
                {
                    Console.WriteLine(text);
                }
                else if (text == "Notifications")
                {
                    Console.WriteLine(text);
                }
                else if (text == "UCP")
                {
                    Console.WriteLine(text);
                }
                else if (text == "Coop")
                {
                    Console.WriteLine(text);
                }
                else if (text == "Friends")
                {
                    Console.WriteLine(text);
                }
                else if (text == "Gameplay")
                {
                    //Console.WriteLine(text);
                }
                else if (text == "Battle")
                {
                    if (array.Length > 1)
                    {
                        if (array[1] == "CurrentState")
                        {
                            var enemies = vars.GetSFSArray("aiMon");
                            var count   = 0;

                            foreach (temtem.networkserialized.NetworkMonster monster in enemies)
                            {
                                if (monster == null)
                                {
                                    continue;
                                }
                                count++;
                            }

                            if (!fleed)
                            {
                                battleTicks.Add(Environment.TickCount);
                                battleTimes.Add(battleTicks.Last() - battleTicks[battleTicks.Count - 2]);
                                Console.WriteLine(DateTime.Now + " : new battle, last battle time " + (battleTimes.Last() / 1000.0f) + ", average time " + battleTimes.Average() / 1000.0f);
                                fleed = true;
                                while (fleeBug)
                                {
                                }
                                fleeBug    = true;
                                fleeThread = new Thread(() =>
                                {
                                    while (fleeBug)
                                    {
                                        if (!SFClient.IsConnected)
                                        {
                                            SFClient.KillConnection();
                                            Console.WriteLine("reseting");
                                            Thread.Sleep(2000);
                                            return;
                                        }
                                        var actype4 = new SFSObject();
                                        actype4.PutByte("actype", 4);
                                        SFClient.Send(new ExtensionRequest("battle", actype4));
                                        SFClient.Send(new ExtensionRequest("battle", actype4));

                                        var aioArray = new SFSArray();
                                        for (Byte i = 0; i < count; i++)
                                        {
                                            var aioObj = new SFSObject();
                                            aioObj.PutByte("slot", (Byte)(64 + i));
                                            aioObj.PutByte("techI", i);
                                            aioObj.PutByte("actype", 0);
                                            aioArray.AddSFSObject(aioObj);
                                        }
                                        var aio = new SFSObject();
                                        aio.PutSFSArray("aiO", aioArray);
                                        Thread.Sleep(2500);
                                        if (fleeBug)
                                        {
                                            SFClient.Send(new ExtensionRequest("battle", aio));
                                        }
                                        Thread.Sleep(1000);
                                    }
                                });
                                fleeThread.Start();
                            }
                            foreach (temtem.networkserialized.NetworkMonster monster in enemies)
                            {
                                if (monster == null)
                                {
                                    continue;
                                }
                                var monsterCache = Temtems.AllTemtems[monster.monsterNumber];
                                Console.WriteLine("    " + monsterCache.name + " (lvl" + monster.level + ") : " + (monster.luma ? "Shiny" : "Normal") + " : " + (monster.gender ? "Female" : "Male"));
                            }
                        }
                        if (array[1] == "BattleFinished")
                        {
                            fleeBug  = false;
                            InBattle = false;
                            fleed    = false;
                            //Thread.Sleep(2000);
                            SFClient.Send(new LogoutRequest());
                        }
                        if (array[1] == "BattleTurnResult")
                        {
                            if (vars.ContainsKey("result"))
                            {
                                var result = vars.GetSFSArray("result");
                                foreach (SFSObject r in result)
                                {
                                    if (r.GetBool("runres"))
                                    {
                                        //Console.WriteLine("run success");
                                    }
                                    //Console.WriteLine("run fail");
                                }
                            }
                            else
                            {
                                Console.WriteLine("no result");
                            }
                        }
                    }
                }
                else if (text == "Inventory")
                {
                    Console.WriteLine(text);
                }
                else if (text == "PromoCode")
                {
                    Console.WriteLine(text);
                }
                else if (text == "UPP")
                {
                    //Console.WriteLine(text);
                }
                else if (text == "Movement")
                {
                    Console.WriteLine(text);
                }
                else if (text == "Breeding")
                {
                    Console.WriteLine(text);
                }
                else if (text == "World")
                {
                    if (!trigger)
                    {
                        trigger = true;

                        /*Task.Run(() =>
                         * {
                         *      System.Threading.Thread.Sleep(1000);
                         *      Login();
                         * });
                         * Task.Run(() =>
                         * {
                         *      System.Threading.Thread.Sleep(2000);
                         *      SFClient.Send(new ExtensionRequest("joinRoom", new SFSObject()));
                         * });*/
                    }
                    Console.WriteLine(text);
                }
                else if (text == "SetNickname")
                {
                    Console.WriteLine(text);
                }
                else if (text == "Trade")
                {
                    Console.WriteLine(text);
                }
                else if (text == "PCControl")
                {
                    Console.WriteLine(text);
                }
                else
                {
                    Console.WriteLine("unk : " + text);
                }
            });
        }