public LevelView(GameData data) { InitializeComponent(); this.data = data; refresh(); resizeWindow(data.XGameArea, data.YGameArea); }
public override void Initialize() { dataLoader = new DataLoader(levelSourcePath); data = dataLoader.ReadData(true); gameComponents = new World(Game, data); base.Initialize(); }
public GameData Clone() { GameData newGameData = new GameData(); newGameData.Blocks = this.Blocks.ToList(); newGameData.Entities = this.Entities.ToList(); newGameData.Name = Name; newGameData.Speed = Speed; newGameData.XGameArea = XGameArea; newGameData.YGameArea = YGameArea; newGameData.Objectives = Objectives.Clone(); return newGameData; }
public MainWindow() { InitializeComponent(); data = new GameData(); dataStack = new Stack<GameData>(); data.OneBlockSize = 20; firstPosition = new PositionInGrid(0); secondPosition = new PositionInGrid(0); blocksLayerCheckBox.IsChecked = true; entitiesLayerCheckBox.IsChecked = true; activateDetectors.IsChecked = true; collectCoins.IsChecked = false; getHome.IsChecked = false; disableControlsForLevel(); }
public void SaveData(GameData data) { try { GameData newData = data.Clone(); newData.Blocks.RemoveAll(filterAir); XmlSerializer serializer = new XmlSerializer(typeof(GameData)); XmlTextWriter writer = new XmlTextWriter(Path, Encoding.UTF8); serializer.Serialize(writer, newData); writer.Close(); } catch (Exception e) { MessageBox.Show(String.Format("Game file ({0}) could not be saved. - {1}", Path, e.Message), "Save error"); MessageBox.Show(e.InnerException.Message); MessageBox.Show(e.InnerException.InnerException.Message); MessageBox.Show(e.InnerException.InnerException.Message); MessageBox.Show(e.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.InnerException.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.InnerException.InnerException.InnerException.InnerException.InnerException.Message); } }
public GameData ReadData(bool forceReload) { if (forceReload || data == null) { data = loadData(); } return data; }
private void undo() { try { data = dataStack.Pop(); } catch (InvalidOperationException e) { changesSaved = true; MessageBox.Show("Nothing left to undo!", "Undo not possible"); } zPressed = false; refresh(); }
private bool load() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Arman level files (*.alvl)|*.alvl|All files (*.*)|*.*"; dialog.Title = "Choose level file to load"; string fileName = String.Empty; if (dialog.ShowDialog().Value) fileName = dialog.FileName; if (fileName != String.Empty) { dataLoader = new DataLoader(fileName); data = dataLoader.ReadData(true); resizeWindow(data.XGameArea, data.YGameArea); refresh(); this.Title = "Arman Level Editor - " + data.Name; changesSaved = true; enableControlsForLevel(); activateDetectors.IsChecked = data.Objectives.ActivateDetectors; collectCoins.IsChecked = data.Objectives.CollectAllCoins; getHome.IsChecked = data.Objectives.GetHome; return true; } return false; }
public Detector(GameData data) { InitializeComponent(); this.data = data; }