Пример #1
0
    public Vector3 GetRandomPoint()
    {
        if (tesselator == null)
        {
            return(GetExitPoint().transform.position);
        }
        // Needs some work
        Vector2[] triangle      = tesselator.GetRandomTriangle();
        float     randomWeight1 = Random.value;
        float     randomWeight2 = Random.value;

        Vector2 randomPoint = (1 - Mathf.Sqrt(randomWeight1)) * triangle [0]
                              + (Mathf.Sqrt(randomWeight1) * (1 - randomWeight2)) * triangle [1]
                              + (randomWeight2 * Mathf.Sqrt(randomWeight1)) * triangle [2];

        Vector3 randomPoint3D = new Vector3(randomPoint.x + transform.position.x,
                                            randomPoint.y + transform.position.y,
                                            2);

        return(randomPoint3D);
    }