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); // 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 //background = contentManager.Load<Texture2D>(""); saut = false; _grillepainDerriere = new Image_Texture(0, "grillepain_MiniJeu", "grille-pain-derriere", new Vector2(140, 380), 200, 87); _grillepainDerriere.LoadContent(contentManager); _grillepainDevant = new Image_Texture(0, "grillepain_MiniJeu", "grille-pain-devant", new Vector2(140, 380), 200, 87); _grillepainDevant.LoadContent(contentManager); _grillepainManette = new Image_Texture(0, "grillepainManette_MiniJeu", "grillepainManette", new Vector2(140, 380), 200, 87); _grillepainManette.LoadContent(contentManager); _tartine = new Image_Texture(0, "tartine_MiniJeu", "tartine", new Vector2(242, 415), 75, 70); _tartine.LoadContent(contentManager); vitesse = new Vector2(1, -18 - generator.Next(16)); if (generator.Next(2) == 1) vitesse.X = generator.Next(4); else vitesse.X = -generator.Next(4); manette = 40; _fini = false; _soundEffect = contentManager.Load<SoundEffect>(@"grillepainSon"); //on parse var data = this.NavigationContext.QueryString; recreation = bool.Parse(data["recreation"]); if (!recreation) { scene = data["scene"]; niveau = data["niveau"]; } //Background _textureBackground = contentManager.Load<Texture2D>(@"Background"); //Nombre de tartine attrapé nbTartine = 0; debut = true; // Démarrez la minuterie timer.Start(); base.OnNavigatedTo(e); }
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); // 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 //background = contentManager.Load<Texture2D>(""); _casserole = new Image_Texture(0, "casserole_MiniJeu", "casserole1" , new Vector2(400, 380), 194, 82); _casserole.LoadContent(contentManager); _jauge = new Image_Texture(0, "jauge_MiniJeu", "jauge", new Vector2(740, 100), 40, 170); _jauge.LoadContent(contentManager); _jaugeInterieur = new Rectangle(745 , 269 , _jauge.Rectangle.First().Width-10, -2); _glacons = new List<Image_Texture>(); for (int i = 0; i < 10; i++) { _glacons.Add(new Image_Texture(0, "glacon_MiniJeu", "glacon" , new Vector2(-50,-50), 50,50)); _glacons.ElementAt(i).LoadContent(contentManager); } _numeroGlacon = 0; _glaconCapture = 0; _fini = false; TouchPanel.EnabledGestures = GestureType.FreeDrag | GestureType.Tap; _affichageGlaconCapture = contentManager.Load<SpriteFont>(@"SpriteFont1"); _affichageTempsRestant = contentManager.Load<SpriteFont>(@"SpriteFont1"); _tempsRestant = TimeSpan.Zero; _soundEffect = contentManager.Load<SoundEffect>(@"casseroleSon"); //On parse var data = this.NavigationContext.QueryString; recreation = bool.Parse(data["recreation"]); if (!recreation) { scene = data["scene"]; niveau = data["niveau"]; } //Background _textureBackground = contentManager.Load<Texture2D>(@"Background"); debut = true; // Démarrez la minuterie timer.Start(); base.OnNavigatedTo(e); }
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); // 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 //background = contentManager.Load<Texture2D>(""); //On valide la question _bouteille = new Image_Texture(0, "bouteille_MiniJeu", "bouteille", new Vector2(7, 100), 446, 600); _bouteille.LoadContent(contentManager); _bouchon = new Image_Texture(0, "bouchon_MiniJeu", "bouchon", new Vector2(118, 5), 80, 87); _bouchon.LoadContent(contentManager); _bouchonTexture = contentManager.Load<Texture2D>("bouchon1"); _bouchonRectangleSource = new Rectangle(0, 0, _bouchonTexture.Width / 6, _bouchonTexture.Height); _bouchonRectangleDestination = new Rectangle(124, 20, 70,64); TouchPanel.EnabledGestures = GestureType.HorizontalDrag; _affichageTempsRestant = contentManager.Load<SpriteFont>(@"SpriteFont1"); _fini = false; //On parse var data = this.NavigationContext.QueryString; recreation = bool.Parse(data["recreation"]); if (!recreation) { scene = data["scene"]; niveau = data["niveau"]; } // Démarrez la minuterie timer.Start(); base.OnNavigatedTo(e); }
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); // 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 _couteau = new Image_Texture(0, "couteau_MiniJeu", "couteau", new Vector2(7, 100), 10, 60); _couteau.LoadContent(contentManager); _labyrinthe = contentManager.Load<Texture2D>("labyrinthe"); _labyrintheRectangleSource = new Rectangle(125, 100, _labyrinthe.Width, _labyrinthe.Height); next = new List<Image_Texture>(); next.Add(new Image_Texture(0, "next_MiniJeu", "next", new Vector2(84, 108-40/2), 40, 40)); next.Add(new Image_Texture(0, "next_MiniJeu", "next", new Vector2(84, 188 - 40 / 2), 40, 40)); next.Add(new Image_Texture(0, "next_MiniJeu", "next", new Vector2(84, 267 - 40 / 2), 40, 40)); next.Add(new Image_Texture(0, "next_MiniJeu", "next", new Vector2(84, 347 - 40 / 2), 40, 40)); foreach (var image in next) image.LoadContent(contentManager); TouchPanel.EnabledGestures = GestureType.Tap; _tableau = new int[4]; _tableau[0] = 2; _tableau[1] = 3; _tableau[2] = 1; _tableau[3] = 0; _solution = generator.Next(4); _position = contentManager.Load<SpriteFont>(@"SpriteFont1"); if (generator.Next(2) == 1) { effet1 = SpriteEffects.FlipHorizontally; int[] tmpTableau = (int[])_tableau.Clone(); for(int i = 0; i < 4; i++) _tableau[tmpTableau[i]] = i; } else { effet1 = SpriteEffects.None; } if (generator.Next(2) == 1) { effet2 = SpriteEffects.FlipVertically; int[] tmpTableau = (int[])_tableau.Clone(); for (int i = 0; i < 4; i++) _tableau[3-i] = 3 - tmpTableau[i]; } else { effet2 = SpriteEffects.None; } switch (_tableau[_solution]) { case 0: _etui = new Image_Texture(0, "etui_MiniJeu", "etui", new Vector2(645, 108-100/2), 66, 100); break; case 1: _etui = new Image_Texture(0, "etui_MiniJeu", "etui", new Vector2(645, 188-100/2), 66, 100); break; case 2: _etui = new Image_Texture(0, "etui_MiniJeu", "etui", new Vector2(645, 267-100/2), 66, 100); break; case 3: _etui = new Image_Texture(0, "etui_MiniJeu", "etui", new Vector2(645, 347-100/2), 66, 100); break; } _etui.LoadContent(contentManager); _fini = false; //on parse var data = this.NavigationContext.QueryString; recreation = bool.Parse(data["recreation"]); if (!recreation) { scene = data["scene"]; niveau = data["niveau"]; } //Background _textureBackground = contentManager.Load<Texture2D>(@"Background"); debut = true; // Démarrez la minuterie timer.Start(); base.OnNavigatedTo(e); }
/// <summary> /// Permet à la page d'exécuter la logique, comme par exemple mettre à jour le monde, /// contrôler les collisions, collecter les données d'entrée, et lire le son. /// </summary> private void OnUpdate(object sender, GameTimerEventArgs e) { if (_collision) { if (gridBlanc.Width == 720) { if (txtQuestion.Visibility == Visibility.Collapsed) { //Audio mp3.IsMuted = false; mp3.Play(); txtQuestion.Visibility = Visibility.Visible; } } else { gridBlanc.Width += 36; gridBlanc.Height += 20; gridBlanc.Margin = new Thickness(gridBlanc.Margin.Left - 18, gridBlanc.Margin.Top - 10, 0, 0); } } else { if (!_collision) { if (Session.cuisine_puzzle == true) { if (_puzzleApparition > 0) { _puzzle.Width += 5; _puzzle.Height += 4; _puzzleApparition--; } _puzzle.X = 400 - _puzzle.Width / 2; _puzzle.Y = 230 - _puzzle.Height / 2; } if (TouchPanel.IsGestureAvailable) { //MouseState state = Mouse.GetState(); GestureSample state = TouchPanel.ReadGesture(); if (state.GestureType == GestureType.Tap) { mouseStatus = string.Format("{0} ; {1}", state.Position.X, state.Position.Y); souris.X = state.Position.X; souris.Y = state.Position.Y; _destinationSouris.X = state.Position.X; if (state.Position.Y < 245) { _destinationSouris.Y = 245; } else if (state.Position.Y > 320) { _destinationSouris.Y = 320; } else { _destinationSouris.Y = state.Position.Y; } click_souris = true; } /*if (_retour.Rectangle.First().X <= state.Position.X && _retour.Rectangle.First().X + _retour.Rectangle.First().Width >= state.Position.X && _retour.Rectangle.First().Y <= state.Position.Y && _retour.Rectangle.First().Y + _retour.Rectangle.First().Height >= state.Position.Y) { NavigationService.Navigate(new Uri("/Adventure/Home/HomeMenu.xaml", UriKind.Relative)); } else*/ if (Session.cuisine_puzzle == true && _puzzle.X <= state.Position.X && _puzzle.X + _puzzle.Width >= state.Position.X && _puzzle.Y <= state.Position.Y && _puzzle.Y + _puzzle.Height >= state.Position.Y) { NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } } if (click_souris) { _victor.Update(new GameTime(e.TotalTime, e.ElapsedTime), SharedGraphicsDeviceManager.Current, _destinationSouris); foreach (var texture in texture_Interactions) { int cpt = 0; foreach (var position in texture.Position) { if (souris.X >= position.X && souris.X <= position.X + texture.Rectangle.ElementAt(cpt).Width && souris.Y >= position.Y && souris.Y <= position.Y + texture.Rectangle.ElementAt(cpt).Height) { _collision = texture.Collision(_victor);// && texture.CollisionParPixel(image); if (_collision) { mouseStatus = "collision"; TouchPanel.EnabledGestures = GestureType.None; _collisionTexture = texture; img_Tap(texture); //timer.Stop(); //image.retour(); return; } } cpt++; } } } else { _victor.Update(new GameTime(e.TotalTime, e.ElapsedTime), SharedGraphicsDeviceManager.Current); } } if (_victor.Position.X > 600 && positionBackground.X + background.Width > 800) { if (positionBackground.X - _victor.Position.X - 200 < -background.Width) { _victor.deplacement(new Vector2(positionBackground.X - _victor.Position.X - 200 + background.Width, 0)); } foreach (Image_Texture intera in texture_Interactions) { intera.Deplacement(new Vector2(600 - _victor.Position.X, 0)); } _lampe.Deplacement(new Vector2(600 - _victor.Position.X, 0)); _grandeAiguille.Deplacement(new Vector2(600 - _victor.Position.X, 0)); _petiteAiguille.Deplacement(new Vector2(600 - _victor.Position.X, 0)); _flammesSprite.deplacement(new Vector2(600 - _victor.Position.X, 0)); souris.X += 600 - _victor.Position.X; _destinationSouris.X += 600 - _victor.Position.X; positionBackground.X += 600 - _victor.Position.X; _victor.deplacement(new Vector2(600 - _victor.Position.X, 0)); } else if (_victor.Position.X < 200 && positionBackground.X < 0) { if (positionBackground.X - (_victor.Position.X - 200) > 0) { _victor.deplacement(new Vector2((positionBackground.X - (_victor.Position.X - 200)), 0)); } foreach (Image_Texture intera in texture_Interactions) { intera.Deplacement(new Vector2(200 - _victor.Position.X, 0)); } _lampe.Deplacement(new Vector2(200 - _victor.Position.X, 0)); _grandeAiguille.Deplacement(new Vector2(200 - _victor.Position.X, 0)); _petiteAiguille.Deplacement(new Vector2(200 - _victor.Position.X, 0)); _flammesSprite.deplacement(new Vector2(200 - _victor.Position.X, 0)); souris.X += 200 - _victor.Position.X; _destinationSouris.X += 200 - _victor.Position.X; positionBackground.X += 200 - _victor.Position.X; _victor.deplacement(new Vector2(200 - _victor.Position.X, 0)); } //On fait bouger la flamme _flammesSprite.UpdateFixe(new GameTime(e.TotalTime, e.ElapsedTime)); //On fait bouger la lampe _elapsedGameTimeLampe += new GameTime(e.TotalTime, e.ElapsedTime).ElapsedGameTime; if (_elapsedGameTimeLampe.TotalMilliseconds >= 60) { _elapsedGameTimeLampe = TimeSpan.Zero; if (_rotationLampe >= 0) { if (!_directionLampe) { _deltaRotationLampe = 10; _directionLampe = true; } _deltaRotationLampe -= 1; } else { if (_directionLampe) { _deltaRotationLampe = -10; _directionLampe = false; } _deltaRotationLampe += 1; } _rotationLampe += _deltaRotationLampe; } _elapsedGameTimePetiteAiguille += new GameTime(e.TotalTime, e.ElapsedTime).ElapsedGameTime; if (_elapsedGameTimePetiteAiguille.TotalMilliseconds >= 60) { _elapsedGameTimePetiteAiguille = TimeSpan.Zero; _rotationPetiteAiguille += 1; if (_rotationPetiteAiguille >= 360) _rotationPetiteAiguille -= 360; } _rotationGrandeAiguille += 6; if (_rotationGrandeAiguille >= 360) _rotationGrandeAiguille -= 360; } }
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); }
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); // 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 //background = contentManager.Load<Texture2D>(""); _fond1 = new Image_Texture(0, "fond1_MiniJeu", "fond1", new Vector2(3, 279), 794, 155); _fond2 = new Image_Texture(0, "fond2_MiniJeu", "fond2", new Vector2(61, 110), 678, 170); _fond3 = new Image_Texture(0, "fond3_MiniJeu", "fond3", new Vector2(143, 20), 514, 90); _fond1.LoadContent(contentManager); _fond2.LoadContent(contentManager); _fond3.LoadContent(contentManager); _jauge = new Image_Texture(0, "jauge_MiniJeu", "jauge", new Vector2(650, 440), 40, 500); _jauge.LoadContent(contentManager); _jaugeInterieur = new Rectangle(159, 443, -2 , 30); _fourFroid = new List<Image_Texture>(); for (int i = 0; i < 6; i++) { _fourFroid.Add(new Image_Texture(0, "fourFroid_MiniJeu", "tete_victor", new Vector2(900, 500), 151, 200)); _fourFroid.ElementAt(i).LoadContent(contentManager); } _fourChaud = new List<Image_Texture>(); for (int i = 0; i < 6; i++) { _fourChaud.Add(new Image_Texture(0, "fourFroid_MiniJeu", "fourChaud", new Vector2(900, 500), 200, 200)); _fourChaud.ElementAt(i).LoadContent(contentManager); } _trouOccupe = new List<short>(); for (int i = 0; i < 6; i++) { _trouOccupe.Add(-1); } _fourFroidMonte = new List<int>(); for (int i = 0; i < 6; i++) { _fourFroidMonte.Add(0); } _fourChaudMonte = new List<int>(); for (int i = 0; i < 6; i++) { _fourChaudMonte.Add(0); } _fourTape = 0; TouchPanel.EnabledGestures = GestureType.Tap; _affichageTempsRestant = contentManager.Load<SpriteFont>(@"SpriteFont1"); _tempsRestant = TimeSpan.Zero; _fini = false; _soundEffect = contentManager.Load<SoundEffect>(@"fourSon"); //on parse var data = this.NavigationContext.QueryString; recreation = bool.Parse(data["recreation"]); if (!recreation) { scene = data["scene"]; niveau = data["niveau"]; } //On s'occupe du fond _textureBackground = contentManager.Load<Texture2D>(@"background"); _rectangle1Background = new Rectangle(0, 0, 800, 230); _rectangle2Background = new Rectangle(0, 230, 800, 200); _rectangle3Background = new Rectangle(0, 430, 800, 50); debut = true; // Démarrez la minuterie timer.Start(); base.OnNavigatedTo(e); }