예제 #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);

        }
예제 #2
0
        public bool Collision(Victor victor)
        {
            //if (!Session.verification_item(Name))
                foreach (var rectangleVictor in victor.Rectangle)
                {
                    if (_rectangle.Intersects(rectangleVictor))
                        return true;
                }
            return false;

        }
예제 #3
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);
        }
예제 #4
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);

            mp3.IsMuted = true;


            //On parse 
            var data = this.NavigationContext.QueryString;
            id = int.Parse(data["id"]);

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

            // Créer un nouveau SpriteBatch, qui peut être utilisé pour dessiner des textures.
            spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);

            // TODO: utilisez ce contenu pour charger ici le contenu de votre jeu
            //On récupère la Photo
            dbc = new DataBaseContext(DataBaseContext.DBConnectionString);
            var photo = from album in dbc.Photos
                        where album.Id == int.Parse(this.NavigationContext.QueryString["id"])
                        select album;

            img = new BitmapImage();

            using (IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (isoStorage.FileExists(photo.First().Background))
                {
                    using (IsolatedStorageFileStream fileStream = isoStorage.OpenFile(photo.First().Background, FileMode.Open, FileAccess.Read))
                    {
                        img.SetSource(fileStream);
                        fileStream.Close();
                    }
                }
            }

            imgRendu.Source = img;

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



            /**
                 * LES OBJETS
                **/
            lstInteractionsPhotos = new List<InteractionPhoto>();

            var images = from image in dbc.InteractionsPhotos
                         where image.PhotoId == int.Parse(this.NavigationContext.QueryString["id"])
                         select image;




            texture_InteractionsPhotos = new List<Image_TexturePhoto>();

            foreach (var interaction in images)
            {
                texture_InteractionsPhotos.Add(new Image_TexturePhoto(interaction.QuestionId, interaction.Question.Nom, new Vector2((float)interaction.X/512 * 800, (float)interaction.Y/307 * 480), (int)((float)interaction.Longueur/512 * 800), (int)((float)interaction.Hauteur/307 * 480)));
                  

                //Créé fonction qui permet d'ajouter une image dans la classe image_interaction
                /*if (i != interaction.Id)
                {
                    if (interaction.Id != images.First().Id)
                    {
                        textureTmp.LoadContent((Application.Current as App).Content);
                        texture_InteractionsPhotos.Add(textureTmp);
                    }
                    textureTmp = new Image_Texture(interaction.QuestionId, interaction.Question.Nom, interaction.Url, new Vector2(interaction.X, interaction.Y), interaction.Longueur, interaction.Hauteur);

                }
                else
                {*/
                //texture_InteractionsPhotos.Add(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.
                //}
            }
            foreach (Image_TexturePhoto interaction in texture_InteractionsPhotos)
            {
                interaction.LoadContent(contentManager);
            }

            dbc.Dispose();


            _victor = new Victor("marche", new Vector2(100,300));
            _victor.LoadContent(contentManager);




            _collision = false;
            click_souris = false;


            /*_retour = new Image_Texture(-1, "retour", "previous", new Vector2(0, 0), 50, 50);
            _retour.LoadContent(contentManager);
            */


            if(!first)
            {
                TouchPanel.EnabledGestures = GestureType.Tap;
                souris.X = 200;
                souris.Y = 300;


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

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



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

            base.OnNavigatedTo(e);
        }