示例#1
0
    void OnTriggerEnter(Collider other)
    {
        MoveRoadItem otherScript = other.gameObject.GetComponent <MoveRoadItem>();

        if (other.gameObject.tag == "Traffic")
        {
            //If the lanes are the same there is a collision
            if (currentLane.ToString() == otherScript.currentLane.ToString())
            {
                Debug.Log("Game over, score: " + GameControllerScript.playerScore);
            }
            //Check for a near miss
            else if (NearMiss(otherScript))
            {
                GameControllerScript.playerScore += 10;
                UIhandlerScript.NewMessage(10.ToString());
            }
            //If there is one lane between playercar and traffic car
            else
            {
                GameControllerScript.playerScore += 5;
                UIhandlerScript.NewMessage(5.ToString());
            }
        }
    }
示例#2
0
    bool NearMiss(MoveRoadItem otherScript)
    {
        if (currentLane.ToString() == "middle")
        {
            return(true);
        }
        else if (otherScript.currentLane.ToString() == "middle")
        {
            return(true);
        }

        return(false);
    }