Ejemplo n.º 1
0
        public void CycleIsCollidingInBounds()
        {
            var gameConfig = new GameConfiguration(new CycleConfiguration(), new MapConfiguration());
            var map = new Map(gameConfig.MapConfig);
            var startPosition = new Vector3(0, gameConfig.CycleConfig.Y_OFFSET, 0);
            var cycle = new Cycle(1, startPosition, new Vector3(1, 0, 0), Math.PI + Math.PI * .5, 0xff0000, map, gameConfig);
            var cycle2 = new Cycle(2, startPosition, new Vector3(1, 0, 0), Math.PI + Math.PI * .5, 0xff0000, map, gameConfig);
            var collisionChecker = new CollisionChecker(map);
            var startLocation = map.Utilities.ToMapLocation(startPosition);
            var cycles = new ConcurrentDictionary<long, Cycle>();
            cycles.TryAdd(cycle.ID, cycle);
            cycles.TryAdd(cycle2.ID, cycle2);
            map.RegisterCycles(cycles);

            map[startLocation] = 2;
            collisionChecker.ValidateCollision(cycle);

            Assert.True(cycle.Colliding);

            map.Clear();
            cycle.Colliding = false;
            map[startLocation] = -cycle.ID;
            collisionChecker.ValidateCollision(cycle);
            Assert.False(cycle.Colliding);

            map.Clear();
            cycle.Colliding = false;
            map[startLocation] = 0;
            collisionChecker.ValidateCollision(cycle);
            Assert.False(cycle.Colliding);
        }
Ejemplo n.º 2
0
 public override void Dispose()
 {
     _map = null;
     _gameConfiguration = null;
     _velocities.Clear();
     _velocities = null;
     base.Dispose();
 }
Ejemplo n.º 3
0
 public CycleMovementController(Vector3 position, Vector3 velocity, double rotation, Map map, GameConfiguration gameConfiguration)
     : base(position, velocity, Math.Round(rotation, 4))
 {
     _gameConfiguration = gameConfiguration;
     _map = map;
     RequestedPosition = position;
     // There aren't many velocities we can have so calculate them prior to cycle activation
     calculateVelocities();
 }
Ejemplo n.º 4
0
        public void FillSpots(ConcurrentDictionary<long, Cycle> cycles, List<GameSpawn> spawns, Map map, GameConfiguration gameConfiguration)
        {
            long aiID = getMaxID(cycles) + 1;
            int cycleCount = cycles.Count;

            for (int i = cycleCount; i < _playerCount; i++)
            {
                cycles.TryAdd(aiID, new CycleAI(aiID, spawns[i].StartPosition, spawns[i].StartVelocity, spawns[i].StartRotation, spawns[i].TrailColor, map, gameConfiguration));
                aiID++;
            }
        }
Ejemplo n.º 5
0
        public void CycleIsCollidingOutOfBounds()
        {
            var gameConfig = new GameConfiguration(new CycleConfiguration(), new MapConfiguration());
            var map = new Map(gameConfig.MapConfig);
            var startPosition = new Vector3(gameConfig.MapConfig.MAP_SIZE.Width * .5 + gameConfig.MapConfig.FLOOR_TILE_SIZE.Width * 10, gameConfig.CycleConfig.Y_OFFSET, 0);
            var cycle = new Cycle(1, startPosition, new Vector3(1, 0, 0), Math.PI + Math.PI * .5, 0xff0000, map, gameConfig);
            var collisionChecker = new CollisionChecker(map);

            collisionChecker.ValidateCollision(cycle);
            Assert.True(cycle.Colliding);

            cycle.Colliding = false;
            cycle.MovementController.Position = new Vector3();
            collisionChecker.ValidateCollision(cycle);
            Assert.False(cycle.Colliding);
        }
Ejemplo n.º 6
0
        public Game(IEnumerable<User> players, IGameMode mode, BroadcastHandler broadcastHandler, Action onFinish)
        {
            _mode = mode;
            _gameConfiguration = _mode.GetConfiguration();
            _broadcastHandler = broadcastHandler;
            _map = new Map(_gameConfiguration.MapConfig);

            var cycleDictionary = createCycles(players);

            _onFinish = onFinish;
            _cycleManager = new CycleManager(cycleDictionary);

            _map.RegisterCycles(cycleDictionary);
            _broadcastHandler.RegisterCycles(cycleDictionary);

            CommandHandler = new CommandHandler(cycleDictionary);
        }
Ejemplo n.º 7
0
 public MapMarker(Map map)
 {
     _map = map;
     _utilities = _map.Utilities;
 }
Ejemplo n.º 8
0
 public CollisionChecker(Map map)
 {
     _map = map;
     _utilities = _map.Utilities;
 }
Ejemplo n.º 9
0
 public RequestValidator(Map map)
 {
     _map = map;
     _utilities = _map.Utilities;
 }