|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 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 += (int)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>();
- }
- }
- }
|