private void OnPaint(UIElement element, SKCanvas canvas) { Background.Draw(HipsterEngine.Surface.Canvas); LayoutTop.Draw(); HipsterEngine.Surface.Canvas.Camera.Update(); HipsterEngine.Surface.Canvas.Save(); HipsterEngine.Surface.Canvas.Translate(HipsterEngine.Surface.Canvas.Camera.X, HipsterEngine.Surface.Canvas.Camera.Y); HipsterEngine.Surface.Canvas.RotateRadians(HipsterEngine.Surface.Canvas.Camera.Angle, HipsterEngine.Surface.Canvas.Camera.CenterRotation.X, HipsterEngine.Surface.Canvas.Camera.CenterRotation.Y); LayoutRecords.Draw(); PlanetStart.Draw(); Map.Draw(); HipsterEngine.Surface.Canvas.Restore(); HipsterEngine.Particles.Draw(HipsterEngine.Surface.Canvas.GetSkiaCanvas()); HipsterEngine.Surface.Canvas.DrawRect(0, 0, Width, Height, new SKPaint { Style = SKPaintStyle.Fill, Color = new SKColor(0, 0, 0, Convert.ToByte(AnimationEndGame.CurrentValue)) }); }
private void OnUpdate(double time, float dt) { LayoutTop.Update(); Map.Update(); PlanetStart.Step(); AnimationEndGame.Update(); Background.Step(); }
private void OnUnloaded(Screen screen) { Triangle.Dispose(); LayoutRecords.Dispose(); LayoutTop.Dispose(); PlanetStart.Dispose(); AnimationEndGame.Dispose(); Update -= OnUpdate; Paint -= OnPaint; MouseDown -= OnMouseDown; Unloaded -= OnUnloaded; }
public override void OnLoad() { Update += OnUpdate; Paint += OnPaint; MouseDown += OnMouseDown; Unloaded += OnUnloaded; LayoutRecords = new LayoutRecord(HipsterEngine); LayoutTop = new LayoutTop(HipsterEngine); PlanetStart = new PlanetStart(HipsterEngine, Width / 2, Height / 4, Height / 8); PlanetStart.AngularVelocity = 0.04f; HipsterEngine.Particles.AddParticleSystem(new ParticlesControllerFire(HipsterEngine)); var triangleRadius = PlanetStart.Radius / 4; var y = PlanetStart.Transform.Y - PlanetStart.Radius - triangleRadius + 2; Triangle = new Triangle(HipsterEngine, Width / 2, y, triangleRadius); Triangle.SetPlanet(PlanetStart); HipsterEngine.Particles.AddParticleSystem(new TriangleParticlesController(HipsterEngine, Triangle)); HipsterEngine.Surface.Canvas.Camera.X = -Width / 2; HipsterEngine.Surface.Canvas.Camera.Y = Height / 2; HipsterEngine.Surface.Canvas.Camera.SetTarget(PlanetStart.Transform.X - Width / 2, PlanetStart.Transform.Y + Height / 4); var profile = LoadProfile(); Map = new MapPlanets(HipsterEngine, Triangle); Map.Generate(profile.Level); Map.EndGame += TriangleOnEndGame; AnimationEndGame = new AnimationFloat(); AnimationEndGame.Timer.Complated += tick => { HipsterEngine.Screens.SetScreen(new MenuScreen()); }; LayoutRecords.TextRecord = profile.Balls.ToString(); PlanetStart.Text = profile.Level.ToString(); Background = new ParallaxBackground(HipsterEngine, Triangle); }