public void OnSelectObject(SelectObjectAtMessage message) { IList <SelectableObject> selectedObjects = GetObjectAt(message.WorldPosition, message.Time); IList <SelectableObject> newlySelectedObjects; IList <SelectableObject> deselectedObjects; if (m_SelctedObject != null) { newlySelectedObjects = selectedObjects.Where(x => !m_SelctedObject.Contains(x)).ToList(); deselectedObjects = m_SelctedObject.Where(x => !selectedObjects.Contains(x)).ToList(); } else { newlySelectedObjects = selectedObjects; deselectedObjects = new List <SelectableObject>(); } m_SelctedObject = selectedObjects; if (newlySelectedObjects.Any()) { m_Bus.Send(new SelectedObjectMessage(newlySelectedObjects.First().Name, newlySelectedObjects.First().Owner == m_Id.Id)); } if (deselectedObjects.Any()) { m_Bus.Send(new DeselectedObjectMessage(deselectedObjects.First().Name)); } }
public void SendsSelectedObjectMessageIfOneObjectIntersects() { var message = new SelectObjectAtMessage(m_Position, m_TestTime); m_Repository.OnSelectObject(message); m_Bus.Received().Send(Arg.Any <SelectedObjectMessage>()); }
public void SendsSelectedObjectMessageIfOneObjectIntersects() { var message = new SelectObjectAtMessage(m_Position, m_TestTime); m_Repository.OnSelectObject(message); m_Bus.Received().Send(Arg.Any<SelectedObjectMessage>()); }
public void SetPathSendsForSelectedObjects() { var message = new SelectObjectAtMessage(m_Position, m_TestTime); m_Repository.OnSelectObject(message); m_Repository.OnSetPath(new SetPathToTargetMessage(m_Position, m_TestTime)); m_Bus.Received().Send(Arg.Any <PathMessage>()); }
public void SetPathSendsForSelectedObjects() { var message = new SelectObjectAtMessage(m_Position, m_TestTime); m_Repository.OnSelectObject(message); m_Repository.OnSetPath(new SetPathToTargetMessage(m_Position, m_TestTime)); m_Bus.Received().Send(Arg.Any<PathMessage>()); }
public void RoundTrip() { var original = new SelectObjectAtMessage(new Vector(5.3, 7), 457); var serialiser = new MessageSerialiser(); serialiser.Register(typeof(SelectObjectAtMessage)); var text = serialiser.Serialise(original); var deserialised = (SelectObjectAtMessage)serialiser.Deserialise(text); Assert.AreEqual(original.WorldPosition, deserialised.WorldPosition); Assert.AreEqual(original.Time, deserialised.Time); }
public void ClearsOldSelectedObject() { var message = new SelectObjectAtMessage(m_Position, m_TestTime); var newPosition = new Vector(50, 5); var secondObject = CreateSelectableObjectAt(newPosition); m_Repository.AddObject(secondObject); m_Repository.OnSelectObject(message); m_Bus.DidNotReceive().Send(Arg.Any<DeselectedObjectMessage>()); m_Repository.OnSelectObject(new SelectObjectAtMessage(newPosition, m_TestTime)); m_Bus.Received().Send(Arg.Any<DeselectedObjectMessage>()); }
public void ClearsOldSelectedObject() { var message = new SelectObjectAtMessage(m_Position, m_TestTime); var newPosition = new Vector(50, 5); var secondObject = CreateSelectableObjectAt(newPosition); m_Repository.AddObject(secondObject); m_Repository.OnSelectObject(message); m_Bus.DidNotReceive().Send(Arg.Any <DeselectedObjectMessage>()); m_Repository.OnSelectObject(new SelectObjectAtMessage(newPosition, m_TestTime)); m_Bus.Received().Send(Arg.Any <DeselectedObjectMessage>()); }
public void OnSelectObject(SelectObjectAtMessage message) { IList<SelectableObject> selectedObjects = GetObjectAt(message.WorldPosition, message.Time); IList<SelectableObject> newlySelectedObjects; IList<SelectableObject> deselectedObjects; if (m_SelctedObject != null) { newlySelectedObjects = selectedObjects.Where(x => !m_SelctedObject.Contains(x)).ToList(); deselectedObjects = m_SelctedObject.Where(x => !selectedObjects.Contains(x)).ToList(); } else { newlySelectedObjects = selectedObjects; deselectedObjects = new List<SelectableObject>(); } m_SelctedObject = selectedObjects; if (newlySelectedObjects.Any()) { m_Bus.Send(new SelectedObjectMessage(newlySelectedObjects.First().Name, newlySelectedObjects.First().Owner == m_Id.Id)); } if (deselectedObjects.Any()) { m_Bus.Send(new DeselectedObjectMessage(deselectedObjects.First().Name)); } }
private void MoveMarker(SelectObjectAtMessage message) { m_Marker.Position = VectorConversions.ToOgreVector(message.WorldPosition); }