public void AddMediumAsteroid() { //Arrange ScoreBoard scoreBoard = new ScoreBoard(); Asteroid bigAsteroid = new Asteroid(0, TimeSpan.Zero, Asteroid.Size.MEDIUM); //Action scoreBoard.AddPoints(bigAsteroid, false); //Assert Assert.AreEqual(50, scoreBoard.CurrentScore); }
public void AddSmallAsteroid() { //Arrange ScoreBoard scoreBoard = new ScoreBoard(); Asteroid bigAsteroid = new Asteroid(0,TimeSpan.Zero, Asteroid.Size.SMALL); //Action scoreBoard.AddPoints(bigAsteroid, false); //Assert Assert.AreEqual(100, scoreBoard.CurrentScore); }
/// <summary> /// Called when a collision occurs in other to make a certain event occure. /// </summary> /// <param name="elapsedGameTime">The elapsed game time.</param> /// <param name="hitter">The hitter.</param> /// <param name="overseeingGame">The overseeing game.</param> public override void OnHit(TimeSpan elapsedGameTime, GameObject hitter, MajorLeagueGamingAsteroids overseeingGame) { if (hitter.ObjectType == GAME_OBJECT_TYPE.ASTEROID && CanMerge(elapsedGameTime)) //If it's destroyed as a merge { if (!((Asteroid)hitter).hasMerged) { float direction = (hitter.RotationAngle + rotationAngle) / 2; Asteroid mergedRoid = new Asteroid(direction, elapsedGameTime, (Size)((int)currentSize + 1)); mergedRoid.Initialize(overseeingGame.GetTexture((MajorLeagueGamingAsteroids.TextureType)((int)currentSize + 1)), position); overseeingGame.AddGameObject(mergedRoid); mergedRoid.movementVector = new Vector2((movementVector.X + hitter.MovementVector.X) / 2, (movementVector.Y + hitter.MovementVector.Y) / 2); hasMerged = true; } } else if (currentSize != Size.SMALL) //If destroyed and should split { Vector2 resultingDirectionVector = new Vector2((movementVector.X + hitter.MovementVector.X) / 2, (movementVector.Y + hitter.MovementVector.Y) / 2); float createdSpeed = (float)Math.Sqrt(resultingDirectionVector.X * resultingDirectionVector.X + resultingDirectionVector.Y * resultingDirectionVector.Y); float resultingDirection = GetAngleFromVector(resultingDirectionVector); Asteroid spawnling = new Asteroid(resultingDirection + (float)(Math.PI)/3, elapsedGameTime, (Size)((int)currentSize - 1)); spawnling.Initialize(overseeingGame.GetTexture((MajorLeagueGamingAsteroids.TextureType)((int)currentSize - 1)), position); overseeingGame.AddGameObject(spawnling); spawnling.movementVector = new Vector2(0, 0); spawnling.AccelerateObject(createdSpeed); spawnling = new Asteroid(resultingDirection - (float)(Math.PI)/3, elapsedGameTime, (Size)((int)currentSize - 1)); spawnling.Initialize(overseeingGame.GetTexture((MajorLeagueGamingAsteroids.TextureType)((int)currentSize - 1)), position); overseeingGame.AddGameObject(spawnling); spawnling.movementVector = new Vector2(0, 0); spawnling.AccelerateObject(createdSpeed); } }
/// <summary> /// Spawns the asteroids. /// </summary> /// <param name="nbrAsteroids">The NBR asteroids.</param> /// <param name="gameTime">The game time.</param> private void SpawnAsteroids(int nbrAsteroids, TimeSpan gameTime) { Vector2 spawnLocation; for (int i = 0; i < nbrAsteroids; ++i) { spawnLocation = GetValidEnemySpawnLocation(); Asteroid roid = new Asteroid(RandomManager.RandomAngleWithVerticalTendency(), gameTime); roid.Initialize(textures[(int)TextureType.ASTEROID_BIG], spawnLocation); objectManager.AddObserver(roid); } }