Пример #1
0
        //Buy a car and save it to the player's garadge
        //The method accepts two parameters - Player and IStoreService
        //Player param is used to determin who is the buyer and
        //IStoreService is to give the player's access to the store
        public void BuyCar(Player player, IStoreService store)
        {
            store.ShowAvailableCarsForPlayer(player);

            Console.Write("Select a car: ");
            int carId = int.Parse(Console.ReadLine());

            /*
             * string[] carParameters = ExtractCarName(carChoise);
             * string brand = carParameters[0];
             * string model = carParameters[1];*/

            //Get a car from the Db
            Car car = this.dbContext.Cars.Where(c => c.Id == carId).FirstOrDefault();

            //Create a new object of mapping class CarPlayer
            CarPlayer carPlayer = new CarPlayer
            {
                Car    = car,
                Player = player
            };

            TaxPlayer(player, car);

            this.dbContext.CarPlayers.Add(carPlayer);
            this.dbContext.SaveChanges();
        }
Пример #2
0
    public void Respawn(Vector3 offset)
    {
        transform.position = new Vector3(gameController.checkPoints[currentCheckpoint].position.x, transform.position.y, gameController.checkPoints[currentCheckpoint].position.z);
        transform.rotation = Quaternion.LookRotation(gameController.checkPoints[currentCheckpoint].forward);
        //transform.LookAt(gameController.waypoints[nextCheckpoint]);
        transform.Translate(offset);
        rigidBody.velocity = Vector3.zero;
        CarPlayer carPlayer = GetComponent <CarPlayer>();

        if (carPlayer)
        {
            carPlayer.DestroyTrails();
        }
    }
Пример #3
0
    public void DeactivateAllCars()
    {
        for (int i = 0; i < cars.Count; i++)
        {
            CarAI carAI = cars[i].GetComponent <CarAI>();
            if (carAI)
            {
                carAI.enabled = false;
            }
            CarPlayer carPlayer = cars[i].GetComponent <CarPlayer>();
            if (carPlayer)
            {
                carPlayer.enabled = false;
            }

            // Stop engine sound
            CarSoundManager soundManager = cars[i].GetComponent <CarSoundManager>();
            if (soundManager)
            {
                soundManager.StopEngine();
            }
        }
    }
Пример #4
0
 void Awake()
 {
     _instance = this;
 }