/** * Calculates the path of travel of the laser and sets the laser to such a * path * * @param laser * @param models */ public static object[] Reflect(LaserModel laser) { FindIntersects(laser, GameInstance.objectManager.GetModels()); // If there exists at least one valid intersection if (intersects.Count != 0) { closest = GetClosestIntersection(); // Find the closest one // Pythagorean theorem to find length of vector float length = (float)MathExtension.Hypotenuse((float)closest[1] - coords[0], (float)closest[2] - coords[1]); laser.SetLength(length); // Modify the laser to the correct length // Calculates reflected vector using the laser's vector and a new vector representing the side of the Model Vector2d resultantV = ReflectionVector(laser.vect, new Vector2d(10d, 10d * (float)closest[3])); ReflectionCallback((Model)closest[0], laser); return(new Object[] { CreateModel.CreateReflectedLaser((float)closest[1], (float)closest[2], resultantV), closest[0] }); } return(null); }