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

Revision 5999, 1.3 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 double Damage { get; set; }
18
19    public double MaxRange { get; set; }
20
21    public Angle Spread { get; set; }
22
23    public Ase(double width, double height, int magazineSize, int maxAmmoInReserve, double reloadTime)
24        :base(width, height)
25    {
26        this.Ammo.MaxValue = magazineSize;
27        this.Ammo.Value = magazineSize;
28        this.ReserveAmmo = new IntMeter(maxAmmoInReserve, 0, maxAmmoInReserve);
29        this.ReloadTime = reloadTime;
30    }
31
32    /// <summary>
33    /// Ladataan ase. Siirtää ammuksia reservistä lippaaseen.
34    /// </summary>
35    public void Reload()
36    {
37        if (this.Ammo.Value == this.Ammo.MaxValue) return;
38
39        int used = this.Ammo.MaxValue - this.Ammo.Value;
40
41        if (this.ReserveAmmo.Value >= this.Ammo.MaxValue)
42            this.Ammo.Value = this.Ammo.MaxValue;
43        else this.Ammo.Value = this.ReserveAmmo.Value;
44
45        this.ReserveAmmo.Value -= used;
46    }
47}
Note: See TracBrowser for help on using the repository browser.