コード例 #1
0
    public int GetIndexInDirection(Vector2 vec)
    {
        var joyDirection        = Vector2Extensions.FullAngle(Vector2.right, vec);
        var degreesBetweenMarks = 360.0f / characterMarks.Count;
        var index   = joyDirection / degreesBetweenMarks;
        var portion = index - (int)index;

        return(Mathf.RoundToInt(index) % characterMarks.Count);
    }
コード例 #2
0
ファイル: MoveType.cs プロジェクト: esg-tim/happycult
    public static Vector2 EvaluateCircle(Vector2 pointA, Vector2 pointB, Vector2 center, float t, bool invert = false)
    {
        center = invert ? (((pointB - pointA) / 2 + pointA) - center) * 2 + center : center;

        var a            = (pointA - center);
        var b            = (pointB - center);
        var radius       = a.magnitude;
        var angleA       = Vector2Extensions.FullAngle(a, Vector2.right);
        var angleB       = Vector2Extensions.FullAngle(b, Vector2.right);
        var currentAngle = Mathf.LerpAngle(angleA, angleB, t);

        return(new Vector2(Mathf.Cos(currentAngle * Mathf.PI / 180.0f) * radius, Mathf.Sin(currentAngle * Mathf.PI / 180.0f) * radius) + center);
    }