void PoliceCarinstantiation_Back() { switch (playerCarControl.currentCarLane) { case playerCarControl.RoadLanes.one: carSpeed = 3.0f; currentCarLane = RoadLanes.two; break; case playerCarControl.RoadLanes.two: carSpeed = 3.0f; currentCarLane = RoadLanes.three; break; case playerCarControl.RoadLanes.three: carSpeed = 3.0f; currentCarLane = RoadLanes.four; break; case playerCarControl.RoadLanes.four: carSpeed = 3.0f; currentCarLane = RoadLanes.three; break; } }
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; }
void policeCarAvoidMode_Front() { Vector3 fwd = thisTrans.TransformDirection(Vector3.forward); if (Physics.Raycast(transform.position, fwd, out hit, 50) && Time.timeSinceLevelLoad - lastTime > 2.0f) { Debug.DrawRay(thisTrans.position, Vector3.forward, Color.red); GameObject hitObj = hit.collider.gameObject; string hitObjTagName = hit.collider.tag; if (hitObjTagName.Contains("Player") || hitObjTagName.Contains("trafficCar") || hitObjTagName.Contains("PoliceCar")) // //Debug.Log("police car"+ hit.collider.name); { lastTime = Time.timeSinceLevelLoad; int random = Random.Range(-1, 1); switch (currentCarLane) { case RoadLanes.one: currentCarLane = RoadLanes.two; break; case RoadLanes.two: if (random > 0) { currentCarLane = RoadLanes.three; } else { currentCarLane = RoadLanes.one; } break; case RoadLanes.three: if (random > 0) { currentCarLane = RoadLanes.four; } else { currentCarLane = RoadLanes.two; } break; case RoadLanes.four: currentCarLane = RoadLanes.three; break; } } } policeCarAvoidMode_Back(); }
void policeCarAggressiveMode() { switch (playerCarControl.currentCarLane) { case playerCarControl.RoadLanes.one: if (currentCarLane == RoadLanes.four) { currentCarLane = RoadLanes.three; } else if (currentCarLane == RoadLanes.three) { currentCarLane = RoadLanes.two; } else { currentCarLane = RoadLanes.one; } break; case playerCarControl.RoadLanes.two: if (currentCarLane == RoadLanes.four) { currentCarLane = RoadLanes.three; } else { currentCarLane = RoadLanes.two; } break; case playerCarControl.RoadLanes.three: if (currentCarLane == RoadLanes.one) { currentCarLane = RoadLanes.two; } else { currentCarLane = RoadLanes.three; } break; case playerCarControl.RoadLanes.four: if (currentCarLane == RoadLanes.one) { currentCarLane = RoadLanes.two; } else if (currentCarLane == RoadLanes.two) { currentCarLane = RoadLanes.three; } else { currentCarLane = RoadLanes.four; } break; } lastCarLane = currentCarLane; }