Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Jypeli; |
---|
6 | |
---|
7 | public class Pelaaja : PlatformCharacter |
---|
8 | { |
---|
9 | private bool potkaissut; |
---|
10 | public bool Potkaissut { get { return potkaissut; } set { potkaissut = value; } } |
---|
11 | |
---|
12 | private bool ilmassa; |
---|
13 | public bool Ilmassa { get { return ilmassa; } set { ilmassa = value; } } |
---|
14 | |
---|
15 | private double sprinttaa; |
---|
16 | public double Sprinttaa { get { return sprinttaa; } set { sprinttaa = value; } } |
---|
17 | |
---|
18 | private double nopeus; |
---|
19 | public double Nopeus { get { return nopeus; } set { nopeus = value; } } |
---|
20 | |
---|
21 | private double lahtoNopeus; |
---|
22 | public double LahtoNopeus { get { return lahtoNopeus; } set { lahtoNopeus = value; nopeus = value; } } |
---|
23 | |
---|
24 | private double maksimiNopeus; |
---|
25 | public double MaksimiNopeus { get { return maksimiNopeus; } set { maksimiNopeus = value; } } |
---|
26 | |
---|
27 | private IntMeter energia; |
---|
28 | public IntMeter Energia { get { return energia; } set { energia = value; } } |
---|
29 | |
---|
30 | public Pelaaja(double width, double height) |
---|
31 | : base(width, height) |
---|
32 | { |
---|
33 | potkaissut = false; |
---|
34 | ilmassa = false; |
---|
35 | energia = new IntMeter(100); |
---|
36 | energia.MaxValue = 100; |
---|
37 | energia.MinValue = 0; |
---|
38 | energia.LowerLimit += delegate { sprinttaa = 0; }; |
---|
39 | } |
---|
40 | |
---|
41 | public bool Potkaise(PhysicsObject kohde, Vector voima) |
---|
42 | { |
---|
43 | if (Vector.Distance(this.Position, kohde.Position) < 50 && !potkaissut) |
---|
44 | { |
---|
45 | kohde.Velocity = voima; |
---|
46 | potkaissut = true; |
---|
47 | Timer.SingleShot(0.5, delegate { potkaissut = false; }); |
---|
48 | return true; |
---|
49 | } |
---|
50 | return false; |
---|
51 | } |
---|
52 | |
---|
53 | public void Hyppaa(Vector voima) |
---|
54 | { |
---|
55 | if (!ilmassa) |
---|
56 | this.Hit(voima); |
---|
57 | ilmassa = true; |
---|
58 | } |
---|
59 | |
---|
60 | public void Laskeudu() |
---|
61 | { |
---|
62 | ilmassa = false; |
---|
63 | } |
---|
64 | |
---|
65 | public override void Update(Time time) |
---|
66 | { |
---|
67 | if (sprinttaa <= 0) |
---|
68 | { |
---|
69 | sprinttaa = 0; |
---|
70 | energia.Value += 1; |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | energia.Value -= 2; |
---|
75 | } |
---|
76 | base.Update(time); |
---|
77 | } |
---|
78 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.