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);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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);
        }