Example #1
0
 private void Redraw()
 {
     MapView.InvalidateVisual();
     Showcase1View.InvalidateVisual();
     Showcase2View.InvalidateVisual();
     Showcase3View.InvalidateVisual();
     DraggingView.InvalidateVisual();
 }
Example #2
0
        private void DraggingView_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (Captured is null || Lost)
            {
                return;
            }

            var draggableLoc = GetHoveredLocation(GameMap, DpiScaler.ScaleDown(Captured.Point), false);

            if (draggableLoc is not null)
            {
                var safeDraggableLoc = draggableLoc.Value;
                if (Captured.Figure.TryPutOnMap(GameMap, safeDraggableLoc))
                {
                    Showcase.Update();
                    Engine.Engine.Score += Captured.Figure.GetTiles().Count();
                    if (Engine.Engine.Score > Properties.Settings.Default.BestScore)
                    {
                        Properties.Settings.Default.BestScore = Engine.Engine.Score;
                        Properties.Settings.Default.Save();
                    }
                    Title = "ะกั‡ั‘ั‚: " + Engine.Engine.Score + " / " + Properties.Settings.Default.BestScore;

                    if (DidLose())
                    {
                        Lost          = true;
                        Captured      = null;
                        MouseLocation = new();
                        MapView.InvalidateVisual();
                        DraggingView.InvalidateVisual();
                        Showcase1View.InvalidateVisual();
                        Showcase2View.InvalidateVisual();
                        Showcase3View.InvalidateVisual();
                        return;
                    }
                }
                else
                {
                    Showcase.Return(Captured.Figure);
                }
            }
            else
            {
                Showcase.Return(Captured.Figure);
            }

            Captured                = null;
            MouseLocation           = new();
            DraggingView.Visibility = Visibility.Hidden;
            MapView.InvalidateVisual();
            DraggingView.InvalidateVisual();
            Showcase1View.InvalidateVisual();
            Showcase2View.InvalidateVisual();
            Showcase3View.InvalidateVisual();
        }