Exemple #1
0
        public void Deserialise(SavPerso Serial, ContentManager Content)
        {
            money           = Serial.money;
            currentLevel    = Serial.currentLevel;
            this.name       = Serial.name;
            this.experience = Serial.experience;
            this.niveau     = Serial.niveau;
            pointRestants   = Serial.pointRestants;
            attaquePoint    = Serial.attaquePoint;
            defensePoint    = Serial.defensePoint;
            dexteritePoint  = Serial.dexteritePoint;
            vitessePoint    = Serial.vitessePoint;

            this.pV         = Serial.pV;
            this.pVMax      = Serial.pVMax;
            this.attaque    = Serial.attaque;
            this.defense    = Serial.defense;
            accuracy        = Serial.accuracy;
            base.accelerate = Serial.accelerateInit;
            base.decelerate = Serial.decelerateInit;
            base.fall       = Serial.fallInit;
            base.jump       = Serial.jumpInit;
            base.vitesseMax = Serial.vitesseMaxInit;
            base.fallMax    = Serial.fallMaxInit;

            base.accelerateInit = accelerate;
            base.decelerateInit = decelerate;
            base.fallInit       = fall;
            base.jumpInit       = jump;
            base.vitesseMaxInit = vitesseMax;
            base.fallMaxInit    = fallMax;
            newChar             = Serial.newChar;
            this.lifes          = Serial.lifes;
            this.spritePerso    = Serial.spritePerso;

            this.currentWeapon = new Weapon(Serial.currentWeapon.prix, Serial.currentWeapon.ammoTexture,
                                            Serial.currentWeapon.itemImage, Serial.currentWeapon.damage,
                                            Serial.currentWeapon.cadence, Serial.currentWeapon.cadenceType,
                                            Serial.currentWeapon.munitions, Serial.currentWeapon.currentAmo,
                                            Serial.currentWeapon.capacity, Serial.currentWeapon.accuracy,
                                            Serial.currentWeapon.range, Serial.currentWeapon.position,
                                            Serial.currentWeapon.speed, Serial.currentWeapon.weaponName,
                                            Serial.currentWeapon.isOnMap, Serial.currentWeapon.id,
                                            Content, Serial.currentWeapon.sound, Serial.currentWeapon.tirs, Serial.currentWeapon.hasSpecialAttack,
                                            Serial.currentWeapon.numBalle, Serial.currentWeapon.numArme);
            for (int i = 0; i < Serial.WeaponsList.Length; i++)
            {
                ItemList.Add(new Weapon(Serial.WeaponsList[i].prix, Serial.WeaponsList[i].ammoTexture,
                                        Serial.WeaponsList[i].itemImage, Serial.WeaponsList[i].damage,
                                        Serial.WeaponsList[i].cadence, Serial.WeaponsList[i].cadenceType,
                                        Serial.WeaponsList[i].munitions, Serial.WeaponsList[i].currentAmo,
                                        Serial.WeaponsList[i].capacity, Serial.WeaponsList[i].accuracy,
                                        Serial.WeaponsList[i].range, Serial.WeaponsList[i].position,
                                        Serial.WeaponsList[i].speed, Serial.WeaponsList[i].weaponName,
                                        Serial.WeaponsList[i].isOnMap, Serial.WeaponsList[i].id, Content,
                                        Serial.WeaponsList[i].sound, Serial.WeaponsList[i].tirs, Serial.WeaponsList[i].hasSpecialAttack,
                                        Serial.WeaponsList[i].numBalle, Serial.WeaponsList[i].numArme));
            }
        }
