예제 #1
0
        public GameWindow(Rectangle rect) : base(rect)
        {
            Resizable = false;

            //in this case we want use a remote file provider (figma url from our document)
            var fileProvider = new RemoteNodeProvider();

            fileProvider.Load("Jv8kwhoRsrmtJDsSHcTgWGYu");

            //we initialize our renderer service, this uses all the converters passed
            //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel>

            var rendererService = new ViewRenderService(fileProvider);

            //play background music
            backgroundMusic = new MusicPlayer("Background", "mp3");
            backgroundMusic.Play(-1);

            coinSound     = new MusicPlayer("Coin", "mp3");
            gameOverSound = new MusicPlayer("GameOver", "mp3");

            //we want load the entire level 1
            rendererService.RenderInWindow(this, "Level1");

            playerTile = rendererService.FindViewStartsWith <IImageView>("Player");

            startingPoint = playerTile.Allocation.Origin;

            pointsLabel = rendererService.FindViewByName <ILabel>("Points");
            gemsTiles   = rendererService.FindViewsStartsWith <IImageView>("Gem")
                          .ToList();
            wallTiles = rendererService.FindViewsStartsWith <IImageView>("Tile")
                        .ToArray();
            spikesTiles = rendererService.FindViewsStartsWith <IImageView>("Spikes")
                          .ToArray();
            heartTiles = rendererService.FindViewsStartsWith <IImageView>("Heart")
                         .OrderBy(s => s.Allocation.X)
                         .ToList();

            WorldUpdate();
        }