Exemplo n.º 1
0
        private void OnLogin(object sender, string username, string ipAddress)
        {
            new Thread(async() =>
            {
                try
                {
                    Packets = await Connections.GetLoginDataPacketForUser();
                }
                catch (NotSupportedException)
                {
                    // Restarting BotClient;
                    Controller.Restart();
                }

                if (Packets.AllSummonerData == null)
                {
                    NewPlayerAccout();
                    OnLogin(sender, username, ipAddress);
                    return;
                }

                await Connections.Subscribe("bc", Packets.AllSummonerData.Summoner.AcctId);
                await Connections.Subscribe("cn", Packets.AllSummonerData.Summoner.AcctId);
                await Connections.Subscribe("gn", Packets.AllSummonerData.Summoner.AcctId);

                if (Packets.AllSummonerData.Summoner.ProfileIconId == -1)
                {
                    SetSummonerIcon();
                }

                SummonerLevel = Packets.AllSummonerData.SummonerLevel.Level;
                SummonerName  = Packets.AllSummonerData.Summoner.Name;
                SummonerId    = Packets.AllSummonerData.Summoner.SumId;
                HeroesArray   = await Connections.GetAvailableChampions();
                Debug.WriteLine(JsonConvert.SerializeObject(HeroesArray.Where(ho => ho.Owned || ho.FreeToPlay)));

                WebService.SetLevel(Account.Id, (int)SummonerLevel);
                WebService.SetMoney(Account.Id, (int)Packets.IpBalance);


                if (SummonerLevel > Account.Maxlevel || Convert.ToInt32(SummonerLevel) == Account.Maxlevel)
                {
                    Client.Status("Maximum level reached!", AccountName);
                    return;
                }

                Hero = await Connections.CreatePlayer();
                OnMessageReceived(sender, new ClientBeforeStart());
                Thread.Sleep(2000);
            }).Start();
        }