//Fill the array with the caamera positions for the race preview
    void Start()
    {
        //Get the scripts corresponding to this car
        mainCarScript  = transform.root.GetComponent <NetworkCar>();
        camChange      = transform.root.GetComponent <cam_change>();
        playerIDScript = transform.root.GetComponent <PlayerID>();
        //Fill the array (indexes 0 and 1 will be useless)
        cameraPos = transform.parent.GetComponentsInChildren <Transform>();
        //Set first camera at position 2
        transform.position = cameraPos[2].position;
        transform.rotation = cameraPos[2].rotation;


        preview = RunPreviewCamera();
        StartCoroutine(preview);

        //Set the racing state to false in the maincarscript
        mainCarScript.racing = false;

        //Get Fanari GUIs
        fanaria = GameObject.Find("Fanari").GetComponentsInChildren <Image>();

        for (int i = 0; i <= 3; i++)
        {
            fanaria[i].enabled = false;
        }

        //Set Previewing to true so the user can't change cameras with enter on cam_change script
        camChange.previewing = true;
        runningFanari        = false;
    }
 //private bool tyre_grounded;
 // Use this for initialization
 void Start()
 {
     script        = transform.root.GetComponent <NetworkCar>();
     tyresArray[0] = GameObject.Find("newcar/Car/Car_Outside/Tyres/Tyres_FL");
     tyresArray[1] = GameObject.Find("newcar/Car/Car_Outside/Tyres/Tyres_FR");
     tyresArray[2] = GameObject.Find("newcar/Car/Car_Outside/Tyres/Tyres_RL");
     tyresArray[3] = GameObject.Find("newcar/Car/Car_Outside/Tyres/Tyres_RR");
 }
Example #3
0
 void Awake()
 {
     carCollider    = gameObject.GetComponent <Collider>();
     carRB          = gameObject.GetComponent <Rigidbody>();
     script         = GetComponent <NetworkCar>();
     myTransform    = transform;
     rend1          = transform.Find("newcar/Car/Car_Outside/carBody").GetComponent <Renderer>();
     spawnPoints[0] = GameObject.Find("Spawn1").GetComponent <Transform>();
     spawnPoints[1] = GameObject.Find("Spawn2").GetComponent <Transform>();
 }
Example #4
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Player")
     {
         /*
          * Debug.Log(col.gameObject);
          * Debug.Log(CheckPointZoneNumber);
          */
         script = col.gameObject.GetComponent <NetworkCar>();
         script.currentCheckpoint = CheckPointZoneNumber;
         //Set true the array index of the car checkpoints to true
         script.fairRace[CheckPointZoneNumber] = true;
     }
 }
Example #5
0
    private IEnumerator roundEnding()
    {
        m_MessageText.text = "ROUND OVER\n\nGOOD JOB :D";
        m_RoundWinner = null;//clear round winner of the previous round
        m_RoundWinner = GetRoundWinner();//get the winner of this round
        if (m_RoundWinner != null)
            m_RoundWinner.m_NumberOfRoundsWon++;//increment the number of rounds won for that player
        m_GameWinner = GetGameWinner();//get the game winner if there is one

        string _Message = GetEndMessage();
        RpcUpdateMessage(_Message);
        RpcRoundEnding();
        yield return m_EndWait;
    }
