Esempio n. 1
0
 public static void Load(ContentManager Content)
 {
     if (GameState.Level == 1)
     {
         time = 0;
         text = "";
         printedText = "";
         background = new Objet(Vector2.Zero, Content.Load<Texture2D>("cinematic/" + GameState.Level));
         FileStream fs = new FileStream("Content/cinematic/t1", FileMode.Open);
         StreamReader sr = new StreamReader(fs);
         text = sr.ReadToEnd();
         sr.Close();
         fs.Close();
     }
 }
Esempio n. 2
0
        public static void Load(Personnage[] perso, ContentManager Content)
        {
            Personnage.portrait = new Objet[GameState.Player];
            if (GameState.Player > 0)
            {
                perso[0] = new Personnage(new Keys[] { Keys.Down, Keys.Right, Keys.Up, Keys.Left, Keys.Space, Keys.RightShift }, new Vector2(300f, 350f), 1, LoadingMenu.PersoClasse[0]);
                portrait[0] = new Objet(new Vector2(15, 10), Content.Load<Texture2D>("ui/" + LoadingMenu.PersoClasse[0]));
            }

            if (GameState.Player > 1)
            {
                perso[1] = new Personnage(new Keys[] { Keys.S, Keys.D, Keys.Z, Keys.Q, Keys.F, Keys.E }, new Vector2(330f, 450f), 2, LoadingMenu.PersoClasse[1]);
                portrait[1] = new Objet(new Vector2(Program.width - 95, 10), Content.Load<Texture2D>("ui/" + LoadingMenu.PersoClasse[1]));
            }

            if (GameState.Player > 2)
            {
                perso[2] = new Personnage(new Keys[] { Keys.NumPad5, Keys.NumPad6, Keys.NumPad8, Keys.NumPad4, Keys.NumPad0, Keys.NumPad7 }, new Vector2(360f, 550f), 3, LoadingMenu.PersoClasse[2]);
                portrait[2] = new Objet(new Vector2(15, 115), Content.Load<Texture2D>("ui/" + LoadingMenu.PersoClasse[2]));
            }

            if (GameState.Player > 3)
            {
                perso[3] = new Personnage(new Keys[] { Keys.L, Keys.M, Keys.O, Keys.K, Keys.J, Keys.P }, new Vector2(390f, 650f), 4, LoadingMenu.PersoClasse[3]);
                portrait[3] = new Objet(new Vector2(Program.width - 95, 115), Content.Load<Texture2D>("ui/" + LoadingMenu.PersoClasse[3]));
            }

            foreach (Personnage p in perso)
                p.F_Load(Content);
        }
Esempio n. 3
0
 public static void Init(ContentManager Content)
 {
     menuFont = Content.Load<SpriteFont>("font/menufont");
     menuObject[0] = new Objet(new Vector2(0, 0), Content.Load<Texture2D>("menu/1"));
     menuObject[1] = new Objet(new Vector2(0, 0), Content.Load<Texture2D>("load/gameOver"));
     currentCursor = 0;
     pause = false;
     oldState = Keyboard.GetState();
 }
