forked from MinaPecheux/UnityTutorials-RTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameResource.cs
More file actions
33 lines (28 loc) · 720 Bytes
/
Copy pathGameResource.cs
File metadata and controls
33 lines (28 loc) · 720 Bytes
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
public class GameResource
{
private string _name;
private int _currentAmount;
public GameResource(string name, int initialAmount)
{
_name = name;
_currentAmount = initialAmount;
}
public void AddAmount(int value)
{
_currentAmount += value;
if (_currentAmount < 0) _currentAmount = 0;
}
public string Name { get => _name; }
public int Amount { get => _currentAmount; set { _currentAmount = value; } }
}
[System.Serializable]
public class ResourceValue
{
public InGameResource code;
public int amount = 0;
public ResourceValue(InGameResource code, int amount)
{
this.code = code;
this.amount = amount;
}
}