예제 #1
0
        public override void Init()
        {
            world =new World(Vector2.UnitY * 20f);

            if (SelectionNiveau.niveauSelect == "level1")
            {
                level = new Level(world, "Jeu\\level1\\background1", personnages, TurkeySmashGame.content);
                Song song = TurkeySmashGame.content.Load<Song>("Sons\\Musiques\\MusicLvl1");
                MediaPlayer.Volume = 0.35f;
                MediaPlayer.Play(song);
            }
            else
            {
                if (SelectionNiveau.niveauSelect == "level2")
                {
                    level = new Level(world, "Jeu\\level2\\background2", personnages, TurkeySmashGame.content);
                    Song song = TurkeySmashGame.content.Load<Song>("Sons\\Musiques\\MusicLvl2");
                    MediaPlayer.Volume = 0.35f;
                    MediaPlayer.Play(song);
                }
                else
                {
                    if (SelectionNiveau.niveauSelect == "level3")
                    {
                        level = new Level(world, "Jeu\\level3\\background3", personnages, TurkeySmashGame.content);
                        Song song = TurkeySmashGame.content.Load<Song>("Sons\\Musiques\\MusicLvl3");
                        MediaPlayer.Volume = 0.35f;
                        MediaPlayer.Play(song);
                    }
                    else
                    {
                        level = new Level(world, "Jeu\\level4\\background4", personnages, TurkeySmashGame.content);
                        Song song = TurkeySmashGame.content.Load<Song>("Sons\\Musiques\\MusicLvl4");
                        MediaPlayer.Volume = 0.35f;
                        MediaPlayer.Play(song);
                    }
                }
            }

            #region loadPersonnage

            #region Selection persoonage

            foreach (string str in SelectionPersonnage.listPerso)
            {
                if (str != null)
                {
                    if (i <= ChoixNombrePersonnage.nombreJoueur - 1)
                    {
                        #region CreationJoueur;
                        if (str == "naruto")
                        {
                            personnages[i] = new Joueur(world, level.spawnPoints[i], 1f, new Vector2(42, 55), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\naruto",
                                FrameRate = 60,
                                FrameSize = new Point(88, 88),
                                Loop = true,
                                NbFrames = new Point(5, 1),
                            });
                        }
                        if (str == "sakura")
                        {
                            personnages[i] = new Joueur(world, level.spawnPoints[i], 1f, new Vector2(40, 50), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\sakura",
                                FrameRate = 60,
                                FrameSize = new Point(80, 80),
                                Loop = true,
                                NbFrames = new Point(6, 1),
                            });
                        }
                        if (str == "sai")
                        {
                            personnages[i] = new Joueur(world, level.spawnPoints[i], 1f, new Vector2(40, 50), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\sai",
                                FrameRate = 60,
                                FrameSize = new Point(80, 80),
                                Loop = true,
                                NbFrames = new Point(6, 1),
                            });
                        }
                        if (str == "suigetsu")
                        {
                            personnages[i] = new Joueur(world, level.spawnPoints[i], 1f, new Vector2(45, 58), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\suigetsu",
                                FrameRate = 60,
                                FrameSize = new Point(92, 92),
                                Loop = true,
                                NbFrames = new Point(6, 1),
                            });
                        }
                        if (str == "turkey")
                        {
                            personnages[i] = new Joueur(world, level.spawnPoints[i], 1f, new Vector2(25, 25), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\turkey",
                                FrameRate = 60,
                                FrameSize = new Point(46, 46),
                                Loop = true,
                                NbFrames = new Point(5, 1),
                            });
                        }
                        #endregion
                    }
                    else
                    {
                        #region CreationIA
                        if (str == "naruto")
                        {
                            personnages[i] = new IA(world, level.spawnPoints[i], 1f, new Vector2(42, 55), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\naruto",
                                FrameRate = 60,
                                FrameSize = new Point(88, 88),
                                Loop = true,
                                NbFrames = new Point(5, 1),
                            });
                        }
                        if (str == "sakura")
                        {
                            personnages[i] = new IA(world, level.spawnPoints[i], 1f, new Vector2(40, 50), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\sakura",
                                FrameRate = 60,
                                FrameSize = new Point(80, 80),
                                Loop = true,
                                NbFrames = new Point(6, 1),
                            });
                        }
                        if (str == "sai")
                        {
                            personnages[i] = new IA(world, level.spawnPoints[i], 1f, new Vector2(40, 50), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\sai",
                                FrameRate = 60,
                                FrameSize = new Point(80, 80),
                                Loop = true,
                                NbFrames = new Point(6, 1),
                            });
                        }
                        if (str == "suigetsu")
                        {
                            personnages[i] = new IA(world, level.spawnPoints[i], 1f, new Vector2(45, 58), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\suigetsu",
                                FrameRate = 60,
                                FrameSize = new Point(92, 92),
                                Loop = true,
                                NbFrames = new Point(6, 1),
                            });
                        }
                        if (str == "turkey")
                        {
                            personnages[i] = new Joueur(world, level.spawnPoints[i], 1f, new Vector2(25, 25), Convert.Int2PlayerIndex(i + 1), new AnimatedSpriteDef()
                            {
                                AssetName = "Jeu\\turkey",
                                FrameRate = 60,
                                FrameSize = new Point(46, 46),
                                Loop = true,
                                NbFrames = new Point(5, 1),
                            });
                        }
                        #endregion
                    }
                    FarseerBodyUserData userdata = (FarseerBodyUserData)personnages[i].body.UserData;
                    if (userdata.AssociatedName != "Jeu\\turkey")
                        personnages[i].body.Mass = fixedMass;
                    else
                        personnages[i].body.Mass = 0.18f;
                    i = i + 1;
                }
            }
            #endregion

            #endregion

            #region initCompteur

            compteur = new AnimatedSprite(TurkeySmashGame.WindowMid - new Vector2(256, 256), new AnimatedSpriteDef()
            {
                AssetName = "Jeu\\compteurDebutDePartie",
                FrameRate = 60,
                FrameSize = new Point(512, 512),
                Loop = false,
                NbFrames = new Point(3, 0),
            });
            compteur.TimeBetweenFrame = 1000;
            compteur.color = Color.Orange;

            #endregion

            hud.Load(personnages);
        }
