Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Jypeli; |
---|
6 | using Jypeli.Assets; |
---|
7 | |
---|
8 | public class Ase : AssaultRifle |
---|
9 | { |
---|
10 | /// <summary> |
---|
11 | /// Ammuksia mukana lippaan ulkopuolella. |
---|
12 | /// </summary> |
---|
13 | public IntMeter ReserveAmmo { get; private set; } |
---|
14 | |
---|
15 | public double ReloadTime { get; set; } |
---|
16 | |
---|
17 | public Ase(double width, double height, int magazineSize, int maxAmmoInReserve, double reloadTime) |
---|
18 | :base(width, height) |
---|
19 | { |
---|
20 | this.Ammo.MaxValue = magazineSize; |
---|
21 | this.Ammo.Value = magazineSize; |
---|
22 | this.ReserveAmmo = new IntMeter(maxAmmoInReserve, 0, maxAmmoInReserve); |
---|
23 | this.ReloadTime = reloadTime; |
---|
24 | } |
---|
25 | |
---|
26 | /// <summary> |
---|
27 | /// Ladataan ase. Siirtää ammuksia reservistä lippaaseen. |
---|
28 | /// </summary> |
---|
29 | public void Reload() |
---|
30 | { |
---|
31 | if (this.Ammo.Value == this.Ammo.MaxValue) return; |
---|
32 | |
---|
33 | int used = this.Ammo.MaxValue - this.Ammo.Value; |
---|
34 | |
---|
35 | if (this.ReserveAmmo.Value >= this.Ammo.MaxValue) |
---|
36 | this.Ammo.Value = this.Ammo.MaxValue; |
---|
37 | else this.Ammo.Value = this.ReserveAmmo.Value; |
---|
38 | |
---|
39 | this.ReserveAmmo.Value -= used; |
---|
40 | } |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.