//Initialises a new drone object in the world private void CreateDrone() { var update = _droneLogic.AddDrone(); if (!update.Value) { return; } var model = Content.Load <Model>("Models/Drones/drone", ContentManagerLoaderSettings.Default); var drone = new Entity(new Vector3(update.Key.Route.First().XPosition, update.Key.Route.First().YPosition, update.Key.Route.First().ZPosition), update.Key.Name); drone.Components.Add(new ModelComponent(model)); drone.Transform.Scale = new Vector3(update.Key.Scale.XPosition, update.Key.Scale.YPosition, update.Key.Scale.ZPosition); drone.Transform.Rotation = Quaternion.Identity; update.Key.Route.RemoveAt(0); Speeds.Add(update.Key.Id, update.Key.Speed); _waypointIndexes.Add(update.Key.Id, 0); if (Drones.IsNullOrEmpty()) { Drones = new Dictionary <int, Entity>(); } Drones.Add(update.Key.Id, drone); DistanceTravelled.Add(update.Key.Id, 0); TotalDroneCount++; _routes.Add(update.Key.Id, update.Key.Route.Select(x => new Vector3(x.XPosition, x.YPosition, x.ZPosition)).ToList()); SceneSystem.SceneInstance.RootScene.Entities.Add(drone); }
public void TestAddDrone() { //Arrange var unitOfWork = new UnitOfWork(new DtsContext()); var comparisionList = unitOfWork.Drones.GetAll().ToList(); unitOfWork.Dispose(); var droneLogic = new DroneLogic(50); droneLogic.SpawnTimes.Clear(); droneLogic.SpawnTimes.Add(DateTime.MinValue.AddSeconds(1)); //Act var result = droneLogic.AddDrone(); //Assert Assert.IsNotEmpty(comparisionList.Where(x => x.Id == result.Key.Id), "The Id generated does not exist"); Assert.IsNotNull(result.Key.CurrentPoint, "The current point was not generated"); Assert.True(result.Value, "The spawn time is incorrect"); ResetValues(result.Key.Id); }