Exemple #1
0
    void OnEnable()
    {
        mainCam        = GameObject.FindGameObjectWithTag("MainCamera");
        skidMarksscrip = GameObject.FindGameObjectWithTag("Player").GetComponent <drawSkidmarks> ();
        GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
        rotation = gameObject.transform.eulerAngles;
                                #if UNITY_WEBPLAYER || UNITY_EDITOR
        tilt = tilt * 2;                       //car is shaking toomuch in device ,due to non-Smooth acceleration value
        //no problem in webplayer
                                #endif
        thisTrans  = transform;
        mainCamera = Camera.main;
        foreach (Transform t in gameObject.GetComponentsInChildren <Transform>())
        {
            if (t.name.Contains("Effect"))
            {
                particleParent = t.gameObject;
            }
        }

        isDoubleSpeed = 1;

        camScript             = Camera.main.GetComponent <carCamera> ();
        camScript.targetTrans = thisTrans;
        currentCarState       = carStates.OnRoad;
        currentCarLane        = RoadLanes.two;
    }
Exemple #2
0
    void OnEnable()
    {
        thisTrans  = transform;
        mainCamera = Camera.main;
        foreach (Transform t in gameObject.GetComponentsInChildren <Transform>())
        {
            if (t.name.Contains("Effect"))
            {
                particleParent = t.gameObject;
            }
        }

        isDoubleSpeed         = 1;
        camScript             = Camera.main.GetComponent <carCamera> ();
        camScript.targetTrans = thisTrans;

                #if UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8
        foreach (Transform t in transform.GetComponentsInChildren <Transform>())
        {
            if (t.name.Contains("Shadow"))
            {
                Debug.Log(t.name);
                Destroy(t.gameObject);
            }
        }
                #endif

                #if !UNITY_EDITOR
        ignoreCollision = false;
                #endif
    }
 void Start()
 {
     //OnGameStart ();
     collectedCoinsCounts = 0;
     if (camScript == null)
     {
         camScript = Camera.main.GetComponent <carCamera> ();
     }
     //playerObj = GameObject.FindGameObjectWithTag ("Player");
     if (playerObj == null)
     {
         playerObj = GameObject.Instantiate(playerCars[carSelection.carIndex]) as GameObject;
     }
     input.playerCarScript   = playerObj.GetComponent <playerCarControl>();
     startPlayerCarPositionZ = playerObj.transform.position.z;
     camScript.targetTrans   = playerObj.transform;
 }
    void Start()
    {
        Static = this;
        //RenderSettings.fog = true;
        //for traffic cars

        collectedCoinsCounts = 0;

        if (camScript == null)
        {
            camScript = Camera.main.GetComponent <carCamera> ();
        }

        playerObj = GameObject.FindGameObjectWithTag("Player");

        if (playerObj == null)
        {
            playerObj = GameObject.Instantiate(playerCars [carSelection.carIndex]) as GameObject;
        }
        startPlayerCarPositionZ = playerObj.transform.position.z;
        camScript.targetTrans   = playerObj.transform;
    }
Exemple #5
0
    void Start()
    {
        Resources.UnloadUnusedAssets();

        trafficCarDistance = 120;
        Destroy(playerObj);
        checkpointOffset     = 2;  //give checkpoint every 2 km
        checkpointWallOffset = 2f; //give checkpoint every 2 km

        finalScore     = 0;
        totalHighSpeed = 0;
        totalOvertakes = 0;
        distTraveled   = 0;



        playerObj = GameObject.Instantiate(playerCars[carSelection.carIndex]) as GameObject;

        GreedyGameAgent.Instance.removeFloatUnit("float-2484");

        if (Application.loadedLevelName == "highway")
        {
            CarController.yStart      = playerObj.transform.localPosition.y;
            CarController.xLimitLeft  = 268.328f;
            CarController.xLimitRight = 274.563f;
            CarController.xStart      = 271.5f;
        }
        if (Application.loadedLevelName == "City")
        {
            CarController.yStart      = playerObj.transform.localPosition.y;
            CarController.xLimitLeft  = -89.683f;
            CarController.xLimitRight = -82.957f;
            CarController.xStart      = -86.447f;
        }
        if (Application.loadedLevelName == "Desert2")
        {
            CarController.yStart      = playerObj.transform.localPosition.y; //put the player car on the y position from the prefab
            CarController.xLimitLeft  = -2.9f;
            CarController.xLimitRight = 3.1f;
            CarController.xStart      = 0.21f;
        }
        if (Application.loadedLevelName == "Desert3")
        {
            CarController.yStart      = playerObj.transform.localPosition.y;
            CarController.xLimitLeft  = -3.0f;
            CarController.xLimitRight = 3.25f;
            CarController.xStart      = 0.21f;
        }


        initialSpawnsPerSecond = SpawnsPerSecond;
        totalCash = 0;
        if (camScript == null)
        {
            camScript = Camera.main.GetComponent <carCamera>();
        }

        startPlayerCarPositionZ = playerObj.transform.position.z;
        camScript.targetTrans   = playerObj.transform;

        nextCarSpawnIndex = Random.Range(0, trafficCars.Length);

        //spawn 8 cars on game start
        int i = 9;

        while (i > 0)
        {
            SpawnCarsOnGameStart();
            i--;
        }

        checkpointWall = (GameObject)Instantiate(Resources.Load("checkpointWall"));
    }
Exemple #6
0
 void Start()
 {
     Static = this;
     speed  = 0.2f;
 }