-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeam.cs
67 lines (54 loc) · 1.42 KB
/
Team.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
using System.Collections.Generic;
using SFML.Graphics;
namespace Tiler
{
// TODO: Add a way to get a player count for a team
public static class TeamManager
{
private static int teamCount = 0;
private static List<Team> teams = new List<Team>();
public static int AddTeam(string name, Color color, List<string> spawnPointNames = null, bool joinable = true)
{
var team = new Team()
{
TeamID = ++teamCount,
Name = name,
Color = color,
SpawnPointNames = spawnPointNames,
Joinable = joinable
};
teams.Add(team);
return team.TeamID;
}
public static Team GetTeamByID(int teamID)
{
if (!teams.Exists(t => t.TeamID == teamID))
throw new KeyNotFoundException();
return teams.Find(t => t.TeamID == teamID);
}
}
public struct Team
{
public int TeamID { get; internal set; }
public string Name { get; internal set; }
public Color Color { get; internal set; }
public List<string> SpawnPointNames { get; internal set; }
public bool Joinable { get; internal set; }
public override bool Equals(object other)
{
return other is Team && ((Team)other).TeamID == TeamID;
}
public override int GetHashCode()
{
return 1866874249 + TeamID.GetHashCode();
}
public static bool operator ==(Team team1, Team team2)
{
return team1.TeamID == team2.TeamID;
}
public static bool operator !=(Team team1, Team team2)
{
return team1.TeamID != team2.TeamID;
}
}
}