source: 2012/23/SimoH/JalkapalloPeli2/JalkapalloPeli2/JalkapalloPeli2/Pelaaja.cs @ 2777

Revision 2777, 2.0 KB checked in by sijoseha, 11 years ago (diff)

Jalispeli kakkonen

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Jypeli;
6
7public 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 void Potkaise(PhysicsObject kohde, Vector voima)
42    {
43        if (Vector.Distance(this.Position, kohde.Position) < 50 && !potkaissut)
44            kohde.Velocity = voima;
45        potkaissut = true;
46        Timer.SingleShot(0.5, delegate { potkaissut = false; });
47    }
48
49    public void Hyppaa(Vector voima)
50    {
51        if (!ilmassa)
52            this.Hit(voima);
53        ilmassa = true;
54    }
55
56    public void Laskeudu()
57    {
58        ilmassa = false;
59    }
60
61    public override void Update(Time time)
62    {
63        if (sprinttaa <= 0)
64        {
65            sprinttaa = 0;
66            energia.Value += 1;
67        }
68        else
69        {
70            energia.Value -= 2;
71        }
72        base.Update(time);
73    }
74}
Note: See TracBrowser for help on using the repository browser.