Esempio n. 1
0
        public Tank1(Model model, GraphicsDevice device, Camera camera)
            : base(model)
        {
            mousePick = new MousePicking(device, camera);
            //载入模型
            turretBone = model.Bones["turret_geo"];
            canonBone = model.Bones["canon_geo"];
            lbackwheelBone = model.Bones["l_back_wheel_geo"];
            rbackwheelBone = model.Bones["r_back_wheel_geo"];
            lfrontwheelBone = model.Bones["l_front_wheel_geo"];
            rfrontwheelBone = model.Bones["r_front_wheel_geo"];
            lsteergeoBone = model.Bones["l_steer_geo"];
            rsteergeoBone = model.Bones["r_steer_geo"];
            hatchgeo = model.Bones["hatch_geo"];

            //赋值给每个部件的变换
            leftBackWheelTransform = lbackwheelBone.Transform;
            rightBackWheelTransform = rbackwheelBone.Transform;
            leftFrontWheelTransform = lfrontwheelBone.Transform;
            rightFrontWheelTransform = rfrontwheelBone.Transform;
            leftSteerTransform = lsteergeoBone.Transform;
            rightSteerTransform = rsteergeoBone.Transform;
            turretTransform = turretBone.Transform;
            hatchTransform = hatchgeo.Transform;
            canonTransform = canonBone.Transform;
        }
Esempio n. 2
0
 public PursuitEnemy(Model model, Vector3 position,GraphicsDevice device, Camera camera,Tank tank)
     : base(model, device, camera)
 {
     tankBox = new BoundingBox(MIN, MAX);
     CurrentPosition = position;
     pickPosition = CurrentPosition;
     translation = Matrix.CreateTranslation(Map.MapToWorld(new Point(10, 10)));
     velocity = Vector3.Zero;
     new Tank(model, device, camera);
     steer = new Steering(100f, 100f);
     map = new Map();
     pathfinder = new Pathfinder(map);
     isMoving = false;
     initialAngle = MathHelper.PiOver2;
     moveorder = 0;
     mousepick = new MousePicking(device, camera);
     targetTank = tank;
 }
Esempio n. 3
0
        public Tank(Model model, GraphicsDevice device, Camera camera)
            : base(model)
        {
            this.tankcamera = camera;
            mousePick = new MousePicking(device, camera);
            currentCameraDirection = tankcamera.cameraDirection;
            //载入模型
            turretBone = model.Bones["turret_geo"];
            canonBone = model.Bones["canon_geo"];
            lbackwheelBone = model.Bones["l_back_wheel_geo"];
            rbackwheelBone = model.Bones["r_back_wheel_geo"];
            lfrontwheelBone = model.Bones["l_front_wheel_geo"];
            rfrontwheelBone = model.Bones["r_front_wheel_geo"];
            lsteergeoBone = model.Bones["l_steer_geo"];
            rsteergeoBone = model.Bones["r_steer_geo"];
            hatchgeo = model.Bones["hatch_geo"];

            //赋值给每个部件的变换
            leftBackWheelTransform = lbackwheelBone.Transform;
            rightBackWheelTransform = rbackwheelBone.Transform;
            leftFrontWheelTransform = lfrontwheelBone.Transform;
            rightFrontWheelTransform = rfrontwheelBone.Transform;
            leftSteerTransform = lsteergeoBone.Transform;
            rightSteerTransform = rsteergeoBone.Transform;
            turretTransform = turretBone.Transform;
            hatchTransform = hatchgeo.Transform;
            canonTransform = canonBone.Transform;
            //rotation = Matrix.CreateRotationY(MathHelper.Pi);

            initialAngle = MathHelper.PiOver2;
            //tankBox = new BoundingBox(MIN, MAX);
            //CurrentPosition = Vector3.Zero;
        }
Esempio n. 4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            //camera.cameraPosition = modelManager.tankCurrentPosition + (new Vector3(camera.cameraDirection.X, 60, camera.cameraDirection.Z +60));

            // TODO: Add your update logic here
            if (shotCountdown <= 0)
            {
                if (Mouse.GetState().RightButton == ButtonState.Pressed)
                {

                    Vector3? pickpos;
                    MousePicking mousePick;

                    mousePick = new MousePicking(device, camera);
                    pickpos = mousePick.GetCollisionPosition();

                    if (pickpos.HasValue)
                    {
                        modelManager.AddBullets(pickpos.Value);
                        soundShot.Play();
                        shotCountdown = 500;
                    }
                }
            }
            else
            {
                shotCountdown -= gameTime.ElapsedGameTime.Milliseconds;
            }

            if (health == 0)
            {
                ChangeGameState(GameState.END, level);
            }

            if (killed >= (int)modelManager.levelInfoList[modelManager.currentLevel].numberEnemies)
            {
                if (modelManager.currentLevel > 10)
                {
                    ChangeGameState(GameState.END, level);
                }
                else
                {

                    ChangeGameState(GameState.LEVEL_CHANGE, level++);
                    modelManager.enemyThisLevel = 0;
                    modelManager.currentLevel++;
                    modelManager.SetNextSpawnTime();
                }
            }

            base.Update(gameTime);
        }