/// <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() { this.networkingClient = new NetworkingClient(this); this.Components.Add(this.networkingClient); this.Services.AddService(typeof(NetworkingClient), this.networkingClient); //this.camera = new Camera(this, new Vector3(0, 0, 100), // new Vector3(1, 0, 0), // new Vector3(0, 1, 0), // new Vector3(0, 0, 0)); //this.Components.Add(this.camera); //this.Services.AddService(typeof(ICameraService), this.camera); //this.gameMap = new Map(this, new Vector3(0, 0, 0), 100, 60); //this.Components.Add(this.gameMap); //this.Services.AddService(typeof(Map), this.gameMap); //this.path = new Path(this); //this.Components.Add(this.path); //this.Services.AddService(typeof(Path), this.path); //this.gamePlayer = new Player(this); //this.Components.Add(this.gamePlayer); //this.Services.AddService(typeof(Player), this.gamePlayer); //this.fps = new FPS(this); //this.Components.Add(fps); //this.mainMenu = new MainMenu(this); //this.Components.Add(mainMenu); this.Services.AddService(typeof(Shooter), this); base.Initialize(); }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { basicEffect = new BasicEffect(this.game.GraphicsDevice); basicEffect.VertexColorEnabled = true; basicEffect.Projection = Matrix.CreateOrthographicOffCenter (0, this.game.GraphicsDevice.Viewport.Width, // left, right this.game.GraphicsDevice.Viewport.Height, 0, // bottom, top 0, 1); // near, far plane vertices = new VertexPositionColor[2]; //Position and orientation playerPosition = new Vector3(0.0f, 0.0f, 2.0f); playerZRoatation = 0.0f; movingSpeed = 0.02f; shootingDistance = 20; playerWaitingTimerThres = 1000; //1s playerWaitingTimer = 0; playerTurnTimerThres = 5000; //5s playerTurnTimer = 0; opponentMovingSpeed = 0.02f; opponentShootingDistance = 20; //Animation playerAlphaTimer = 0; playerAlphaSpeed = 1; playerAlpha = 1.0f; lineEffect = new BasicEffect(this.Game.GraphicsDevice); lineEffect.VertexColorEnabled = true; this.camera = this.game.Services.GetService(typeof(ICameraService)) as ICameraService; if (this.camera == null) { throw new InvalidOperationException("ICameraService not found."); } this.path = this.game.Services.GetService(typeof(Path)) as Path; if (this.path == null) { throw new InvalidOperationException("Path not found."); } this.shooter = this.game.Services.GetService(typeof(Shooter)) as Shooter; if (this.shooter == null) { throw new InvalidOperationException("Shooter not found."); } this.networkingClient = this.game.Services.GetService(typeof(NetworkingClient)) as NetworkingClient; if (this.shooter == null) { throw new InvalidOperationException("Networking not found."); } this.map = this.game.Services.GetService(typeof(Map)) as Map; if (this.map == null) { throw new InvalidOperationException("Map not found."); } internalBoolMap = map.getCurrentDisplayedMapDetail(); //this.playerId = networkingClient.GetPlayerId(); base.Initialize(); }