示例#1
0
    void OnTriggerEnter(Collider collision)
    {
        if (collision.transform.name == "Perfect Enter Collider" && mode == "PREDRIFT")
        {
            perfectDrift = true;
        }


        if (collision.transform.name == "Perfect Exit Collider" && mode != "GAMEOVER")
        {
            perfectDrift = false;
        }


        if (collision.transform.tag == "Big Road Object" && mode == "FORWARD")
        {
            soundEffectController.playHit();
            previousMode   = mode;
            mode           = "GAMEOVER";
            gameOverReason = "STRAIGHT HIT";
        }

        if (collision.transform.tag == "Big Road Object")
        {
            soundEffectController.playHit();
            if (mode == "LEFT" || mode == "RIGHT")
            {
                previousMode = mode;
                mode         = "GAMEOVER";
                Debug.Log("Drift hit GG" + collision.transform.tag);

                gameOverReason = "DRIFT HIT";
            }
        }

        //When car exit a tile
        if (collision.transform.name == "Enter Collider")
        {
            tileController.nextTile();
            StartCoroutine(RemoveTileRoad());

            tileDestroyTime = Time.time;

            currentInteractRoadExitCollider = collision.gameObject;

            currentInteractingTileVector = collision.transform.position;
            //collision.transform.gameObject.SetActive(false);
        }


        if (collision.transform.name == "Exit DriftZone Collider" && mode != "GAMEOVER")
        {
            collision.transform.gameObject.SetActive(false);

            if (mode == "PREDRIFT")
            {
                if (previousMode == "LEFT")
                {
                    GameOverDriftDirection = "LEFT";
                }
                else if (previousMode == "RIGHT")
                {
                    GameOverDriftDirection = "RIGHT";
                }
                else if (previousMode == "FORWARD")
                {
                    GameOverDriftDirection = "FORWARD";
                }
                soundEffectController.playHit();

                //GameOver when car hits the road and its still in predrift mode.
                previousMode   = mode;
                mode           = "GAMEOVER";
                gameOverReason = "LATE DRIFT";
            }
            StartCoroutine(RemoveTileDrift());
            //collision.transform.gameObject.SetActive(false);
        }


        if (collision.transform.name == "Ready Drift DriftZone Collider" && mode != "GAMEOVER")
        {
            collision.transform.gameObject.SetActive(false);
            readyDrift = true;
        }



        if (collision.transform.name == "Enter DriftZone Collider" && mode != "GAMEOVER")
        {
            collision.transform.gameObject.SetActive(false);
            //Enter Predrift mode when enter drift zone
            previousMode = mode;
            mode         = "PREDRIFT";
        }
    }