Exemple #2
0
        protected override void LoadContent()
        {
            sbHUD               = new SpriteBatch(GraphicsDevice);
            spriteBatch         = new SpriteBatch(GraphicsDevice);
            spriteBatchMini     = new SpriteBatch(GraphicsDevice);
            spriteBatchMini2    = new SpriteBatch(GraphicsDevice);
            destrucTileList     = new List <Vector3>();
            entityList          = new List <Entity>();
            animationList       = new List <Animate>();
            particlesEngineList = new List <ParticleEngine>();
            particleList        = new List <Particles>();
            explosionReseau     = new List <Vector2>();

            switch (gameState)
            {
            case GameState.initialize:
                //Load Cursor Texture and Position

                personalFolder           = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "TDZ";
                cursor                   = Tools.LoadTexture("Others/cursor", Content);
                controles.cursorPosition = new Vector2();
                Langage.LoadLanguage();
                destroyTile = Tools.LoadTexture("SpriteTexture/destroyed", Content);

                #region Load Textures

                TexturesGame.LoadAmmo(Content);
                TexturesGame.LoadPlayers(Content);
                TexturesGame.LoadArmes(Content);
                TexturesGame.LoadItem(Content);
                TexturesGame.LoadImpact(Content);
                TexturesGame.Loadtest(Content);
                TexturesGame.LoadBonus(Content);
                TexturesGame.LoadIAs(Content);
                TexturesGame.LoadPlatForm(Content);
                TexturesGame.Loadtest(Content);
                TexturesGame.LoadSpeedUp(Content);
                TexturesGame.LoadBackgrounds(Content);

                #endregion Load Textures

                menu      = new Menu(Content, GraphicsDevice);
                font      = Tools.LoadFont("Fonts/AngryBirds/24", Content);
                GameOver  = Tools.LoadTexture("Menu/GameOver", Content);
                fondRadar = Tools.LoadTexture("Others/fondRadar", Content);
                HUDarmes  = Tools.LoadTexture("HUD/HUD_armes", Content);
                gameState = GameState.menu;
                sound     = new Sound(Content);

                Player player = new Player(new Vector2(0, 0), TexturesGame.PlayerTab[0], 0, GraphicsDevice, LoadWeapons.LoadKnife(Content), true, FlagsType.blue);
                menu = new Menu(Content, GraphicsDevice);
                try
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(Opt));
                    FileStream    fs         = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Options/OptionMenu", FileMode.Open);
                    XmlReader     reader     = XmlReader.Create(fs);
                    Opt           obj        = (Opt)serializer.Deserialize(reader);
                    fullScreenON = obj.Fullscreen;
                    menu.optionsMenu.toFullScreen = obj.Fullscreen;
                    soundON                = obj.SoundOn;
                    sound.playEffects      = soundON;
                    controles.controleTab  = obj.controleTab;
                    Langage.langueactuelle = obj.language;

                    if (obj.masterServerAdress != null)
                    {
                        ConnectMaster.MasterIPAdress = obj.masterServerAdress;
                    }
                    fs.Close();

                    XmlSerializer serializer2 = new XmlSerializer(typeof(SavPerso));
                    FileStream    fs2         = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Sauvegardes/" + obj.name, FileMode.Open);
                    XmlReader     reader2     = XmlReader.Create(fs2);
                    SavPerso      obj2        = (SavPerso)serializer2.Deserialize(reader2);
                    player.Deserialise(obj2, Content);
                    fs2.Close();
                }
                catch (Exception)
                {
                    player = new Player(new Vector2(0, 0), TexturesGame.PlayerTab[0], 0, GraphicsDevice, LoadWeapons.LoadKnife(Content), true, FlagsType.blue);
                    player.ItemList.Add(LoadWeapons.LoadKnife(Content));
                }
                currentPlayer = player;
                solo          = new Solo(player.currentLevel, player);
                menu.LaunchMenuSound(sound);
                break;

            case GameState.editor:

                sound.soundPlayer.Stop();

                // Prepare the process to run
                ProcessStartInfo start = new ProcessStartInfo();
                // Enter the executable to run, including the complete path
                start.FileName = "./MapEditor.exe";
                // Do you want to show a console window?
                start.WindowStyle    = ProcessWindowStyle.Hidden;
                start.CreateNoWindow = true;

                // Run the external process & wait for it to finish
                using (Process proc = Process.Start(start))
                {
                    proc.WaitForExit();
                }


                gameState = GameState.menu;
                menu      = new Menu(Content, GraphicsDevice);
                menu.LaunchMenuSound(sound);
                break;

            case GameState.solo:

                sound.soundPlayer.Stop();

                //Load List Tirs and Texture
                shotsPlayer = new Shot();

                //Load Map
                LoadMap(menu.mapname + ".xml");
                LoadMapTextures();

                //Load Player Array
                hostPlayer = 0;
                LoadPlayer();
                players[hostPlayer].position = mapWorld.spawnPoint;
                players[hostPlayer].image    = TexturesGame.PlayerTab[players[hostPlayer].spritePerso];
                // LoadEnemy();
                LoadSurvivalEnemy();
                LoadItem();

                //Load HUD
                LoadHUD();

                background = new Background(Content, mapWorld);
                camera     = new Camera(players, hostPlayer, scaleNormValue, GraphicsDevice, mapWorld);

                break;

            case GameState.scenario:

                sound.soundPlayer.Stop();

                //Load List Tirs and Texture
                shotsPlayer = new Shot();

                //Load Map
                LoadMap(solo.currentMap + ".xml");
                LoadMapTextures();

                //Load Player Array
                solo.player.position = mapWorld.spawnPoint;
                hostPlayer           = 0;
                players = new List <Player>();
                players.Add(solo.player);
                entityList.Add(solo.player);

                Enemys = new List <Enemy>();

                for (int i = 0; i < mapWorld.IASpawnList.Count; i++)
                {
                    Enemys.Add(new Enemy(mapWorld.IASpawnList[i], TexturesGame.IATab[0], 100 + i, Content, LoadWeapons.LoadIAGun(Content), false, 0, GraphicsDevice));
                    Enemys[i].iaType = IAType.patrouille;
                    entityList.Add(Enemys[i]);
                    Enemys[i].attaque = currentPlayer.niveau * 0.1f;
                    Enemys[i].defense = 2 / currentPlayer.niveau;
                }

                LoadItem();

                //Load HUD
                LoadHUD();

                background = new Background(Content, mapWorld);
                camera     = new Camera(players, hostPlayer, scaleNormValue, GraphicsDevice, mapWorld);

                break;

            case GameState.multi:
                sound.soundPlayer.Stop();

                //Launch Network and Load Map
                mapWorld = new Map();
                client   = new Client(ConnectMaster.MasterIPAdress, Convert.ToInt32(menu.multiMenu.tmpserv.port), ref hostPlayer, mapWorld, Content, menu.multiMenu.tmpserv.mode);

                if (client.mode == ModeMulti.ctf)
                {
                    flags    = new Flag[2];
                    flags[0] = new Flag(mapWorld.drapeau2, Content, FlagsType.red);
                    flags[1] = new Flag(mapWorld.drapeau1, Content, FlagsType.blue);
                    foreach (Flag item in flags)
                    {
                        mapWorld.itemList.Add(item);
                    }
                }

                LoadMapTextures();

                //Platforms
                for (int i = 0; i < mapWorld.platFormList.Count; i++)
                {
                    entityList.Add(mapWorld.platFormList[i]);
                }

                //Load List Tirs and Texture
                shotsPlayer = new Shot();

                //Load Player Array
                LoadPlayer();
                SetCurrentPlayer();
                Enemys = new List <Enemy>();

                //Load HUD
                LoadHUD();

                background = new Background(Content, mapWorld);
                camera     = new Camera(players, hostPlayer, scaleNormValue, GraphicsDevice, mapWorld);

                break;

            default:
                break;
            }
        }
