|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System.Collections.Generic;
-
- namespace GameClass.GameObj
- {
- public class Team
- {
- private static long currentMaxTeamID = 0;
- public static long CurrentMaxTeamID => currentMaxTeamID;
- private readonly long teamID;
- public long TeamID => teamID;
- public const long invalidTeamID = long.MaxValue;
- public const long noneTeamID = long.MinValue;
- private readonly List<Character> playerList;
- public int Score
- {
- get {
- int score = 0;
- foreach (var player in playerList)
- score += player.Score;
- return score;
- }
- }
- public Character? GetPlayer(long ID)
- {
- foreach (Character player in playerList)
- {
- if (player.ID == ID)
- {
- return player;
- }
- }
- return null;
- }
- public void AddPlayer(Character player)
- {
- playerList.Add(player);
- }
- public void OutPlayer(long ID)
- {
- int i;
- for (i = 0; i < playerList.Count; ++i)
- {
- if (playerList[i].ID == ID)
- break;
- }
- playerList.RemoveAt(i);
- }
- public long[] GetPlayerIDs()
- {
- long[] playerIDs = new long[playerList.Count];
- int num = 0;
- foreach (Character player in playerList)
- {
- playerIDs[num++] = player.ID;
- }
- return playerIDs;
- }
- public static bool teamExists(long findTeamID)
- {
- return findTeamID < currentMaxTeamID;
- }
- public Team()
- {
- teamID = currentMaxTeamID++;
- playerList = new List<Character>();
- }
- }
- }
|