예제 #2
0
        public override void Init()
        {
            backgroundMenu.Load(TurkeySmashGame.content, "Menu1\\Scores\\fondMenuFin");
            nomMenu.Load(TurkeySmashGame.content, "Menu1\\Scores\\Scores");
            nomMenu.Position = new Vector2(TurkeySmashGame.WindowSize.X / 2, nomMenu.Height / 2 + 10);
            boutonRejouer.Load(TurkeySmashGame.content, boutons);
            boutonMainMenu.Load(TurkeySmashGame.content, boutons);

            #region affichage frames
            goldFrame.Load(TurkeySmashGame.content, "Menu1\\Scores\\or", ImagesMenu);
            silverFrame.Load(TurkeySmashGame.content, "Menu1\\Scores\\argent", ImagesMenu);

            if (Results.ResultsBoard[2][1] != -999) // Si il y a 3 joueurs
                bronzeFrame.Load(TurkeySmashGame.content, "Menu1\\Scores\\bronze", ImagesMenu);
            if (Results.ResultsBoard[3][1] != -999) // Si il y a 4 joueurs
                bronzeFrame2.Load(TurkeySmashGame.content, "Menu1\\Scores\\bronze", ImagesMenu);
            #endregion

            for (int i = 0; i < 4; i++)
            {
                if (joueurs[i] != null)
                {
                    joueurs[i].NameFont = "pourcent";
                    joueurs[i].Load(TurkeySmashGame.content, textes);
                }
                if (classement[i] != null)
                {
                    classement[i].NameFont = "pourcent";
                    classement[i].SizeText = 2f;
                    classement[i].Load(TurkeySmashGame.content, textes);
                }
                if (results[i] != null)
                {
                    results[i].NameFont = "pourcent";
                    results[i].Load(TurkeySmashGame.content, textes);
                    results[i].SizeText = 1.1f;
                }
                if (suicide[i] != null)
                {
                    suicide[i].SizeText = 1.1f;
                    suicide[i].NameFont = "pourcent";
                    suicide[i].Load(TurkeySmashGame.content, textes);
                }
                if (OptionsCombat.TypePartieSelect == "temps")
                {
                    for (int j = 0; j < 3; j++)
                        if (kills[j][i] != null)
                        {
                            kills[j][i].NameFont = "pourcent";
                            kills[j][i].Load(TurkeySmashGame.content, textes);
                            kills[j][i].SizeText = 0.7f;
                        }
                }
                if (OptionsCombat.TypePartieSelect == "vie")
                {
                    if (timers[i] != null)
                    {
                        timers[i].SizeText = 1.1f;
                        timers[i].NameFont = "pourcent";
                        timers[i].Load(TurkeySmashGame.content, textes);
                    }
                }

                switch (SelectionPersonnage.listPerso[i])
                {
                    case "naruto" :
                        frameSize = new Point(88, 88);
                        nbFrame = new Point(5, 11);
                        break;
                    case "sakura" :
                        frameSize = new Point(80, 80);
                        nbFrame = new Point(6, 11);
                        break;
                    case "sai":
                        frameSize = new Point(80, 80);
                        nbFrame = new Point(6, 11);
                        break;
                    case "suigetsu":
                        frameSize = new Point(92, 92);
                        nbFrame = new Point(6, 11);
                        break;
                    case "turkey":
                        frameSize = new Point(46, 46);
                        nbFrame = new Point(5, 11);
                        break;
                    default :
                        frameSize = new Point(88, 88);
                        nbFrame = new Point(5, 11);
                        break;
                }
                if (SelectionPersonnage.listPerso[i] != null)
                {
                    string assetName = "Jeu\\" + SelectionPersonnage.listPerso[i];
                    animJoueurs[i] = new AnimatedSprite(new Vector2(Xpos / 4 * i + 90, Ypos * 0.39f), new AnimatedSpriteDef()
                    {
                        AssetName = assetName,
                        FrameRate = 60,
                        FrameSize = frameSize,
                        Loop = true,
                        NbFrames = nbFrame
                    });
                    animJoueurs[i].CurrentFrame.Y = 1;
                }
            }
        }
예제 #3
0
        public override void Update(GameTime gameTime, Input input)
        {
            if (input.Escape())
            {
                MediaPlayer.Pause();
                Basic.SetScreen(new Pause());
            }

            if (gameStarted)
            {
                compteur = null;
                level.Update(gameTime);
                hud.Update(gameTime, personnages);

                //Mise a jour du world en 30 FPS
                world.Step(Math.Min((float)gameTime.ElapsedGameTime.TotalSeconds, (1f / 60.0f)));
            }
            else
            {
                compteur.Update(gameTime);
                if (compteurMusique)
                {
                    compteurMusic.Play();
                    compteurMusique = false;
                }
                if (compteurDebutDePartie > 3000)
                    gameStarted = true;
                compteurDebutDePartie += gameTime.ElapsedGameTime.Milliseconds;
            }
        }