IEnumerator CarRush(CarProperty car) { if(rush) yield break; skillUsing = true; rush = true; car.AddSkillTime(); foreach(GameObject effect in speedUpEffects) { effect.active = true; } car.SlowDown(false); car.RPMUp(skillSetting[skillLevel - 1].effectPercent); car.TorqueUp(skillSetting[skillLevel - 1].effectPercent, Color.white); car.CanBrake(false); RushHornAudio.Play(); /* show effect while(){} */ yield return new WaitForSeconds(skillSetting[skillLevel - 1].skillEffectTimes); car.SlowDown(true); car.RPMUp(0); car.TorqueUp(0, Color.white); car.CanBrake(true); foreach(GameObject effect in speedUpEffects) { effect.active = false; } rush = false; skillUsing = false; RushHornAudio.Stop(); }
IEnumerator DashCar(CarProperty car) { skillUsing = true; speedUpSource = gameObject.AddComponent<AudioSource>(); speedUpSource.loop = false; speedUpSource.clip = speedUpAudio; speedUpSource.Play(); car.rigidbody.AddForce(car.transform.forward * car.rigidbody.mass * startForce); car.TorqueUp(speedUpPercent, skillColor); yield return new WaitForSeconds(effectTime); car.TorqueUp(0.0f, Color.white); Destroy(speedUpSource); skillUsing = false; }
IEnumerator BiggerRush(CarProperty car) { if(rush) yield break; rush = true; skillUsing = true; animation["skill"].time = 0.0f; animation["skill"].speed = 1.0f; animation.CrossFade("skill"); StartCoroutine(ShowEffect()); StartCoroutine(ChangeColor(false)); car.AddSkillTime(); car.SlowDown(false); car.RPMUp(skillSetting[skillLevel - 1].effectPercent); car.TorqueUp(skillSetting[skillLevel - 1].effectPercent, Color.white); car.UnCrash(true); boxCollider.isTrigger = false; // boxCollider.transform.localPosition = Vector3.zero; float size = 1.0f; while(size < changeSize) { size += 0.1f; car.ChangeSize(size); if(smoothFollow.target == transform.root) smoothFollow.SendMessage("SetTarget", transform, SendMessageOptions.DontRequireReceiver); //smoothFollow.height = smoothFollow.height + 0.3f; yield return new WaitForSeconds(0.1f); } BigRushGrowAudio.Stop(); yield return new WaitForSeconds(skillSetting[skillLevel - 1].skillEffectTimes); car.SlowDown(true); car.RPMUp(0); car.TorqueUp(0, Color.white); while(size > 1.0f) { size -= 0.1f; car.ChangeSize(size); yield return new WaitForSeconds(0.1f); } foreach(GameObject effect in speedUpEffects) { effect.active = false; } animation["skill"].time = animation["skill"].length; animation["skill"].speed = -1.0f; animation.CrossFade("skill"); StartCoroutine(ChangeColor(true)); car.UnCrash(false); boxCollider.isTrigger = true; // boxCollider.transform.localPosition = new Vector3(0, -0.5f, 0); BigRushTurboAudio.Stop(); rush = false; skillUsing = false; if(smoothFollow.target == transform.root) { smoothFollow.SendMessage("SetTarget", transform, SendMessageOptions.DontRequireReceiver); } }
IEnumerator InvincibleCar(CarProperty car) { if(skillUsing) yield break; skillUsing = true; InvincibleTrigger invincibleTrigger = gameObject.AddComponent<InvincibleTrigger>(); car.Protect(true); boxCollider.isTrigger = false; car.SlowDown(false); if(turboAudio) { turboSource = gameObject.AddComponent<AudioSource>(); turboSource.loop = true; turboSource.clip = turboAudio; } if(growAudio) { growSource = gameObject.AddComponent<AudioSource>(); growSource.loop = true; growSource.clip = growAudio; growSource.Play(); } car.RPMUp(skillSetting[skillLevel - 1].effectPercent); car.TorqueUp(skillSetting[skillLevel - 1].effectPercent, skillColor); car.UnCrash(true); float size = 1.0f; while(size < changeSize) { size += 0.1f; car.ChangeSize(size); if(smoothFollow.target == transform.root) smoothFollow.SendMessage(methodName, transform, SendMessageOptions.DontRequireReceiver); //smoothFollow.height = smoothFollow.height + 0.3f; yield return new WaitForSeconds(0.1f); } growSource.Stop(); turboSource.Play(); yield return new WaitForSeconds(skillSetting[skillLevel - 1].skillEffectTimes); turboSource.Stop(); growSource.Play(); while(size > 1.0f) { size -= 0.1f; car.ChangeSize(size); growSource.Play(); if(smoothFollow.target == transform.root) smoothFollow.SendMessage(methodName, transform, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds(0.1f); } growSource.Stop(); car.Protect(false); boxCollider.isTrigger = true; car.SlowDown(true); car.RPMUp(0); car.TorqueUp(0, Color.white); car.UnCrash(false); Destroy(turboSource); Destroy(growSource); Destroy(invincibleTrigger); skillUsing = false; }