Advertisement
pivotraze

Lose Script

Dec 2nd, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BOO 1.22 KB | None | 0 0
  1. /* This script is licensed under the BSD license.
  2. Author: Cody Dostal
  3. Author Email: allysman21@gmail.com
  4. Date Written: 4/22/2012
  5. Date Last Edited: 4/24/2012
  6. Engine Version: 3.5.1f2
  7. Script Version: v1.1
  8. */
  9.  
  10. /* NOTE: With good chance, you may have to change any hard-coded values in these scripts.
  11. These values work with my version, and may not with your version. */
  12.  
  13. import UnityEngine
  14.  
  15. class Lose (MonoBehaviour):
  16.    
  17.     public loseTexture as Texture
  18.     private infoTxt as string = "You have lost! Do you want to retry?"
  19.  
  20.     def OnGUI ():
  21.         GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), loseTexture)
  22.        
  23.         // Capture mouse click. If you click on button, takes to menu. Click anywhere else, takes back to game.
  24.         if GUI.Button(Rect(10, 10, 150, 50), "Menu"):
  25.             Application.LoadLevel(0)
  26.         elif Event.current != null and Event.current.isMouse:
  27.             resetAndLoad()
  28.            
  29.         // If any key EXCEPT the left mouse button is clicked, call resetAndLoad()
  30.         if Input.anyKeyDown and not Input.GetMouseButtonDown(0):
  31.             resetAndLoad()
  32.            
  33.     def resetAndLoad():
  34.         // Reset all things related to player.
  35.         player.score = 0
  36.         player.lives = 3
  37.         player.missed = 0
  38.        
  39.         // Load the game again, skip menu.
  40.         Application.LoadLevel(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement