Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        winners = new List <GameObject>();

        laps  = new int[cars.Length + 1];
        times = new List <float>();

        respawnTimes         = new float[cars.Length + planes.Length + 1];
        distanceLeftToTravel = new float[cars.Length + planes.Length + 1];
        scripts         = new CarController[cars.Length];
        airplaneScripts = new AirplaneController[planes.Length];
        waypoint        = new Transform[cars.Length + planes.Length + 1];
        finished        = new bool[cars.Length + 1];

        //intialize the arrays with starting values
        for (int i = 0; i < cars.Length; ++i)
        {
            scripts[i]              = cars[i].gameObject.GetComponent <CarController>();
            scripts[i].enabled      = false;
            respawnTimes[i]         = respawnDelay;
            distanceLeftToTravel[i] = float.MaxValue;
            laps[i]     = 0;
            finished[i] = false;
            scripts[i].StartTimer();
        }

        //Planes
        //Start at the cars arrays length for the index, then push forward while less then the two added together
        for (int i = cars.Length; i < cars.Length + planes.Length; i++)
        {
            airplaneScripts[i - cars.Length] = planes[i - cars.Length].gameObject.GetComponent <AirplaneController>();
            respawnTimes[i]         = respawnDelay;
            distanceLeftToTravel[i] = float.MaxValue;
        }

        playerIndex  = cars.Length + planes.Length;
        playerScript = playerCar.gameObject.GetComponent <Car>();
        playerScript.KillTheEngine();
        respawnTimes[playerIndex]             = playerRespawnDelay;
        laps[playerIndex - planes.Length]     = 0;
        distanceLeftToTravel[playerIndex]     = float.MaxValue;
        finished[playerIndex - planes.Length] = false;
        playerScript.StartTimer();

        playerWaypointScript = playerWaypointMarker.GetComponent <WaypointGates>();
        UpdatePlayerMarker();
    }
    // Use this for initialization
    void Start()
    {
        winners = new List<GameObject>();

        laps = new int[cars.Length + 1];
        times = new List<float>();

        respawnTimes = new float[cars.Length + planes.Length +1];
        distanceLeftToTravel = new float[cars.Length + planes.Length +1];
        scripts = new CarController[cars.Length];
        airplaneScripts = new AirplaneController[planes.Length];
        waypoint = new Transform[cars.Length + planes.Length +1];
        finished = new bool[cars.Length + 1];

        //intialize the arrays with starting values
        for(int i=0; i < cars.Length; ++i)
        {
            scripts[i] = cars[i].gameObject.GetComponent<CarController>();
            scripts[i].enabled = false;
            respawnTimes[i] = respawnDelay;
            distanceLeftToTravel[i] = float.MaxValue;
            laps[i] = 0 ;
            finished[i] = false;
            scripts[i].StartTimer();
        }

        //Planes
        //Start at the cars arrays length for the index, then push forward while less then the two added together
        for(int i = cars.Length; i < cars.Length + planes.Length; i++)
        {
            airplaneScripts[i - cars.Length] = planes[i - cars.Length].gameObject.GetComponent<AirplaneController>();
            respawnTimes[i] = respawnDelay;
            distanceLeftToTravel[i] = float.MaxValue;
        }

        playerIndex = cars.Length + planes.Length;
        playerScript = playerCar.gameObject.GetComponent<Car>();
        playerScript.KillTheEngine();
        respawnTimes[playerIndex] = playerRespawnDelay;
        laps[playerIndex - planes.Length] = 0;
        distanceLeftToTravel[playerIndex] = float.MaxValue;
        finished[playerIndex - planes.Length] = false;
        playerScript.StartTimer();

        playerWaypointScript = playerWaypointMarker.GetComponent<WaypointGates>();
        UpdatePlayerMarker();
    }