Exemplo n.º 1
0
 private void GameManagerViewModelOnCatchSuccess(object sender, EventArgs eventArgs)
 {
     CatchStarted.Stop();
     AudioUtils.StopSound(AudioUtils.ENCOUNTER_POKEMON);
     AudioUtils.PlaySound(AudioUtils.GOTCHA);
     ShowCatchStatsModalStoryboard.Begin();
 }
Exemplo n.º 2
0
 private void GameManagerViewModelOnCatchFlee(object sender, EventArgs eventArgs)
 {
     CatchEscape.Completed += (s, e) =>
     {
         ViewModel.PokeballButtonEnabled = false;
         CatchFlee.Begin();
     };
     CatchStarted.Stop();
     CatchEscape.Begin();
 }
Exemplo n.º 3
0
        private async void PokeballUpdateLoop(ThreadPoolTimer timer)
        {
            if (UpdateLoopMutex.WaitOne(0))
            {
                var curTime = DateTime.Now;

                // timeDelta is the seconds since last update
                var timeDelta = (curTime - prevTime).Milliseconds / 1000f;

                var gravity = new Vector3(0, 300f, 0);

                // Apply basic Kinematics
                ThrowItemPosition += ThrowItemVelocity * timeDelta + .5f * gravity * timeDelta * timeDelta;
                ThrowItemVelocity += gravity * timeDelta;

                /*
                 * Logger.Write("Position" + ThrowItemPosition.X + ", " + ThrowItemPosition.Y + ", " + ThrowItemPosition.Z);
                 * Logger.Write("Velocity" + ThrowItemVelocity.X + ", " + ThrowItemVelocity.Y + ", " + ThrowItemVelocity.Z);
                 */

                prevTime = curTime;

                // Shotty attempt at converting from world space to screen space without a matrix
                var translateX = ThrowItemPosition.X * Math.Max(1.0f - ThrowItemPosition.Z / 400.0f, 0.0f);
                var translateY = ThrowItemPosition.Y - ThrowItemPosition.Z;
                var scaleX     = Math.Max(1.0f - ThrowItemPosition.Z / 200.0f, 0.0f);
                var scaleY     = scaleX;

                var pokeballStopped = false;
                var pokemonHit      = false;

                if (Vector3.DistanceSquared(PokemonPosition, ThrowItemPosition) < PokemonRadiusSq)
                {
                    // We hit the pokemon!
                    pokeballStopped = true;
                    pokemonHit      = true;
                    timer.Cancel();
                    GameClient.CurrentSession.Logger.Info("Hit Pokemon! " + ThrowItemPosition.X + ", " + ThrowItemPosition.Y + ", " +
                                                          ThrowItemPosition.Z);
                }
                else if (ThrowItemPosition.Y > 50)
                {
                    // We missed the pokemon...
                    timer.Cancel();
                    pokeballStopped = true;
                    GameClient.CurrentSession.Logger.Info("Missed Pokemon! " + ThrowItemPosition.X + ", " + ThrowItemPosition.Y + ", " +
                                                          ThrowItemPosition.Z);
                }

                UpdateLoopMutex.ReleaseMutex();

                await PokeballTransform.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    PokeballTransform.TranslateX = translateX;
                    PokeballTransform.TranslateY = translateY;
                    PokeballTransform.ScaleX     = scaleX;
                    PokeballTransform.ScaleY     = scaleY;
                    if (pokeballStopped)
                    {
                        if (pokemonHit)
                        {
                            // TODO: il casino è qua, se parte l'animazione poi non funziona più il movimento

                            ViewModel.UseSelectedCaptureItem.Execute(true);
                            var last = ViewModel.LastItemUsed;
                            if (last != null)
                            {
                                if (last == ItemId.ItemRazzBerry ||
                                    last == ItemId.ItemBlukBerry ||
                                    last == ItemId.ItemNanabBerry ||
                                    last == ItemId.ItemPinapBerry ||
                                    last == ItemId.ItemWeparBerry)
                                {
                                    ReInitItemLocation();
                                    return;
                                }
                            }
                            CatchStarted.Begin();
                            ViewModel.PokeballButtonEnabled = false;
                        }
                        else
                        {
                            // TODO: move the missed command if you want
                            ViewModel.UseSelectedCaptureItem.Execute(false);
                            ReInitItemLocation();
                        }
                    }
                });
            }
        }
Exemplo n.º 4
0
 private void GameManagerViewModelOnCatchEscape(object sender, EventArgs eventArgs)
 {
     CatchStarted.Stop();
     CatchEscape.Begin();
 }
Exemplo n.º 5
0
 private void GameManagerViewModelOnCatchSuccess(object sender, EventArgs eventArgs)
 {
     CatchStarted.Stop();
     ShowCatchStatsModalStoryboard.Begin();
 }