激光魔法屬矩形直線穿梭類型,傷害計算特殊。點擊 B 點,激光從主角手部 A 發出,計算 A-B 角度旋轉激光,傷害範圍為不規則矩形:

已知 A、B 座標與激光長度,可算出 4 頂點座標,使用 System.Drawing 判斷精靈是否在多邊形內:
public static bool PointInPolygon(System.Drawing.Point[] range, System.Drawing.Point target)
{
System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
System.Drawing.Region myRegion = new System.Drawing.Region();
myGraphicsPath.Reset();
myGraphicsPath.AddPolygon(range);
myRegion.MakeEmpty();
myRegion.Union(myGraphicsPath);
return myRegion.IsVisible(target);
}
此法可擴展至任意多邊形(閉合/不閉合),所有範圍攻擊魔法均適用。下節將展示矢量魔法的萬變特效。