public TurretSpinningEvent(VTankBot _game, int id, double angle, VTankObject.Direction direction)
     : base(_game)
 {
     this.id = id;
     this.angle = angle;
     this.direction = direction;
 }
Exemplo n.º 2
0
 public SpawnUtilityEvent(VTankBot bot, int utilityId, VTankObject.Utility utility, VTankObject.Point pos)
     : base(bot)
 {
     ID = utilityId;
     this.utility = utility;
     position = pos;
 }
Exemplo n.º 3
0
 /// <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);
     }
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 6
0
 public AddUtilityEvent(VTankBot _game, 
     int _utilityID, VTankObject.Utility _utility, VTankObject.Point _position)
     : base(_game)
 {
     utilityID = _utilityID;
     utility = _utility;
     position = _position;
 }
Exemplo n.º 7
0
 public PlayerMoveEvent(VTankBot _game, int id, VTankObject.Point point,
     VTankObject.Direction direction)
     : base(_game)
 {
     this.id = id;
     this.direction = direction;
     this.point = point;
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 16
0
        /// <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);
            }
        }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
        /// <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;
 }
Exemplo n.º 20
0
 public MapRotationEvent(VTankBot bot)
     : base(bot)
 {
 }
Exemplo n.º 21
0
 /// <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();
 }
Exemplo n.º 22
0
 public BotPackage(VTankBot bot, GameServerInfo info, Thread thread)
 {
     Bot = bot;
     Server = info;
     Thread = thread;
     state = BotRunnerState.Offline;
     IsShuttingDown = false;
 }
Exemplo n.º 23
0
 public ResetPositionEvent(VTankBot _game, VTankObject.Point position)
     : base(_game)
 {
     this.position = position;
 }
Exemplo n.º 24
0
 public FlagDespawnedEvent(VTankBot _game, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.flagColor = flagColor;
 }
 public DestroyProjectileEvent(VTankBot _game, int projectileId)
     : base(_game)
 {
     this.projectileId = projectileId;
 }
Exemplo n.º 26
0
 public FlagPickedUpEvent(VTankBot _game, int pickedUpById, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.pickedUpById = pickedUpById;
     this.flagColor = flagColor;
 }
Exemplo n.º 27
0
 public ResetBasesEvent(VTankBot _game, GameSession.Alliance winner)
     : base(_game)
 {
     this.winner = winner;
 }
Exemplo n.º 28
0
 public PlayerLeftEvent(VTankBot _game, int id)
     : base(_game)
 {
     this.id = id;
 }
Exemplo n.º 29
0
 /// <summary>
 /// Enqueue a bot onto the queue.
 /// </summary>
 /// <param name="bot"></param>
 public void Enqueue(VTankBot bot)
 {
     lock (this)
     {
         botQueue.Enqueue(bot);
     }
 }
Exemplo n.º 30
0
 public FlagReturnedEvent(VTankBot _game, int returnedById, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.returnedById = returnedById;
     this.flagColor = flagColor;
 }