Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Jypeli; |
---|
6 | |
---|
7 | namespace MagnetaNS |
---|
8 | { |
---|
9 | public class Seuraaja : Seurattava |
---|
10 | { |
---|
11 | public bool Seurataanko { get; set; } |
---|
12 | public Seurattava olioJotaSeurataan { get; set; } |
---|
13 | |
---|
14 | public Seuraaja(double leveys, double korkeus, int hele) |
---|
15 | : base(leveys, korkeus, hele) |
---|
16 | { |
---|
17 | Seurataanko = false; |
---|
18 | } |
---|
19 | |
---|
20 | protected override void MoveToTarget() |
---|
21 | { |
---|
22 | // tähän ehto että ollaanko "Riittävän lähellä" |
---|
23 | // jos ollaan, |
---|
24 | if (!this.moveTarget.HasValue) return; |
---|
25 | if (this.Velocity.Magnitude < 2.0 && (this.moveTarget.Value - this.AbsolutePosition).Magnitude < 50.0) |
---|
26 | { |
---|
27 | // ensin StopMoveTo |
---|
28 | base.StopMoveTo(); |
---|
29 | // tässä välissä voisi kutsua myös arrivedActionia |
---|
30 | // sen jälkeen return |
---|
31 | return; |
---|
32 | } |
---|
33 | base.MoveToTarget(); |
---|
34 | } |
---|
35 | |
---|
36 | public bool Seuraa() |
---|
37 | { |
---|
38 | if (Seurataanko) |
---|
39 | { |
---|
40 | if (!olioJotaSeurataan.IsDestroyed) |
---|
41 | { |
---|
42 | MoveTo(olioJotaSeurataan.AbsolutePosition, 100); |
---|
43 | return true; |
---|
44 | } |
---|
45 | Seurataanko = false; |
---|
46 | } |
---|
47 | return false; |
---|
48 | } |
---|
49 | |
---|
50 | public void Seuraa(Seurattava seurattava) |
---|
51 | { |
---|
52 | LisaaSeurattava(seurattava); |
---|
53 | Seurataanko = true; |
---|
54 | Seuraa(); |
---|
55 | } |
---|
56 | |
---|
57 | public void LisaaSeurattava(Seurattava seurattava) |
---|
58 | { |
---|
59 | this.olioJotaSeurataan = seurattava; |
---|
60 | } |
---|
61 | |
---|
62 | public void PoistaSeurattava() |
---|
63 | { |
---|
64 | this.olioJotaSeurataan = null; |
---|
65 | } |
---|
66 | |
---|
67 | public void lopetaSeuraaminen() |
---|
68 | { |
---|
69 | Seurataanko = false; |
---|
70 | } |
---|
71 | } |
---|
72 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.