Beispiel #1
0
        private double GetPokemonLevel(float levelAngle)
        {
            int    playerLevel = GoOnTapApplication.Config.PlayerLevel;
            double maxLevel    = Math.Min(playerLevel + 2, 40);
            Dictionary <double, double> levels = new Dictionary <double, double>();

            for (double level = 1; level <= maxLevel; level += 0.5)
            {
                double angle = PokemonInfo.GetLevelAngle(level, playerLevel) * 10;
                levels.Add(level, Math.Abs(levelAngle - angle));
            }

            return(levels.OrderBy(p => p.Value).First().Key);
        }
Beispiel #2
0
        private void RefreshStats(bool now = false)
        {
            if (data == null || pokemon == null)
            {
                return;
            }

            Task.Run(() =>
            {
                int playerLevel = GoOnTapApplication.Config.PlayerLevel;

                int cpMin = pokemon.GetMinimumCP(pokemonLevel);
                int cpMax = pokemon.GetMaximumCP(pokemonLevel);

                int hpMin = pokemon.GetMinimumHP(pokemonLevel);
                int hpMax = pokemon.GetMaximumHP(pokemonLevel);

                // Update UI
                assistantLayout.Post(() =>
                {
                    // Text views
                    levelValue.Text = pokemonLevel.ToString();
                    cpValue.Text    = data.CP.ToString();
                    hpValue.Text    = data.HP.ToString();

                    // Seek bars
                    levelSeek.Enabled       = false;
                    cpSeek.Enabled          = false;
                    hpSeek.Enabled          = false;
                    playerLevelSeek.Enabled = false;

                    levelSeek.Max            = Math.Min(playerLevel * 2 + 2, 78);
                    levelSeek.Progress       = (int)(pokemonLevel * 2) - 2;
                    cpSeek.Max               = cpMax - cpMin;
                    cpSeek.Progress          = data.CP - cpMin;
                    hpSeek.Max               = hpMax - hpMin;
                    hpSeek.Progress          = data.HP - hpMin;
                    playerLevelSeek.Progress = playerLevel - 1;

                    levelSeek.Enabled       = true;
                    cpSeek.Enabled          = true;
                    hpSeek.Enabled          = true;
                    playerLevelSeek.Enabled = true;

                    // Arc feedback
                    float density    = Context.Resources.DisplayMetrics.Density;
                    float levelAngle = (float)PokemonInfo.GetLevelAngle(pokemonLevel, playerLevel);
                    float feedbackX  = data.ArcX - (float)Math.Cos(levelAngle * Math.PI / 180) * data.ArcSize;
                    float feedbackY  = data.ArcY - (float)Math.Sin(levelAngle * Math.PI / 180) * data.ArcSize;

                    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams((int)(20 * density), (int)(20 * density));
                    layoutParams.LeftMargin = (int)(feedbackX - 10 * density);
                    layoutParams.TopMargin  = (int)(feedbackY - 10 * density);

                    arcFeedback.LayoutParameters = layoutParams;
                    arcFeedback.Visibility       = ViewStates.Visible;

                    string pokemonName = pokemon.GetLocalizedName(Locale.Default.ToString());

                    // Pokemon image
                    if (name.Text != pokemonName)
                    {
                        name.Text = pokemonName;

                        lastBitmap?.Recycle();
                        lastBitmap = GetPokemonIcon(pokemon.Id);
                        image.SetImageBitmap(lastBitmap);
                    }
                });

                RefreshIVs(now);
            });
        }