Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. // ThirdPersonStatus: Handles the player's state machine.
  2.  
  3. // Keeps track of inventory, health, lives, etc.
  4.  
  5.  
  6. var health : int = 6;
  7. var maxHealth : int = 6;
  8. var lives : int = 4;
  9. var currentmultiplier : int;
  10. var forbid : int;
  11. var midPlatform : GameObject;
  12. var firstRailings : GameObject;
  13. var bigBridges : GameObject;
  14. var bridgeLightsLeft : GameObject;
  15. var bridgeLightsRight : GameObject;
  16. var circularPlatforms : GameObject;
  17. var impoundLot1 : GameObject;
  18. var firstLights : GameObject;
  19.  
  20. var forbiddenfruit : int;
  21. var inc = 2;
  22. var interactiontime : int;
  23. var valueFuel : int;
  24. var forbidGem : int;
  25. var currentmultiplierGem : int;
  26.  
  27.  
  28. // sound effects.
  29. var struckSound: AudioClip;
  30. var deathSound: AudioClip;
  31.  
  32.  
  33. private var levelStateMachine : LevelStatus; // link to script that handles the level-complete sequence.
  34.  
  35. private var remainingItems : int; // total number to pick up on this level. Grabbed from LevelStatus.
  36.  
  37. var other : Emitter;
  38. var FPSlink : FPS;
  39.  
  40. //var hello1 : float;
  41.  
  42. function Update(){
  43. if (valueFuel > 0)
  44. {
  45. valueFuel -=Time.deltaTime;
  46. }
  47. else
  48. return;
  49. }
  50.  
  51. function Awake()
  52. {
  53.  
  54. levelStateMachine = FindObjectOfType(LevelStatus);
  55. if (!levelStateMachine)
  56. Debug.Log("No link to Level Status");
  57.  
  58. remainingItems = levelStateMachine.itemsNeeded;
  59. remainingGems = levelStateMachine.gemsNeeded;
  60. other = FindObjectOfType(Emitter);
  61. if (!other)
  62. Debug.Log("no link to emitter");
  63.  
  64. FPSlink = FindObjectOfType(FPS);
  65. if (!FPSlink)
  66. Debug.Log("no link to FPS");
  67.  
  68. bigBridges.renderer.enabled = false;
  69. bridgeLightsLeft.renderer.enabled = false;
  70. bridgeLightsRight.renderer.enabled = false;
  71. circularPlatforms.renderer.enabled = false;
  72. midPlatform.renderer.enabled = false;
  73. firstRailings.renderer.enabled = false;
  74. firstLights.renderer.enabled = false;
  75.  
  76. }
  77.  
  78.  
  79.  
  80. // Utility function used by HUD script:
  81. function GetRemainingItems() : int
  82. {
  83. //return remainingItems;
  84. return valueFuel;
  85. }
  86.  
  87. function GetTimeLeft() : int
  88. {
  89. return interactiontime;
  90. }
  91.  
  92. /*Window example*/
  93.  
  94. function AddLife (powerUp : int) // FUEL CELL COUNT - THE CURRENTMULTIPLIER SHOULD NOT BE USED
  95. {
  96. lives--;
  97. //currentmultiplierGem = 5;
  98. //forbidGem = powerUp * currentmultiplierGem;
  99. //forbiddenfruit += forbidGem;
  100. //other.emission += forbidGem;
  101. //FPSlink.guiText.material.color = Color.green;
  102. //Debug.Log(powerUp);
  103. //valueFuel += powerUp * 5;
  104. if (lives <= 3 && lives > 2)
  105. {
  106. midPlatform.renderer.enabled = true;
  107. firstRailings.renderer.enabled = true;
  108. impoundLot1.collider.isTrigger = true;
  109. firstLights.renderer.enabled = true;
  110. }
  111. if (lives <= 0)
  112. {
  113. bigBridges.renderer.enabled = true;
  114. bridgeLightsLeft.renderer.enabled = true;
  115. bridgeLightsRight.renderer.enabled = true;
  116. circularPlatforms.renderer.enabled = true;
  117.  
  118. }
  119. //Debug.Log(forbiddenfruit);
  120. //timeinc+=lives;
  121. }
  122.  
  123. //function AddHealth (gems : int)
  124. //{
  125. // lives +=gems;
  126. // if(health>maxHealth)
  127. // {
  128. // health=maxHealth;
  129. // }
  130. //}
  131. function FoundItem (numFound: int)
  132. {
  133. //currentmultiplier = Random.Range(1,60);
  134. //currentmultiplier = 5;
  135. //forbid = numFound * currentmultiplier;
  136. if (midPlatform.renderer.enabled == false)
  137. {
  138. valueFuel += numFound * 5; // where 10 equals the amount that the sacred gem is worth in this level
  139. }
  140. if ((midPlatform.renderer.enabled == true) && (bigBridges.renderer.enabled == false))
  141. {
  142. valueFuel += numFound * 10;
  143. }
  144. if ((midPlatform.renderer.enabled == true) && (bigBridges.renderer.enabled == true))
  145. {
  146. valueFuel += numFound * 15;
  147. }
  148. print(valueFuel);
  149. //print("currentmultiplier" + currentmultiplier);
  150. //forbiddenfruit -=forbid;
  151. //other.emission -= forbid;
  152. //FPSlink.guiText.material.color = Color.red;
  153.  
  154. //Debug.Log(forbiddenfruit);
  155. //forbiddenfruit+= numFound * currentmultiplier;
  156.  
  157. // NOTE: We are deliberately not clamping this value to zero.
  158. // This allows for levels where the number of pickups is greater than the target number needed.
  159. // This also lets us speed up the testing process by temporarily reducing the collecatbles needed.
  160. // Our HUD will clamp to zero for us.
  161.  
  162. }
  163.  
  164. //function ChangeOxygen ()
  165. //{
  166. //changeoxygenscript = FindObjectOfType(Emitter);
  167. //changeoxygenscript.emission=changeoxy;
  168. //changeoxy+=forbiddenfruit;
  169. //}
  170.  
  171. /*function Increase () {
  172.  
  173. if(Application.loadedLevel == 0){
  174. currentmultiplier = 10;
  175. //Debug.Log(currentmultiplier);
  176. }
  177. else if(Application.loadedLevel == 1){
  178. currentmultiplier = 20;
  179. //Debug.Log(currentmultiplier);
  180. }
  181. else if(Application.loadedLevel == 2){
  182. currentmultiplier = 30;
  183. //Debug.Log(currentmultiplier);
  184. }
  185. else if(Application.loadedLevel == 3){
  186. currentmultiplier = 40;
  187. //Debug.Log(currentmultiplier);
  188. }
  189. else{
  190. inc+=0;
  191. }
  192. }
  193. */
  194.  
  195. function FalloutDeath ()
  196. {
  197. Die();
  198. return;
  199. }
  200.  
  201. function Die ()
  202. {
  203. // play the death sound if available.
  204. if (deathSound)
  205. {
  206. AudioSource.PlayClipAtPoint(deathSound, transform.position);
  207.  
  208. }
  209.  
  210. //if(lives <= 0)
  211. // Application.LoadLevel("TheGame");
  212.  
  213. // If we've reached here, the player still has lives remaining, so respawn.
  214. respawnPosition = Respawn.currentRespawn.transform.position;
  215. Camera.main.transform.position = respawnPosition - (transform.forward * 4) + Vector3.up; // reset camera too
  216. // Hide the player briefly to give the death sound time to finish...
  217. SendMessage("HidePlayer");
  218.  
  219. // 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.
  220. transform.position = respawnPosition + Vector3.up;
  221.  
  222. yield WaitForSeconds(1.6); // give the sound time to complete.
  223.  
  224. // (NOTE: "HidePlayer" also disables the player controls.)
  225.  
  226. SendMessage("ShowPlayer"); // Show the player again, ready for...
  227. // ... the respawn point to play it's particle effect
  228. Respawn.currentRespawn.FireEffect ();
  229. }
  230. function LevelCompleted()
  231. {
  232. levelStateMachine.LevelCompleted();
  233. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement