public void Determine_Collision_Exists() { var shipA = new Ship { Position = new Vector(0, 0, 0), Velocity = new Vector(10, 0, 0) }; var shipB = new Ship { Position = new Vector(10, 10, 0), Velocity = new Vector(0, 20, 0) }; var list = new MovementList(new List<Ship> { shipA, shipB }); Assert.IsTrue(list.HasCollisions); }
private void AccumulateMotion() { // to hasten the process when there is no movement if (MovementList.Count == 0) { return; } // removes movements that are already non-active for (int i = 0; i < MovementList.Count;) { if (!MovementList[i].IsActive) { MovementList.RemoveAt(i); } else { i++; } } foreach (IMovement movement in MovementList) { movement.ChangeMotion(this); } }
private async Task ExecuteRefresh() { try { MovementViewModel sm = SelectedMovement; var moves = await _warehouse.DBService.GetMovements(DateFrom.TimeStamp, DateTo.TimeStamp, Location, TransportUnit); MovementList.Clear(); foreach (var m in moves) { MovementList.Add(new MovementViewModel { Movement = m }); } if (sm != null) { SelectedMovement = MovementList.FirstOrDefault(p => p.ID == sm.ID); } Records = MovementList.Count; } catch (Exception e) { _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception, string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message)); } }
public bool RemoveMovement(IMovement movement) { if (movement == null) { return(false); } return(MovementList.Remove(movement)); }
public void AddMovement(IMovement movement) { if (movement == null) { return; } MovementList.Add(movement); }
public void Ships_Are_In_New_Position() { var shipA = new Ship {Position = new Vector(0, 0, 0), Velocity = new Vector(2, 0, 0)}; var shipB = new Ship { Position = new Vector(10, 10, 10), Velocity = new Vector(2, 0, 0) }; var list = new MovementList(new List<Ship> {shipA, shipB}); list.ApplyMovement(); Assert.That(shipA.Position, Is.EqualTo(new Vector(2, 0, 0))); Assert.That(shipB.Position, Is.EqualTo(new Vector(12, 10, 10))); }
public void LoadTags(IEnumerable <string> movementFilenames, IEnumerable <WesternClassicalMusicFileTEO> trackTeos) { MovementFilenames = movementFilenames;// fileTeoList.Select(x => x.File); SetMovementTEOList(trackTeos); var performanceIdList = MovementList.Select(t => t.PerformanceId).Distinct(); Debug.Assert(performanceIdList.Count() == 1); PerformanceId = performanceIdList.First();// ?? 0; ComposerTag = new TagValueStatus(TagNames.Composer, MovementList.Where(x => x.ComposerTag != null).SelectMany(x => x.ComposerTag.Values)); CompositionTag = new TagValueStatus(TagNames.Composition, MovementList.Where(x => x.CompositionTag != null).SelectMany(x => x.CompositionTag.Values)); OrchestraTag = new TagValueStatus(TagNames.Orchestra, MovementList.Where(x => x.OrchestraTag != null).SelectMany(x => x.OrchestraTag.Values)); ConductorTag = new TagValueStatus(TagNames.Conductor, MovementList.Where(x => x.ConductorTag != null).SelectMany(x => x.ConductorTag.Values)); var allPerformers = MovementList .Where(x => x.PerformerTag != null) .SelectMany(x => x.PerformerTag.Values) .Select(x => x.Value) .ToList(); for (int i = 0; i < allPerformers.Count(); ++i) { var performer = allPerformers[i]; var p = Regex.Replace(performer, @"\(.*?\)", "").Trim(); allPerformers[i] = p; } allPerformers = allPerformers .Select(x => musicOptions.ReplaceAlias(x)) .Distinct(accentsAndCaseInsensitiveComparer) .OrderBy(x => x.GetLastName()) .ToList(); // now remove any performers that are already defined as orchestras foreach (var name in OrchestraTag.Values.Select(x => x.Value)) { var matched = allPerformers.FirstOrDefault(x => x.IsEqualIgnoreAccentsAndCase(name)); if (matched != null) { allPerformers.Remove(matched); } } // now remove any performers that are already defined as conductors foreach (var name in ConductorTag.Values.Select(x => x.Value)) { var matched = allPerformers.FirstOrDefault(x => x.IsEqualIgnoreAccentsAndCase(name)); if (matched != null) { allPerformers.Remove(matched); } } PerformerTag = new TagValueStatus(TagNames.Performer, allPerformers, true); }
public void RecordChanges() { var tracks = MovementList.Select(x => x.MusicFile.Track); var performancesInDb = tracks.Select(t => t.Performance).Distinct(); Debug.Assert(performancesInDb.Count() == 1); var performance = performancesInDb.First(); var composition = performance.Composition; if (ComposerTag.GetValue <string>() != composition.Artist.Name) { log.Information($"{composition.Artist.Name}, \"{composition.Name}\": Artist changed from {composition.Artist.Name} to {ComposerTag.GetValue<string>()}"); log.Warning("Composer name changes are not supported"); } if (CompositionTag.GetValue <string>() != composition.Name) { log.Information($"{composition.Artist.Name}, \"{composition.Name}\": Composition changed from {composition.Name} to {CompositionTag.GetValue<string>()}"); composition.Name = CompositionTag.GetValue <string>(); } var performerList = PerformerTag.GetValues <string>().ToList(); performerList.AddRange(OrchestraTag.GetValues <string>()); performerList.AddRange(ConductorTag.GetValues <string>()); var performers = string.Join(", ", performerList); if (performers != performance.Performers) { log.Information($"{composition.Artist.Name}, \"{composition.Name}\": Performers changed from {performance.Performers} to {performers}"); performance.Performers = performers; } foreach (var m in MovementList) { var t = tracks.First(x => m.TrackId == x.Id); if (m.MovementNumberTag.GetValue <int>() != t.MovementNumber) { log.Information($"{composition.Artist.Name}, \"{composition.Name}\", \"{performance.Performers}\": movement number changed from {t.MovementNumber} to {m.MovementNumberTag.GetValue<int>()}"); log.Warning("Movement number changes are not supported"); } if (m.TitleTag.GetValue <string>() != t.Title) { log.Information($"{composition.Artist.Name}, \"{composition.Name}\", \"{performance.Performers}\": title changed changed from {t.Title} to {m.TitleTag.GetValue<string>()}"); t.Title = m.TitleTag.GetValue <string>(); } } }
// Use this for initialization public void Initialize() { m_MovementList = new MovementList(); m_MovementList.Initialize(); m_SkillList = new SkillList(); m_SkillList.Initialize(); m_NameGenerator = new NameGenerator(); m_NameGenerator.Initialize(); m_NodeFormation = new NodeFormations(); QualitySettings.vSyncCount = 1; Physics.autoSimulation = false; }