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
        public void BuildGameComponents(int mapSeed)
        {
            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.Services.AddService(typeof(ICameraService), this.camera);

            Console.WriteLine(" {0}  ", mapSeed);
            this.gameMap = new Map(this, new Vector3(0, 0, 0), mapSeed);
            this.Services.AddService(typeof(Map), this.gameMap);

            this.path = new Path(this);
            this.Services.AddService(typeof(Path), this.path);

            this.gamePlayer = new Player(this);
            this.Services.AddService(typeof(Player), this.gamePlayer);

            this.fps = new FPS(this);

            this.mainMenu = new MainMenu(this);

            this.Components.Add(this.camera);
            this.Components.Add(this.gameMap);
            this.Components.Add(mainMenu);
            this.Components.Add(fps);
            this.Components.Add(this.path);
            this.Components.Add(this.gamePlayer);
        }