Example #1
0
        public LevelPolygon( LevelVertex[] vertices )
        {
            init();

                foreach( LevelVertex vertex in vertices ) {
                    vertex.PositionChange += new EventHandler( vertex_PositionChange );
                    this.vertices.Add( vertex );
                }

                calculateAverageVertexPosition();
        }
Example #2
0
        // TODO: The SkiStuntLevel object should not be directly tied to the editor's undoable 'Action' paradigm.
        /**
         * <summary>
         * Removes a specified LevelVertex from the level.  Any LevelPolygon in the level that uses the specified
         * vertex will have the vertex remove from it as well.  If said LevelPolygon ends up with less than 3
         * total vertices, the polygon will be removed from the level.
         * </summary>
         * <param name="vertex">Vertex to remove from the level.</param>
         */
        public DeleteVertexAction RemoveVertex( LevelVertex vertex )
        {
            if( !vertices.Contains( vertex ) ) return null;

                DeleteVertexAction dva = new DeleteVertexAction();

                dva.vertexDeleted = vertex;
                vertices.Remove( vertex );

                foreach( LevelPolygon p in polygons )
                {
                    if( p.ContainsVertex( vertex ) )
                    {
                        if( p.NonBezierVertexCount == 3 ) {
                            dva.collateralPolygons.Add( p );
                        } else
                        {
                            dva.polygonsAffected.Add( p );
                            dva.precedingVertices.Add( p.GetPrecedingVertex( vertex ) );
                            p.RemoveVertex( vertex );
                        }
                    }
                }

                foreach( LevelPolygon p in dva.collateralPolygons )
                {
                    RemovePolygon( p );
                }

                return dva;
        }
Example #3
0
 /**
  * <summary>Adds a vertex to the level's set of total vertices if the vertex is not already
  * a part of the level.</summary>
  * <param name="vertex">Vertex to add to the level.</param>
  */
 public void AddVertex( LevelVertex vertex )
 {
     if( !vertices.Contains( vertex ) ) vertices.Add( vertex );
 }
Example #4
0
 public VertexCurveQualityAction( LevelVertex relevantVertex, int previousCurveQuality, int newCurveQuality )
 {
     this.relevantVertex       = relevantVertex;
         this.previousCurveQuality = previousCurveQuality;
         this.newCurveQuality      = newCurveQuality;
 }
Example #5
0
 public InsertVertexAction( LevelPolygon targetPolygon, LevelVertex precedingVertex, LevelVertex newVertex )
 {
     this.targetPolygon   = targetPolygon;
         this.precedingVertex = precedingVertex;
         this.newVertex       = newVertex;
 }
Example #6
0
 public void RemoveVertex( LevelVertex vertex )
 {
     if( vertices.Contains( vertex ) ) {
             vertices.Remove( vertex );
             calculateAverageVertexPosition();
         }
 }
Example #7
0
 /**
  * <summary>Adds a vertex to the polygon at the end of its internal vertex list, provided that
  * the specified vertex object is not already part of the polygon.</summary>
  */
 public void InsertVertex( LevelVertex vertex, LevelVertex afterVertex )
 {
     if( !vertices.Contains( afterVertex ) ) afterVertex = vertices[0];
         if( !vertices.Contains( vertex ) ) {
             vertices.Insert( vertices.IndexOf( afterVertex ) + 1, vertex );
             calculateAverageVertexPosition();
         }
 }
Example #8
0
        public LevelVertex GetPrecedingVertex( LevelVertex v )
        {
            if( ! vertices.Contains( v ) ) return null;

                int i = vertices.IndexOf( v ) - 1;

                return ( i < 0 ) ? vertices[ vertices.Count - 1 ] : vertices[ i ];
        }
Example #9
0
 /**
  * <summary>Returns true if the polygon contains the specified vertex object.</summary>
  */
 public bool ContainsVertex( LevelVertex vertex )
 {
     return vertices.Contains( vertex );
 }
Example #10
0
 /**
  * <summary>Adds a vertex to the polygon at the end of its internal vertex list, provided that
  * the specified vertex object is not already part of the polygon.</summary>
  */
 public void AddVertex( LevelVertex vertex )
 {
     if( !vertices.Contains( vertex ) ) {
             vertices.Add( vertex );
             calculateAverageVertexPosition();
         }
 }