//void InitialiserAvatars()
        //{
        //   ListeAvatar = new List<Avatar_>();
        //   ListeAvatar.Add(new Avatar_(this, "unicorn", new Vector3(0, 10, -1), 1 / 60f, 1, manager1));
        //   ListeAvatar.Add(new Avatar_(this, "unicorn", new Vector3(0, 10, -1), 2 / 60f, 2, manager2));
        //   ListeAvatar.Add( new Avatar_(this, "unicorn", new Vector3(0, 10, -1), 3 / 60f, 2, manager2));
        //   ListeAvatar.Add(new Avatar_(this, "unicorn", new Vector3(0, 10, -1), 4 / 60f, 2, manager2));
        //}

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
           NbJoueurs = 2;

           TestView1 = new Viewport(0, 0, GameConstants.WindowWidth / 2, GameConstants.WindowHeight);
           TestView2 = new Viewport(GameConstants.WindowWidth / 2, 0, GameConstants.WindowWidth / 2, GameConstants.WindowHeight);

           ModelManager ManagerDeModele = new ModelManager(this);
           IOManager manager1 = new IOManager(this,1);
           IOManager manager2 = new IOManager(this, 2);
           CubeColoré CubeBlanc = new Sol(this, 1f, Vector3.Zero, Vector3.Zero, Color.White, new Vector3(20, 1, 10), 1 / 60f);
           CubeColoré CubeRouge = new Sol(this, 1f, Vector3.Zero, new Vector3(0,1,-5), Color.Red, new Vector3(20, 1.5f, 10), 1 / 60f);
           CubeColoré CubeBleu = new Sol(this, 1f, Vector3.Zero, new Vector3(0, 1, 10), Color.Blue, new Vector3(20, 1.5f, 10), 1 / 60f);
           CubeColoré CubeSol = new Sol(this, 1f, Vector3.Zero, new Vector3(0, -3, 0), Color.Yellow, new Vector3(200, 2, 200), INTERVALLE_CALCUL_STANDARD);
           licorne = new Avatar_(this, "cubefache", new Vector3(0, 10, -1), 1 / 60f, 1, manager1);
           Avatar_ licorne2 = new Avatar_(this, "unicorn", new Vector3(0, 10, -1), 1 / 60f, 2, manager2);
           ManagerÉcranDEBUG = new ScreenManager(this, Vector2.Zero);

           Vector3 positionCaméra = new Vector3(10,10,10);
           Vector3 positionObjet = new Vector3(0, 0, 0);
           Vector3 rotationObjet = new Vector3(0, MathHelper.PiOver2, 0);

           GestionnaireDeFonts = new RessourcesManager<SpriteFont>(this, "Fonts");
           GestionnaireDeTextures = new RessourcesManager<Texture2D>(this, "Textures");
           GestionnaireDeModèles = new RessourcesManager<Model>(this, "Models");
           spriteBatch = new SpriteBatch(GraphicsDevice);
           GestionInput = new InputManager(this);
           CaméraJeu = new CaméraFixe(this,new Vector3(10,10,10),Vector3.Zero,Vector3.Up);
           Caméra1 = new CaméraAvatar(this, licorne.Position, Vector3.Up, licorne,TestView1);
           Caméra2 = new CaméraAvatar(this, licorne.Position, Vector3.Up, licorne2, TestView2);
           defaut = GraphicsDevice.Viewport;


           //Components.Add(new ArrièrePlanDéroulant(this, "CielÉtoilé", INTERVALLE_CALCUL_STANDARD));
           //Components.Add(new ObjetDeBase(this, "unicorn", 10, rotationObjet, positionObjet));
           Components.Add(new AfficheurFPS(this, "Arial20", Color.Chartreuse, INTERVALLE_CALCUL_FPS));
           Components.Add(new Afficheur3D(this));
           Components.Add(GestionInput);
           Components.Add(Caméra1);
           Components.Add(Caméra2);
           Components.Add(CaméraJeu);
           //Components.Add(CubeBlanc);
           //Components.Add(CubeRouge);
           //Components.Add(CubeBleu);
           Components.Add(manager1);
           Components.Add(manager2);
           Components.Add(ManagerDeModele);
           //Components.Add(licorne);
           //Components.Add(licorne2);

           ManagerDeModele.AjouterModele(CubeBlanc);
           ManagerDeModele.AjouterModele(CubeBleu);
           ManagerDeModele.AjouterModele(CubeRouge);
           ManagerDeModele.AjouterModele(CubeSol);
           ManagerDeModele.AjouterModele(licorne);
           ManagerDeModele.AjouterModele(licorne2);
           ManagerDeModele.AjouterCaméra(Caméra1);
           ManagerDeModele.AjouterCaméra(Caméra2);

           Services.AddService(typeof(RessourcesManager<SpriteFont>), GestionnaireDeFonts);
           Services.AddService(typeof(RessourcesManager<Texture2D>), GestionnaireDeTextures);
           Services.AddService(typeof(RessourcesManager<Model>), GestionnaireDeModèles);
           Services.AddService(typeof(InputManager), GestionInput);
           Services.AddService(typeof(Caméra), CaméraJeu);
           Services.AddService(typeof(SpriteBatch), spriteBatch);
           base.Initialize();

           ListePhysique = new List<ICollisionable>();
           ListePhysique.Add(CubeBlanc as ICollisionable);
           ListePhysique.Add(CubeRouge as ICollisionable);
           ListePhysique.Add(licorne as ICollisionable);
           ListePhysique.Add(CubeBleu as ICollisionable);
           ListePhysique.Add(licorne2 as ICollisionable);
           ListePhysique.Add(CubeSol as ICollisionable);


           ManagerÉcranDEBUG.Initialize();
           ManagerÉcranDEBUG.AjouterItem(licorne);
           ManagerÉcranDEBUG.AjouterItem(licorne2);

           CubeBlanc.InitialiserSommets(Color.White);
           CubeBleu.InitialiserSommets(Color.Blue);
           CubeRouge.InitialiserSommets(Color.Red);
        }
