Track vertex joining and definition when creating a polygon

I am trying to work with a game mechanic in C #, which involves connecting vertices and forming polygons.

There can be any number of 5-30 vertices. Each vertex can be connected to a straight line ( Lines cannot intersect ). When a line covers a polygon, a specific color is painted inside the polygon. ( You cannot close a polygon if there is a dot inside it during closing )

For example, the two images below cannot be:

First wrong move Second wrong move

However, this may:

Right move

, , , ( , , ). , , , .

, AB, ED, CD, CA .. , , , , . , .

( ), n, .

Move example

- , ? , , .

+4
2

, , Dictionary<Face,List<Vertex>>, linq.

, . Dictionary<Vertex, List<Faces>>

1: ,

DC, D C , . D List<Vertex> C.

C -> D.

2 , D -> E -> C C -> A -> B -> D, D -> C, , .

2. ,

.

3. eges,

Face1: ABDEC Face2: AGF

FC. F Face2 C, Face1.

: Face1.Face2 == , 2 2 .

FA
 FGA

AC
 ABDEC

F A,

FAC FGAC FABDEC FGABDEC

.

(3 , ), , .

, , 3 , ,

+1

, :

  • , ;
  • , ( ), , , , - ;
  • :
    • , - - .
    • . - , , ( ) , ( s), . , .

, , .

0

Source: https://habr.com/ru/post/1682743/


All Articles