-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
133 lines (120 loc) · 2.17 KB
/
Player.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
133
using System;
using System.Runtime.InteropServices;
/// <summary>
///
/// </summary>
public class Player
{
public IntPtr ptr;
protected int ID;
protected int iteration;
public Player()
{
}
public Player(IntPtr p)
{
ptr = p;
ID = Client.playerGetId(ptr);
iteration = BaseAI.iteration;
}
public bool validify()
{
if(iteration == BaseAI.iteration) return true;
for(int i = 0; i < BaseAI.players.Length; i++)
{
if(BaseAI.players[i].ID == ID)
{
ptr = BaseAI.players[i].ptr;
iteration = BaseAI.iteration;
return true;
}
}
throw new ExistentialError();
}
#region Commands
/// <summary>
/// Allows a player to display messages on the screen
/// </summary>
public bool talk(string message)
{
validify();
return (Client.playerTalk(ptr, message) == 0) ? false : true;
}
#endregion
#region Getters
/// <summary>
/// Unique Identifier
/// </summary>
public int Id
{
get
{
validify();
int value = Client.playerGetId(ptr);
return value;
}
}
/// <summary>
/// Player's Name
/// </summary>
public string PlayerName
{
get
{
validify();
IntPtr value = Client.playerGetPlayerName(ptr);
return Marshal.PtrToStringAuto(value);
}
}
/// <summary>
/// Time remaining, updated at start of turn
/// </summary>
public float Time
{
get
{
validify();
float value = Client.playerGetTime(ptr);
return value;
}
}
/// <summary>
/// The amount of water a player has.
/// </summary>
public int WaterStored
{
get
{
validify();
int value = Client.playerGetWaterStored(ptr);
return value;
}
}
/// <summary>
/// Resource used to spawn in units.
/// </summary>
public int Oxygen
{
get
{
validify();
int value = Client.playerGetOxygen(ptr);
return value;
}
}
/// <summary>
/// The player's oxygen cap.
/// </summary>
public int MaxOxygen
{
get
{
validify();
int value = Client.playerGetMaxOxygen(ptr);
return value;
}
}
#endregion
#region Properties
#endregion
}