Beispiel #1
0
        public Mario()
        {
            InitializeComponent();

            // Obtenir le gestionnaire de contenu à partir de l'application
            contentManager = (Application.Current as App).Content;
            map1 = new Map("Images/Mario/backgroundMario");
            _obstacle = new List<Obstacle>();

            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(1400,350,80,80)));
            
            //_obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(1460, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(1840, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(1920, 350, 80, 80)));
            //_obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(1920, 300, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(2600, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(2680, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(2760, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(2840, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(2920, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3000, 270, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3080, 270, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3160, 270, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3240, 270, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3400, 190, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3480, 190, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(3560, 190, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(4400, 350, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(5000, 190, 80, 80)));
            _obstacle.Add(new Obstacle("Images/Mario/bloc", new Rectangle(5500, 350, 80, 80)));

            // Créez une minuterie pour cette page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(133333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;
            _victorCourt = new Victor("marche", new Vector2(500, 280));
            _bouteilleCourt = new BouteilleCours("Images/Mario/bidon", new Vector2(30, 140), 6);

        }
Beispiel #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Définissez le mode de partage de l'appareil graphique pour activer le rendu XNA
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

            if (sonPremiere)
            {
                mp3.IsMuted = false;
                mp3.Source = new Uri("/MP3/Home/Menu/HomeMenu.mp3", UriKind.Relative);
                mp3.Position = new TimeSpan(0);
                mp3.Volume = 1;
                mp3.Play();
                sonPremiere = false;
            }
            else
			mp3.IsMuted = true;
            // Créer un nouveau SpriteBatch, qui peut être utilisé pour dessiner des textures.
            spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);

            question = new Question();
            gridBlanc.Margin = new Thickness(900);
            gridBlanc.Width = 0;

            if (first == true)
            {
                // TODO: utilisez ce contenu pour charger ici le contenu de votre jeu

                //On récupère le niveau et la scène
                var data = this.NavigationContext.QueryString;

                niveau = data["niveau"];
                lvl = data["scene"];

                //Connexion à la BDD
                dbc = new DataBaseContext(DataBaseContext.DBConnectionString);

                /**
                 * BACKGROUND
                **/
                //On récupère l'arrière plan de la scène
                var bg = from scene in dbc.Scenes
                         where scene.Nom == lvl
                         select scene;

                //On affecte
                background = (Application.Current as App).Content.Load<Texture2D>(bg.First().Background);
                positionBackground = Vector2.Zero;

                //Debug, indication des coordonnées du pointeur
                font = (Application.Current as App).Content.Load<SpriteFont>(@"SpriteFont1");

                /**
                 * LES OBJETS
                **/
                lstImage_Interactions = new List<Interaction>();

                var images = from image in dbc.Interactions
                                   where image.Scene.Nom == lvl
                                   select image;               

                /**
                 * RENDU
                **/

                int i = -1;
                Image_Texture textureTmp = new Image_Texture();
                texture_Interactions = new List<Image_Texture>();

                foreach (var interaction in images)
                {
                    //Si l'interaction n'a pas encore d'image 
                    //Créé fonction qui permet d'ajouter une image dans la classe image_interaction
                    if(i != interaction.Id)
                    {
                        if(interaction.Id != images.First().Id)//Si il y a eu une interaction avant, on lance le loader
                        {
                            textureTmp.LoadContent(contentManager);
                            texture_Interactions.Add(textureTmp);
                        }
                        textureTmp = new Image_Texture(interaction.QuestionId, interaction.Question.Nom, interaction.Url, new Vector2(interaction.X, interaction.Y), interaction.Longueur, interaction.Hauteur);
                        
                    }
                    else//Si l'interaction à deja une image ou plusieurs, on rajoute une image
                    {
                        textureTmp.AjoutTexture(interaction.Url, new Vector2(interaction.X, interaction.Y), interaction.Longueur, interaction.Hauteur, (Application.Current as App).Content);
                        //Ajouter une image a l'objet Image_interaction crée précédement.
                    }
                    i = interaction.Id;

                }
                if (images.Count() != 0)//Si il y a des interactions, il faut lancer le content pour la dernière interaction et l'ajouter a la liste
                {
                    textureTmp.LoadContent(contentManager);
                    texture_Interactions.Add(textureTmp);
                }

                //On s'occupe de la lampe
                _lampe = new Image_Texture(-1, "lampe_cuisine", "lampe_cuisine", new Vector2(1250, 0), 130, 258);
                _lampe.LoadContent(contentManager);

                _rotationLampe = 0;
                _deltaRotationLampe = 10;
                _directionLampe = true;


                //On s'occupe des aiguilles
                _petiteAiguille = new Image_Texture(-1, "petite_aiguille", "aiguille-p", new Vector2(379, 43), 3, 12);
                _petiteAiguille.LoadContent(contentManager);
                _rotationGrandeAiguille = 180;

                _grandeAiguille = new Image_Texture(-1, "grande_aiguille", "aiguille-g", new Vector2(379, 43), 3, 23);
                _grandeAiguille.LoadContent(contentManager);
                _rotationPetiteAiguille = 180;



                //On s'occupe de la flamme
                _flammesSprite = new BouteilleCours("FlammesSprites", new Vector2(860, 290), 4);
                _flammesSprite.LoadContent(contentManager);

                /**
                 * FERMETURE BDD
                **/
                dbc.Dispose();

                _uiRenderer = new UIElementRenderer(gridLayout, SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Width, SharedGraphicsDeviceManager.Current.GraphicsDevice.Viewport.Height);

                /**
                 * LES INTERACTIONS
                **/
                TouchPanel.EnabledGestures = GestureType.Tap;

                /**
                 * AUTRES
                **/

                _victor = new Victor("marche", new Vector2(200, 300));


                    _victor.LoadContent(contentManager);
                

                first = false;
            }
            //On replace victor au milieu de l'écran
            else
            {
                TouchPanel.EnabledGestures = GestureType.Tap;
                souris.X = 200;
                souris.Y = 300;
                _destinationSouris.X = 200;
                _destinationSouris.Y = 300;


                    Vector2 tmpVector = new Vector2(200, 300);
                    _victor.Position = tmpVector;
                    _victor.repositionnement();
            }

            _puzzleTexture = contentManager.Load<Texture2D>("puzzle1");
            _puzzle = new Rectangle(900, 900, 0, 0);
            Session.isPuzzleCuisineAvailable();
            _puzzleApparition = 50;
            _collision = false;
            //_retour = new Image_Texture(-1, "retour", "previous", new Vector2(0, 0), 50, 50);
            //_retour.LoadContent(contentManager);

            // Démarrez la minuterie
            timer.Start();

            base.OnNavigatedTo(e);
        }