示例#1
0
        public void LoadGame(FileInfo path)
        {
            NeedsSave = false;

            _workingDirectory = path.Directory;

            var files = WorkingDirectory.GetFiles("*.*", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                var asset = ViewModelLocator.AssetsTabViewModel.LoadAsset(file);
                if (file.FullName == path.FullName)
                {
                    // registers the game definition asset

                    var gameSerializer = new GameSerializer();
                    Game                   = (Game)gameSerializer.Deserialize(path.FullName);
                    Asset                  = new AssetController(AssetType.Xml);
                    asset.LockName         = true;
                    asset.IsReserved       = true;
                    Asset.SelectedAsset    = asset;
                    Asset.PropertyChanged += AssetUpdated;
                    {
                    };
                }
            }
        }
示例#2
0
 public bool UnlinkAsset(AssetController control)
 {
     if (_linkedAssets.Contains(control))
     {
         _linkedAssets.Remove(control);
         RaisePropertyChanged("LinkedAssetsCount");
         return(true);
     }
     return(false);
 }
示例#3
0
        public void CreateGame()
        {
            _workingDirectory = Directory.CreateDirectory(Path.Combine(Config.Instance.Paths.GraveyardPath, "Game"));

            var resourcePath = Path.Combine(_workingDirectory.FullName, "Assets");

            Directory.CreateDirectory(resourcePath);

            //load in some sample assets

            var back = Path.Combine(resourcePath, "back.png");

            Properties.Resources.back.Save(back);
            ViewModelLocator.AssetsTabViewModel.LoadAsset(new FileInfo(back));

            var front = Path.Combine(resourcePath, "front.png");

            Properties.Resources.front.Save(front);
            ViewModelLocator.AssetsTabViewModel.LoadAsset(new FileInfo(front));

            var hand = Path.Combine(resourcePath, "hand.png");

            Properties.Resources.hand.Save(hand);
            ViewModelLocator.AssetsTabViewModel.LoadAsset(new FileInfo(hand));

            var deck = Path.Combine(resourcePath, "deck.png");

            Properties.Resources.deck.Save(deck);
            ViewModelLocator.AssetsTabViewModel.LoadAsset(new FileInfo(deck));

            var score = Path.Combine(resourcePath, "score.png");

            Properties.Resources.score.Save(score);
            ViewModelLocator.AssetsTabViewModel.LoadAsset(new FileInfo(score));

            var background = Path.Combine(resourcePath, "background.jpg");

            Properties.Resources.background.Save(background);
            ViewModelLocator.AssetsTabViewModel.LoadAsset(new FileInfo(background));

            Game = new Game()
            {
                Id                  = Guid.NewGuid(),
                Name                = "My Game",
                Version             = new Version(1, 0, 0, 0),
                ScriptVersion       = new Version(3, 1, 0, 2),
                OctgnVersion        = typeof(Config).Assembly.GetName().Version,
                NoteBackgroundColor = "#FFEBE8C5",
                NoteForegroundColor = "#FF000000",
                Filename            = Path.Combine(WorkingDirectory.FullName, "definition.xml"),
                InstallPath         = WorkingDirectory.FullName
            };
            Game.CardSizes.Add("", new CardSize
            {
                Name   = "Default",
                Height = 88,
                Width  = 63,
                Back   = back,
                Front  = front
            });

            var gameAsset = ViewModelLocator.AssetsTabViewModel.NewAsset(new string[] { }, "definition", ".xml");

            gameAsset.LockName   = true;
            gameAsset.IsReserved = true;
            Asset = new AssetController(AssetType.Xml);
            Asset.SelectedAsset    = gameAsset;
            Asset.PropertyChanged += AssetUpdated;

            livesInTempDirectory = true;
        }