private void CreateBreakout() { Entity breakoutManager = new Entity("Gestionnaire_CasseBriques"); breakoutManager.entity_id = _entitiesController.generator.NewID(); breakoutManager.originalImage = new Image(); breakoutManager.AddComponent(new BreakoutComponentControl(breakoutManager)); breakoutManager.originalImage.Name = "_" + breakoutManager.entity_id.ToString(); breakoutManager.canvas_image_data.image_id = breakoutManager.originalImage.Name; _entitiesController.AddCanvasEntity(breakoutManager.Name, breakoutManager); _entitiesController.generator.Update(); _mainWindow.AddEntityToList(breakoutManager); Canvas.SetLeft(breakoutManager.originalImage, breakoutManager.Transform.x); Canvas.SetTop(breakoutManager.originalImage, breakoutManager.Transform.y); breakoutManager.SetImage("pack://application:,,,/Src/letter-e124.png"); Entity breakoutBat = new Entity("Balle_CasseBriques"); breakoutBat.entity_id = _entitiesController.generator.NewID(); breakoutBat.originalImage = new Image(); breakoutBat.AddComponent(new BreakoutBatComponentControl(breakoutBat)); breakoutBat.originalImage.Name = "_" + breakoutBat.entity_id.ToString(); breakoutBat.canvas_image_data.image_id = breakoutBat.originalImage.Name; _entitiesController.AddCanvasEntity(breakoutBat.Name, breakoutBat); _entitiesController.generator.Update(); _mainWindow.AddEntityToList(breakoutBat); Canvas.SetLeft(breakoutBat.originalImage, breakoutBat.Transform.x); Canvas.SetTop(breakoutBat.originalImage, breakoutBat.Transform.y); breakoutBat.SetImage("pack://application:,,,/Src/letter-e124.png"); Entity breakoutBall = new Entity("Batte_CasseBriques"); breakoutBall.entity_id = _entitiesController.generator.NewID(); breakoutBall.originalImage = new Image(); breakoutBall.AddComponent(new BreakoutBallComponentControl(breakoutBall)); breakoutBall.originalImage.Name = "_" + breakoutBall.entity_id.ToString(); breakoutBall.canvas_image_data.image_id = breakoutBall.originalImage.Name; _entitiesController.AddCanvasEntity(breakoutBall.Name, breakoutBall); _entitiesController.generator.Update(); _mainWindow.AddEntityToList(breakoutBall); Canvas.SetLeft(breakoutBall.originalImage, breakoutBall.Transform.x); Canvas.SetTop(breakoutBall.originalImage, breakoutBall.Transform.y); breakoutBall.SetImage("pack://application:,,,/Src/letter-e124.png"); GetMetadata(PrefabEnum.BREAKOUT).entities.Add(breakoutBall); GetMetadata(PrefabEnum.BREAKOUT).entities.Add(breakoutBat); GetMetadata(PrefabEnum.BREAKOUT).entities.Add(breakoutManager); }
public void LoadScene(string name) { try { var scene = LoadFFScene(name); var rect = new System.Windows.Shapes.Rectangle(); foreach (var item in _entitiesController.CanvasValues()) { item.Select(); } _entitiesController.DeleteSelectedEntities(); _window.RemoveEntitiesFromList(_window.dataListEntities); foreach (Entities.Entity entity in scene.entities) { entity.DeserializeData(); entity.originalImage.Name = "_" + entity.entity_id.ToString(); entity.canvas_image_data.image_id = entity.originalImage.Name; _entitiesController.AddCanvasEntity(entity.Name, entity); _entitiesController.generator.Update(); _window.AddEntityToList(entity); Canvas.SetLeft(entity.originalImage, entity.Transform.x); Canvas.SetTop(entity.originalImage, entity.Transform.y); } } catch (Exception exception) { #if DEBUG throw exception; #else MessageBox.Show("Il semblerait qu'il y ait eu une erreur durant l'ouverture de votre scène.", "Erreur d'Ouverture de scène"); #endif } finally { _entitiesController.UnselectAll(); } }