コード例 #1
0
ファイル: CarSounds.cs プロジェクト: Kappers/AIRacingMarket
    // Use this for initialization
    void Start()
    {
        engineDSource = CreateAudioSource(engineDClip);
        skidSource    = CreateAudioSource(skidClip);

        ourCar = gameObject.GetComponent <OurCar>();
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        //otherThing = Instantiate(thing) as GameObject;

        car         = GetComponent <OurCar>();
        detector    = transform.FindChild("Detector");
        targetPoint = centerLane.GetPoint(targetAmountAlongSpline % 1);
    }
コード例 #3
0
ファイル: HUD.cs プロジェクト: Kappers/AIRacingMarket
    public void Update()
    {
        // Setup the car states as soon as the race starts.
        if (carStates == null && carManager.IsRaceStarted)
        {
            carStates = new CarState[carManager.Cars.Count];

            Dictionary <string, int> nameFrequencies = new Dictionary <string, int>();
            endOfRaceObject = new EndOfRaceObject(this);

            for (int i = 0; i < carStates.Length; i++)
            {
                OurCar ourCar = carManager.Cars[i].GetComponentInChildren <OurCar>();
                carStates[i].car           = ourCar;
                carStates[i].position      = i;
                carStates[i].lap           = 0;
                carStates[i].stage         = 0;
                carStates[i].flipStartTime = -1;
                carStates[i].originalName  = ourCar.Name;
                carStates[i].ResetCheckpointTime();

                // If there are multiple cars with the same name, then add the
                // occurence number onto the end of the name.
                int nameFrequency = nameFrequencies.ContainsKey(ourCar.Name)
                    ? nameFrequencies[ourCar.Name] : 0;
                carStates[i].name = ourCar.Name + ((nameFrequency == 0)
                    ? "" : " " + (nameFrequency + 1));
                nameFrequencies[ourCar.Name] = nameFrequency + 1;
            }
        }

        // Check if all cars have finished or have stalled.
        if (carStates != null)
        {
            endOfRaceObject.CheckRaceOver(carStates, raceMode);

            UpdateCarPositions();

            // Check if the script names have changed during a test.
            if (raceMode == RaceMode.Test)
            {
                for (int i = 0; i < carStates.Length; i++)
                {
                    if (carStates[i].originalName != carStates[i].car.Name)
                    {
                        // This is horrible, everything should just use 'carStates[i].car.Name' instead.
                        carStates[i].name         = carStates[i].car.Name;
                        carStates[i].originalName = carStates[i].car.Name;
                    }
                }
            }
        }
    }
コード例 #4
0
 public void createCar(string carModel, GameObject carObject)
 {
     this.carObject = carObject;
     car            = carObject.GetComponentsInChildren <OurCar>(true)[0];
     carModels[carModel]();
 }