Example #1
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;
            }
        }
Example #2
0
        private void LoadSurvivalEnemy()
        {
            Enemys = new List <Enemy>();
            int nbIa = 0;

            if (mapWorld.IASpawnList.Count > 2)
            {
                nbIa = 2;
            }
            else
            {
                nbIa = mapWorld.IASpawnList.Count;
            }

            for (int i = 0; i < nbIa; i++)
            {
                Enemys.Add(new Enemy(mapWorld.IASpawnList[i], TexturesGame.IATab[0], 100 + i, Content, LoadWeapons.LoadIAGun(Content), true, 0, GraphicsDevice));
                entityList.Add(Enemys[i]);
            }
        }
Example #3
0
 private void LoadSurvival(List <Enemy> Enemys)
 {
     if (Player1Events.SurvivalLvl1 == Player1Events.SurvivalLvL0 && Player1Events.SurvivalLvl1 > 0 && Enemys.Count < 20)
     {
         for (int i = 0; i < 2; i++)
         {
             Enemys.Capacity++;
             Enemys.Add(new Enemy(mapWorld.IASpawnList[Enemys.Count % mapWorld.IASpawnList.Count], TexturesGame.IATab[0], 100 + Enemys.Count, Content, LoadWeapons.LoadIAGun(Content), true, 0, GraphicsDevice));
             entityList.Capacity++;
             entityList.Add(Enemys[Enemys.Count - 1]);
         }
         Player1Events.SurvivalLvl1++;
     }
 }
Example #4
0
        private void LoadEnemy()
        {
            Enemys = new List <Enemy>();

            for (int i = 0; i < 2; i++) ///!
            {
                Enemys.Add(new Enemy(mapWorld.IASpawnList[i], TexturesGame.IATab[0], 100 + i, Content, LoadWeapons.LoadIAGun(Content), true, 0, GraphicsDevice));
            }
        }