Example #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            s = new Shutter(this, "Shutter", INTERVALLE_CALCUL_STANDARD);

             NbJoueurs = 2;
             ListeAvatar = new List<Avatar>();
             terrain = new Map(this, new Vector3(10,0,10), Vector3.Zero);
             ListeManagerControle = new List<IOManager>();
             ListeCaméraAvatars = new List<Caméra>();
             ModelManager ManagerDeModele = new ModelManager(this);
             GestionnaireGameState = new GamestateManager(this);
             ManagerÉcranDEBUG = new ScreenManager(this, Vector2.Zero);
             ViewPortDefaut = GraphicsDevice.Viewport;
             CaméraJeu = new CaméraFixe(this, new Vector3(10, 10, 10), Vector3.Zero, Vector3.Up);
             GénérerViewports(NbJoueurs);

             for (int i = 0; i < NbJoueurs; ++i)
             {
            ListeManagerControle.Add(new IOManager(this, ListePlayerIndex[i],INTERVALLE_CALCUL_STANDARD));
             }
             for (int i = 0; i < NbJoueurs; ++i)
             {
             ListeAvatar.Add(new Avatar(this, Content.Load<DescriptionAvatar>("Descriptions/Avatar" + i), ListePlayerIndex[i], ListeManagerControle[i]));
             }
             for (int i = 0; i < NbJoueurs; ++i)
             {
            ListeCaméraAvatars.Add(new CaméraAvatar(this, ListeAvatar[i].Position, Vector3.Up, ListeAvatar[i] as Avatar, ListeViewports[i]));
             }

             CubeColoré CubeBlanc = new Sol(this, 1f, new Vector3(0, 0, 0.2f), Vector3.Zero, Color.White, new Vector3(50, 2, 10), 1 / 60f);
             CubeColoré CubeRouge = new Sol(this, 1f, new Vector3(0, 0, 0f), new Vector3(0, 3, -5), Color.Red, new Vector3(20, 2f, 10), 1 / 60f);
             CubeColoré CubeBleu = new Sol(this, 1f, new Vector3(0, 0, 0f), new Vector3(0, 1f, 10), Color.Blue, new Vector3(20, 2f, 10), 1 / 60f);
             CubeColoré CubeSol = new Sol(this, 1f, new Vector3(0f, 0, 0f), new Vector3(0, -1, 0), Color.Yellow, new Vector3(200, 2, 200), INTERVALLE_CALCUL_STANDARD);
             //CubeColoré testCollision = new Sol(this, 1, Vector3.Zero, new Vector3(0, -1, 0), Color.Aqua, new Vector3(4, 2, 4), INTERVALLE_CALCUL_STANDARD);

             terrain.Initialize();

             GestionnaireDeFonts = new RessourcesManager<SpriteFont>(this, "Fonts");
             GestionnaireDeTextures = new RessourcesManager<Texture2D>(this, "Textures");
             GestionnaireDeModèles = new RessourcesManager<Model>(this, "Models");
             spriteBatch = new SpriteBatch(GraphicsDevice);
             GestionInput = new InputManager(this);

             //Components.Add(new AfficheurFPS(this, "Arial20", Color.Chartreuse, INTERVALLE_CALCUL_FPS));
             Components.Add(new Afficheur3D(this));
             Components.Add(GestionInput);
             Components.Add(CaméraJeu);
             Components.Add(ManagerDeModele);
             Components.Add(GestionnaireGameState);
             Components.Add(terrain);
             Components.Add(s);

             foreach (IOManager i in ListeManagerControle)
            Components.Add(i);
             foreach (Caméra c in ListeCaméraAvatars)
            Components.Add(c);

             ManagerDeModele.AjouterAvatars(ListeAvatar);
             ManagerDeModele.AjouterCaméra(ListeCaméraAvatars);
             ManagerDeModele.AjouterModele(CubeBlanc);
             ManagerDeModele.AjouterModele(CubeBleu);
             ManagerDeModele.AjouterModele(CubeRouge);
             //ManagerDeModele.AjouterModele(testCollision);
             ManagerDeModele.AjouterModele(CubeSol);

             Services.AddService(typeof(RessourcesManager<SpriteFont>), GestionnaireDeFonts);
             Services.AddService(typeof(RessourcesManager<Texture2D>), GestionnaireDeTextures);
             Services.AddService(typeof(RessourcesManager<Model>), GestionnaireDeModèles);
             Services.AddService(typeof(InputManager), GestionInput);
             Services.AddService(typeof(Caméra), CaméraJeu);
             Services.AddService(typeof(SpriteBatch), spriteBatch);

             ListePhysique = new List<ICollisionable>();
             foreach (Avatar a in ListeAvatar)
             ListePhysique.Add(a as ICollisionable);

             ListePhysique.Add(CubeBlanc as ICollisionable);
             ListePhysique.Add(CubeRouge as ICollisionable);
             ListePhysique.Add(CubeBleu as ICollisionable);
             ListePhysique.Add(CubeSol as ICollisionable);
             //ListePhysique.Add(testCollision as ICollisionable);

             Grille = new Grid(new Vector3(50, -8f, 50), 0.5f, this);
             //for (int i = 0; i < 1; i++)
             //{
             //    Ennemi ennemi = new Ennemi(this, "unicorn", new Vector3(i, 2, i), new Vector3(1, 2, 1), INTERVALLE_CALCUL_STANDARD, 0.5f, GameConstants.ViePersonnageMax, ListeAvatar, grille, i, new Vector3[8]);//, path);
             //    ManagerDeModele.AjouterModele(ennemi);
             //    ListePhysique.Add(ennemi as ICollisionable);
             //    if (i == 0)
             //    {
             //        Ennemi = ennemi;
             //    }
             //}
             Bazooka Bazooka = new Bazooka(this, "Bazooka", new Vector3(0, 2, 0), Vector3.One, 0.05f);
             SupportFusil SupportFusil = new SupportFusil(this, "SupportFusil", new Vector3(0, 10, 0), Vector3.One, 0.05f, Bazooka);
             ManagerDeModele.AjouterModele(Bazooka);
             ManagerDeModele.AjouterModele(SupportFusil);
             ListePhysique.Add(Bazooka as ICollisionable);
             ListePhysique.Add(SupportFusil as ICollisionable);

             foreach (Sol objet in terrain.ListeObjets)
             {
             ManagerDeModele.AjouterModele(objet as IModele3d);
             ListePhysique.Add(objet as ICollisionable);
             }

              base.Initialize();

             ManagerÉcranDEBUG.Initialize();
             foreach (Avatar a in ListeAvatar)
            ManagerÉcranDEBUG.AjouterItem(a);

             CubeBlanc.InitialiserSommets(Color.White);
             CubeBleu.InitialiserSommets(Color.Blue);
             CubeRouge.InitialiserSommets(Color.Red);
             //testCollision.InitialiserSommets(Color.Red);
        }
