source: 2015/24/LeeviK/AS Bandit Experience/AS Bandit Experience/AS Bandit Experience/Ase.cs @ 5982

Revision 5982, 1.2 KB checked in by lesejuku, 6 years ago (diff)
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Jypeli;
6using Jypeli.Assets;
7
8public 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.