Example #1
0
        /// <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();
        }
Example #2
0
        /// <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();
        }