Example #3
0
      /// <summary>
      /// Allows the game to perform any initialization it needs to before starting to run.
      /// This is where it can query for any required services and load any non-graphic
      /// related content.  Calling base.Initialize will enumerate through any components
      /// and initialize them as well.
      /// </summary>
      protected override void Initialize()
      {
         NbJoueurs = 2;
         ListeAvatar = new List<Avatar>();
         ListeManagerControle = new List<IOManager>();
         ListeCaméraAvatars = new List<Caméra>();
         ModelManager ManagerDeModele = new ModelManager(this);
         ManagerÉcranDEBUG = new ScreenManager(this, Vector2.Zero);
         ViewPortDefaut = GraphicsDevice.Viewport;
         CaméraJeu = new CaméraFixe(this, new Vector3(10, 10, 10), Vector3.Zero, Vector3.Up);
         GénérerViewports(NbJoueurs);

         for (int i = 0; i < NbJoueurs; ++i)
         {
            ListeManagerControle.Add(new IOManager(this, i+1));
         }
         for (int i = 0; i < NbJoueurs; ++i)
         {
            ListeAvatar.Add(new Avatar(this, "unicorn", PositionAvatars[i], new Vector3(1, 1, 1), INTERVALLE_CALCUL_STANDARD, GameConstants.ViePersonnageMax, i+1, ListeManagerControle[i]));
         }
         for (int i = 0; i < NbJoueurs; ++i)
         {
            ListeCaméraAvatars.Add(new CaméraAvatar(this, ListeAvatar[i].Position, Vector3.Up, ListeAvatar[i] as Avatar, ListeViewports[i]));
         }

         CubeColoré CubeBlanc = new Sol(this, 1f, Vector3.Zero, Vector3.Zero, Color.White, new Vector3(20, 2, 10), 1 / 60f);
         CubeColoré CubeRouge = new Sol(this, 1f, Vector3.Zero, new Vector3(0, 1, -5), Color.Red, new Vector3(20, 2f, 10), 1 / 60f);
         CubeColoré CubeBleu = new Sol(this, 1f, Vector3.Zero, new Vector3(0, 1f, 10), Color.Blue, new Vector3(20, 2f, 10), 1 / 60f);
         CubeColoré CubeSol = new Sol(this, 1f, Vector3.Zero, new Vector3(0, -1, 0), Color.Yellow, new Vector3(200, 2, 200), INTERVALLE_CALCUL_STANDARD);
         CubeColoré testCollision = new Sol(this, 1, Vector3.Zero, new Vector3(0, -1, 0), Color.Aqua, new Vector3(4, 2, 4), INTERVALLE_CALCUL_STANDARD);

         GestionnaireDeFonts = new RessourcesManager<SpriteFont>(this, "Fonts");
         GestionnaireDeTextures = new RessourcesManager<Texture2D>(this, "Textures");
         GestionnaireDeModèles = new RessourcesManager<Model>(this, "Models");
         spriteBatch = new SpriteBatch(GraphicsDevice);
         GestionInput = new InputManager(this);

         Components.Add(new AfficheurFPS(this, "Arial20", Color.Chartreuse, INTERVALLE_CALCUL_FPS));
         Components.Add(new Afficheur3D(this));
         Components.Add(GestionInput);
         Components.Add(CaméraJeu);
         Components.Add(ManagerDeModele);
         foreach (IOManager i in ListeManagerControle)
            Components.Add(i);
         foreach (Caméra c in ListeCaméraAvatars)
            Components.Add(c);

         ManagerDeModele.AjouterAvatars(ListeAvatar);
         ManagerDeModele.AjouterCaméra(ListeCaméraAvatars);
         ManagerDeModele.AjouterModele(CubeBlanc);
         ManagerDeModele.AjouterModele(CubeBleu);
         ManagerDeModele.AjouterModele(CubeRouge);
         ManagerDeModele.AjouterModele(testCollision);
         ManagerDeModele.AjouterModele(CubeSol);

         Services.AddService(typeof(RessourcesManager<SpriteFont>), GestionnaireDeFonts);
         Services.AddService(typeof(RessourcesManager<Texture2D>), GestionnaireDeTextures);
         Services.AddService(typeof(RessourcesManager<Model>), GestionnaireDeModèles);
         Services.AddService(typeof(InputManager), GestionInput);
         Services.AddService(typeof(Caméra), CaméraJeu);
         Services.AddService(typeof(SpriteBatch), spriteBatch);
         base.Initialize();

         ListePhysique = new List<ICollisionable>();
         foreach(Avatar a in ListeAvatar)
            ListePhysique.Add(a as ICollisionable);

         ListePhysique.Add(CubeBlanc as ICollisionable);
         ListePhysique.Add(CubeRouge as ICollisionable);
         ListePhysique.Add(CubeBleu as ICollisionable);
         ListePhysique.Add(CubeSol as ICollisionable);
         ListePhysique.Add(testCollision as ICollisionable);

         ManagerÉcranDEBUG.Initialize();
         foreach (Avatar a in ListeAvatar)
            ManagerÉcranDEBUG.AjouterItem(a);

         CubeBlanc.InitialiserSommets(Color.White);
         CubeBleu.InitialiserSommets(Color.Blue);
         CubeRouge.InitialiserSommets(Color.Red);
         testCollision.InitialiserSommets(Color.Red);
      }