source: 2014/27/AleksanteriV/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Protokolla236TrueSurvivor/Radar.cs @ 5396

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