示例#1
0
        public LevelView(GameData data)
        {
            InitializeComponent();

            this.data = data;

            refresh();
            resizeWindow(data.XGameArea, data.YGameArea);
        }
示例#2
0
文件: GameArea.cs 项目: Cendrb/Arman
        public override void Initialize()
        {
            dataLoader = new DataLoader(levelSourcePath);

            data = dataLoader.ReadData(true);

            gameComponents = new World(Game, data);

            base.Initialize();
        }
示例#3
0
文件: GameData.cs 项目: Cendrb/Arman
 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;
 }
示例#4
0
        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();
        }
示例#5
0
 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);
     }
 }
示例#6
0
 public GameData ReadData(bool forceReload)
 {
     if (forceReload || data == null)
     {
         data = loadData();
     }
     return data;
 }
示例#7
0
 private void undo()
 {
     try
     {
         data = dataStack.Pop();
     }
     catch (InvalidOperationException e)
     {
         changesSaved = true;
         MessageBox.Show("Nothing left to undo!", "Undo not possible");
     }
     zPressed = false;
     refresh();
 }
示例#8
0
 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;
 }
示例#9
0
 public Detector(GameData data)
 {
     InitializeComponent();
     this.data = data;
 }