public void GivenTorpedo_WhenProcessTick_ThenTorpedoMoves()
        {
            SetupFakeWorld(true, false);
            var bot = FakeGameObjectProvider.GetBotWithActions();

            bot.CurrentHeading = 90;
            bot.Speed          = 20;
            bot.IsMoving       = true;

            var torpedoPosition = VectorCalculatorService.GetPositionFrom(bot.Position, bot.Size + EngineConfigFake.Value.Torpedo.Size + 1, bot.CurrentAction.Heading);
            var torpedoSalvo    = new TorpedoGameObject()
            {
                Id             = Guid.NewGuid(),
                Position       = torpedoPosition,
                Size           = EngineConfigFake.Value.Torpedo.Size,
                Speed          = EngineConfigFake.Value.Torpedo.Speed,
                CurrentHeading = 45,
                FiringPlayerId = bot.Id,
                IsMoving       = true
            };

            WorldStateService.AddGameObject(torpedoSalvo);

            tickProcessingService = new TickProcessingService(
                collisionHandlerResolver,
                VectorCalculatorService,
                WorldStateService,
                collisionService);

            Assert.DoesNotThrow(() => tickProcessingService.SimulateTick());

            Assert.AreNotEqual(torpedoPosition, torpedoSalvo.Position);
        }
Exemplo n.º 2
0
        public void GivenBotAndWormhole_WhenResolveCollision_ReturnBotInNewPositionAndShrunkWormholes()
        {
            WorldStateService.GenerateStartingWorld();
            var state = WorldStateService.GetState();

            List <Tuple <GameObject, GameObject> > wormholes = state.WormholePairs;
            var wormhole     = wormholes[0].Item1;
            var wormholeSize = wormhole.Size;

            var bot = FakeGameObjectProvider.GetBotAt(
                new Position(wormhole.Position.X + wormhole.Size + 5, wormhole.Position.Y + wormhole.Size + 5));

            var handler = collisionHandlerResolver.ResolveHandler(wormhole, bot);

            handler.ResolveCollision(wormhole, bot);

            var expectedPosition = VectorCalculatorService.GetPositionFrom(
                wormholes[0].Item2.Position,
                wormholeSize + bot.Size,
                bot.CurrentHeading);

            Assert.AreEqual(expectedPosition.X, bot.Position.X);
            Assert.AreEqual(expectedPosition.Y, bot.Position.Y);
            Assert.AreEqual(EngineConfigFake.Value.ScoreRates[GameObjectType.Wormhole], bot.Score);

            Assert.True(state.WormholePairs[0].Item1.Size < wormholeSize);
            Assert.True(state.WormholePairs[0].Item2.Size < wormholeSize);
            Assert.True(state.WormholePairs[0].Item2.Size == state.WormholePairs[0].Item1.Size);
        }