Exemplo n.º 1
0
 public Player(ContentManager content, Map map, FirstPersonCamera cam)
 {
     prevmous         = Mouse.GetState();
     bullets          = new List <Bullet>();
     this.bulletmodel = content.Load <Model>("Models/bullet");
     this.map         = map;
     this.cam         = cam;
 }
Exemplo n.º 2
0
 public Player(ContentManager content,Map map,FirstPersonCamera cam)
 {
     prevmous = Mouse.GetState();
     bullets = new List<Bullet>();
     this.bulletmodel = content.Load<Model>("Models/bullet");
     this.map = map;
     this.cam = cam;
 }
Exemplo n.º 3
0
        public Map(ContentManager content, FirstPersonCamera cam)
        {
            Blocks = new List <Sprite3D>();
            images = new List <Image3D>();
            map    = new List <string>();

            this.content = content;
            this.cam     = cam;
        }
Exemplo n.º 4
0
        public Map(ContentManager content,FirstPersonCamera cam)
        {
            Blocks = new List<Sprite3D>();
            images = new List<Image3D>();
            map = new List<string>();

            this.content = content;
            this.cam = cam;
        }
Exemplo n.º 5
0
        public PlayState(GameStateManager gsm, ContentManager content)
            : base(gsm, content)
        {
            keyb = Keyboard.GetState();

            cam = new FirstPersonCamera(Vector3.Zero, Vector3.Zero, Consts.WORLDSCALE/15f, 0.001f);

            map = new Map(content,cam);
            map.setLevel(1);

            cam.setMap(map);

            player = new Player(content, map,cam);
        }
Exemplo n.º 6
0
        public Bullet(Model model,FirstPersonCamera cam)
        {
            shape = new Sprite3D(model);
            this.cam = cam;
            shape.setPosition(cam.getPosition());
            shape.setScale(Consts.WORLDSCALE / 10f);

            float dx = cam.getLookAt().X - shape.getPosition().X;
            float dy = cam.getLookAt().Y - shape.getPosition().Y;
            float dz = cam.getLookAt().Z - shape.getPosition().Z;
            float d = (float)(Math.Sqrt(dx * dx + dy * dy + dz * dz));

            this.velocity = new Vector3(dx / d * Consts.BULLETSPEED, dy / d * Consts.BULLETSPEED, dz / d * Consts.BULLETSPEED);
        }
Exemplo n.º 7
0
        public PlayState(GameStateManager gsm, ContentManager content)
            : base(gsm, content)
        {
            keyb = Keyboard.GetState();

            cam = new FirstPersonCamera(Vector3.Zero, Vector3.Zero, Consts.WORLDSCALE / 15f, 0.001f);

            map = new Map(content, cam);
            map.setLevel(1);

            cam.setMap(map);

            player = new Player(content, map, cam);
        }
Exemplo n.º 8
0
        public Bullet(Model model, FirstPersonCamera cam)
        {
            shape    = new Sprite3D(model);
            this.cam = cam;
            shape.setPosition(cam.getPosition());
            shape.setScale(Consts.WORLDSCALE / 10f);

            float dx = cam.getLookAt().X - shape.getPosition().X;
            float dy = cam.getLookAt().Y - shape.getPosition().Y;
            float dz = cam.getLookAt().Z - shape.getPosition().Z;
            float d  = (float)(Math.Sqrt(dx * dx + dy * dy + dz * dz));

            this.velocity = new Vector3(dx / d * Consts.BULLETSPEED, dy / d * Consts.BULLETSPEED, dz / d * Consts.BULLETSPEED);
        }
Exemplo n.º 9
0
 public void draw(FirstPersonCamera cam)
 {
     Matrix[] transforms = new Matrix[model.Bones.Count];
     model.CopyAbsoluteBoneTransformsTo(transforms);
     foreach (ModelMesh mesh in model.Meshes)
     {
         foreach (BasicEffect effect in mesh.Effects)
         {
             effect.EnableDefaultLighting();
             effect.World      = transforms[mesh.ParentBone.Index] * getWorld();
             effect.View       = cam.getView();
             effect.Projection = cam.projection;
         }
         mesh.Draw();
     }
 }
Exemplo n.º 10
0
        public void draw(FirstPersonCamera cam)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * getWorld();
                    effect.View = cam.getView();
                    effect.Projection = cam.projection;

                }
                mesh.Draw();
            }
        }
Exemplo n.º 11
0
        private void drawMatrix(FirstPersonCamera cam, Matrix world)
        {
            effect.EnableDefaultLighting();
            effect.LightingEnabled = true;
            effect.World           = world;
            effect.View            = cam.getView();
            effect.Projection      = cam.projection;
            effect.Texture         = texture;
            effect.TextureEnabled  = true;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                effect.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
                effect.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
            }
        }
Exemplo n.º 12
0
 public void draw(FirstPersonCamera camera)
 {
     drawMatrix(camera, getWorld());
     drawMatrix(camera, getWorldReversed());
 }
Exemplo n.º 13
0
        private void drawMatrix(FirstPersonCamera cam, Matrix world)
        {
            effect.EnableDefaultLighting();
            effect.LightingEnabled = true;
            effect.World = world;
            effect.View = cam.getView();
            effect.Projection = cam.projection;
            effect.Texture = texture;
            effect.TextureEnabled = true;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                effect.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
                effect.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
            }
        }
Exemplo n.º 14
0
 public void draw(FirstPersonCamera camera)
 {
     drawMatrix(camera, getWorld());
     drawMatrix(camera, getWorldReversed());
 }