/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Shooter game = new Shooter()) { game.Run(); } }
public NetworkingClient(Game game) : base(game) { this.game = (Shooter)game; this.prevKeyboardState = Keyboard.GetState(); NetPeerConfiguration config = new NetPeerConfiguration("projectorigin"); config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); client = new NetClient(config); client.Start(); }
public FPS(Game game) : base(game) { this.shooter = game.Services.GetService(typeof(Shooter)) as Shooter; if (this.shooter == null) { throw new InvalidOperationException("Shooter not found."); } this.map = game.Services.GetService(typeof(Map)) as Map; if (this.map == null) { throw new InvalidOperationException("Map not found."); } }
/// <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() { // TODO: Add your initialization code here this.camera = this.Game.Services.GetService(typeof(ICameraService)) as ICameraService; if (this.camera == null) { throw new InvalidOperationException("ICameraService not found."); } this.gameMap = this.Game.Services.GetService(typeof(Map)) as Map; if (this.gameMap == null) { throw new InvalidOperationException("Map not found."); } this.player = this.Game.Services.GetService(typeof(Player)) as Player; if (this.player == null) { throw new InvalidOperationException("Player not found."); } this.shooter = this.Game.Services.GetService(typeof(Shooter)) as Shooter; if (this.shooter == null) { throw new InvalidOperationException("Shooter not found."); } base.Initialize(); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); backgroundPlayerPicTexture = this.Game.Content.Load<Texture2D>("Models\\backgroundPlayer"); backgroundPlayerPicPos = new Vector2(-20, this.Game.GraphicsDevice.Viewport.Height / 2- 50); backgroundPlayerPicCenter = new Vector2(0, 0); backgroundPicTexture = this.Game.Content.Load<Texture2D>("Models\\background"); backgroundPicPos = new Vector2(this.Game.GraphicsDevice.Viewport.Width / 2, this.Game.GraphicsDevice.Viewport.Height / 2); backgroundPicCenter = new Vector2(backgroundPicTexture.Width / 2, backgroundPicTexture.Height / 2); menuTexture = this.Game.Content.Load<Texture2D>("Models\\mainMenu"); menuPos = new Vector2(this.Game.GraphicsDevice.Viewport.Width / 2, this.Game.GraphicsDevice.Viewport.Height / 4 * 3); menuCenter = new Vector2(menuTexture.Width / 2, menuTexture.Height / 2); titleTexture = this.Game.Content.Load<Texture2D>("Models\\title"); titlePos = new Vector2(this.Game.GraphicsDevice.Viewport.Width / 5 * 2, this.Game.GraphicsDevice.Viewport.Height / 4); titleCenter = new Vector2(titleTexture.Width / 2, titleTexture.Height / 2); soundEffect = this.Game.Content.Load<Song>("Sounds\\bgm"); this.shooter = this.Game.Services.GetService(typeof(Shooter)) as Shooter; if (this.shooter == null) { throw new InvalidOperationException("Shooter not found."); } MediaPlayer.Play(soundEffect); base.LoadContent(); }
public override void Initialize() { int widthNum; int heightNum; widthNum = this.internalMap.NumGridsWidth; heightNum = this.internalMap.NumGridsHeight; this.pointMatrics = new VertexPositionColor[heightNum][]; for (int row = 0; row < heightNum; row++) { VertexPositionColor[] temp = new VertexPositionColor[widthNum * 2 + 2]; for (int col = 0; col <= widthNum; col++) { temp[col * 2].Position = new Vector3(this.start.X + (InternalMap.GridSize * col), this.start.Y + (this.start.Y + InternalMap.GridSize * row) , this.start.Z); temp[col * 2 + 1].Position = new Vector3(this.start.X + (InternalMap.GridSize * col), this.start.Y + (this.start.Y + InternalMap.GridSize * row) + InternalMap.GridSize, this.start.Z); temp[col * 2].Color = Map.DefaultColor; temp[col * 2 + 1].Color = Map.DefaultColor; } this.pointMatrics[row] = temp; } this.shooter = this.Game.Services.GetService(typeof(Shooter)) as Shooter; if (this.shooter == null) { throw new InvalidOperationException("Shooter not found."); } 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(); }