public void Update(float dt) { var mousePos = GetMousePos(); foreach (var testObject in m_TestObjects) { var toMouse = (mousePos - testObject.Key.Position).Normalized(); testObject.Key.Position += (testObject.Value + toMouse) * dt * m_SpeedMultiplier; testObject.Key.FillColor = Color.Blue; WrapPosition(testObject.Key); } m_Grid.Update(); foreach (var obj in m_Grid.GetKClosestObjects(GetMousePos(), 30)) { obj.FillColor = Color.Red; } var closest = m_Grid.GetClosestObject(GetMousePos()); if (closest != null) { closest.FillColor = Color.Green; } }
public void KClosestBG() { m_Grid.GetKClosestObjects(RandomPosition(), K, (float)(m_Random.NextDouble() * 100)); }