public TurretSpinningEvent(VTankBot _game, int id, double angle, VTankObject.Direction direction)
     : base(_game)
 {
     this.id = id;
     this.angle = angle;
     this.direction = direction;
 }
Пример #2
0
 public SpawnUtilityEvent(VTankBot bot, int utilityId, VTankObject.Utility utility, VTankObject.Point pos)
     : base(bot)
 {
     ID = utilityId;
     this.utility = utility;
     position = pos;
 }
Пример #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);
     }
 }
Пример #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;
 }
Пример #6
0
 public AddUtilityEvent(VTankBot _game, 
     int _utilityID, VTankObject.Utility _utility, VTankObject.Point _position)
     : base(_game)
 {
     utilityID = _utilityID;
     utility = _utility;
     position = _position;
 }
Пример #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;
 }
Пример #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;
 }
Пример #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);
 }
Пример #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;
 }
Пример #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;
 }
Пример #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);
            }
        }
Пример #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);
 }
Пример #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;
 }
Пример #20
0
 public MapRotationEvent(VTankBot bot)
     : base(bot)
 {
 }
Пример #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();
 }
Пример #22
0
 public BotPackage(VTankBot bot, GameServerInfo info, Thread thread)
 {
     Bot = bot;
     Server = info;
     Thread = thread;
     state = BotRunnerState.Offline;
     IsShuttingDown = false;
 }
Пример #23
0
 public ResetPositionEvent(VTankBot _game, VTankObject.Point position)
     : base(_game)
 {
     this.position = position;
 }
Пример #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;
 }
Пример #26
0
 public FlagPickedUpEvent(VTankBot _game, int pickedUpById, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.pickedUpById = pickedUpById;
     this.flagColor = flagColor;
 }
Пример #27
0
 public ResetBasesEvent(VTankBot _game, GameSession.Alliance winner)
     : base(_game)
 {
     this.winner = winner;
 }
Пример #28
0
 public PlayerLeftEvent(VTankBot _game, int id)
     : base(_game)
 {
     this.id = id;
 }
Пример #29
0
 /// <summary>
 /// Enqueue a bot onto the queue.
 /// </summary>
 /// <param name="bot"></param>
 public void Enqueue(VTankBot bot)
 {
     lock (this)
     {
         botQueue.Enqueue(bot);
     }
 }
Пример #30
0
 public FlagReturnedEvent(VTankBot _game, int returnedById, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.returnedById = returnedById;
     this.flagColor = flagColor;
 }