Beispiel #1
0
 /// <summary>
 /// Registers and returns a new ID for an object of the given type.
 /// </summary>
 /// <returns>A new unique ID that can be used to identify the object.</returns>
 public int RegisterBotID()
 {
     if (Bots.Any() && _botID <= Bots.Max(e => e.ID))
     {
         _botID = Bots.Max(e => e.ID) + 1;
     }
     return(_botID++);
 }
Beispiel #2
0
 public int GetFreeTeamID(string exceptUser)
 {
     return
         (Enumerable.Range(0, TasClient.MaxTeams - 1).FirstOrDefault(
              teamID =>
              !Users.Where(u => !u.IsSpectator).Any(user => user.Name != exceptUser && user.TeamNumber == teamID) &&
              !Bots.Any(x => x.TeamNumber == teamID)));
 }
Beispiel #3
0
        public bool IsPositionBlocked(Position position)
        {
            var positionHasBot = Bots.Any(b => b.Position.Equals(position));
            var positionHasBlockingGameObject =
                this.GameObjects.Any(gi => gi.IsBlocking && gi.Position.Equals(position));

            return(positionHasBot ||
                   positionHasBlockingGameObject);
        }
Beispiel #4
0
        private bool IsPositionEmpty(Position position)
        {
            var positionHasBot        = Bots.Any(b => b.Position.Equals(position));
            var positionHasBase       = Bots.Any(b => b.Base.Equals(position));
            var positionHasDiamond    = Diamonds.Contains(position);
            var positionHasGameObject = GameObjects.Any(gi => gi.Position.Equals(position));

            return(positionHasBot == false &&
                   positionHasBase == false &&
                   positionHasDiamond == false &&
                   positionHasGameObject == false);
        }
Beispiel #5
0
        private Task WaitForNextTurnAsync()
        {
            var speedUp = Bots.Any() ? new TimeSpan(Settings.NextTurnDelay.Ticks / Bots.Count(b => b.HP > 0)) : new TimeSpan();

            return(Task.Delay(Settings.NextTurnDelay - speedUp));
        }