Esempio n. 1
0
        private void LeaveTeam()
        {
            for (int i = team.Count - 1; i >= 0; i--)
            {
                TeamOrbitBehaviour otherMember = team[i];
                otherMember.RemoveFromTeam(this);
            }

            UpdateOrbitIDsOfTeam();
        }
Esempio n. 2
0
 private void UpdateOrbitIDsOfTeam()
 {
     for (int i = 0; i < team.Count; i++)
     {
         TeamOrbitBehaviour member = team[i];
         if (!HasUniqueAndValidID(member))
         {
             member.orbitID = GetUniqueID(member);
         }
     }
 }
Esempio n. 3
0
 private bool CheckMemberInList(TeamOrbitBehaviour member)
 {
     for (int i = 0; i < team.Count; i++)
     {
         if (team[i] == member)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 4
0
 public void AddToTeam(TeamOrbitBehaviour member)
 {
     if (CheckMemberInList(member))
     {
         return;
     }
     team.Add(member);
     if (!HasUniqueAndValidID(member))
     {
         member.orbitID = GetUniqueID(member);
     }
 }
Esempio n. 5
0
 private void ShareTeamList()
 {
     for (int i = 0; i < team.Count; i++)
     {
         TeamOrbitBehaviour otherMember = team[i];
         for (int j = 0; j < otherMember.team.Count; j++)
         {
             for (int k = 0; k < team.Count; k++)
             {
                 otherMember.team[j].AddToTeam(team[k]);
                 AddToTeam(otherMember.team[j]);
             }
         }
     }
 }
Esempio n. 6
0
        private bool HasUniqueAndValidID(TeamOrbitBehaviour member)
        {
            int id = member.orbitID;

            if (id >= team.Count || id < 0)
            {
                return(false);
            }
            for (int i = 0; i < team.Count; i++)
            {
                if (team[i] != member && team[i].orbitID == id)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 7
0
 private int GetUniqueID(TeamOrbitBehaviour member)
 {
     for (int i = 0; i < team.Count; i++)
     {
         bool IDTaken = false;
         for (int j = 0; j < team.Count; j++)
         {
             if (team[j] != member && team[j].orbitID == i)
             {
                 IDTaken = true;
                 break;
             }
         }
         if (!IDTaken)
         {
             return(i);
         }
     }
     Debug.Log("No unique ID found");
     return(-1);
 }
Esempio n. 8
0
 private void RemoveFromTeam(TeamOrbitBehaviour member) => team.Remove(member);
Esempio n. 9
0
 private void JoinTeam(TeamOrbitBehaviour member)
 {
     AddToTeam(member);
     ShareTeamList();
     UpdateOrbitIDsOfTeam();
 }