public void InitStage() { var levelInfo = _logicHandler.GameController.CurLevel; const float MIN_SHIP_VELOCITY = 2.769f; //3.692f; const float SHIP_VELOCITY_INCREMENT = 0.601f; //0.572f; //0.635f; //0.706f; const float LEVEL_TIME_SECONDS = 40f; const float ASTEROID_LINES_PER_UNIT_DISTANCE = 0.42f; ////original number of asteroid lines was 84 lines per 200 units of distance ShipVelocity = MIN_SHIP_VELOCITY + SHIP_VELOCITY_INCREMENT * (levelInfo.Level - 1); var levelLength = (int)(ShipVelocity * LEVEL_TIME_SECONDS); //we want the level to last 40 seconds. var numAsteroidLines = (int)(levelLength * ASTEROID_LINES_PER_UNIT_DISTANCE); _asteroidPlacementLogicImplementer.AsteroidDensity = _logicHandler.GameController.CurLevel.SubLevel; _lastAsteroid = _asteroidPlacementLogicImplementer.InitAsteroids(levelLength, numAsteroidLines); }
public void OnStart() { #region arrange var playerShip = Substitute.For <IGameObject>(); var playerShipScript = Substitute.For <IPlayerShipScript>(); playerShipScript.GameEngineInterface = null; playerShip.GetComponent <IPlayerShipScript>().Returns(playerShipScript); _gameEngineInterface.FindGameObject("PlayerShip").Returns(playerShip); var quad = Substitute.For <IGameObject>(); _gameEngineInterface.FindGameObject("Quad").Returns(quad); var txtLives = Substitute.For <IGameObject>(); var iTextLives = Substitute.For <IText>(); txtLives.GetComponent <IText>().Returns(iTextLives); _gameEngineInterface.FindGameObject("txtLives").Returns(txtLives); var txtCurLevel = Substitute.For <IGameObject>(); var iTextCurLevel = Substitute.For <IText>(); txtCurLevel.GetComponent <IText>().Returns(iTextCurLevel); _gameEngineInterface.FindGameObject("txtCurLevel").Returns(txtCurLevel); _dataLayer.GetNumLivesRemaining().Returns(1); _logicHandler.GameController = Substitute.For <IGameController>(); _logicHandler.GameController.CurLevel.Returns(new LevelInfo(1, 1)); _asteroidPlacementLogicImplementer.InitAsteroids(Arg.Any <int>(), Arg.Any <int>()).Returns((IGameObject)null); #endregion #region act _gameLogicProvider.OnStart(); #endregion #region assert _gameEngineInterface.Received(1).FindGameObject("GlobalObject"); _gameEngineInterface.Received(1).FindGameObject("PlayerShip"); //_gameEngineInterface.Received(1).FindGameObject("PlayerShield"); _gameEngineInterface.Received(1).FindGameObject("MainCamera"); playerShip.Received().GetComponent <IPlayerShipScript>(); Assert.IsNotNull(playerShipScript.GameEngineInterface); _gameEngineInterface.Received(1).FindGameObject("Asteroid"); _gameEngineInterface.Received(1).FindGameObject("Explosion"); _gameEngineInterface.Received(1).FindGameObject("Quad"); quad.Received(1).EnableTextureWrapping(); _gameEngineInterface.Received(1).FindGameObject("txtLives"); Assert.AreEqual("LIVES: 1", iTextLives.Text); _gameEngineInterface.Received(1).FindGameObject("txtCurLevel"); Assert.AreEqual("LEVEL: 1-1", iTextCurLevel.Text); _gameEngineInterface.Received(1).SetupLighting(); _asteroidPlacementLogicImplementer.Received(1).InitAsteroids(Arg.Any <int>(), Arg.Any <int>()); Assert.AreEqual(1, playerShipScript.Health); #endregion }