Exemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Car" /> class.
 /// </summary>
 /// <param name="speed">The speed.</param>
 /// <param name="direction">The direction.</param>
 public Car(int speed, Direction direction)
 {
     Speed     = speed;
     Direction = direction;
     Sprite    = new CarSprite();
     RenderSprite();
 }
Exemplo n.º 2
0
 private void initializeCarSprite()
 {
     Sprite = new CarSprite
     {
         Visibility = Visibility.Collapsed
     };
 }
Exemplo n.º 3
0
        public override void LoadContent()
        {
            if (m_content == null)
            {
                m_content = new ContentManager(Game.Services, "Content");
            }

            string selectedTrack = SelectionScreen.SelectedTrack;
            string selectedCar   = SelectionScreen.SelectedCar;
            var    carTypes      = SelectionScreen.CarTypes;

            var obstacleMap = m_content.Load <ObstacleMap>(string.Format("DataMaps/Obstacles/{0}", selectedTrack));

            m_trackImage = m_content.Load <Texture2D>(string.Format("Images/RaceTracks/{0}", selectedTrack));

            m_background    = m_content.Load <Texture2D>("Images/Backgrounds/DefaultBackground");
            m_obstacleImage = m_content.Load <Texture2D>("Images/BorderingTire");

            m_raceEngine = new RaceEngine();
            m_raceEngine.AddObstacles(obstacleMap);


            CarSprite player = new CarSprite();

            player.Data = new RaceCar();
            m_raceEngine.AddCar(player.Data);
            player.Image = m_content.Load <Texture2D>(string.Format("Images/Cars/{0}", selectedCar));
            m_carSprites.Add(player);

            player.Data.CarControls = new CarController_Player(this.ScreenManager.InputState, this.ControllingPlayer.Value);


            base.LoadContent();
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Car" /> class.
        /// </summary>
        /// <param name="direction">direction the vehicle is facing</param>
        /// <param name="initialSpeed">initial speed of vehicle</param>
        public Car(Direction direction, double initialSpeed) : base(direction, initialSpeed)
        {
            Sprite = new CarSprite();
            SetSpeed(initialSpeed, SpeedY);

            if (direction == Direction.Right)
            {
                FlipSprite();
            }
        }
Exemplo n.º 5
0
        private void createVehicleFromType(VehicleType vehicleType)
        {
            switch (vehicleType)
            {
            case VehicleType.Car:
                Sprite = new CarSprite();
                break;

            case VehicleType.SemiTruck:
                Sprite = new SemiTruckSprite();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(vehicleType), vehicleType, null);
            }
        }
Exemplo n.º 6
0
 /// <summary>Initializes a new instance of the <see cref="Car" /> class.</summary>
 /// <param name="heading">The heading of the sprite</param>
 public Car(Heading heading)
 {
     Sprite = new CarSprite();
     this.SetHeading(heading);
 }
Exemplo n.º 7
0
 /// <summary>Initializes a new instance of the <see cref="PoliceCar" /> class.</summary>
 /// <param name="defaultSpeed">The default speed.</param>
 /// <param name="direction">The direction.</param>
 public PoliceCar(double defaultSpeed, Direction direction) : base(defaultSpeed, direction)
 {
     Sprite = new CarSprite();
 }
Exemplo n.º 8
0
 /// <summary>Initializes a new instance of the <see cref="Car" /> class.</summary>
 /// <param name="direction">The direction.</param>
 /// Precondition: None
 /// Postcondition: None
 public Car(Direction direction) : base(direction)
 {
     Sprite = new CarSprite();
     reflectSpriteIfFacingLeft();
 }
Exemplo n.º 9
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Car" /> class.
 ///     Precondition: none
 ///     Post-condition: none
 /// </summary>
 public Car()
 {
     Sprite = new CarSprite();
 }