1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Controls; |
---|
6 | using Jypeli.Effects; |
---|
7 | using Jypeli.Widgets; |
---|
8 | |
---|
9 | class Radar : GameObject |
---|
10 | { |
---|
11 | private GameObject mapObject; |
---|
12 | private GameObject shipObject; |
---|
13 | Proto236b parent; |
---|
14 | public Radar(Proto236b parent) |
---|
15 | : base(300 / parent.Camera.ZoomFactor, 300 / parent.Camera.ZoomFactor) |
---|
16 | { |
---|
17 | this.parent = parent; |
---|
18 | this.Animation = new Animation(parent.ImageLists["HUD_radar"]); |
---|
19 | this.Animation.FPS = 30; |
---|
20 | this.Animation.Start(); |
---|
21 | if (parent.CurrentLevel.IsPlanet) |
---|
22 | { |
---|
23 | //planet radar |
---|
24 | this.mapObject = new GameObject(200 / parent.Camera.ZoomFactor, 200 / parent.Camera.ZoomFactor); |
---|
25 | mapObject.Shape = Shape.Circle; |
---|
26 | mapObject.Animation = new Animation(parent.ImageLists["planet_map"]); |
---|
27 | mapObject.Animation.FPS = 30; |
---|
28 | mapObject.Animation.Start(); |
---|
29 | Add(mapObject); |
---|
30 | } |
---|
31 | else |
---|
32 | { |
---|
33 | //space radar |
---|
34 | this.mapObject = new GameObject(250 / parent.Camera.ZoomFactor, 250 / parent.Camera.ZoomFactor); |
---|
35 | mapObject.Image = parent.Images["galaxy_map"]; |
---|
36 | Add(mapObject); |
---|
37 | } |
---|
38 | this.shipObject = new GameObject(25 / parent.Camera.ZoomFactor, 25 / parent.Camera.ZoomFactor); |
---|
39 | shipObject.Image = parent.Images["HUD_ship"]; |
---|
40 | Add(shipObject); |
---|
41 | } |
---|
42 | public override void Update(Time time) |
---|
43 | { |
---|
44 | if (this.parent.CurrentLevel.IsPlanet) |
---|
45 | { |
---|
46 | //laske pelaajan positio planeettamapissa |
---|
47 | //jos haluaa joku selityksen näille kahdelle niin selitän mielelläni T:Mikko |
---|
48 | double length = ((parent.Player.Y - (parent.Level.Top - 150 * 40)) / parent.Level.Width) * 60 / parent.Camera.ZoomFactor + 90 / parent.Camera.ZoomFactor; |
---|
49 | Angle shipAngle = Angle.FromRadians((Math.PI * 2) * ((parent.Player.X + parent.Level.Width / 2) / parent.Level.Width)); |
---|
50 | this.shipObject.Position = Vector.FromLengthAndAngle(length, shipAngle); |
---|
51 | } |
---|
52 | else |
---|
53 | { |
---|
54 | //laske pelaajan positio avaruusmapissa |
---|
55 | this.shipObject.Position = new Vector( |
---|
56 | parent.Player.X / parent.Level.Width * mapObject.Width, |
---|
57 | parent.Player.Y / parent.Level.Height * mapObject.Height |
---|
58 | ); |
---|
59 | } |
---|
60 | base.Update(time); |
---|
61 | } |
---|
62 | } |
---|