public FormSimpleAnimation(List <GraphicObjects> objects) { //Set Styles for Painting without "Flackern" SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); //Initate the Displayed Objects and the Player gobjects = new List <GraphicObjects>(objects); player_graph = gobjects[0]; gobjects.RemoveAt(0); //Initialate the Form InitializeComponent(); //Führt das SizeChanged Commando Zur Initalisierung der Labels und ihrer Beschriftung durch (ALternative: Labels Direkt Angeben was sie am Anfang machen sollen) //Entfernung des Ursprünglichen Codes zur Verhinderung von Code Duplezierung FormSimpleAnimation_SizeChanged(null, null); //Starte FPS_display fps_display_start(lblFPS); //Random Change the Direction of Objects randomDirectionChangeTimerforRandomObject(); // Datenobjekte initialisieren player_obj = new Player_PlayerOne(0, "Spieler"); writePlayerHp(player_obj.HP); }
private Error loadFile(String fileName) { XmlReaderSettings readerSettings = new XmlReaderSettings(); XmlReader reader = XmlReader.Create(fileName); String type = null; Color color = Color.Red; SolidBrush color_brush = null; int width = 0; int hight = 0; String startDirection = null; Direction startMovingDirection; String[] startPosition = null; //Read the tags out of the File in Strings while (reader.Read()) { if (reader.IsEmptyElement) { //damit weniger Überprüfungen Stattfinden müssen... } else { switch (reader.Name) { case "Type": type = (reader.ReadString()).ToLower(); break; case "Color": color = Color.FromName(reader.ReadString().ToLower()); break; case "Width": width = Int32.Parse(reader.ReadString()); break; case "Hight": hight = Int32.Parse(reader.ReadString()); break; case "StartDirection": startDirection = (reader.ReadString()).ToLower(); break; case "StartPosition": startPosition = (reader.ReadString()).ToLower().Split(','); break; } } } //Interpret the tags int start_x = Int32.Parse(startPosition[0]); int start_y = Int32.Parse(startPosition[1]); color_brush = new SolidBrush(color); switch (startDirection) { case "up": startMovingDirection = Direction.Up; break; case "down": startMovingDirection = Direction.Down; break; case "left": startMovingDirection = Direction.Left; break; case "right": startMovingDirection = Direction.Right; break; case "upleft": startMovingDirection = Direction.Up_Left; break; case "upright": startMovingDirection = Direction.Up_Right; break; case "downleft": startMovingDirection = Direction.Down_Left; break; case "downright": startMovingDirection = Direction.Down_Right; break; default: startMovingDirection = Direction.Down; break; } //Construct the new Graphic Object GraphicObjects gobject = null; switch (type) { case "rectangle": gobject = new GraphicObjectRectangle(start_x, start_y, width, hight, startMovingDirection, color_brush); break; case "ellipse": gobject = new GraphicObjectEllipse(start_x, start_y, width, hight, startMovingDirection, color_brush); break; } if (gobject != null) { graphicObjects.Add(gobject); } return(Error.okay); }