public frmTextureSelect( SkiStuntLevel level, LevelPolygon polygon ) { InitializeComponent(); this.level = level; this.polygon = polygon; if( polygon.TextureID < 0 ) { curTexIndex = 0; radColor.Select(); } else { curTexIndex = polygon.TextureID; radTexture.Select(); } resetTextboxValues(); redrawPreviewBox(); }
/** * <summary>Removes a polygon from the level.</summary> * <param name="polygon">Polygon to remove from the level.</param> */ public void RemovePolygon( LevelPolygon polygon ) { if( ! polygons.Contains( polygon ) ) return; polygons.Remove( polygon ); polygon.StopListeningToTextureList( textureList ); for( int i = 0 ; i < polygon.VertexCount ; ++i ) { LevelVertex v = polygon.GetVertex( i ); bool usedElsewhere = false; foreach( LevelPolygon p in polygons ) { if( p.ContainsVertex( v ) ) { usedElsewhere = true; break; } } if( !usedElsewhere ) vertices.Remove( v ); } }
/** * <summary>Moves a polygon to be rendered in the front of the level.</summary> */ public void MovePolygonToFront( LevelPolygon polygon ) { if( !polygons.Contains( polygon ) ) return; polygons.Remove( polygon ); polygons.Add( polygon ); }
/** * <summary>Moves a polygon to be rendered behind all the others in the level.</summary> */ public void MovePolygonToBack( LevelPolygon polygon ) { if( !polygons.Contains( polygon ) ) return; polygons.Remove( polygon ); polygons.Insert( 0, polygon ); }
/** * <summary>Moves a polygon to be rendered in front of the polygon ahead of it of the level.</summary> */ public void MovePolygonForward( LevelPolygon polygon ) { if( !polygons.Contains( polygon ) ) return; int originalIndex = polygons.IndexOf( polygon ); if( originalIndex == polygons.Count - 1 ) return; polygons.Remove( polygon ); polygons.Insert( originalIndex + 1, polygon ); }
/** * <summary>Moves a polygon to be rendered behind the polgon behind it in the level.</summary> */ public void MovePolygonBackward( LevelPolygon polygon ) { if( !polygons.Contains( polygon ) ) return; int originalIndex = polygons.IndexOf( polygon ); if( originalIndex == 0 ) return; polygons.Remove( polygon ); polygons.Insert( originalIndex - 1, polygon ); }
/** * <summary>Adds a polygon to the level's set of total polygons if the polygon is not already * a part of the level.</summary> * <param name="polygon">Polygon to add to the level.</param> */ public void AddPolygon( LevelPolygon polygon ) { if( polygons.Contains( polygon ) ) return; polygons.Add( polygon ); polygon.ListenToTextureList( textureList ); for( int i = 0 ; i < polygon.VertexCount ; ++i ) { AddVertex( polygon.GetVertex( i ) ); } }
public static SkiStuntLevel LoadFolder( string folder ) { SkiStuntLevel level = new SkiStuntLevel( folder ); if( ! File.Exists( folder + "\\studioFile.txt" ) ) return level; StreamReader studioFile = new StreamReader( folder + "\\studioFile.txt", false ); level.LevelTitle = studioFile.ReadLine(); level.GoalText = studioFile.ReadLine(); level.HintText = studioFile.ReadLine(); level.PlayerStart.x = float.Parse( studioFile.ReadLine() ); level.PlayerStart.y = float.Parse( studioFile.ReadLine() ); level.endzoneA.x = float.Parse( studioFile.ReadLine() ); level.endzoneA.y = float.Parse( studioFile.ReadLine() ); level.endzoneB.x = float.Parse( studioFile.ReadLine() ); level.endzoneB.y = float.Parse( studioFile.ReadLine() ); level.EndzoneRequirements = (EndzoneRequirementType)uint.Parse( studioFile.ReadLine() ); int vertexCount = int.Parse( studioFile.ReadLine() ); for( int i = 0 ; i < vertexCount ; ++i ) { level.vertices.Add( new LevelVertex ( float.Parse( studioFile.ReadLine() ), float.Parse( studioFile.ReadLine() ), int .Parse( studioFile.ReadLine() ) )); } int polygonCount = int.Parse( studioFile.ReadLine() ); for( int i = 0 ; i < polygonCount ; ++i ) { LevelPolygon p = new LevelPolygon(); p.Friction = float.Parse( studioFile.ReadLine() ); p.Bounce = float.Parse( studioFile.ReadLine() ); p.Solidity = float.Parse( studioFile.ReadLine() ); p.SolidAtAll = bool.Parse( studioFile.ReadLine() ); p.TextureID = int.Parse( studioFile.ReadLine() ); if( p.TextureID >= 0 ) { p.TextureOffsetX = float.Parse( studioFile.ReadLine() ); p.TextureOffsetY = float.Parse( studioFile.ReadLine() ); p.TextureScaleX = float.Parse( studioFile.ReadLine() ); p.TextureScaleY = float.Parse( studioFile.ReadLine() ); } else { p.Color = Color.FromArgb( int.Parse( studioFile.ReadLine() ) ); } int polyVertCount = int.Parse( studioFile.ReadLine() ); for( int j = 0 ; j < polyVertCount ; ++j ) { p.AddVertex( level.vertices[ int.Parse( studioFile.ReadLine() ) ] ); } level.AddPolygon( p ); } int objectCount = int.Parse( studioFile.ReadLine() ); for( int i = 0 ; i < objectCount ; ++i ) { LevelObject o = new LevelObject(); o.x = float.Parse( studioFile.ReadLine() ); o.y = float.Parse( studioFile.ReadLine() ); o.rotation = float.Parse( studioFile.ReadLine() ); o.type = (LevelObject.ObjectType)uint.Parse( studioFile.ReadLine() ); o.anchor = (LevelObject.AnchorType)uint.Parse( studioFile.ReadLine() ); level.AddObject( o ); } studioFile.Close(); return level; }
public DeletePolygonAction( LevelPolygon relevantPolygon ) { this.relevantPolygon = relevantPolygon; }
public CreatePolygonAction( LevelPolygon newPolygon ) { this.newPolygon = newPolygon; }
public InsertVertexAction( LevelPolygon targetPolygon, LevelVertex precedingVertex, LevelVertex newVertex ) { this.targetPolygon = targetPolygon; this.precedingVertex = precedingVertex; this.newVertex = newVertex; }
/** * <summary> * This function will generate a polygon from a set of points described in the format Ski Stunt Simulator uses (GND.TXT / GND.PTS). * It can be used to import an existing level shape, or a single polygon from another Studio level. * </summary> */ public static LevelPolygon CreateFromFile( string path ) { char[] separators = { ' ', '\t' }; string[] curLine; int curLegitIndex; float curReadX = 0.0f; LevelPolygon ret = new LevelPolygon(); using( StreamReader s = new StreamReader( path ) ) { while( !s.EndOfStream ) { curLegitIndex = 0; curLine = s.ReadLine().Split( separators ); for( int i = 0 ; i < curLine.Length ; ++i ) { if( curLine[i].Length == 0 ) continue; switch( curLegitIndex++ ) { case 0: curReadX = float.Parse( curLine[i] ); break; case 1: ret.AddVertex( new LevelVertex( curReadX, -float.Parse( curLine[i] ) ) ); break; case 2: ret.Friction = float.Parse( curLine[i] ); break; } } } s.Close(); } return ret; }