Advertisement
kasru

Battle Select System

Mar 4th, 2013
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //****** Donations are greatly appreciated.  ******
  2. //****** You can donate directly to Jesse through paypal at  https://www.paypal.me/JEtzler   ******
  3.  
  4. var turn : int = 1;
  5. var phase : int = 0;
  6. var enemyToAttack : String;
  7.  
  8. //player stats
  9. var playerCurHp : float = 100.0;
  10. var playerMaxHp : float = 100.0;
  11. var playerMinAttack : float = 5.0;
  12. var playerMaxAttack : float = 10.0;
  13.  
  14. var enemyTurnActivated : boolean = false;
  15.  
  16. function OnGUI () {
  17.  
  18.     var otherScript: MainGame1 = gameObject.Find("MainGame").GetComponent(MainGame1);
  19.     if(otherScript.inBattle == true) {
  20.         // If it's the players turn then show combat buttons
  21.         if(turn == 1) {
  22.  
  23.             //select attack
  24.             if(phase == 0) {
  25.  
  26.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Attack")) {
  27.             phase = 1;
  28.         }
  29.  
  30.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Item")) {
  31.             phase = 2;
  32.         }
  33.  
  34.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 250,140,20), "Run")) {
  35.             phase = 3;
  36.         }
  37. }
  38.  
  39.     //attack selection
  40.     if(phase == 1) {
  41.  
  42.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Slice")) {
  43.             turn = 2;
  44.             phase = 0;
  45.         }
  46.  
  47.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Back")) {
  48.             phase = 0;
  49.         }
  50.     }
  51.  
  52.     if(phase == 2) {
  53.  
  54.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Health Potion")) {
  55.             turn = 2;
  56.             phase = 0;
  57.         }
  58.  
  59.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Back")) {
  60.             phase = 0;
  61.         }
  62.     }
  63.  
  64.     if(phase == 3) {
  65.  
  66.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Run Away")) {
  67.             phase = 0;
  68.             otherScript.inBattle = false;
  69.         }
  70.  
  71.         if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Back")) {
  72.             phase = 0;
  73.         }
  74.     }
  75. }
  76. }
  77. }
  78.  
  79.  
  80.  
  81. function Update () {
  82.  
  83.     //enemies turn
  84.     if(turn == 2 && enemyTurnActivated == false) {
  85.         enemyTurnActivated = true;
  86.         enemyTurn();
  87.     }
  88. }
  89.  
  90.  
  91. //After the player attacks then it's the enemy attack phase
  92. function enemyTurn () {
  93.  
  94.     Debug.Log("enemy 1 turn began");
  95.     Debug.Log("enemy 1 attacked");
  96.     enemyTurnActivated = false;
  97.     turn = 1;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement