Exemple #1
0
        /// <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()
        {
            // TODO: Add your initialization logic here
            input = new Input();
            GraphicsDevice.BlendState = BlendState.AlphaBlend;
            dpsLockDepthWrite = new DepthStencilState();
            dpsLockDepthWrite.DepthBufferWriteEnable = false;
            DepthStencilState dpsUnLockDepthWrite = new DepthStencilState();
            dpsUnLockDepthWrite.DepthBufferWriteEnable = true;

            //graphics.PreferredBackBufferWidth = 1280;
            //graphics.PreferredBackBufferHeight = 720;
            //b = new Bat(-11f, Vector3.UnitZ, Vector3.Up, 0.9f, 0.9f, 0.9f, Color.Gray, graphics);

            myCamera = new CameraComponent(graphics);

            //model = new GameModel(this, Content, myCamera, Matrix.Identity, e, "box");
            //Components.Add(model);
            float width = 2.0f;
            float height = 1.2f;
            tunnel = new Tunnel(this, graphics, myCamera, Content, 1, 15, Vector3.Zero, Vector3.Backward, Vector3.Up, width, height);

            frontBat = new Bat(-2.0f, Vector3.Backward, Vector3.Up, .2f, .2f, Color.Red, myCamera, graphics, width, height);
            backBat = new Bat(-15.0f, Vector3.Backward, Vector3.Up, .2f, .2f, Color.Green, myCamera, graphics, width, height);
            Components.Add(tunnel);

            base.Initialize();
        }
Exemple #2
0
        public Bat(float zeta, Vector3 normal, Vector3 up, float width, float height, Color color, CameraComponent camera, GraphicsDeviceManager gdm, float boundWidth, float boundHeight)
        {
            boundW = boundWidth;
            boundH = boundHeight;
            _camera = camera;
            _color = color;
            _gdm = gdm;

            _left = Vector3.Cross(normal, up) * width / 2 + Vector3.UnitZ * zeta;
            _upperLeft = _left + Vector3.UnitY * height/2;
            _upperRight = _upperLeft + Vector3.UnitX * width;
            _lowerLeft = _upperLeft - Vector3.UnitY * height;
            _lowerRight = _lowerLeft + Vector3.UnitX * width;

            _vertices = new VertexPositionColor[4];
            _indexes = new int[6];
            fillVertices();
            be = new BasicEffect(gdm.GraphicsDevice);

            be.World = Matrix.Identity;
            be.View = camera.View;
            be.Projection = camera.Proj;
            be.Alpha = 0.5f;
            be.VertexColorEnabled = true;
        }
Exemple #3
0
 public GameModel(Game game, ContentManager cm, CameraComponent myCamera, Matrix world, Effect effect, string modelName)
     : base(game)
 {
     // TODO: Construct any child components here
     _modelname = modelName;
     _cm = cm;
     _camera = myCamera;
     _world = world;
     _needeffect = effect;
 }
Exemple #4
0
 public Tunnel(Game game, GraphicsDeviceManager gdm, CameraComponent camera, ContentManager cm, int near, int far, Vector3 origin, Vector3 normal, Vector3 up, float width, float height)
     : base(game)
 {
     // TODO: Construct any child components here
     _origin = origin;
     _normal = normal;
     _up = up;
     _width = width;
     _height = height;
     _graphics = gdm;
     _content = cm;
     _camera = camera;
     _near = near;
     _far = far;
 }