void Update() { Swipe(); Nitro(); carTorque = gameObject.GetComponent <CarControleScript>().maxTorque = currentTorque; if (nitroVolume <= 0) { nitro = false; nitroVolume = 0; currentTorque = maxTorque; particleEffectLeft.GetComponent <ParticleEmitter>().emit = false; particleEffectRight.GetComponent <ParticleEmitter>().emit = false; particleEffectLeft.GetComponent <LensFlare>().enabled = false; particleEffectRight.GetComponent <LensFlare>().enabled = false; } if (nitroVolume > maxNitrovolume) { nitroVolume = maxNitrovolume; } if (Input.GetKey(KeyCode.Z)) { nitro = true; } else { nitro = false; } if (Input.touchCount == 0) { nitro = false; } }
//Engine Sound void EngineSound() { for (FIXME_VAR_TYPE i = 0; i < gearRatio.length; i++) { if (gearRatio[i] > currentSpeed) { break; } } float gearMinValue = 0.00f; float gearMaxValue = 0.00f; if (i == 0) { gearMinValue = 0; } else { gearMinValue = gearRatio[i - 1]; } gearMaxValue = gearRatio[i]; float enginePitch = ((currentSpeed - gearMinValue) / (gearMaxValue - gearMinValue)) + 1; GetComponent <AudioSource>().pitch = enginePitch; }
void SetDir(ArrayList dirList) { upArrow.SetActive(false); downArrow.SetActive(false); leftArrow.SetActive(false); rightArrow.SetActive(false); for (int i = 0; i < dirList.length; i++) { FIXME_VAR_TYPE str = dirList[i]; if (str == "up") { upArrow.SetActive(true); } else if (str == "down") { downArrow.SetActive(true); } else if (str == "left") { leftArrow.SetActive(true); } else if (str == "right") { rightArrow.SetActive(true); } } }
//Friction calculation and triggers for the effects void Update() { WheelHit hit; transform.GetComponent <WheelCollider>().GetGroundHit(hit); currentFrictionValue = Mathf.Abs(hit.sidewaysSlip); FIXME_VAR_TYPE rpm = transform.GetComponent <WheelCollider>().rpm; if (skidAt <= currentFrictionValue && soundWait <= 0 || rpm < 300 && rpm > 10 && Input.GetAxis("Vertical") > 0 && soundWait <= 0 && startSkid && hit.collider) { Instantiate(skidSound, hit.point, Quaternion.identity); soundWait = 1; } soundWait -= Time.deltaTime * soundEmition; if (skidAt <= currentFrictionValue || rpm < 300 && rpm > 10 && Input.GetAxis("Vertical") > 0 && startSkid && hit.collider) { skidSmoke.particleEmitter.emit = true; SkidMesh(); } else { skidSmoke.particleEmitter.emit = false; skidding = 0; } }
//CollisioN FX void OnCollisionEnter(Collision other) { if (other.transform != transform && other.contacts.length != 0) { for (FIXME_VAR_TYPE i = 0; i < other.contacts.length; i++) { //Instantiate(spark,other.contacts[i].point,Quaternion.identity); GameObject clone = Instantiate(collisionSound, other.contacts[i].point, Quaternion.identity); clone.transform.parent = transform; } } }
void Swipe() { int fingerCount = 0; if (fingerCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Ended) { touchFacing = (initTouchPos - Input.GetTouch(0).position).normalized; if (Vector2.Dot(touchFacing, -Vector2.up) > 0.8f && Vector2.Distance(initTouchPos, Input.GetTouch(0).position) > 20) { nitro = true; } } }
private Vector3 rotationVector; //Rotation Vector //Positioning void LateUpdate() { FIXME_VAR_TYPE wantedAngel = rotationVector.y; FIXME_VAR_TYPE wantedHeight = car.position.y + height; FIXME_VAR_TYPE myAngel = transform.eulerAngles.y; FIXME_VAR_TYPE myHeight = transform.position.y; myAngel = Mathf.LerpAngle(myAngel, wantedAngel, rotationDamping * Time.deltaTime); myHeight = Mathf.Lerp(myHeight, wantedHeight, heightDamping * Time.deltaTime); FIXME_VAR_TYPE currentRotation = Quaternion.Euler(0, myAngel, 0); transform.position = car.position; transform.position -= currentRotation * Vector3.forward * distance; transform.position.y = myHeight; transform.LookAt(car); }
//--------------------------------------------------------------------------------- void InstantiateGrenade (){ RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5f, Screen.height*0.5f, 0)); if (Input.GetMouseButtonDown(0)) { AudioSource.PlayClipAtPoint(gunshotSound, transform.position, 1); if (Physics.Raycast (ray, hit, 500)) { FIXME_VAR_TYPE particleClone= Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal)); FIXME_VAR_TYPE hitRotation= Quaternion.FromToRotation(Vector3.up, hit.normal); Instantiate(bulletHole, hit.point, hitRotation); Destroy(particleClone.gameObject, 2); hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver); } } }
void Nitro() { if (nitro) { currentTorque = maxNitroAccelaration; nitroVolume -= 1; particleEffectLeft.GetComponent <ParticleEmitter>().emit = true; particleEffectRight.GetComponent <ParticleEmitter>().emit = true; particleEffectRight.GetComponent <LensFlare>().enabled = true; particleEffectLeft.GetComponent <LensFlare>().enabled = true; } if (!nitro) { currentTorque = maxTorque; nitroVolume += 1; particleEffectLeft.GetComponent <ParticleEmitter>().emit = false; particleEffectRight.GetComponent <ParticleEmitter>().emit = false; particleEffectLeft.GetComponent <LensFlare>().enabled = false; particleEffectRight.GetComponent <LensFlare>().enabled = false; } }
void Update() { if (!enumeratedJoysticks) { // Collect all joysticks in the game, so we can relay finger latching messages joysticks = FindObjectsOfType(Joystick) as Joystick[]; enumeratedJoysticks = true; } FIXME_VAR_TYPE count = Input.touchCount; // Adjust the tap time window while it still available if (tapTimeWindow > 0) { tapTimeWindow -= Time.deltaTime; } else { tapCount = 0; } if (count == 0) { ResetJoystick(); } else { for (int i = 0; i < count; i++) { Touch touch = Input.GetTouch(i); Vector2 guiTouchPos = touch.position - guiTouchOffset; bool shouldLatchFinger = false; if (touchPad) { if (touchZone.Contains(touch.position)) { shouldLatchFinger = true; } } else if (gui.HitTest(touch.position)) { shouldLatchFinger = true; } // Latch the finger if this is a new touch if (shouldLatchFinger && (lastFingerId == -1 || lastFingerId != touch.fingerId)) { if (touchPad) { gui.color.a = 0.15f; lastFingerId = touch.fingerId; fingerDownPos = touch.position; fingerDownTime = Time.time; } lastFingerId = touch.fingerId; // Accumulate taps if it is within the time window if (tapTimeWindow > 0) { tapCount++; } else { tapCount = 1; tapTimeWindow = tapTimeDelta; } // Tell other joysticks we've latched this finger foreach (Joystick j in joysticks) { if (j != null && j != this) { j.LatchedFinger(touch.fingerId); } } } if (lastFingerId == touch.fingerId) { // Override the tap count with what the iPhone SDK reports if it is greater // This is a workaround, since the iPhone SDK does not currently track taps // for multiple touches if (touch.tapCount > tapCount) { tapCount = touch.tapCount; } if (touchPad) { // For a touchpad, let's just set the position directly based on distance from initial touchdown position.x = Mathf.Clamp((touch.position.x - fingerDownPos.x) / (touchZone.width / 2), -1, 1); position.y = Mathf.Clamp((touch.position.y - fingerDownPos.y) / (touchZone.height / 2), -1, 1); } else { // Change the location of the joystick graphic to match where the touch is position.x = (touch.position.x - guiCenter.x) / guiTouchOffset.x; position.y = (touch.position.y - guiCenter.y) / guiTouchOffset.y; } if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { ResetJoystick(); } } } } // Calculate the length. This involves a squareroot operation, // so it's slightly expensive. We re-use this length for multiple // things below to avoid doing the square-root more than one. float length = position.magnitude; if (length < deadZone) { // If the length of the vector is smaller than the deadZone radius, // set the position to the origin. position = Vector2.zero; } else { if (length > 1) { // Normalize the vector if its length was greater than 1. // Use the already calculated length instead of using Normalize(). position = position / length; } else if (normalize) { // Normalize the vector and multiply it with the length adjusted // to compensate for the deadZone radius. // This prevents the position from snapping from zero to the deadZone radius. position = position / length * Mathf.InverseLerp(length, deadZone, 1); } } if (!touchPad) { // Change the location of the joystick graphic to match the position gui.pixelInset.x = (position.x - 1) * guiTouchOffset.x + guiCenter.x; gui.pixelInset.y = (position.y - 1) * guiTouchOffset.y + guiCenter.y; } }