Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ThirdPersonStatus: Handles the player's state machine.
- // Keeps track of inventory, health, lives, etc.
- var health : int = 6;
- var maxHealth : int = 6;
- var lives : int = 4;
- var currentmultiplier : int;
- var forbid : int;
- var midPlatform : GameObject;
- var firstRailings : GameObject;
- var bigBridges : GameObject;
- var bridgeLightsLeft : GameObject;
- var bridgeLightsRight : GameObject;
- var circularPlatforms : GameObject;
- var impoundLot1 : GameObject;
- var firstLights : GameObject;
- var forbiddenfruit : int;
- var inc = 2;
- var interactiontime : int;
- var valueFuel : int;
- var forbidGem : int;
- var currentmultiplierGem : int;
- // sound effects.
- var struckSound: AudioClip;
- var deathSound: AudioClip;
- private var levelStateMachine : LevelStatus; // link to script that handles the level-complete sequence.
- private var remainingItems : int; // total number to pick up on this level. Grabbed from LevelStatus.
- var other : Emitter;
- var FPSlink : FPS;
- //var hello1 : float;
- function Update(){
- if (valueFuel > 0)
- {
- valueFuel -=Time.deltaTime;
- }
- else
- return;
- }
- function Awake()
- {
- levelStateMachine = FindObjectOfType(LevelStatus);
- if (!levelStateMachine)
- Debug.Log("No link to Level Status");
- remainingItems = levelStateMachine.itemsNeeded;
- remainingGems = levelStateMachine.gemsNeeded;
- other = FindObjectOfType(Emitter);
- if (!other)
- Debug.Log("no link to emitter");
- FPSlink = FindObjectOfType(FPS);
- if (!FPSlink)
- Debug.Log("no link to FPS");
- bigBridges.renderer.enabled = false;
- bridgeLightsLeft.renderer.enabled = false;
- bridgeLightsRight.renderer.enabled = false;
- circularPlatforms.renderer.enabled = false;
- midPlatform.renderer.enabled = false;
- firstRailings.renderer.enabled = false;
- firstLights.renderer.enabled = false;
- }
- // Utility function used by HUD script:
- function GetRemainingItems() : int
- {
- //return remainingItems;
- return valueFuel;
- }
- function GetTimeLeft() : int
- {
- return interactiontime;
- }
- /*Window example*/
- function AddLife (powerUp : int) // FUEL CELL COUNT - THE CURRENTMULTIPLIER SHOULD NOT BE USED
- {
- lives--;
- //currentmultiplierGem = 5;
- //forbidGem = powerUp * currentmultiplierGem;
- //forbiddenfruit += forbidGem;
- //other.emission += forbidGem;
- //FPSlink.guiText.material.color = Color.green;
- //Debug.Log(powerUp);
- //valueFuel += powerUp * 5;
- if (lives <= 3 && lives > 2)
- {
- midPlatform.renderer.enabled = true;
- firstRailings.renderer.enabled = true;
- impoundLot1.collider.isTrigger = true;
- firstLights.renderer.enabled = true;
- }
- if (lives <= 0)
- {
- bigBridges.renderer.enabled = true;
- bridgeLightsLeft.renderer.enabled = true;
- bridgeLightsRight.renderer.enabled = true;
- circularPlatforms.renderer.enabled = true;
- }
- //Debug.Log(forbiddenfruit);
- //timeinc+=lives;
- }
- //function AddHealth (gems : int)
- //{
- // lives +=gems;
- // if(health>maxHealth)
- // {
- // health=maxHealth;
- // }
- //}
- function FoundItem (numFound: int)
- {
- //currentmultiplier = Random.Range(1,60);
- //currentmultiplier = 5;
- //forbid = numFound * currentmultiplier;
- if (midPlatform.renderer.enabled == false)
- {
- valueFuel += numFound * 5; // where 10 equals the amount that the sacred gem is worth in this level
- }
- if ((midPlatform.renderer.enabled == true) && (bigBridges.renderer.enabled == false))
- {
- valueFuel += numFound * 10;
- }
- if ((midPlatform.renderer.enabled == true) && (bigBridges.renderer.enabled == true))
- {
- valueFuel += numFound * 15;
- }
- print(valueFuel);
- //print("currentmultiplier" + currentmultiplier);
- //forbiddenfruit -=forbid;
- //other.emission -= forbid;
- //FPSlink.guiText.material.color = Color.red;
- //Debug.Log(forbiddenfruit);
- //forbiddenfruit+= numFound * currentmultiplier;
- // NOTE: We are deliberately not clamping this value to zero.
- // This allows for levels where the number of pickups is greater than the target number needed.
- // This also lets us speed up the testing process by temporarily reducing the collecatbles needed.
- // Our HUD will clamp to zero for us.
- }
- //function ChangeOxygen ()
- //{
- //changeoxygenscript = FindObjectOfType(Emitter);
- //changeoxygenscript.emission=changeoxy;
- //changeoxy+=forbiddenfruit;
- //}
- /*function Increase () {
- if(Application.loadedLevel == 0){
- currentmultiplier = 10;
- //Debug.Log(currentmultiplier);
- }
- else if(Application.loadedLevel == 1){
- currentmultiplier = 20;
- //Debug.Log(currentmultiplier);
- }
- else if(Application.loadedLevel == 2){
- currentmultiplier = 30;
- //Debug.Log(currentmultiplier);
- }
- else if(Application.loadedLevel == 3){
- currentmultiplier = 40;
- //Debug.Log(currentmultiplier);
- }
- else{
- inc+=0;
- }
- }
- */
- function FalloutDeath ()
- {
- Die();
- return;
- }
- function Die ()
- {
- // play the death sound if available.
- if (deathSound)
- {
- AudioSource.PlayClipAtPoint(deathSound, transform.position);
- }
- //if(lives <= 0)
- // Application.LoadLevel("TheGame");
- // If we've reached here, the player still has lives remaining, so respawn.
- respawnPosition = Respawn.currentRespawn.transform.position;
- Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too
- // Hide the player briefly to give the death sound time to finish...
- SendMessage("HidePlayer");
- // 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;
- yield WaitForSeconds(1.6); // give the sound time to complete.
- // (NOTE: "HidePlayer" also disables the player controls.)
- SendMessage("ShowPlayer"); // Show the player again, ready for...
- // ... the respawn point to play it's particle effect
- Respawn.currentRespawn.FireEffect ();
- }
- function LevelCompleted()
- {
- levelStateMachine.LevelCompleted();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement