コード例 #1
0
ファイル: PlayerShip.cs プロジェクト: dsaf/ShipGame
        ChaseCamera chaseCamera;                 // chase camera object

        /// <summary>
        /// Create a new player ship
        /// </summary>
        public PlayerShip(
            GameManager game,        // game manager
            int player,              // player id
            Model model,             // model for player ship
            EntityList entities,     // entity list for ship model
            float radius)            // collision box radius
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            // save parameters
            gameManager  = game;
            shipModel    = model;
            shipEntities = entities;
            playerIndex  = player;

            // create movement controller
            movement             = new PlayerMovement();
            movement.maxVelocity = GameOptions.MovementVelocity;

            // enable collision sound
            collisionSound = true;

            // create engine particle system with infinite life time
            particleBoost = gameManager.AddParticleSystem(
                ParticleSystemType.ShipTrail,
                transform);
            particleBoost.SetTotalTime(1e10f);
            boostTransform = shipEntities.GetTransform("engine");

            // create the ship collision box
            box = new CollisionBox(-radius, radius);

            // random bobbing offset
            random      = new Random(player);
            bobbingTime = (float)random.NextDouble();

            // setup 3rd person camera parameters
            camera3rdPerson = false;
            chaseCamera     = new ChaseCamera();
            chaseCamera.DesiredPositionOffset = GameOptions.CameraOffset;
            chaseCamera.LookAtOffset          = GameOptions.CameraTargetOffset;
            chaseCamera.Stiffness             = GameOptions.CameraStiffness;
            chaseCamera.Damping = GameOptions.CameraDamping;
            chaseCamera.Mass    = GameOptions.CameraMass;
        }
コード例 #2
0
ファイル: PlayerShip.cs プロジェクト: CS583/The3dgamesample
        // collision box radius
        /// <summary>
        /// Create a new player ship
        /// </summary>
        public PlayerShip(
            GameManager game,        // game manager
            int player,              // player id
            Model model,             // model for player ship
            EntityList entities,     // entity list for ship model
            float radius)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            // save parameters
            gameManager = game;
            shipModel = model;
            shipEntities = entities;
            playerIndex = player;

            // create movement controller
            movement = new PlayerMovement();
            movement.maxVelocity = GameOptions.MovementVelocity;

            // enable collision sound
            collisionSound = true;

            // create engine particle system with infinite life time
            particleBoost = gameManager.AddParticleSystem(
                                                ParticleSystemType.ShipTrail,
                                                transform);
            particleBoost.SetTotalTime(1e10f);
            boostTransform = shipEntities.GetTransform("engine");

            // create the ship collision box
            box = new CollisionBox(-radius, radius);

            // random bobbing offset
            random = new Random(player);
            bobbingTime = (float)random.NextDouble();

            // setup 3rd person camera parameters
            camera3rdPerson = false;
            chaseCamera = new ChaseCamera();
            chaseCamera.DesiredPositionOffset = GameOptions.CameraOffset;
            chaseCamera.LookAtOffset = GameOptions.CameraTargetOffset;
            chaseCamera.Stiffness = GameOptions.CameraStiffness;
            chaseCamera.Damping = GameOptions.CameraDamping;
            chaseCamera.Mass = GameOptions.CameraMass;
        }