-
Notifications
You must be signed in to change notification settings - Fork 0
/
Armoury.cs
132 lines (111 loc) · 3.16 KB
/
Armoury.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Collections.Generic;
using Mogre;
namespace Game
{
class Armoury
{
/// <summary>
/// Constructor
/// This creates a new List for the class Gun called collectedGuns.
/// </summary>
public Armoury()
{
this.collectedGuns = new List<Gun>();
}
Gun gun;
protected bool gunChange;
/// <summary>
/// Boolean to change guns.
/// returns gunchange and sets value.
/// </summary>
public bool GunChange
{
get { return gunChange; }
set { gunChange = value; }
}
protected Gun activeGun;
/// <summary>
/// returns active gun and sets value
/// </summary>
public Gun ActiveGun
{
get { return activeGun; }
set { activeGun = value; }
}
protected List<Gun> collectedGuns;
/// <summary>
/// This returns the value of the list created in the constructor.
/// </summary>
public List<Gun> CollectedGuns
{
get { return collectedGuns; }
}
/// Need to add (new List<Gun>();) to the constructor.
///<summary>
/// Change gun method.
/// </summary>
public void ChangeGun(Gun gun)
{
activeGun = new Gun();
gunChange = true;
}
/// <summary>
/// Swaps the gun currently held for another gun picked up.
/// </summary>
/// <param name="i"></param>
public void SwapGun(int i)
{
if(collectedGuns != null)
{
ChangeGun(gun);
}
if(activeGun != null)
{
ChangeGun(gun);
}
}
/// <summary>
/// Add the gun to the collection and reloads the ammo to full.
/// </summary>
/// <param name="gun"></param>
/// <param name="add"></param>
public void AddGun(Gun gun, bool add = true)
{
foreach (Gun g in collectedGuns)
{
if (add == true && (g.GetType() == gun.GetType()))
{
g.ReloadAmmo();
ChangeGun(g);
add = false;
}
}
if(add == true)
{
ChangeGun(gun);
collectedGuns.Add(gun);
}
else
{
gun.Dispose();
}
///if both add == true && (g.GetType()==gun.GetType()) = true
///Call the change gun method passing g to it and then set add to false.
}
/// <summary>
/// Armoury dispose method. Gets rid of collectedGuns and activeGun.
/// </summary>
protected void Dispose()
{
if(collectedGuns != null)
{
///Dispose each gun in the collectedGuns list
}
if(activeGun != null)
{
///Dispose each gun in the acitveGun list.
}
}
}
}