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

Revision 5395, 2.0 KB checked in by mijoilmo, 5 years ago (diff)

Optimoitu levelin kopioimista. Lisätty basic !space leveli

Line 
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{
11    private GameObject mapObject;
12    private GameObject shipObject;
13    Proto236b parent;
14    public Radar(Proto236b parent)
15        : base(200 / parent.Camera.ZoomFactor, 200 / 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(133 / parent.Camera.ZoomFactor, 133 / parent.Camera.ZoomFactor);
25            mapObject.Shape = Shape.Circle;
26            Add(mapObject);
27            this.shipObject = new GameObject(15 / parent.Camera.ZoomFactor, 15 / parent.Camera.ZoomFactor);
28            shipObject.Animation = new Animation(parent.ImageLists["HUD_ship"]);
29            this.Animation.FPS = 3;
30            this.Animation.Start();
31            Add(shipObject);
32        }
33        else
34        {
35            //space radar
36            this.mapObject = new GameObject(180 / parent.Camera.ZoomFactor, 180 / parent.Camera.ZoomFactor);
37            Add(mapObject);
38        }
39    }
40    public override void Update(Time time)
41    {
42        if (this.parent.CurrentLevel.IsPlanet)
43        {
44            this.shipObject.X = 0;
45            this.shipObject.Y = 0;
46            //jos haluaa joku selityksen näille kahdelle niin selitän mielelläni T:Mikko
47            double length = ((parent.Player.Y - (parent.Level.Top - 150 * 40)) / parent.Level.Width) * 40 + 67;
48            Angle shipAngle = Angle.FromRadians((Math.PI * 2) * ((parent.Player.X + parent.Level.Width / 2) / parent.Level.Width));
49            this.shipObject.Position += Vector.FromLengthAndAngle(length, shipAngle);
50        }
51        base.Update(time);
52    }
53}
Note: See TracBrowser for help on using the repository browser.