/// <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); }
/// <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); }