diff --git a/AnimatedFlowUVs.js b/AnimatedFlowUVs.js index eb58e92..d3d917d 100644 --- a/AnimatedFlowUVs.js +++ b/AnimatedFlowUVs.js @@ -9,7 +9,7 @@ private var resetTime : float; private var thisRenderer : Material; function Start () { - thisRenderer = renderer.material; + thisRenderer = GetComponent.().material; thisRenderer.mainTextureOffset = Vector2(0,0); resetTime = Mathf.Abs(1/speed); } diff --git a/AudioDuckingRegion.js b/AudioDuckingRegion.js index 8b8b201..0a594cc 100644 --- a/AudioDuckingRegion.js +++ b/AudioDuckingRegion.js @@ -3,8 +3,10 @@ var duckingObject : GameObject; var duckingVal : float = .5f; var StopAudioOnComplete : boolean = false; +var audioSource : AudioSource; function Start () { + audioSource = duckingObject.GetComponent.(); } function OnTriggerEnter (other : Collider) { @@ -21,17 +23,17 @@ function OnTriggerExit (other : Collider) { function lerpDuck (timer : float, endVal : float) { - var start = duckingObject.audio.volume; + var start = audioSource.volume; var end = endVal; var i = 0.0; var step = 1.0/timer; while (i <= 1.0) { i += step * Time.deltaTime; - duckingObject.audio.volume = Mathf.Lerp(start, end, i); + audioSource.volume = Mathf.Lerp(start, end, i); yield; } yield WaitForSeconds (timer); - if (StopAudioOnComplete) {duckingObject.audio.Stop();} + if (StopAudioOnComplete) {audioSource.Stop();} } diff --git a/AudioPlayTrigger.js b/AudioPlayTrigger.js index fa4ba18..201f45e 100644 --- a/AudioPlayTrigger.js +++ b/AudioPlayTrigger.js @@ -1,13 +1,19 @@ #pragma strict +var audioSource : AudioSource; + +function Start () { + audioSource = GetComponent.(); +} + function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - if (audio) {audio.Play();} + if (audioSource) {audioSource.Play();} } } function OnTriggerExit (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - if (audio) {audio.Stop();} + if (audioSource) {audioSource.Stop();} } } \ No newline at end of file diff --git a/AudioPlayVisibility.js b/AudioPlayVisibility.js index 4dde046..e16f4a1 100644 --- a/AudioPlayVisibility.js +++ b/AudioPlayVisibility.js @@ -1,5 +1,11 @@ #pragma strict +var audioSource : AudioSource; + +function Start () { + audioSource = GetComponent.(); +} + function OnBecameVisible () { - if (audio) {audio.Play();} + if (audioSource) {audioSource.Play();} } \ No newline at end of file diff --git a/BouncingBall.js b/BouncingBall.js deleted file mode 100644 index 3dbba74..0000000 --- a/BouncingBall.js +++ /dev/null @@ -1,16 +0,0 @@ - -#pragma strict -var firstTimeVelocitySave = false; -var savedVelocity : Vector3; -var myRigidbody : Rigidbody; -var BounceRate:float =1.5; - -function OnCollisionEnter(col : Collision) { -//print("Collision! " + rigidbody.velocity); -if (! firstTimeVelocitySave) { -savedVelocity = rigidbody.velocity; -firstTimeVelocitySave = true; -} -myRigidbody.velocity.y = savedVelocity.y; -savedVelocity.y=savedVelocity.y/BounceRate; -} \ No newline at end of file diff --git a/CombineConnectedCylinders.js b/CombineConnectedCylinders.js deleted file mode 100644 index 5acc26d..0000000 --- a/CombineConnectedCylinders.js +++ /dev/null @@ -1,8 +0,0 @@ -function Start () { -yield WaitForSeconds(1); -GetComponent(CombineChildren).enabled = true; -} - -function Update () { - -} \ No newline at end of file diff --git a/EndSequence1stPerson.js b/EndSequence1stPerson.js index 0312b04..81a6b8e 100644 --- a/EndSequence1stPerson.js +++ b/EndSequence1stPerson.js @@ -54,7 +54,7 @@ function PlayOutro () { //LerpIntoDiamond(14); MusicBedInterpolated.falsifyCheckDistance(); FadeMusic(8, OutroMusicBed); - animation.Play("end-player-anim"); + GetComponent.().Play("end-player-anim"); EndTriggerComponent.AddDiamondCore(5); yield WaitForSeconds (1); EndTriggerComponent.AddDiamond3DCore(6); @@ -134,7 +134,7 @@ function LerpIntoDiamond (timer : float) { function FadeEndMenuLogo(timer:float){ EndMenuLogoCamera.GetComponent(Camera).enabled = true; - EndMenuLogoObject.renderer.enabled = true; + EndMenuLogoObject.GetComponent.().enabled = true; var start = 0; var end = 1.0; var i = 0.0; @@ -142,7 +142,7 @@ function FadeEndMenuLogo(timer:float){ while (i <= 1.0) { i += step * Time.deltaTime; - EndMenuLogoObject.renderer.material.color.a = Mathf.Lerp(start, end, i); + EndMenuLogoObject.GetComponent.().material.color.a = Mathf.Lerp(start, end, i); yield; } diff --git a/EndSequenceTrigger.js b/EndSequenceTrigger.js index b60390d..1060664 100644 --- a/EndSequenceTrigger.js +++ b/EndSequenceTrigger.js @@ -10,10 +10,16 @@ var diamondCore : GameObject; var diamond3DCore1 : GameObject; var diamond3DCore2 : GameObject; +var audioSource : AudioSource; + function Awake () { EndScriptComponent = Player.GetComponent("EndSequence1stPerson"); } +function Start () { + audioSource = GetComponent.(); +} + function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player") && lifeCountdown.inOutro == false) { lifeCountdown.inOutro = true; @@ -25,9 +31,9 @@ function OnTriggerEnter (other : Collider) { } for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) - shard.animation.Play(); + shard.GetComponent.().Play(); - if (audio) {audio.Play();} + if (audioSource) {audioSource.Play();} FallingPlayer.ScoreFlashTextureScript.FadeFlash (12.0, FadeDir.In); //yield WaitForSeconds (1.0); @@ -59,7 +65,7 @@ function SwapDiamonds(timer : float){ i += step * Time.deltaTime; for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) - shard.transform.Find("sky-rock-angled-segment").renderer.material.color = Color.Lerp(start, end, i); + shard.transform.Find("sky-rock-angled-segment").GetComponent.().material.color = Color.Lerp(start, end, i); yield; } @@ -80,7 +86,7 @@ function AddDiamondCore(timer : float){ while (i <= 1.0) { i += step * Time.deltaTime; - diamondCore.renderer.material.color.a = Mathf.Lerp(start, end, i); + diamondCore.GetComponent.().material.color.a = Mathf.Lerp(start, end, i); yield; } @@ -90,14 +96,14 @@ function AddDiamondCore(timer : float){ function FadeDiamond(timer : float){ - var start = endDiamond.renderer.material.color; + var start = endDiamond.GetComponent.().material.color; var end = Color.black; var i = 0.0; var step = 1.0/timer; while (i <= 1.0) { i += step * Time.deltaTime; - endDiamond.renderer.material.color = Color.Lerp(start, end, i); + endDiamond.GetComponent.().material.color = Color.Lerp(start, end, i); yield; } @@ -111,14 +117,14 @@ function AddDiamond3DCore(timer : float){ diamond3DCore2.active = true; var start = Color.black; - var end = diamond3DCore1.renderer.material.color; + var end = diamond3DCore1.GetComponent.().material.color; var i = 0.0; var step = 1.0/timer; while (i <= 1.0) { i += step * Time.deltaTime; - diamond3DCore1.renderer.material.color = Color.Lerp(start, end, i); - diamond3DCore2.renderer.material.color = Color.Lerp(start, end, i); + diamond3DCore1.GetComponent.().material.color = Color.Lerp(start, end, i); + diamond3DCore2.GetComponent.().material.color = Color.Lerp(start, end, i); yield; } diff --git a/FallingPlayer.js b/FallingPlayer.js index f789315..22f5843 100644 --- a/FallingPlayer.js +++ b/FallingPlayer.js @@ -80,6 +80,8 @@ private var myTransform : Transform; private var BackdropMist : GameObject; BackdropMist = transform.FindChild("Cylinder").gameObject; +var rb : Rigidbody; + function Awake() { // if (iPhoneInput.orientation == iPhoneOrientation.LandscapeRight) { // flipMultiplier = -1; @@ -90,7 +92,7 @@ function Awake() { function Start() { // startingFogColor = RenderSettings.fogColor * 2; startingFogEndDistance = RenderSettings.fogEndDistance; - startingCameraFarClipPlane = myTransform.FindChild("Camera").camera.farClipPlane; + startingCameraFarClipPlane = myTransform.FindChild("Camera").GetComponent.().farClipPlane; isAlive = 1; UIscriptComponent = UIscriptName.GetComponent(fallingUITest); lifeStartTime = Time.time; @@ -104,7 +106,10 @@ function Start() { // fadeInAudio (); FadeAudio (0.1, FadeDir.In); isPausable = false; - rigidbody.isKinematic = false; + + rb = GetComponent.(); + rb.isKinematic = false; + if (!introComponent) { UIscriptComponent.UnhideGUI(); } @@ -155,7 +160,7 @@ function FadeAudio (timer : float, fadeType : FadeDir) { function DeathRespawn () { isPausable = false; - rigidbody.isKinematic = true; + rb.isKinematic = true; lifeStartTime = Time.time; var respawnPosition = Respawn.currentRespawn.transform.position; @@ -182,14 +187,14 @@ function DeathRespawn () { RenderSettings.fogEndDistance = startingFogEndDistance; // Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too - collider.attachedRigidbody.transform.Translate(respawnPosition); + GetComponent.().attachedRigidbody.transform.Translate(respawnPosition); // Relocate the player. We need to do this or the camera will keep trying to focus on the (invisible) player where he's standing on top of the FalloutDeath box collider. myTransform.position = respawnPosition; // + Vector3.up; // Camera.main.SendMessage("fadeIn"); FadeAudio (fadeTime, FadeDir.In); // thisOceanCamera.SendMessage("fadeIn"); - rigidbody.isKinematic = false; + rb.isKinematic = false; // isAlive = 1; MoveController.controlMultiplier = 1; @@ -200,7 +205,7 @@ function DeathRespawn () { function LatestCheckpointRespawn () { isPausable = false; - rigidbody.isKinematic = true; + rb.isKinematic = true; var respawnPosition = Respawn.currentRespawn.transform.position; //UIscriptComponent.fadeOut(); @@ -212,11 +217,11 @@ function LatestCheckpointRespawn () { isAlive = 1; RenderSettings.fogEndDistance = startingFogEndDistance; - collider.attachedRigidbody.transform.Translate(respawnPosition); + GetComponent.().attachedRigidbody.transform.Translate(respawnPosition); myTransform.position = respawnPosition; // + Vector3.up; FadeAudio (fadeTime, FadeDir.In); - rigidbody.isKinematic = false; + rb.isKinematic = false; MoveController.controlMultiplier = 1; @@ -237,11 +242,11 @@ function changeLevelBackdrop () { changeBackdrop.cloudRenderer.enabled = false; changeBackdrop.endSphereRenderer.enabled = false; -// the Fade argument below this breaks unpredictably if player gameobject lacks a Fade script component -// Fade.use.Colors(guiTexture, (RenderSettings.fogColor * 2), startingFogColor, 2.0); + // the Fade argument below this breaks unpredictably if player gameobject lacks a Fade script component + // Fade.use.Colors(guiTexture, (RenderSettings.fogColor * 2), startingFogColor, 2.0); RenderSettings.fogEndDistance = startingFogEndDistance; - myTransform.FindChild("Camera").camera.farClipPlane = startingCameraFarClipPlane; - myTransform.FindChild("plane-close").renderer.materials = [origMat]; + myTransform.FindChild("Camera").GetComponent.().farClipPlane = startingCameraFarClipPlane; + myTransform.FindChild("plane-close").GetComponent.().materials = [origMat]; iTween.ColorTo(BackdropMist,{"a":startingCloudsAlpha,"time":.5}); } diff --git a/FallingPlayerScratch.js b/FallingPlayerScratch.js deleted file mode 100644 index 389cb2d..0000000 --- a/FallingPlayerScratch.js +++ /dev/null @@ -1,115 +0,0 @@ -#pragma strict - - public var force:float = 1.0; - var dir : Vector3 = Vector3.zero; - public var touchingSomething:boolean = false; - - -// Move object using accelerometer -var speed = 5.0; -var target : Transform; -var smooth = 2.0; -var tiltAngle = 30.0; - -var script : ScoreController; -script = GetComponent("ScoreController"); - -static var isAlive : boolean; - -function DeathRespawn () { - var respawnPosition = Respawn.currentRespawn.transform.position; - Camera.main.SendMessage("fadeOut"); - isAlive = true; - gameObject.SendMessage ("ResetScore", 0); - yield WaitForSeconds(1); -// gameObject.SendMessage ("DecrementScore"); -// gameObject.SendMessage ("ZeroScore", 1); - -// Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too - collider.attachedRigidbody.transform.Translate(respawnPosition); - // Relocate the player. We need to do this or the camera will keep trying to focus on the (invisible) player where he's standing on top of the FalloutDeath box collider. - transform.position = respawnPosition; // + Vector3.up; - Camera.main.SendMessage("fadeIn"); - } - - -function Update () { - var dir : Vector3 = Vector3.zero; - - var tiltAroundZ = -Input.acceleration.y * tiltAngle; - var tiltAroundX = -Input.acceleration.x * tiltAngle; - var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ); - - // Dampen towards the target rotation - transform.rotation = Quaternion.Slerp(transform.rotation, target, - Time.deltaTime * smooth);; - // Debug.Log(isAlive); -// Debug.Log(script.currentScore); - } - -// private var speed : Vector3 = Vector3 (3, 0, 0); -// var startingPosition = (0, 129, 0); -var deadlyObjectName : String = "DeathByFire"; -var initialRespawn : Respawn; // set this to the initial respawn point for the level. -// var damping:float = 0.7; // is this necessary? - -// textfield to hold the score and score variable -private var textfield:GUIText; -private var score:int; - -public var simulateAccelerometer:boolean = false; - - -function OnCollisionEnter (collision : Collision) { -// Debug.Log("Hit something!" + collision.contacts[0].normal + dir.x + dir.z + Input.acceleration.x); - Screen.sleepTimeout = 0.0f; -// collider.attachedRigidbody.velocity.y *= damping; - - -// collider.attachedRigidbody.AddForce(dir * force); - -// iPhoneUtils.Vibrate (); -// var relativeStartingPosition = transform.InverseTransformPoint(0, -500, 0); - - - -// if (collision.gameObject.name == deadlyObjectName){ - if (collision.gameObject.CompareTag ("Death")) { - DeathRespawn (); - } - - -// if (collision.gameObject.layer == 8){ -// collider.attachedRigidbody.transform.Translate(relativeStartingPosition); - -// Destroy the projectile -// Destroy (gameObject); -//if (relativeStartingPosition.y > 100) -// Debug.Log("You've moved up more than 100 units"); - -} - - -// function FixedUpdate () { -// rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);} - - -function OnTriggerEnter (other : Collider) { - if (other.gameObject.CompareTag ("Score")){ - // Debug.Log("You scored!"); - Camera.main.SendMessage("flashOut"); - gameObject.SendMessage ("IncrementScore", 10); - if (audio) - { - audio.Play(); - } - } - yield WaitForSeconds(.2); - Camera.main.SendMessage("flashUp"); - -} - - - - -@script AddComponentMenu("Scripts/FallingPlayer") \ No newline at end of file diff --git a/FallingPlayerStart.js b/FallingPlayerStart.js index 48268d0..14a14f6 100644 --- a/FallingPlayerStart.js +++ b/FallingPlayerStart.js @@ -31,7 +31,7 @@ function DeathRespawn () { // gameObject.SendMessage ("ZeroScore", 1); // Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too - collider.attachedRigidbody.transform.Translate(respawnPosition); + GetComponent.().attachedRigidbody.transform.Translate(respawnPosition); // Relocate the player. We need to do this or the camera will keep trying to focus on the (invisible) player where he's standing on top of the FalloutDeath box collider. transform.position = respawnPosition; // + Vector3.up; Camera.main.SendMessage("fadeIn"); @@ -108,10 +108,10 @@ function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Score")){ // Debug.Log("You scored!"); gameObject.SendMessage ("IncrementScore", 10); - if (audio) - { - audio.Play(); - } +// if (audio) +// { +// audio.Play(); +// } } if (other.gameObject.CompareTag ("CloudLevelSelect")){ diff --git a/FallingStartMenu.js b/FallingStartMenu.js index 8e6caed..e91704c 100644 --- a/FallingStartMenu.js +++ b/FallingStartMenu.js @@ -39,6 +39,9 @@ var tiltAngle = 30.0; //var flipMultiplier : int = 1; //var flipMultiplier = FallingLaunch.flipMultiplier; +private var rb : Rigidbody; +private var mainCamera: Camera; + var script : ScoreController; script = GetComponent("ScoreController"); @@ -54,7 +57,8 @@ function Awake() { // if (iPhoneInput.orientation == iPhoneOrientation.LandscapeRight) { // flipMultiplier = -1; //} - if (camera.main.aspect < 1.5) { + mainCamera = GetComponent.(); + if (mainCamera.aspect < 1.5) { titleCard.transform.Translate(-200,0,0); } } @@ -62,14 +66,17 @@ function Awake() { function Start() { // startingFogColor = RenderSettings.fogColor * 2; startingFogEndDistance = RenderSettings.fogEndDistance; - startingCameraFarClipPlane = gameObject.Find("Camera").camera.farClipPlane; + startingCameraFarClipPlane = mainCamera.farClipPlane; + // formerly startingCameraFarClipPlane = gameObject.Find("Camera").camera.farClipPlane; isAlive = 1; UIscriptComponent = UIscriptName.GetComponent(fallingStartMenuUI); AudioListener.pause = false; // fadeInAudio (); FadeAudio (0.1, FadeDir.In); isPausable = true; - rigidbody.isKinematic = false; + + rb = GetComponent.(); + rb.isKinematic = false; UIscriptComponent.UnhideGUI(); } @@ -91,7 +98,7 @@ function FadeAudio (timer : float, fadeType : FadeDir) { function DeathRespawn () { isPausable = false; - rigidbody.isKinematic = true; + rb.isKinematic = true; var respawnPosition = Respawn.currentRespawn.transform.position; Camera.main.SendMessage("fadeOut"); // isAlive = 1; @@ -106,14 +113,14 @@ function DeathRespawn () { gameObject.SendMessage ("ResetScore", 0); yield WaitForSeconds(1); // Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too - collider.attachedRigidbody.transform.Translate(respawnPosition); + GetComponent.().attachedRigidbody.transform.Translate(respawnPosition); // Relocate the player. We need to do this or the camera will keep trying to focus on the (invisible) player where he's standing on top of the FalloutDeath box collider. transform.position = respawnPosition; // + Vector3.up; Camera.main.SendMessage("fadeIn"); FadeAudio (fadeTime, FadeDir.In); // thisOceanCamera.SendMessage("fadeIn"); isPausable = true; - rigidbody.isKinematic = false; + rb.isKinematic = false; isAlive = 1; } @@ -126,8 +133,8 @@ function changeLevelBackdrop () { // the Fade argument below this breaks unpredictably if player gameobject lacks a Fade script component // Fade.use.Colors(guiTexture, (RenderSettings.fogColor * 2), startingFogColor, 2.0); RenderSettings.fogEndDistance = startingFogEndDistance; - gameObject.Find("Camera").camera.farClipPlane = startingCameraFarClipPlane; - transform.Find("plane-close").renderer.materials = [origMat]; + gameObject.Find("Camera").GetComponent.().farClipPlane = startingCameraFarClipPlane; + transform.Find("plane-close").GetComponent.().materials = [origMat]; var BackdropMist = gameObject.Find("Cylinder"); iTween.ColorTo(BackdropMist,{"a":startingCloudsAlpha,"time":.5}); diff --git a/Gui Text.js b/Gui Text.js deleted file mode 100755 index f0ce74a..0000000 --- a/Gui Text.js +++ /dev/null @@ -1,29 +0,0 @@ -var Button1 : Texture2D; -var Button2 : Texture2D; -var Leveltoload : String; -var isquit = false; -var Sound : AudioClip; - -function OnMouseEnter() -{ - guiTexture.texture = Button2; - audio.PlayOneShot(Sound); -} - -function OnMouseExit() -{ - guiTexture.texture = Button1; -} - -function OnMouseUp() -{ - if (isquit) - { - Application.Quit(); - } - else - { - Application.LoadLevel(Leveltoload); - } -} - diff --git a/IntroEndTrigger.js b/IntroEndTrigger.js index a4bb80d..ecb5533 100644 --- a/IntroEndTrigger.js +++ b/IntroEndTrigger.js @@ -5,9 +5,11 @@ var IntroScriptComponent : IntroSequence1stPerson; //IntroScriptComponent = Player.GetComponent("IntroSequence1stPerson"); var activeIntro : boolean = false; +var audioSource : AudioSource; + function Start () { IntroScriptComponent = Player.GetComponent("IntroSequence1stPerson"); - + audioSource = GetComponent.(); } function OnTriggerEnter (other : Collider) { @@ -15,6 +17,6 @@ function OnTriggerEnter (other : Collider) { activeIntro = true; FallingPlayer.ScoreFlashTextureScript.FadeFlash (3, FadeDir.Out); IntroScriptComponent.EndIntro(true); - if (audio) {audio.Play();} + if (audioSource) {audioSource.Play();} } } \ No newline at end of file diff --git a/IntroSequence1stPerson.js b/IntroSequence1stPerson.js index ceab572..f15e96d 100644 --- a/IntroSequence1stPerson.js +++ b/IntroSequence1stPerson.js @@ -19,10 +19,11 @@ function Start () { for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) { destructible = shard.GetComponent(ProjectileDestroy); - shard.renderer.enabled = false; - shard.rigidbody.isKinematic = true; + var shardRenderer : Renderer = shard.GetComponent.(); + shardRenderer.enabled = false; + shard.GetComponent.().isKinematic = true; destructible.enabled = false; - shardColor = shard.renderer.material.color; + shardColor = shardRenderer.material.color; } } else if (FallingLaunch.NewGamePlus) { @@ -47,10 +48,12 @@ function EndIntro (playAudio : boolean) { for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) { destructible = shard.GetComponent(ProjectileDestroy); - shard.rigidbody.isKinematic = false; + shard.GetComponent.().isKinematic = false; //yield WaitForSeconds(.25); - if (shard.audio && playAudio) {shard.audio.Play();} - shard.renderer.enabled = true; + var shardAudio : AudioSource = shard.GetComponent.(); + if (shardAudio && playAudio) {shardAudio.Play();} + + shard.GetComponent.().enabled = true; destructible.enabled = true; } @@ -62,7 +65,7 @@ function EndIntro (playAudio : boolean) { while (i <= 1.0) { i += step * Time.deltaTime; for(var shard : GameObject in GameObject.FindGameObjectsWithTag("Shard")) - shard.renderer.material.color = Color.Lerp(start, end, i); + shard.GetComponent.().material.color = Color.Lerp(start, end, i); yield; } } diff --git a/IntroUITrigger.js b/IntroUITrigger.js index 11b2585..c59199c 100644 --- a/IntroUITrigger.js +++ b/IntroUITrigger.js @@ -22,6 +22,8 @@ var iconDepth : int = 0; static var activeIntro : boolean = false; var textHeight : int; +private var audioSource: AudioSource; + function Start () { if (thisTrigger == Triggers.trigger1) { @@ -59,7 +61,9 @@ function Start () { helpIcon.pixelsFromBottom(textHeight); helpIcon.hidden = true; - + + audioSource = GetComponent.(); + } function OnTriggerEnter (other : Collider) { @@ -67,7 +71,7 @@ function OnTriggerEnter (other : Collider) { activeIntro = true; fallingIntroUIComponent.ShowIcon(helpIcon, thisTimer, tutorialSprite); tutorialSpritePosition(thisTimer); - if (audio) {audio.Play();} + if (audioSource) {audioSource.Play();} } } diff --git a/LaunchProjectile.js b/LaunchProjectile.js index d2e0415..d270a76 100644 --- a/LaunchProjectile.js +++ b/LaunchProjectile.js @@ -5,6 +5,8 @@ var launchInterval : float = 10.0; var randomTrajectory : boolean = false; private var isLaunched : boolean = false; +private var audioSource: AudioSource; + // Starting in 2 seconds. // a projectile will be launched every 5 seconds @@ -19,6 +21,10 @@ private var isLaunched : boolean = false; // } //} +function Start () { + audioSource = GetComponent.(); +} + function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player")){ if (isLaunched == false) { @@ -41,5 +47,5 @@ function OnTriggerExit (other : Collider) { function LaunchProjectile () { var instance : Rigidbody = Instantiate(projectilePrefab, transform.position, transform.rotation); if (randomTrajectory == true) {instance.velocity = Random.onUnitSphere * 5;} - if (audio) {audio.Play();} + if (audioSource) {audioSource.Play();} } \ No newline at end of file diff --git a/MoveController.js b/MoveController.js index b8186b8..b3a79b7 100644 --- a/MoveController.js +++ b/MoveController.js @@ -28,6 +28,8 @@ var SpeedLinesTextureScript : GUITextureLaunch; var SpeedLinesMesh : GameObject; static var SpeedLinesMeshScript : SpeedLines; +var audioSource : AudioSource; + var changingPitch : boolean = false; var shouldChangePitch : boolean = true; @@ -49,6 +51,8 @@ function Start() { startTime = Time.time; Slowdown = FallingLaunch.levelEndSlowdown; + audioSource = mainCamera.GetComponent.(); + //Calibrate(); lerpSlowdown(.5); @@ -211,13 +215,13 @@ function speedsUp () { //SpeedLinesTextureScript.LinesFlash (0.25, FadeDir.In); SpeedLinesMeshScript.LinesFlash (0.25, FadeDir.In); FallingPlayer.UIscriptComponent.showThreatBar(1); - if (mainCamera.audio && shouldChangePitch == true) {lerpPitchUp(.5, 2, .3);} + if (audioSource && shouldChangePitch == true) {lerpPitchUp(.5, 2, .3);} } else { //SpeedLinesTextureScript.LinesFlashOut (0.75, FadeDir.In); SpeedLinesMeshScript.LinesFlashOut (0.5, FadeDir.In); FallingPlayer.UIscriptComponent.hideThreatBar(.5); - if (mainCamera.audio && shouldChangePitch == true && changingPitch == false) {lerpPitchDown(1, 1, 1);} + if (audioSource && shouldChangePitch == true && changingPitch == false) {lerpPitchDown(1, 1, 1);} } } @@ -273,10 +277,10 @@ function lerpSlowdown (timer : float) { function lerpPitchUp (timer : float, endPitch : float, endVolume : float) { - var startVol = mainCamera.audio.volume; + var startVol = audioSource.volume; var endVol = endVolume; - var start = mainCamera.audio.pitch; + var start = audioSource.pitch; var end = endPitch; var i = 0.0; var step = 1.0/timer; @@ -284,8 +288,8 @@ function lerpPitchUp (timer : float, endPitch : float, endVolume : float) { while (i <= 1.0) { i += step * Time.deltaTime; - mainCamera.audio.pitch = Mathf.Lerp(start, end, i); - mainCamera.audio.volume = Mathf.SmoothStep(startVol, endVol, i); + audioSource.pitch = Mathf.Lerp(start, end, i); + audioSource.volume = Mathf.SmoothStep(startVol, endVol, i); yield; if (Slowdown < 1) {break;} @@ -297,18 +301,18 @@ function lerpPitchDown (timer : float, endPitch : float, endVolume : float) { changingPitch = true; - var startVol = mainCamera.audio.volume; + var startVol = audioSource.volume; var endVol = endVolume; - var start = mainCamera.audio.pitch; + var start = audioSource.pitch; var end = endPitch; var i = 0.0; var step = 1.0/timer; while (i <= 1.0) { i += step * Time.deltaTime; - mainCamera.audio.pitch = Mathf.Lerp(start, end, i); - mainCamera.audio.volume = Mathf.SmoothStep(startVol, endVol, i); + audioSource.pitch = Mathf.Lerp(start, end, i); + audioSource.volume = Mathf.SmoothStep(startVol, endVol, i); yield; if (Slowdown > 17999) {changingPitch = false; break;} diff --git a/ObjectDistanceFade.js b/ObjectDistanceFade.js index a345000..8a085bf 100644 --- a/ObjectDistanceFade.js +++ b/ObjectDistanceFade.js @@ -10,7 +10,7 @@ private var sqrRtLen : float; function Start () { myTransform = transform; - myRendererMatl = renderer.material; + myRendererMatl = GetComponent.().material; } function OnBecameVisible() { diff --git a/ProjectileDestroy.js b/ProjectileDestroy.js index ba90dfd..cff8d7a 100644 --- a/ProjectileDestroy.js +++ b/ProjectileDestroy.js @@ -15,7 +15,7 @@ function OnCollisionEnter (collision : Collision) { if (collision.gameObject.CompareTag ("Player")) { // throw an analytics event! GA.API.Design.NewEvent("Projectile:Collision:" + ProjectileName, FallingLaunch.secondsAlive, transform.position); - rigidbody.isKinematic = true; + gameObject.GetComponent.().isKinematic = true; Destroy(gameObject, 1); } diff --git a/Respawn.js b/Respawn.js index 699e1fb..80998a1 100644 --- a/Respawn.js +++ b/Respawn.js @@ -43,6 +43,8 @@ static var currentRespawn : Respawn; var myCheckpoint : String; var mainRespawnScript : boolean = false; +private var audioSource: AudioSource; + function Start() { // Get some of the objects we need later. @@ -54,9 +56,10 @@ function Start() // set up the looping "RespawnActive" sound, but leave it switched off for now: if (SFXRespawnActiveLoop) { - audio.clip = SFXRespawnActiveLoop; - audio.loop = true; - audio.playOnAwake = false; + audioSource = GetComponent.(); + audioSource.clip = SFXRespawnActiveLoop; + audioSource.loop = true; + audioSource.playOnAwake = false; } // Assign the respawn point to be this one - Since the player is positioned on top of a respawn point, it will come in and overwrite it. diff --git a/SlowdownTrigger.js b/SlowdownTrigger.js index 20f7031..d8fee43 100644 --- a/SlowdownTrigger.js +++ b/SlowdownTrigger.js @@ -1,10 +1,8 @@ // Applies an upwards force to all rigidbodies that enter the trigger. - - function OnTriggerStay (other : Collider) { if (other.attachedRigidbody) { // other.attachedRigidbody.AddForce(Vector3.up * 30); -var speed = other.attachedRigidbody.gameObject.transform.rigidbody.velocity.magnitude; +var speed = other.attachedRigidbody.gameObject.transform.GetComponent.().velocity.magnitude; other.attachedRigidbody.AddForce(Vector3.up * (speed/4)); // var speed = rigidbody.velocity.magnitude; //Debug.Log (other.attachedRigidbody.gameObject.transform.rigidbody.velocity.magnitude); diff --git a/SmoothFollowCamera.js b/SmoothFollowCamera.js deleted file mode 100644 index 00a0cc7..0000000 --- a/SmoothFollowCamera.js +++ /dev/null @@ -1,230 +0,0 @@ -/// This camera is similar to the one used in Super Mario 64 - -/* - -"Fire2" snaps the camera - -*/ - -// The target we are following -var target : Transform; - -// The distance in the x-z plane to the target - -var distance = 7.0; - -// the height we want the camera to be above the target -var height = 3.0; - -var angularSmoothLag = 0.3; -var angularMaxSpeed = 15.0; - -var heightSmoothLag = 0.3; - -var snapSmoothLag = 0.2; -var snapMaxSpeed = 720.0; - -var clampHeadPositionScreenSpace = 0.75; - -var lockCameraTimeout = 0.2; - -private var headOffset = Vector3.zero; -private var centerOffset = Vector3.zero; - -private var heightVelocity = 0.0; -private var angleVelocity = 0.0; -private var snap = false; -private var controller : ThirdPersonController; -private var targetHeight = 100000.0; - -function Awake () -{ - if (target) - { - controller = target.GetComponent(ThirdPersonController); - } - - if (controller) - { - var characterController : CharacterController = target.collider; - centerOffset = characterController.bounds.center - target.position; - headOffset = centerOffset; - headOffset.y = characterController.bounds.max.y - target.position.y; - } - else - Debug.Log("Please assign a target to the camera that has a ThirdPersonController script attached."); - - - Cut(target, centerOffset); -} - -function DebugDrawStuff () -{ - Debug.DrawLine(target.position, target.position + headOffset); - -} - -function AngleDistance (a : float, b : float) -{ - a = Mathf.Repeat(a, 360); - b = Mathf.Repeat(b, 360); - - return Mathf.Abs(b - a); -} - -function Apply (dummyTarget : Transform, dummyCenter : Vector3) -{ - // Early out if we don't have a target - if (!controller) - return; - - var targetCenter = target.position + centerOffset; - var targetHead = target.position + headOffset; - -// DebugDrawStuff(); - - // Calculate the current & target rotation angles - var originalTargetAngle = target.eulerAngles.y; - var currentAngle = transform.eulerAngles.y; - - // Adjust real target angle when camera is locked - var targetAngle = originalTargetAngle; - - // When pressing Fire2 (alt) the camera will snap to the target direction real quick. - // It will stop snapping when it reaches the target - if (Input.GetButton("Fire2")) - snap = true; - - if (snap) - { - // We are close to the target, so we can stop snapping now! - if (AngleDistance (currentAngle, originalTargetAngle) < 3.0) - snap = false; - - currentAngle = Mathf.SmoothDampAngle(currentAngle, targetAngle, angleVelocity, snapSmoothLag, snapMaxSpeed); - } - // Normal camera motion - else - { - if (controller.GetLockCameraTimer () < lockCameraTimeout) - { - targetAngle = currentAngle; - } - - // Lock the camera when moving backwards! - // * It is really confusing to do 180 degree spins when turning around. - if (AngleDistance (currentAngle, targetAngle) > 160 && controller.IsMovingBackwards ()) - targetAngle += 180; - - currentAngle = Mathf.SmoothDampAngle(currentAngle, targetAngle, angleVelocity, angularSmoothLag, angularMaxSpeed); - } - - - // When jumping don't move camera upwards but only down! - if (controller.IsJumping ()) - { - // We'd be moving the camera upwards, do that only if it's really high - var newTargetHeight = targetCenter.y + height; - if (newTargetHeight < targetHeight || newTargetHeight - targetHeight > 5) - targetHeight = targetCenter.y + height; - } - // When walking always update the target height - else - { - targetHeight = targetCenter.y + height; - } - - // Damp the height - var currentHeight = transform.position.y; - currentHeight = Mathf.SmoothDamp (currentHeight, targetHeight, heightVelocity, heightSmoothLag); - - // Convert the angle into a rotation, by which we then reposition the camera - var currentRotation = Quaternion.Euler (0, currentAngle, 0); - - // Set the position of the camera on the x-z plane to: - // distance meters behind the target - transform.position = targetCenter; - transform.position += currentRotation * Vector3.back * distance; - - // Set the height of the camera - transform.position.y = currentHeight; - - // Always look at the target - SetUpRotation(targetCenter, targetHead); -} - -function LateUpdate () { - Apply (transform, Vector3.zero); -} - -function Cut (dummyTarget : Transform, dummyCenter : Vector3) -{ - var oldHeightSmooth = heightSmoothLag; - var oldSnapMaxSpeed = snapMaxSpeed; - var oldSnapSmooth = snapSmoothLag; - - snapMaxSpeed = 10000; - snapSmoothLag = 0.001; - heightSmoothLag = 0.001; - - snap = true; - Apply (transform, Vector3.zero); - - heightSmoothLag = oldHeightSmooth; - snapMaxSpeed = oldSnapMaxSpeed; - snapSmoothLag = oldSnapSmooth; -} - -function SetUpRotation (centerPos : Vector3, headPos : Vector3) -{ - // Now it's getting hairy. The devil is in the details here, the big issue is jumping of course. - // * When jumping up and down we don't want to center the guy in screen space. - // This is important to give a feel for how high you jump and avoiding large camera movements. - // - // * At the same time we dont want him to ever go out of screen and we want all rotations to be totally smooth. - // - // So here is what we will do: - // - // 1. We first find the rotation around the y axis. Thus he is always centered on the y-axis - // 2. When grounded we make him be centered - // 3. When jumping we keep the camera rotation but rotate the camera to get him back into view if his head is above some threshold - // 4. When landing we smoothly interpolate towards centering him on screen - var cameraPos = transform.position; - var offsetToCenter = centerPos - cameraPos; - - // Generate base rotation only around y-axis - var yRotation = Quaternion.LookRotation(Vector3(offsetToCenter.x, 0, offsetToCenter.z)); - - var relativeOffset = Vector3.forward * distance + Vector3.down * height; - transform.rotation = yRotation * Quaternion.LookRotation(relativeOffset); - - // Calculate the projected center position and top position in world space - var centerRay = camera.ViewportPointToRay(Vector3(.5, 0.5, 1)); - var topRay = camera.ViewportPointToRay(Vector3(.5, clampHeadPositionScreenSpace, 1)); - - var centerRayPos = centerRay.GetPoint(distance); - var topRayPos = topRay.GetPoint(distance); - - var centerToTopAngle = Vector3.Angle(centerRay.direction, topRay.direction); - - var heightToAngle = centerToTopAngle / (centerRayPos.y - topRayPos.y); - - var extraLookAngle = heightToAngle * (centerRayPos.y - centerPos.y); - if (extraLookAngle < centerToTopAngle) - { - extraLookAngle = 0; - } - else - { - extraLookAngle = extraLookAngle - centerToTopAngle; - transform.rotation *= Quaternion.Euler(-extraLookAngle, 0, 0); - } -} - -function GetCenterOffset () -{ - return centerOffset; -} - -@script AddComponentMenu ("Third Person Camera/Smooth Follow Camera") -@script RequireComponent (Camera) \ No newline at end of file diff --git a/SpeedLines.js b/SpeedLines.js index 29fa050..e49eab8 100644 --- a/SpeedLines.js +++ b/SpeedLines.js @@ -8,9 +8,9 @@ var speedLinesAudio1 : AudioSource; var speedLinesAudio2 : AudioSource; function Start () { - speedLinesRenderer = renderer; - speedLinesMaterial = renderer.material; - peakValue = renderer.material.color.a; + speedLinesRenderer = GetComponent.(); + speedLinesMaterial = speedLinesRenderer.material; + peakValue = speedLinesMaterial.color.a; speedLinesMaterial.color.a = 0.0; speedLinesRenderer.enabled = false; } diff --git a/TentacleFlail.js b/TentacleFlail.js index fe38600..fdf2c8f 100644 --- a/TentacleFlail.js +++ b/TentacleFlail.js @@ -6,16 +6,24 @@ var triggerAnimation : String; var triggerInTime : float = 0.5; var triggerOutTime : float = 1.0; +private var audioSource: AudioSource; +private var thisAnimation: Animation; + +function Start () { + audioSource = GetComponent.(); + thisAnimation = GetComponent.(); +} + function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - animation.CrossFade(triggerAnimation, triggerInTime); - if (audio) {audio.Play();} + thisAnimation.CrossFade(triggerAnimation, triggerInTime); + if (audioSource) {audioSource.Play();} } } function OnTriggerExit (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - //animation.PlayQueued("twist2", QueueMode.PlayNow); - animation.CrossFade(mainAnimation, triggerOutTime); + //thisAnimation.PlayQueued("twist2", QueueMode.PlayNow); + thisAnimation.CrossFade(mainAnimation, triggerOutTime); } } \ No newline at end of file diff --git a/TentacleFlailRandom.js b/TentacleFlailRandom.js index e26f266..2152083 100644 --- a/TentacleFlailRandom.js +++ b/TentacleFlailRandom.js @@ -7,6 +7,14 @@ var triggerAnimation2 : String; var triggerInTime : float = 0.5; var triggerOutTime : float = 1.0; +private var audioSource: AudioSource; +private var thisAnimation: Animation; + +function Start() { + audioSource = GetComponent.(); + thisAnimation = GetComponent.(); +} + function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player")) { var seconds : int = Time.time; @@ -15,14 +23,14 @@ function OnTriggerEnter (other : Collider) { var animationToRun : String; // Debug.Log("oddeven was " + oddeven); animationToRun = (oddeven == 0) ? triggerAnimation1 : triggerAnimation2 ; - animation.CrossFade(animationToRun, triggerInTime); - if (audio) {audio.Play();} + thisAnimation.CrossFade(animationToRun, triggerInTime); + if (audioSource) {audioSource.Play();} } } function OnTriggerExit (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - //animation.PlayQueued("twist2", QueueMode.PlayNow); - animation.CrossFade(mainAnimation, triggerOutTime); + //thisAnimation.PlayQueued("twist2", QueueMode.PlayNow); + thisAnimation.CrossFade(mainAnimation, triggerOutTime); } } \ No newline at end of file diff --git a/TongueAnimation.js b/TongueAnimation.js index 823c855..c0c8c68 100644 --- a/TongueAnimation.js +++ b/TongueAnimation.js @@ -2,14 +2,20 @@ var triggerAnimation : String; +private var thisAnimation: Animation; + +function Start() { + thisAnimation = GetComponent.(); +} + function OnTriggerEnter (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - animation.Play(triggerAnimation); + thisAnimation.Play(triggerAnimation); } } function OnTriggerExit (other : Collider) { if (other.gameObject.CompareTag ("Player")) { - animation.Stop(triggerAnimation); + thisAnimation.Stop(triggerAnimation); } } \ No newline at end of file diff --git a/changeBackdrop.js b/changeBackdrop.js index 4e9f582..1d7ae1c 100644 --- a/changeBackdrop.js +++ b/changeBackdrop.js @@ -7,6 +7,8 @@ var origMat : Material; var fadeTex : Texture2D; var mainCamera : GameObject; +var cam : Camera; + static var oceanCamera : GameObject; var backdropMist : GameObject; static var oceanRenderer : Renderer; @@ -48,6 +50,7 @@ function Start () { if (mistLevel == true) { backdropMist = transform.FindChild("Cylinder").gameObject; } + cam = mainCamera.GetComponent.(); } function OnTriggerEnter (other : Collider) { @@ -56,7 +59,7 @@ function OnTriggerEnter (other : Collider) { // not needed if not actually changing backdrop // transform.Find("plane-close").renderer.materials = [newMat]; if (ShouldChangeBackdrop == true) { - transform.Find("plane-close").renderer.materials = [newMat];} + transform.Find("plane-close").GetComponent.().materials = [newMat];} // FadeBetweenCameras (); // Enable the above method to re-add the fade 2d image backdrop on trigger enter. @@ -90,7 +93,7 @@ function FadeCameraFarClipPlane (type : int) { iTween.ValueTo ( gameObject, { - "from" : mainCamera.camera.farClipPlane, + "from" : cam.farClipPlane, "to" : farClipPlaneValue2, "onupdate" : "ChangeCameraFarClipPlane", "time" : farClipPlaneFadeTime2, @@ -100,7 +103,7 @@ function FadeCameraFarClipPlane (type : int) { else { iTween.ValueTo ( gameObject, { - "from" : mainCamera.camera.farClipPlane, + "from" : cam.farClipPlane, "to" : farClipPlaneValue, "onupdate" : "ChangeCameraFarClipPlane", "time" : farClipPlaneFadeTime, @@ -154,7 +157,7 @@ function ChangeFogEndDistance (i : int) { } function ChangeCameraFarClipPlane (i : int) { - mainCamera.camera.farClipPlane = i; + cam.farClipPlane = i; } function enableOceanCamera () { @@ -167,6 +170,6 @@ function enableOceanCamera () { function OnTriggerExit (other : Collider) { if (other.gameObject.CompareTag ("changeBackdrop") && ShouldChangeBackdrop == true) { - transform.Find("plane-close").renderer.materials = [origMat]; + transform.Find("plane-close").GetComponent.().materials = [origMat]; } } \ No newline at end of file diff --git a/controllerITween.js b/controllerITween.js deleted file mode 100644 index 1588c8f..0000000 --- a/controllerITween.js +++ /dev/null @@ -1,113 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var duration : float = 18000; -var endPoint = 0.0; -private var startPoint = 18000.0; -private var startTime : float; -private var timeSinceTap : float; -private var timeAtTap : float; -var Slowdown : int = 0; - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; - - - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - } - - // if (touchingSomething) - // { - // dir.z = Input.acceleration.x; - // } - -// rigidbody.AddForce(dir * force); - Screen.sleepTimeout = 0.0f; -} - -/* -function OnCollisionEnter (collision : Collision) { - Debug.Log("Hit something!" + collision.contacts[0].normal + dir.x + dir.z + Input.acceleration.x); -// dir = collision.contacts[0].normal; - // for (var contact : ContactPoint in collision.contacts) { -// Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2); - } - - - -// collider.attachedRigidbody.AddForce(dir * force); -*/ - - -// Animate score changes using iTween's ValueTo -function SmoothSlowdown () { - - iTween.ValueTo ( gameObject, - { - "from" : 18000, - "to" : 0, - "onupdate" : "ChangeSlowdown", - "time" : 1, - "easetype": "easeOutExpo" - } - ); - -} - -function ChangeSlowdown ( i : int ) { -Slowdown = i; -} - - - -function Update () { -var fingerCount = 0; - - for (var touch : Touch in Input.touches) { - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) - fingerCount++; - } - - rigidbody.AddRelativeForce (Vector3.down * Slowdown); - - - if (fingerCount > 0) - { -// constantForce.relativeForce = Vector3.down * Slowdown; -// rigidbody.AddRelativeForce (Vector3.down * Slowdown); - timeAtTap = Time.time; -// print("User has " + fingerCount + " finger(s) touching the screen. Your touching slowdown is " + Slowdown); - SmoothSlowdown (); - } - } diff --git a/controllerITween2 1242am 7-28-2012.js b/controllerITween2 1242am 7-28-2012.js deleted file mode 100644 index 11763b4..0000000 --- a/controllerITween2 1242am 7-28-2012.js +++ /dev/null @@ -1,136 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var endPoint = 0.0; -//private var startPoint = 18000.0; -private var startTime : float; -private var timeTapEnded : float; -private var timeAtTap : float; -private var timeVar : float; -var Slowdown : int = 0; -var speed = 10.0; -private var accelerationState : int = 0; - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -// Edit yo FPS here, fool! -// Application.targetFrameRate = 60; -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - rigidbody.AddRelativeForce (Vector3.down * Slowdown); - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; -// print("Your X and Z accel are: " + dir.x + ", " + dir.z); - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - - // Make it move 10 meters per second instead of 10 meters per frame... - dir *= Time.deltaTime; - - // Move object - transform.Translate (dir * speed); - } - -// constantForce.relativeForce = (Vector3.down * Slowdown); - Screen.sleepTimeout = 0.0f; -} - - - -// Animate score changes using iTween's ValueTo -function SmoothSpeedup () { - - iTween.ValueTo ( gameObject, - { - "from" : 0, - "to" : 20000, - "onupdate" : "ChangeSpeed", - "time" : 1, - "easetype": "easeOutExpo" - } - ); - -} - -function SmoothSlowdown () { - - iTween.ValueTo ( gameObject, - { - "from" : Slowdown, - "to" : 0, - "onupdate" : "ChangeSpeed", - "time" : 1, - "easetype": "easeOutCirc" - } - ); - -} - -function ChangeSpeed ( i : int ) { -Slowdown = i; -//constantForce.relativeForce = (Vector3.down * i); -} - -function Update () { -var fingerCount = 0; - - for (var touch : Touch in Input.touches) { - -//if (touch.phase == TouchPhase.Began){ -//SmoothSpeedup (); -//accelerationState = 1; -//} - -//if ((touch.phase == TouchPhase.Ended) || (touch.phase == TouchPhase.Canceled)){ -//SmoothSlowdown (); -//} - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled){ - fingerCount++;} - } - - if (Slowdown == 0) - { accelerationState = 0;} - - if ((fingerCount > 0) && (accelerationState != 1)) - { - Camera.main.SendMessage("speedLinesUp"); - SmoothSpeedup (); - accelerationState = 1;} - - if ((fingerCount == 0) && (Slowdown != 0) && (accelerationState != 2)) - {Camera.main.SendMessage("speedLinesDown"); - SmoothSlowdown (); - accelerationState = 2;} - -//constantForce.relativeForce = (Vector3.down * Slowdown); - // rigidbody.AddRelativeForce (Vector3.down * Slowdown); - - // constantForce.relativeForce = (Vector3.down * Slowdown); - -} diff --git a/controllerITween2 7-282012 1020pm.js b/controllerITween2 7-282012 1020pm.js deleted file mode 100644 index 5fcf819..0000000 --- a/controllerITween2 7-282012 1020pm.js +++ /dev/null @@ -1,135 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var endPoint = 0.0; -//private var startPoint = 18000.0; -private var startTime : float; -private var timeTapEnded : float; -private var timeAtTap : float; -private var timeVar : float; -var Slowdown : int = 0; -var speed = 10.0; - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -// Edit yo FPS here, fool! -// Application.targetFrameRate = 60; -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; -// print("Your X and Z accel are: " + dir.x + ", " + dir.z); - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - - // Make it move 10 meters per second instead of 10 meters per frame... - dir *= Time.deltaTime; - - // Move object - transform.Translate (dir * speed); - } - -// constantForce.relativeForce = (Vector3.down * Slowdown); - Screen.sleepTimeout = 0.0f; -} - - - -// Animate score changes using iTween's ValueTo -function SmoothSpeedup () { - - iTween.ValueTo ( gameObject, - { - "from" : Slowdown, - "to" : 20000, - "onupdate" : "ChangeSpeed", - "time" : 1, - "easetype": "easeOutExpo" - } - ); - -} - -function SmoothSlowdown () { - - iTween.ValueTo ( gameObject, - { - "from" : Slowdown, - "to" : 0, - "onupdate" : "ChangeSpeed", - "time" : 1, - "easetype": "easeOutCirc" - } - ); - -} - -function ChangeSpeed ( i : int ) { -Slowdown = i; -//constantForce.relativeForce = (Vector3.down * i); -} - -function Update () { -var fingerCount = 0; - - for (var touch : Touch in Input.touches) { - -//if (touch.phase == TouchPhase.Began){ -//SmoothSpeedup (); -//accelerationState = 1; -//} - -//if ((touch.phase == TouchPhase.Ended) || (touch.phase == TouchPhase.Canceled)){ -//SmoothSlowdown (); -//} - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled){ - fingerCount++;} - } - - - if ((fingerCount > 0)) - { - Camera.main.SendMessage("speedLinesUp"); - SmoothSpeedup (); - } - - else if ((fingerCount == 0) && (Slowdown > 0) && (Slowdown < 21000)) - { - Camera.main.SendMessage("speedLinesDown"); - SmoothSlowdown (); - } - -// rigidbody.AddRelativeForce (Vector3.down * Slowdown); - -constantForce.relativeForce = (Vector3.down * Slowdown); - // rigidbody.AddRelativeForce (Vector3.down * Slowdown); - - // constantForce.relativeForce = (Vector3.down * Slowdown); - -} diff --git a/controllerITween2 crude, works, but not smooth.js b/controllerITween2 crude, works, but not smooth.js deleted file mode 100644 index 39dbda1..0000000 --- a/controllerITween2 crude, works, but not smooth.js +++ /dev/null @@ -1,154 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var duration : float = 18000; -var endPoint = 0.0; -private var startPoint = 18000.0; -private var startTime : float; -private var timeTapEnded : float; -private var timeAtTap : float; -private var timeVar : float; -var Slowdown : int = 0; -var speed = 10.0; -var Accel : int = 1; - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -// Edit yo FPS here, fool! -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; -// print("Your X and Z accel are: " + dir.x + ", " + dir.z); - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - - // Make it move 10 meters per second instead of 10 meters per frame... - dir *= Time.deltaTime; - - // Move object - transform.Translate (dir * speed); - - } - - // if (touchingSomething) - // { - // dir.z = Input.acceleration.x; - // } - -// rigidbody.AddForce(dir * force); - Screen.sleepTimeout = 0.0f; -} - -/* -function OnCollisionEnter (collision : Collision) { - Debug.Log("Hit something!" + collision.contacts[0].normal + dir.x + dir.z + Input.acceleration.x); -// dir = collision.contacts[0].normal; - // for (var contact : ContactPoint in collision.contacts) { -// Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2); - } - - - -// collider.attachedRigidbody.AddForce(dir * force); -*/ - - -// Animate score changes using iTween's ValueTo -function SmoothSpeedup () { - - iTween.ValueTo ( gameObject, - { - "from" : 18000, - "to" : 0, - "onupdate" : "ChangeSpeed", - "time" : 1.5, - "easetype": "easeInExpo", - "oncomplete": "ResumeAccel" - } - ); - -} - -function ChangeSpeed ( i : int ) { -Slowdown = i; -} - - -function ResumeAccel () { -Accel = 1; -} - -function Update () { -var fingerCount = 0; - - for (var touch : Touch in Input.touches) { - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled){ - fingerCount++;} -// else -// {Camera.main.SendMessage("speedLinesDown"); -// print(fingerCount); -// } - -// if (touch.phase == TouchPhase.Began){ -// Camera.main.SendMessage("speedLinesUp");} - // print("Speedlines Start"); -// if (fingerCount == 0) { -// Camera.main.SendMessage("speedLinesDown");} -// print(fingerCount); -//touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled || - -/* - if (touch.phase == TouchPhase.Began) - { - timeAtTap = Time.time; - timeTapEnded = 0; - } - if (touch.phase == TouchPhase.Ended) - { - timeTapEnded = Time.time; - } - */ - } - -// rigidbody.AddRelativeForce (Vector3.down * Slowdown); - constantForce.relativeForce = (Vector3.down * Slowdown); - - if ((fingerCount > 0) && (Accel == 1)) - { -// constantForce.relativeForce = Vector3.down * Slowdown; -// rigidbody.AddRelativeForce (Vector3.down * Slowdown); -// print("User has " + fingerCount + " finger(s) touching the screen. Your touching slowdown is " + Slowdown + " and your timeVar is " + timeVar); - SmoothSpeedup (); - Accel = 0; - Camera.main.SendMessage("speedLinesUp"); - } - else if (fingerCount == 0) - {Camera.main.SendMessage("speedLinesDown"); Accel = 1;} - } diff --git a/controllerITween2-elaborate.js b/controllerITween2-elaborate.js deleted file mode 100644 index 5142719..0000000 --- a/controllerITween2-elaborate.js +++ /dev/null @@ -1,153 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var duration : float = 18000; -var endPoint = 0.0; -private var startPoint = 18000.0; -private var startTime : float; -private var timeTapEnded : float; -private var timeAtTap : float; -private var timeVar : float; -var Slowdown : int = 0; -var speed = 10.0; - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -// Edit yo FPS here, fool! -// Application.targetFrameRate = 60; -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; -// print("Your X and Z accel are: " + dir.x + ", " + dir.z); - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - - // Make it move 10 meters per second instead of 10 meters per frame... - dir *= Time.deltaTime; - - // Move object - transform.Translate (dir * speed); - - } - - // if (touchingSomething) - // { - // dir.z = Input.acceleration.x; - // } - -// rigidbody.AddForce(dir * force); - Screen.sleepTimeout = 0.0f; -} - -/* -function OnCollisionEnter (collision : Collision) { - Debug.Log("Hit something!" + collision.contacts[0].normal + dir.x + dir.z + Input.acceleration.x); -// dir = collision.contacts[0].normal; - // for (var contact : ContactPoint in collision.contacts) { -// Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2); - } - - - -// collider.attachedRigidbody.AddForce(dir * force); -*/ - - -// Animate score changes using iTween's ValueTo -function SmoothSpeedup () { - - iTween.ValueTo ( gameObject, - { - "from" : 18000, - "to" : 0, - "onupdate" : "ChangeSpeed", - "time" : 1.5, - "easetype": "easeInExpo" - } - ); - -} - -function ChangeSpeed ( i : int ) { -Slowdown = i; -} - -function Update () { -var fingerCount = 0; -//timeVar = Mathf.Abs(timeTapEnded - timeAtTap); - - for (var touch : Touch in Input.touches) { - -if (touch.phase == TouchPhase.Began){ -SmoothSpeedup (); -} - - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled){ - fingerCount++;} -// else -// {Camera.main.SendMessage("speedLinesDown"); -// print(fingerCount); -// } - -// if (touch.phase == TouchPhase.Began){ -// Camera.main.SendMessage("speedLinesUp");} - // print("Speedlines Start"); -// if (fingerCount == 0) { -// Camera.main.SendMessage("speedLinesDown");} -// print(fingerCount); -//touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled || - -/* - if (touch.phase == TouchPhase.Began) - { - timeAtTap = Time.time; - timeTapEnded = 0; - } - if (touch.phase == TouchPhase.Ended) - { - timeTapEnded = Time.time; - } - */ - } - -// rigidbody.AddRelativeForce (Vector3.down * Slowdown); - constantForce.relativeForce = (Vector3.down * Slowdown); - - if (fingerCount > 0) - { -// constantForce.relativeForce = Vector3.down * Slowdown; -// rigidbody.AddRelativeForce (Vector3.down * Slowdown); -// print("User has " + fingerCount + " finger(s) touching the screen. Your touching slowdown is " + Slowdown + " and your timeVar is " + timeVar); -// SmoothSpeedup (); - Camera.main.SendMessage("speedLinesUp"); - } - else - {Camera.main.SendMessage("speedLinesDown");} - } diff --git a/controllerITween2-scratch.js b/controllerITween2-scratch.js deleted file mode 100644 index de3f87f..0000000 --- a/controllerITween2-scratch.js +++ /dev/null @@ -1,128 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var duration : float = 18000; -var endPoint = 0.0; -private var startPoint = 18000.0; -private var startTime : float; -private var timeTapEnded : float; -private var timeAtTap : float; -private var timeVar : float; -var Slowdown : int = 0; -var speed = 10.0; -private var notAccelerating : boolean = true; - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -// Edit yo FPS here, fool! -// Application.targetFrameRate = 60; -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; -// print("Your X and Z accel are: " + dir.x + ", " + dir.z); - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - - // Make it move 10 meters per second instead of 10 meters per frame... - dir *= Time.deltaTime; - - // Move object - transform.Translate (dir * speed); - } - - Screen.sleepTimeout = 0.0f; -} - - - -// Animate score changes using iTween's ValueTo -function SmoothSpeedup () { - - iTween.ValueTo ( gameObject, - { - "from" : 0, - "to" : 18000, - "onupdate" : "ChangeSpeed", - "time" : 1, - "easetype": "easeInOutCubic" - } - ); - -} - -function SmoothSlowdown () { - - iTween.ValueTo ( gameObject, - { - "from" : Slowdown, - "to" : 0, - "onupdate" : "ChangeSpeed", - "time" : 1.5, - "easetype": "easeInOutCubic" - } - ); - -} - -function ChangeSpeed ( i : int ) { -Slowdown = i; -} - -function Update () { -var fingerCount = 0; - - for (var touch : Touch in Input.touches) { - -if (touch.phase == TouchPhase.Began){ -SmoothSpeedup (); -notAccelerating = false; -} - -//if ((touch.phase == TouchPhase.Ended) || (touch.phase == TouchPhase.Canceled)){ -//SmoothSlowdown (); -//} - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled){ - fingerCount++;} - } - - rigidbody.AddRelativeForce (Vector3.down * Slowdown); -// constantForce.relativeForce = (Vector3.down * Slowdown); - - if (fingerCount > 0) - { - Camera.main.SendMessage("speedLinesUp"); - } - else - {Camera.main.SendMessage("speedLinesDown");} - - if ((fingerCount == 0) && (Slowdown != 0) && (notAccelerating == false)) - {SmoothSlowdown (); - notAccelerating = true;} -} diff --git a/controllerModded.js b/controllerModded.js deleted file mode 100644 index fb976cb..0000000 --- a/controllerModded.js +++ /dev/null @@ -1,141 +0,0 @@ -public var force:float = 1.0; -public var simulateAccelerometer:boolean = false; -public var touchedBy:boolean = false; -public var doBlah:boolean = false; -// public var fingerCount:float = 0; -var dir : Vector3 = Vector3.zero; -var duration : float = 18000; -var endPoint = 0.0; -private var startPoint = 18000.0; -private var startTime : float; -private var timeSinceTap : float; -private var timeAtTap : float; -private var timeTapEnded : float; -var blah = Mathf.Lerp(startPoint, endPoint, (timeTapEnded - timeAtTap)); - -function Start() -{ - // make landscape view - iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape; - Screen.sleepTimeout = 0.0f; -// startPoint = transform.position; - startTime = Time.time; -} - -function FixedUpdate () { - var dir : Vector3 = Vector3.zero; - - if (simulateAccelerometer) - { - // using joystick input instead of iPhone accelerometer - dir.x = Input.GetAxis("Horizontal"); - dir.z = Input.GetAxis("Vertical"); - } - else - { - // we assume that device is held parallel to the ground - // and Home button is in the right hand - - // remap device acceleration axis to game coordinates - // 1) XY plane of the device is mapped onto XZ plane - // 2) rotated 90 degrees around Y axis - dir.x = -Input.acceleration.y; - dir.z = Input.acceleration.x; - - - // clamp acceleration vector to unit sphere - if (dir.sqrMagnitude > 1) - dir.Normalize(); - } - - Screen.sleepTimeout = 0.0f; -} - -/* -function OnCollisionEnter (collision : Collision) { - Debug.Log("Hit something!" + collision.contacts[0].normal + dir.x + dir.z + Input.acceleration.x); -// dir = collision.contacts[0].normal; - // for (var contact : ContactPoint in collision.contacts) { -// Debug.DrawLine(contact.point, contact.point + contact.normal, Color.green, 2); - } - - - -// collider.attachedRigidbody.AddForce(dir * force); -*/ - -function Update () { -var fingerCount = 0; - - for (var touch : Touch in Input.touches) { - if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) - fingerCount++; - } - - /* - - if (fingerCount > 0) - { - print ("User has " + fingerCount + " finger(s) touching the screen"); - constantForce.relativeForce = Vector3.down * 18000; - timeAtTap = Time.time; - } - else - { - timeSinceTap = (Time.time - timeAtTap); - - */ - - - for (var touch : Touch in Input.touches) { - - if (touch.phase == TouchPhase.Began) - { - timeAtTap = Time.time; - } - - if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) - { - constantForce.relativeForce = Vector3.down * 18000; - } - - if - (touch.phase == TouchPhase.Ended) - { - timeTapEnded = Time.time; - doBlah = true; - print ("your blah is: " + blah + ", your timeAtTap is " + timeAtTap + " and your timeTapEnded is " + timeTapEnded); - //timeSinceTap = (Time.time - timeAtTap); - } - - -/* var minimum = 18000; - var maximum = 0.0; - var blah = Mathf.Lerp(minimum, maximum, Time.deltaTime); - constantForce.relativeForce = Vector3.down * blah; - fingerCount = 0; - - */ -// var blah = Mathf.Lerp(startPoint, endPoint, (Time.time - startTime) / duration); -// var blah = Mathf.Lerp(startPoint, endPoint, (timeSinceTap - startTime)); - // / duration); - - - -// print ("your blah is: timeTapEnded " + timeTapEnded + " timeSinceTap " + timeSinceTap + ", Time " + (Time.time - startTime) + " divided by duration " + duration + " = blah " + blah + ", based on " + Vector3.down); - -//constantForce.relativeForce = Vector3.down * blah; - -//transform.position = Vector3.Lerp(startPoint, endPoint, (Time.time - startTime) / duration); -} - - - } - - if (doBlah == true) - { - while (blah > 1) - { - constantForce.relativeForce = Vector3.down * blah; - } -} \ No newline at end of file diff --git a/dontgothroughthings.js b/dontgothroughthings.js index b21b7d6..35b871d 100644 --- a/dontgothroughthings.js +++ b/dontgothroughthings.js @@ -7,11 +7,13 @@ private var partialExtent : float; private var sqrMinimumExtent : float; private var previousPosition : Vector3; private var myRigidbody : Rigidbody; + //initialize values function Awake() { myRigidbody = rigidbody; previousPosition = myRigidbody.position; - minimumExtent = Mathf.Min(Mathf.Min(collider.bounds.extents.x, collider.bounds.extents.y), collider.bounds.extents.z); + var cldr : Collider = GetComponent.(); + minimumExtent = Mathf.Min(Mathf.Min(cldr.bounds.extents.x, cldr.bounds.extents.y), cldr.bounds.extents.z); partialExtent = minimumExtent*(1.0 - skinWidth); sqrMinimumExtent = minimumExtent*minimumExtent; } diff --git a/fallingUITest.js b/fallingUITest.js index f82c2fe..f750280 100644 --- a/fallingUITest.js +++ b/fallingUITest.js @@ -591,7 +591,7 @@ function LevelComplete() { fallingPlayerComponent.FadeAudio (.9, FadeDir.Out); yield WaitForSeconds (1); // Time.timeScale = 0; - player.rigidbody.isKinematic = true; + player.GetComponent.().isKinematic = true; AudioListener.pause = true; Application.LoadLevel(levelToLoad); // not necessary because Respawn.js resets the latest checkpoint in its Start @@ -605,7 +605,7 @@ function LevelComplete() { function BeginOutroUI() { FadeOutGUI(); FallingPlayer.isPausable = false; - player.rigidbody.isKinematic = true; + player.GetComponent.().isKinematic = true; } function OldGameCompleteUI() { diff --git a/jumpingPlayer.js b/jumpingPlayer.js deleted file mode 100644 index e85c65a..0000000 --- a/jumpingPlayer.js +++ /dev/null @@ -1,27 +0,0 @@ -var bounce : float = 1.0; -var Player : Transform; - var dir : Vector3 = Vector3.zero; - -function OnCollisionEnter (other : Collision) { - bounce = 1.0; - if(other.gameObject.tag == "Ground") - //bounce = 190.0; - bounce = Mathf.Abs((Input.acceleration.y)*100000); - //Debug.Log("Hit something!" + other.contacts[0].normal + bounce); - - // + dir.x + dir.z + Input.acceleration.x); - - if(other.gameObject.tag == "Rubber") - bounce = 5.0; - if(other.gameObject.tag == "Spike") - bounce = 0.0;// player is dead -} - - -function Update () -{ - if(bounce>1.0) - Player.rigidbody.velocity.y = bounce; - bounce = 1.0; -} - diff --git a/playerdeath.js b/playerdeath.js deleted file mode 100644 index 30d5c05..0000000 --- a/playerdeath.js +++ /dev/null @@ -1,34 +0,0 @@ - var dir : Vector3 = Vector3.zero; - - -function OnCollisionEnter (collision : Collision) { - Debug.Log("Hit something!" + collision.contacts[0].normal + dir.x + dir.z + Input.acceleration.x); - Screen.sleepTimeout = 0.0f; -// collider.attachedRigidbody.velocity.y *= damping; - - -// collider.attachedRigidbody.AddForce(dir * force); - -// iPhoneUtils.Vibrate (); -// var relativeStartingPosition = transform.InverseTransformPoint(0, -500, 0); - -// if (collision.gameObject.name == deadlyObjectName){ - if (collision.gameObject.CompareTag ("Death")){ - //collider.attachedRigidbody.transform.Translate(relativeStartingPosition, Space.World); - - var respawnPosition = Respawn.currentRespawn.transform.position; - Camera.main.SendMessage("fadeOut"); - yield WaitForSeconds(1); - gameObject.SendMessage ("ZeroScore", 1); -// gameObject.SendMessage ("DecrementScore"); - - -// Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too - collider.attachedRigidbody.transform.Translate(respawnPosition); - // Relocate the player. We need to do this or the camera will keep trying to focus on the (invisible) player where he's standing on top of the FalloutDeath box collider. - transform.position = respawnPosition; // + Vector3.up; - Camera.main.SendMessage("fadeIn"); - - - } - } \ No newline at end of file diff --git a/slowlyRotate2.js b/slowlyRotate2.js index 2f57a81..a501641 100644 --- a/slowlyRotate2.js +++ b/slowlyRotate2.js @@ -16,8 +16,11 @@ var dirGlobal:float = 1; //var y : RotVector; //var z : RotVector; +var myRenderer : Renderer; + function Start () { // Loop (); + myRenderer = GetComponent.(); } function Loop () { @@ -27,7 +30,7 @@ function Loop () { } function RotateNow (delay : float) { -if (renderer.isVisible) { +if (myRenderer.isVisible) { iTween.RotateUpdate(gameObject, transform.eulerAngles, 2); yield WaitForSeconds(delay); } @@ -36,7 +39,7 @@ if (renderer.isVisible) { //function FixedUpdate () {transform.Rotate(Vector3(x, y, z) * (dir*3) * Time.deltaTime, Space.World);} function FixedUpdate() { -if (renderer.isVisible) { +if (myRenderer.isVisible) { transform.Rotate(Vector3.right * (dirLocal*3) * Time.deltaTime); transform.Rotate(Vector3.up * (dirGlobal*3) * Time.deltaTime, Space.World); }