public TurretSpinningEvent(VTankBot _game, int id, double angle, VTankObject.Direction direction) : base(_game) { this.id = id; this.angle = angle; this.direction = direction; }
public SpawnUtilityEvent(VTankBot bot, int utilityId, VTankObject.Utility utility, VTankObject.Point pos) : base(bot) { ID = utilityId; this.utility = utility; position = pos; }
/// <summary> /// Check of the bot queue contains a given bot. /// </summary> /// <param name="bot"></param> /// <returns></returns> public bool Contains(VTankBot bot) { lock (this) { return botQueue.Contains(bot); } }
public PlayerRotateEvent(VTankBot _game, int id, double angle, VTankObject.Direction direction) : base(_game) { this.id = id; this.angle = angle; this.direction = direction; }
public SetBaseHealthEvent(GameSession.Alliance color, int eventId, int health, VTankBot _game) : base(_game) { this.baseColor = color; this.baseEventId = eventId; this.newBaseHealth = health; }
public AddUtilityEvent(VTankBot _game, int _utilityID, VTankObject.Utility _utility, VTankObject.Point _position) : base(_game) { utilityID = _utilityID; utility = _utility; position = _position; }
public PlayerMoveEvent(VTankBot _game, int id, VTankObject.Point point, VTankObject.Direction direction) : base(_game) { this.id = id; this.direction = direction; this.point = point; }
public ApplyUtilityEvent(VTankBot _game, int _utilityID, VTankObject.Utility _utility, int _playerID) : base(_game) { utilityID = _utilityID; utility = _utility; playerID = _playerID; }
public PlayerDamagedByEnvironmentEvent(VTankBot _game, int playerId, int environId, int damageTaken, bool killingBlow) : base(_game) { this.playerId = playerId; this.environId = environId; this.damageTaken = damageTaken; this.killingBlow = killingBlow; }
public BaseCapturedEvent(int eventId, GameSession.Alliance newBaseColor, int capturerId, GameSession.Alliance oldBaseColor, VTankBot _game) : base(_game) { this.baseEventId = eventId; this.newBaseColor = newBaseColor; this.capturerId = capturerId; this.oldBaseColor = oldBaseColor; }
public SpawnEnvironmentEffectEvent(VTankBot _game, int id, int typeId, VTankObject.Point location, int ownerId) : base(_game) { this.id = id; this.typeId = typeId; this.location = location; this.ownerId = ownerId; envEffect = WeaponLoader.GetEnvironmentProperty(typeId); }
public PlayerDamagedEvent(VTankBot _game, int victimId, int projectileId, int ownerId, int damageTaken, bool killingBlow) : base(_game) { this.victimId = victimId; this.projectileId = projectileId; this.ownerId = ownerId; this.damageTaken = damageTaken; this.killingBlow = killingBlow; }
public DamageBaseEvent(int eventId, int damageAmount, int playerId, int projectileId, bool isDestroyed, VTankBot _game) : base(_game) { this.baseEventId = eventId; this.damageAmount = damageAmount; this.playerId = playerId; this.projectileId = projectileId; this.isDestroyed = isDestroyed; }
public DamageBaseByEnvironmentEvent(VTankBot _game, GameSession.Alliance baseColor, int baseId, int envId, int damage, bool isDestroyed) : base(_game) { this.baseColor = baseColor; this.baseId = baseId; this.environmentEffectId = envId; this.damage = damage; this.isDestroyed = isDestroyed; }
public CreateProjectileEvent(VTankBot _game, int projectileTypeId, VTankObject.Point point, int ownerId, int projectileId) : base(_game) { this.type = WeaponLoader.GetProjectile(projectileTypeId); this.point = point; this.ownerId = ownerId; this.projectileId = projectileId; }
/// <summary> /// Do the main game loop. /// </summary> /// <param name="bot"></param> private void DoLoop(BotPackage package, VTankBot bot) { bool crash = false; const int WAIT_TIME = 14; // ms try { while (true) { Thread.Sleep(WAIT_TIME); bot.InvokeUpdate(); } } catch (System.Threading.ThreadInterruptedException) { Console.WriteLine("Bot {0} was interrupted.", bot.AuthInfo.Username); } catch (ThreadAbortException) { Console.WriteLine("Bot {0} was aborted.", bot.AuthInfo.Username); } catch (Exception ex) { Console.Error.WriteLine(ex); crash = true; } if (crash && OnCrash != null) { package.State = BotRunnerState.Offline; OnCrash(bot); } else { SetState(package, BotRunnerState.Offline); } }
/// <summary> /// Connect to the given game server. /// </summary> /// <param name="bot"></param> /// <param name="server"></param> private static void ConnectToServer(VTankBot bot, GameServerInfo server) { bot.ConnectToGameServer(server); }
/// <summary> /// Kill the given bot and the thread running the bot. /// </summary> /// <param name="bot">Bot to kill.</param> public void Kill(VTankBot bot) { if (bot == null) return; lock (botLock) { for (int i = 0; i < threads.Count; ++i) { BotPackage package = threads[i]; if (package.Bot == bot) { try { if (!package.IsShuttingDown) { package.Thread.Abort(); } package.Bot.Dispose(); } catch (Exception e) { Console.Error.WriteLine(e); } threads.RemoveAt(i); break; } } } CullOfflineBots(); }
public CreateProjectilesEvent(VTankBot _game, GameSession.ProjectileDamageInfo[] projectiles) : base(_game) { this.projectiles = projectiles; }
public MapRotationEvent(VTankBot bot) : base(bot) { }
/// <summary> /// /// </summary> /// <param name="parentBot"></param> public GameTracker(VTankBot parentBot) { players = new Dictionary<int, MetaPlayer>(); projectiles = new Dictionary<int, MetaProjectile>(); bot = parentBot; PathfindingAlgorithm = new PathAlgorithms.AStarAlgorithm(); }
public BotPackage(VTankBot bot, GameServerInfo info, Thread thread) { Bot = bot; Server = info; Thread = thread; state = BotRunnerState.Offline; IsShuttingDown = false; }
public ResetPositionEvent(VTankBot _game, VTankObject.Point position) : base(_game) { this.position = position; }
public FlagDespawnedEvent(VTankBot _game, GameSession.Alliance flagColor) : base(_game) { this.flagColor = flagColor; }
public DestroyProjectileEvent(VTankBot _game, int projectileId) : base(_game) { this.projectileId = projectileId; }
public FlagPickedUpEvent(VTankBot _game, int pickedUpById, GameSession.Alliance flagColor) : base(_game) { this.pickedUpById = pickedUpById; this.flagColor = flagColor; }
public ResetBasesEvent(VTankBot _game, GameSession.Alliance winner) : base(_game) { this.winner = winner; }
public PlayerLeftEvent(VTankBot _game, int id) : base(_game) { this.id = id; }
/// <summary> /// Enqueue a bot onto the queue. /// </summary> /// <param name="bot"></param> public void Enqueue(VTankBot bot) { lock (this) { botQueue.Enqueue(bot); } }
public FlagReturnedEvent(VTankBot _game, int returnedById, GameSession.Alliance flagColor) : base(_game) { this.returnedById = returnedById; this.flagColor = flagColor; }