Exemple #3
0
        public void Update(ref Player player, double mousseCoef, Controles controles, ContentManager content, GraphicsDevice graphics)
        {
            switch (state)
            {
            case SubGestion.fichePerso:
                butAttaque.Update(mousseCoef, controles);
                butDefense.Update(mousseCoef, controles);
                butDext.Update(mousseCoef, controles);
                butPv.Update(mousseCoef, controles);
                butVitesse.Update(mousseCoef, controles);
                butInventaire.Update(mousseCoef, controles);
                butLoad.Update(mousseCoef, controles);

                if (butAttaque.isCliked)
                {
                    butAttaque.isCliked = false;
                    if (player.pointRestants > 0)
                    {
                        player.attaquePoint++;
                        if (player.attaque < 3)
                        {
                            player.attaque *= 1.1f;
                        }
                        player.pointRestants--;
                    }
                }
                if (butDefense.isCliked)
                {
                    butDefense.isCliked = false;
                    if (player.pointRestants > 0)
                    {
                        player.defensePoint++;
                        player.defense *= 0.9f;
                        player.pointRestants--;
                    }
                }
                if (butDext.isCliked)
                {
                    butDext.isCliked = false;
                    if (player.pointRestants > 0 && player.accuracy > 0)
                    {
                        player.dexteritePoint++;
                        player.accuracy--;
                        player.pointRestants--;
                    }
                }
                if (butPv.isCliked)
                {
                    butPv.isCliked = false;
                    if (player.pointRestants > 0)
                    {
                        player.pVMax = (int)(player.pVMax * 1.1f);
                        player.pV    = player.pVMax;
                        player.pointRestants--;
                    }
                }
                if (butVitesse.isCliked)
                {
                    butVitesse.isCliked = false;
                    if (player.pointRestants > 0)
                    {
                        player.vitessePoint++;
                        player.vitesseMaxInit += 0.5f;
                        player.vitesseMax      = player.vitesseMaxInit;
                        player.pointRestants--;
                    }
                }

                if (butInventaire.isCliked)
                {
                    butInventaire.isCliked = false;
                    inventaire             = new Inventaire(content, player);
                    state = SubGestion.inventaire;
                }

                if (player.newChar)
                {
                    if (saveName.IsFinish)
                    {
                        saveName.IsFinish = false;
                        player.name       = saveName.text;
                        player.newChar    = false;
                    }
                    else
                    {
                        saveName.Update(controles);
                    }
                }
                else
                {
                    saveName.SetText(player.name);
                }

                if (butLoad.isCliked)
                {
                    butLoad.isCliked = false;
                    state            = SubGestion.LoadChar;
                }
                break;

            case SubGestion.inventaire:
                inventaire.update(controles, mousseCoef, player, content);
                break;

            case SubGestion.LoadChar:
                butNewChar.Update(mousseCoef, controles);
                listviewperso.Update(mousseCoef, controles);
                Button item = listviewperso.GetClickedButton();
                if (item != null)
                {
                    player = new Player(new Vector2(0, 0), TexturesGame.PlayerTab[0], 0, player.graphics, LoadWeapons.LoadKnife(content), true, FlagsType.red);
                    XmlSerializer serializer2 = new XmlSerializer(typeof(SavPerso));
                    FileStream    fs2         = new FileStream((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Sauvegardes/") + item.text[0], FileMode.Open);
                    XmlReader     reader2     = XmlReader.Create(fs2);
                    SavPerso      obj2        = (SavPerso)serializer2.Deserialize(reader2);
                    player.Deserialise(obj2, content);
                    fs2.Close();
                    state = SubGestion.fichePerso;
                }
                else if (butNewChar.isCliked)
                {
                    butNewChar.isCliked = false;
                    player = new Player(new Vector2(0, 0), TexturesGame.PlayerTab[0], 0, player.graphics, LoadWeapons.LoadKnife(content), true, FlagsType.red);
                    player.ItemList.Add(LoadWeapons.LoadKnife(content));
                    saveName = new TextView(graphics, font, player.name, true, true);
                    saveName.SetPositionAndColor(new Vector2(font.MeasureString(Langage.getString(Langage.langueactuelle, 7)).X + 500, 400), Color.Black);
                    state = SubGestion.fichePerso;
                }
                break;

            default:
                break;
            }
        }
Exemple #4
0
        protected override void Update(GameTime gameTime)
        {
            UpdateOption();
            currentPlayer.UpdateLevel(controles, animationList, Content);
            if (controles.Pause())
            {
                if (gameState == GameState.scenario || gameState == GameState.solo)
                {
                    oldGameState = gameState;
                    gameState    = GameState.pause;
                    pause        = new Pause(Content);
                }
                else if (gameState == GameState.pause || gameState == GameState.multiPause)
                {
                    gameState = oldGameState;
                }
                else if (gameState == GameState.creation)
                {
                    currentPlayer.newChar = false;
                    SavPerso obj = new SavPerso();
                    currentPlayer.Serialize(obj);
                    System.Xml.Serialization.XmlSerializer writer2 = new System.Xml.Serialization.XmlSerializer(typeof(SavPerso));
                    System.IO.StreamWriter file2 = new System.IO.StreamWriter((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Sauvegardes/") + currentPlayer.name);
                    writer2.Serialize(file2, obj);
                    file2.Close();
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                }
                else if (gameState == GameState.menu)
                {
                    gameState = GameState.menu;
                    menu      = new Menu(Content, GraphicsDevice);
                }
                else if (gameState == GameState.multi)
                {
                    oldGameState = gameState;
                    gameState    = GameState.multiPause;
                    pause        = new Pause(Content);
                }
                else
                {
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                    sound.soundPlayer.Stop();
                    menu.LaunchMenuSound(sound);
                }
            }

            //Events States Mouse and Keyboard

            msg = "";

            switch (gameState)
            {
            case GameState.solo:

                sound.UpdateMusic();
                destrucTileList = new List <Vector3>();
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                shotsPlayer.Update(animationList);
                UpdateItem();
                UpdateExplosion();
                UpdateAnimation();
                Reset();
                UpdateParticleEngine();

                #region IA Update

                if (!currentPlayer.God)
                {
                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.otherTirList = new List <Tirs>();
                        Enemys[i].shotsIA.otherTirList = shotsPlayer.tirList;
                        for (int j = 0; j < Enemys[i].shotsIA.tirList.Count; j++)
                        {
                            shotsPlayer.otherTirList.Add(Enemys[i].shotsIA.tirList[j]);
                        }
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        IA.IACheckEvents(Enemys[i], IAType.Survival, mapWorld, players, Enemys[i].shotsIA, destrucTileList, hostPlayer, sound, entityList, animationList, particlesEngineList, Content, Enemys, explosionReseau);
                        LoadSurvival(Enemys);
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.Update(animationList);
                    }
                }

                #endregion IA Update

                mapWorld.Update();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                break;

            case GameState.pause:
                pause.Update(mouseCoef, controles);
                if (pause.menu)
                {
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                    sound.soundPlayer.Stop();
                    menu.LaunchMenuSound(sound);
                }
                else if (pause.resumeGame)
                {
                    gameState = oldGameState;
                }
                break;

            case GameState.scenario:
                sound.UpdateMusic();

                solo.Update(players[hostPlayer], mapWorld);
                if (solo.levelUp)
                {
                    solo = new Solo(solo.currentLevel, solo.player);
                    LoadContent();
                }
                if (currentPlayer.lifes < 1)
                {
                    gameState = GameState.gameOver;
                }
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                shotsPlayer.Update(animationList);
                UpdateItem();
                UpdateExplosion();
                UpdateAnimation();
                Reset();
                UpdateParticleEngine();
                if (!currentPlayer.God)
                {
                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.otherTirList = new List <Tirs>();
                        Enemys[i].shotsIA.otherTirList = shotsPlayer.tirList;
                        for (int j = 0; j < Enemys[i].shotsIA.tirList.Count; j++)
                        {
                            shotsPlayer.otherTirList.Add(Enemys[i].shotsIA.tirList[j]);
                        }
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        IA.IACheckEvents(Enemys[i], IAType.patr_Snd, mapWorld, players, Enemys[i].shotsIA, destrucTileList, hostPlayer, sound, entityList, animationList, particlesEngineList, Content, Enemys, explosionReseau);
                        if (!Enemys[i].IsAlive)
                        {
                            entityList.Remove(Enemys[i]);
                            Enemys.RemoveAt(i);
                        }
                    }

                    for (int i = 0; i < Enemys.Count; i++)
                    {
                        Enemys[i].shotsIA.Update(animationList);
                    }
                }

                mapWorld.Update();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                break;

            case GameState.multi:
                sound.UpdateMusic();
                destrucTileList = new List <Vector3>();
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                //Player1Events.SurvivalLvL0 = Player1Events.killplayer0 / 50;
                UpdateParticleEngine();
                shotsPlayer.Update(animationList);
                UpdateExplosion();
                UpdateItem();
                UpdateAnimation();
                Reset();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                bool flagCapture = false;
                if (client.mode == ModeMulti.ctf)
                {
                    foreach (Flag flag in flags)
                    {
                        flagCapture = flag.Update(players[hostPlayer], mapWorld);
                    }
                }
                UpdateNetwork(flagCapture);
                break;

            case GameState.multiPause:

                sound.UpdateMusic();
                destrucTileList = new List <Vector3>();
                players[hostPlayer].Update(animationList);
                Player1Events.CheckEvents(players[hostPlayer], mapWorld, destrucTileList, hostPlayer, shotsPlayer, sound, ref msg, controles, entityList, animationList, particlesEngineList, Content, explosionReseau);
                Player1Events.MouseEvents(players[hostPlayer], shotsPlayer, camera, sound, controles, animationList, particlesEngineList);
                //Player1Events.SurvivalLvL0 = Player1Events.killplayer0 / 50;
                UpdateParticleEngine();
                shotsPlayer.Update(animationList);
                UpdateExplosion();
                UpdateItem();
                UpdateAnimation();
                Reset();
                camera.UpdateCentered(players, hostPlayer, scaleNormValue, GraphicsDevice, controles);
                flagCapture = false;
                if (client.mode == ModeMulti.ctf)
                {
                    foreach (Flag flag in flags)
                    {
                        flagCapture = flag.Update(players[hostPlayer], mapWorld);
                    }
                }
                UpdateNetwork(flagCapture);
                pause.Update(mouseCoef, controles);
                if (pause.menu)
                {
                    for (int i = 0; i < players[hostPlayer].ItemList.Count; i++)
                    {
                        if (players[hostPlayer].ItemList[i].type == objectType.flag)
                        {
                            players[hostPlayer].ItemList[i].isOnMap            = true;
                            ((Flag)players[hostPlayer].ItemList[i]).isCaptured = false;
                            mapWorld.itemList.Add(players[hostPlayer].ItemList[i]);
                            players[hostPlayer].ItemList.RemoveAt(i);
                            break;
                        }
                    }
                    client.SendExit(hostPlayer);
                    gameState      = GameState.menu;
                    menu.menuState = MenuState.main;
                    menu           = new Menu(Content, GraphicsDevice);
                    sound.soundPlayer.Stop();
                    menu.LaunchMenuSound(sound);
                }
                else if (pause.resumeGame)
                {
                    gameState = oldGameState;
                }
                break;

            case GameState.menu:
                menu.Update(ref gameState, mouseCoef, Content, ref fullScreenON, ref soundON, sound, controles);

                if (gameState == GameState.exit)
                {
                    Opt option = new Opt();
                    option.Fullscreen         = fullScreenON;
                    option.SoundOn            = soundON;
                    option.controleTab        = controles.controleTab;
                    option.name               = currentPlayer.name;
                    option.language           = Langage.langueactuelle;
                    option.masterServerAdress = ConnectMaster.MasterIPAdress;
                    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(Opt));
                    System.IO.StreamWriter file = new System.IO.StreamWriter((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Options/OptionMenu"));
                    writer.Serialize(file, option);
                    file.Close();

                    SavPerso obj = new SavPerso();
                    currentPlayer.Serialize(obj);
                    System.Xml.Serialization.XmlSerializer writer2 = new System.Xml.Serialization.XmlSerializer(typeof(SavPerso));
                    System.IO.StreamWriter file2 = new System.IO.StreamWriter((Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TDZ/Sauvegardes/") + currentPlayer.name);
                    writer2.Serialize(file2, obj);
                    file2.Close();

                    Exit();
                }
                if (gameState == GameState.multi || gameState == GameState.solo || gameState == GameState.editor || gameState == GameState.scenario)
                {
                    LoadContent();
                }

                break;

            case GameState.creation:
                menu.gestion.Update(ref currentPlayer, mouseCoef, controles, Content, GraphicsDevice);
                break;

            default:
                break;
            }

            //Save old Events State

            base.Update(gameTime);
        }
Exemple #5
0
        public void Serialize(SavPerso Serial)
        {
            List <Weapon> weaplist = new List <Weapon>();

            for (int i = 0; i < ItemList.Count; i++)
            {
                if (ItemList[i].GetType() == typeof(Weapon))
                {
                    weaplist.Add((Weapon)ItemList[i]);
                }
            }
            Serial.WeaponsList = new SavWeapon[weaplist.Count];
            SavWeapon savweapon = new SavWeapon();

            savweapon.accuracy         = currentWeapon.accuracy;
            savweapon.prix             = currentWeapon.prix;
            savweapon.ammoTexture      = currentWeapon.ammo;
            savweapon.cadence          = currentWeapon.cadence;
            savweapon.cadenceType      = currentWeapon.weaponType;
            savweapon.capacity         = currentWeapon.capacity;
            savweapon.currentAmo       = currentWeapon.currentAmo;
            savweapon.damage           = currentWeapon.damage;
            savweapon.id               = currentWeapon.id;
            savweapon.isOnMap          = currentWeapon.isOnMap;
            savweapon.itemImage        = currentWeapon.imagename;
            savweapon.munitions        = currentWeapon.munitions;
            savweapon.tirs             = currentWeapon.tirtype;
            savweapon.position         = currentWeapon.position;
            savweapon.range            = currentWeapon.range;
            savweapon.speed            = currentWeapon.speed;
            savweapon.weaponName       = currentWeapon.weaponName;
            savweapon.sound            = currentWeapon.shotSound;
            savweapon.tirs             = currentWeapon.tirtype;
            savweapon.numBalle         = currentWeapon.numBalle;
            savweapon.numArme          = currentWeapon.numArme;
            savweapon.hasSpecialAttack = currentWeapon.hasSpecialAttack;
            Serial.currentWeapon       = savweapon;

            for (int i = 0; i < weaplist.Count; i++)
            {
                savweapon                  = new SavWeapon();
                savweapon.prix             = weaplist[i].prix;
                savweapon.accuracy         = weaplist[i].accuracy;
                savweapon.ammoTexture      = weaplist[i].ammo;
                savweapon.cadence          = weaplist[i].cadence;
                savweapon.cadenceType      = weaplist[i].weaponType;
                savweapon.capacity         = weaplist[i].capacity;
                savweapon.currentAmo       = weaplist[i].currentAmo;
                savweapon.damage           = weaplist[i].damage;
                savweapon.id               = weaplist[i].id;
                savweapon.tirs             = weaplist[i].tirtype;
                savweapon.isOnMap          = weaplist[i].isOnMap;
                savweapon.itemImage        = weaplist[i].imagename;
                savweapon.munitions        = weaplist[i].munitions;
                savweapon.position         = weaplist[i].position;
                savweapon.range            = weaplist[i].range;
                savweapon.speed            = weaplist[i].speed;
                savweapon.weaponName       = weaplist[i].weaponName;
                savweapon.sound            = weaplist[i].shotSound;
                savweapon.numArme          = weaplist[i].numArme;
                savweapon.numBalle         = weaplist[i].numBalle;
                savweapon.hasSpecialAttack = weaplist[i].hasSpecialAttack;
                Serial.WeaponsList[i]      = savweapon;
            }

            Serial.name           = name;
            Serial.experience     = experience;
            Serial.niveau         = niveau;
            Serial.pointRestants  = pointRestants;
            Serial.attaquePoint   = attaquePoint;
            Serial.defensePoint   = defensePoint;
            Serial.dexteritePoint = dexteritePoint;
            Serial.vitessePoint   = vitessePoint;
            Serial.lifes          = lifes;
            Serial.accuracy       = accuracy;
            Serial.accelerateInit = accelerateInit;
            Serial.decelerateInit = decelerateInit;
            Serial.fallInit       = fallInit;
            Serial.jumpInit       = jumpInit;
            Serial.vitesseMaxInit = vitesseMaxInit;
            Serial.fallMaxInit    = fallMaxInit;
            Serial.attaque        = attaque;
            Serial.spritePerso    = spritePerso;

            Serial.pV           = pV;
            Serial.pVMax        = pVMax;
            Serial.defense      = defense;
            Serial.newChar      = newChar;
            Serial.money        = money;
            Serial.currentLevel = currentLevel;
        }