Beispiel #1
0
    /// <summary>
    /// 頂点の追加
    /// </summary>
    private bool AddVertex(Vector2 point)
    {
        //例外検出
        if (ExceptionDetector(point))
        {
            return(false);
        }

        polyLine.Add(point);

        //予告線の基点を変更
        if (noticeLine.GetVertexCount() == 0)
        {
            noticeLine.Add(point);
        }
        else
        {
            noticeLine.Change(0, point);
        }

        //アニメーションの距離更新
        targetDistance = polyLine.TotalDistance;
        lerped         = true;

        //コールバック
        if (addVertexCallback != null)
        {
            addVertexCallback(point);
        }

        return(true);
    }
Beispiel #2
0
        /// <summary>
        /// 全ての頂点の消去
        /// </summary>
        public void Clear()
        {
            int count = mainLine.GetVertexCount();

            for (int i = 0; i < count; ++i)
            {
                //エフェクト用
                RemoveLast();
            }
            subLine.Clear();
            mf.mesh = null;
        }
Beispiel #3
0
    /// <summary>
    /// 頂点追加前の例外検出。例外を検出した場合はtrueを返す
    /// </summary>
    private bool ExceptionDetector(Vector2 point)
    {
        int count = polyLine.GetVertexCount();

        //同一点の検出
        if (doublePointRemoval)
        {
            if (count > 1)
            {
                Vector2 prevPoint = polyLine.GetVertex(count - 1);
                float   dis       = (point - prevPoint).magnitude;
                if (dis < doublePointThreshold)
                {
                    if (doublePointCallback != null)
                    {
                        doublePointCallback();
                    }
                    return(true);
                }
            }
        }

        //線分の交差判定
        if (crossLineRemoval)
        {
            if (count > 2)
            {
                //検出線分の作成
                LineSegment line = new LineSegment(polyLine.GetVertex(count - 1), point);
                for (int i = 0; i < count - 2; ++i)
                {
                    //比較線分の作成
                    LineSegment sample = new LineSegment(polyLine.GetVertex(i), polyLine.GetVertex(i + 1));
                    if (line.Intersects(sample))
                    {
                        if (crossLineCallback != null)
                        {
                            crossLineCallback();
                        }
                        return(true);
                    }
                }
            }
        }

        return(false);
    }