Example #1
0
        void toStartShadowLine(Vector2 pos, Vector2[] vertexs, World.Gate gate, Action<Vector2, Vector2> callback)
        {
            Vector2? a = null;
            Vector2? b = null;

            Action<Vector2> extremePoints = point =>
            {

                if (a == null)
                {
                    a = point - pos; //����������� ������
                    b = point - pos; //������������ ������
                }

                var sample = point - pos;

                if (a.Value.X * (-sample.Y) + a.Value.Y * sample.X > 0)
                    a = sample;

                if (b.Value.X * (-sample.Y) + b.Value.Y * sample.X < 0)
                    b = sample;
            };

            if (gate == null)
                vertexs.ForEach(extremePoints);
            else
                Vector.cutShape(pos, vertexs, new Segment2(gate.Vertexes[0].Position.ToVector2(), gate.Vertexes[1].Position.ToVector2()), extremePoints);

            if (a != null)
                callback(pos + a.Value, pos + b.Value);
        }