Esempio n. 4
0
        public static int Update(Personnage[] perso, ContentManager Content)
        {
            /******* STATE ********\
             * 0 : Menu principal *
             * 1 : Choix nb perso *
             * 2 : Setup          *
             * 9 : Exit           *
            \**********************/

            newState = Keyboard.GetState();

            #region Raccourcis
            if (newState.IsKeyDown(Keys.F11))
            {
                persoClasse = new int[1];
                persoClasse[0] = 1;
                return 1;
            }
            if (newState.IsKeyDown(Keys.F12))
            {
                persoClasse = new int[2];
                persoClasse[0] = 1;
                persoClasse[1] = 3;
                return 2;
            }
            #endregion

            if (state <= 5 || state == 9)
            {
                float posX = menuObject[1].Position.X;
                if (posX > 42)
                    speedX -= 0.2f;
                if (posX < 42)
                    speedX += 0.2f;
                menuObject[1].S_PosX(posX + speedX / 2);
                menuObject[1].S_PosY(300 + 125 * currentCursor);
            }

            #region Menu principal
            if (state == (int)MenuState.Principal)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 3;
                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 4;
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (currentCursor == 0)
                    {
                        state = (int)MenuState.NombrePerso_;
                    }
                    else if (currentCursor == 1)
                    {
                        temp = 0;
                        fs = new FileStream("Config/save", FileMode.Open);
                        sr = new StreamReader(fs);
                        save = new string[int.Parse(sr.ReadLine())];
                        for (int i = 0; i < save.GetLength(0); i++)
                        {
                            save[i] = sr.ReadLine();
                        }
                        sr.Close();
                        fs.Close();
                        if (save.GetLength(0) != 0)
                        {
                            fs = new FileStream("Save/" + save[0] + ".save", FileMode.Open);
                            sr = new StreamReader(fs);
                            state = (int)MenuState.LoadSave_;
                        }
                    }
                    else if (currentCursor == 2)
                    {
                        state = (int)MenuState.Setup_;
                    }
                    else if (currentCursor == 3)
                    {
                        state = (int)MenuState.Exit_;
                    }

                    speedX = 35;
                }
            }
            #endregion
            #region Load
            else if (state == (int)MenuState.LoadSave)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 1;
                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 2;
                }
                if (newState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left))
                {
                    sr.Close();
                    fs.Close();
                    fs = new FileStream("Save/" + save[temp] + ".save", FileMode.Open);
                    sr = new StreamReader(fs);
                    temp--;
                    if (temp == -1)
                        temp = save.GetLength(0) - 1;
                }
                if (newState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right))
                {
                    sr.Close();
                    fs.Close();
                    fs = new FileStream("Save/" + save[temp] + ".save", FileMode.Open);
                    sr = new StreamReader(fs);
                    temp = (temp + 1) % save.GetLength(0);
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    sr.Close();
                    fs.Close();
                    if (currentCursor == 0)
                    {
                        menuObject[1] = new Objet(new Vector2(230, 270), Content.Load<Texture2D>("menu/levelSelector"));
                        menuObject[2] = new Objet(new Vector2(233, 0), Content.Load<Texture2D>("menu/_"));
                        Program.save = save[temp];
                        state = (int)MenuState.ChooseLevel;
                        temp = SaveLoad.Loading();
                    }
                    else if (currentCursor == 1)
                    {
                        currentCursor = 0;
                        state = (int)MenuState.Principal;
                    }
                }
            }
            #endregion
            #region ChooseLevel
            else if (state == (int)MenuState.ChooseLevel)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 11;
                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 12;
                }
                if (newState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left))
                {
                    currentCursor -= 6;
                    if (currentCursor < 0)
                    {
                        currentCursor += 12;
                    }
                }
                if (newState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right))
                {
                    currentCursor += 6;
                    if (currentCursor > 11)
                    {
                        currentCursor -= 12;
                    }
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    sr.Close();
                    fs.Close();
                    if (currentCursor == 5 || currentCursor == 11)
                    {
                        currentCursor = 0;
                        state = (int)MenuState.Principal;
                        menuObject[1] = new Objet(new Vector2(0, 350), Content.Load<Texture2D>("menu/epee"));
                    }
                    else
                    {
                        if (currentCursor < 5)
                        {
                            GameState.Level = currentCursor + 1;
                        }
                        else
                        {
                            GameState.Level = currentCursor;
                        }
                        return temp;
                    }
                }
            }
            #endregion
            #region Nombre Perso
            else if (state == (int)MenuState.NombrePerso)
            {

                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 2;
                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 3;
                }
                if (newState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right))
                {
                    nbPlayer = (nbPlayer % 4) + 1;
                }
                if (newState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left))
                {
                    nbPlayer--;
                    if (nbPlayer == 0)
                        nbPlayer = 4;
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (currentCursor == 0)
                    {
                        persoClasse = new int[nbPlayer];
                        state = (int)MenuState.SelecClasse1;
                        temp = 0;
                    }
                    else if (currentCursor == 1)
                    {
                        state = (int)MenuState.Principal;
                        currentCursor = 0;
                        menuObject[1].S_PosX(-42);
                        speedX = 0;
                    }
                    else if (currentCursor == 2)
                    {
                        Program.gs.Exit();
                    }
                }
            }
            #endregion
            #region Setup
            else if (state == (int)MenuState.Setup)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 3;

                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 4;
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (currentCursor == 0)
                    {
                        state = (int)MenuState.SetupVideo;
                    }
                    else if (currentCursor == 1)
                    {
                        state = (int)MenuState.SetupAudio;
                    }
                    else if (currentCursor == 2)
                    {
                        state = (int)MenuState.SetupLocal;
                    }
                    else if (currentCursor == 3)
                    {
                        state = (int)MenuState.Principal;
                        menuObject[1] = new Objet(new Vector2(0, 350), Content.Load<Texture2D>("menu/epee"));
                        speedX = 0;
                    }
                    currentCursor = 0;
                }
            }
            else if (state == (int)MenuState.SetupVideo)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 2;

                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 3;
                }
                if (newState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right))
                {
                    if (currentCursor == 0)
                        setup[currentCursor] = (setup[currentCursor] + 1) % 3;
                    else if (currentCursor == 1)
                        setup[currentCursor] = (setup[currentCursor] + 1) % 2;
                }
                if (newState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left))
                {
                    if (currentCursor != 2)
                    {
                        setup[currentCursor]--;
                        if (setup[currentCursor] == -1)
                        {
                            if (currentCursor == 0)
                                setup[currentCursor] = 2;
                            else
                                setup[currentCursor] = 1;
                        }
                    }
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (currentCursor <= 1)
                    {
                        ApplyChanges(Content);
                    }
                    else
                    {
                        currentCursor = 0;
                        state = (int)MenuState.Setup;
                        menuObject[1] = new Objet(new Vector2(0, 350), Content.Load<Texture2D>("menu/epee"));
                        speedX = 0;
                    }
                }
            }
            else if (state == (int)MenuState.SetupAudio)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 2;

                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 3;
                }
                if (currentCursor == 0)
                {
                    if (newState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right))
                    {
                        setup[2] = (setup[2] + 1) % 2;
                    }
                    if (newState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left))
                    {
                        setup[2]--;
                        if (setup[2] == -1)
                        {
                            setup[2] = 1;
                        }
                    }
                }
                if (currentCursor == 1)
                {
                    if (newState.IsKeyDown(Keys.Right))
                    {
                        setup[3]++;
                        if (setup[3] > 100)
                            setup[3] = 100;
                    }
                    if (newState.IsKeyDown(Keys.Left))
                    {
                        setup[3]--;
                        if (setup[3] < 0)
                            setup[3] = 0;
                    }
                    Program.volume = setup[3];
                    Son.InstanceVolume();
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (currentCursor <= 1)
                    {
                        ApplyChanges(Content);
                    }
                    else
                    {
                        currentCursor = 0;
                        state = (int)MenuState.Setup;
                        menuObject[1] = new Objet(new Vector2(0, 350), Content.Load<Texture2D>("menu/epee"));
                        speedX = 0;
                    }
                }
            }
            else if (state == (int)MenuState.SetupLocal)
            {
                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    currentCursor--;
                    if (currentCursor == -1)
                        currentCursor = 2;

                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    currentCursor = (currentCursor + 1) % 3;
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (currentCursor <= 1)
                    {
                        setup[4] = currentCursor;
                        ApplyChanges(Content);
                    }
                    else
                    {
                        currentCursor = 0;
                        state = (int)MenuState.Setup;
                        menuObject[1] = new Objet(new Vector2(0, 350), Content.Load<Texture2D>("menu/epee"));
                        speedX = 0;
                    }
                }
            }
            #endregion
            #region Selection Classe
            else if (state >= 5 && state <= 8)
            {
                menuObject[1] = new Objet(new Vector2(100, 500), Content.Load<Texture2D>("perso/1/10"));
                menuObject[2] = new Objet(new Vector2(300, 500), Content.Load<Texture2D>("perso/2/10"));
                menuObject[3] = new Objet(new Vector2(500, 500), Content.Load<Texture2D>("perso/3/10"));
                menuObject[4] = new Objet(new Vector2(700, 500), Content.Load<Texture2D>("perso/4/10"));
                menuObject[5] = new Objet(new Vector2(92 + (200 * currentCursor), 480), Content.Load<Texture2D>("menu/selection"));

                if (newState.IsKeyDown(Keys.Up) && !oldState.IsKeyDown(Keys.Up))
                {
                    temp--;
                    if (temp == -1)
                        temp = 1;

                }
                if (newState.IsKeyDown(Keys.Down) && !oldState.IsKeyDown(Keys.Down))
                {
                    temp = (temp + 1) % 2;
                }
                if (newState.IsKeyDown(Keys.Right) && !oldState.IsKeyDown(Keys.Right))
                {
                    if (temp == 0)
                        currentCursor = (currentCursor + 1) % 4;
                }
                if (newState.IsKeyDown(Keys.Left) && !oldState.IsKeyDown(Keys.Left))
                {
                    if (temp == 0)
                    {
                        currentCursor--;
                        if (currentCursor == -1)
                            currentCursor = 3;
                    }
                }
                if (newState.IsKeyDown(Keys.Enter) && !oldState.IsKeyDown(Keys.Enter))
                {
                    if (temp == 0)
                    {
                        persoClasse[state - 5] = currentCursor + 1;
                        state++;
                        if (state - 5 == nbPlayer)
                        {
                            SaveLoad.NewGame(nbPlayer);
                            return nbPlayer;
                        }
                    }
                    else
                    {
                        currentCursor = 0;
                        speedX = 0;
                        state = 1;
                        menuObject[1] = new Objet(new Vector2(-42, 350), Content.Load<Texture2D>("menu/epee"));
                    }
                }
            }
            #endregion
            #region Other
            else if (state == (int)MenuState.Exit)
            {
                Program.gs.Exit();
            }
            if (state == 10 || state == 20 || state == 110 || state == 300)
            {
                menuObject[1].S_PosX(menuObject[1].Position.X + speedX / 2);
                if (menuObject[1].Position.X > Program.width)
                {
                    state /= 10;
                    currentCursor = 0;
                    menuObject[1].S_PosX(-42);
                    speedX = 0;
                }
            }
            #endregion
            oldState = newState;
            return 0;
        }
Esempio n. 5
0
        public static void Init(ContentManager Content)
        {
            menuObject[0] = new Objet(new Vector2(0, 0), Content.Load<Texture2D>("menu/1"));
            menuObject[1] = new Objet(new Vector2(-42, 350), Content.Load<Texture2D>("menu/epee"));
            background = new Objet(new Vector2(0, 0), Content.Load<Texture2D>("load/1"));
            speedX = 0;
            state = (int)MenuState.Principal;
            nbPlayer = 1;
            currentCursor = 0;
            local = new string[Program.MAXLOCAL];
            oldState = Keyboard.GetState();

            InitSetup();
        }