Example #6
0
    void  OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")
        {
            passedAllCheckpoints = true;
            carscript            = col.GetComponent <NetworkCar>();
            Debug.Log(carscript);
            //Check if the car has passed from all checkpoints
            Debug.Log(carscript.currentLap);
            for (int i = 0; i <= 6; i++)
            {
                if (carscript.fairRace[i] != true)
                {
                    passedAllCheckpoints = false;
                }
            }
            if (passedAllCheckpoints == true)
            {
                //Finish race
                if (carscript.currentLap == 3 && !carscript.raceFinished)
                {
                    carscript.speed        = 0;
                    carscript.racing       = false;
                    carscript.raceFinished = true;
                    carscript.raceWon      = true;
                }

                //Add a lap if the car has passed from all checkpoints
                carscript.currentLap = carscript.currentLap + 1;
                lapText.text         = "Lap: " + carscript.currentLap;
                //Change the besttime GUI text if the car did a better lap
                if (carscript.lapTime < carscript.bestTime || carscript.bestTime == 0)
                {
                    //If it's not the start of the race show green arrow and better time
                    if (carscript.bestTime != 0)
                    {
                        betterLapImage.enabled = true;
                        betterLapText.text     = (carscript.lapTime - carscript.bestTime).ToString("F3");
                        betterLapText.enabled  = true;
                        StartCoroutine(WaitFiveGreen());
                    }


                    //Set the best time as this laptime.
                    carscript.bestTime = carscript.lapTime;
                    bestTimeText.text  = carscript.bestTime.ToString("F3");
                }
                else if (carscript.lapTime >= carscript.bestTime && carscript.bestTime != 0)
                {
                    //if it's not the start of the race show red arrow and worse time
                    worseLapImage.enabled = true;
                    worseLapText.text     = (carscript.lapTime - carscript.bestTime).ToString("F3");
                    worseLapText.enabled  = true;
                    StartCoroutine(WaitFiveRed());
                }
                //Show final lap if it's race mode

                //Debug.Log(SceneManager.GetActiveScene().name);
                if (carscript.currentLap == 3 && SceneManager.GetActiveScene().name == "Physics_Test_scene")
                {
                    Debug.Log("Physics");
                    FinalLapText.enabled = true;
                    StartCoroutine(WaitFiveFinal());
                }

                carscript.lapTime = 0;
            }

            passedAllCheckpoints = false;
            //Reset array
            for (int i = 0; i <= 6; i++)
            {
                carscript.fairRace[i] = false;
            }
        }
    }
    void  OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")
        {
            passedAllCheckpoints = true;

            carscript = col.GetComponent <NetworkCar>();
            //Check if the car has passed from all checkpoints
            for (int i = 0; i <= 6; i++)
            {
                if (carscript.fairRace[i] != true)
                {
                    passedAllCheckpoints = false;
                }
            }
            if (passedAllCheckpoints == true)
            {
                //This is for race so the game ends at lap3

                /*
                 * if (carscript.currentLap == 3)
                 * {
                 *  carscript.speed = 0;
                 *  carscript.racing = false;
                 * }
                 */

                //Add a lap if the car has passed from all checkpoints
                carscript.currentLap = carscript.currentLap + 1;
                lapText.text         = "Lap: " + carscript.currentLap;
                //Change the besttime GUI text if the car did a better lap
                if (carscript.lapTime < carscript.bestTime || carscript.bestTime == 0)
                {
                    //If it's not the start of the race show green arrow and better time
                    if (carscript.bestTime != 0)
                    {
                        betterLapImage.enabled = true;
                        betterLapText.text     = (carscript.lapTime - carscript.bestTime).ToString("F3");
                        betterLapText.enabled  = true;
                        StartCoroutine(WaitFiveGreen());
                    }


                    //Set the best time as this laptime.
                    carscript.bestTime = carscript.lapTime;
                    bestTimeText.text  = carscript.bestTime.ToString("F3");
                }
                else if (carscript.lapTime >= carscript.bestTime && carscript.bestTime != 0)
                {
                    //if it's not the start of the race show red arrow and worse time
                    worseLapImage.enabled = true;
                    worseLapText.text     = (carscript.lapTime - carscript.bestTime).ToString("F3");
                    worseLapText.enabled  = true;
                    StartCoroutine(WaitFiveRed());
                }
                //Show final lap if it's race mode

                /*
                 * if (carscript.currentLap == 3)
                 * {
                 *  FinalLapText.enabled = true;
                 *  StartCoroutine(WaitFiveFinal());
                 * }
                 */

                carscript.lapTime = 0;
            }

            passedAllCheckpoints = false;
            //Reset array
            for (int i = 0; i <= 6; i++)
            {
                carscript.fairRace[i] = false;
            }
        }
    }
Example #8
0
 void Awake()
 {
     myNetworkCar = GetComponent<NetworkCar>();
     myAudioSource = GetComponent<AudioSource>();
 }
Example #9
0
 private void Start()
 {
     m_Car = carGameObject.GetComponent <NetworkCar>();
 }