Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //****** Donations are greatly appreciated. ******
- //****** You can donate directly to Jesse through paypal at https://www.paypal.me/JEtzler ******
- var turn : int = 1;
- var phase : int = 0;
- var enemyToAttack : String;
- //player stats
- var playerCurHp : float = 100.0;
- var playerMaxHp : float = 100.0;
- var playerMinAttack : float = 5.0;
- var playerMaxAttack : float = 10.0;
- var enemyTurnActivated : boolean = false;
- function OnGUI () {
- var otherScript: MainGame1 = gameObject.Find("MainGame").GetComponent(MainGame1);
- if(otherScript.inBattle == true) {
- // If it's the players turn then show combat buttons
- if(turn == 1) {
- //select attack
- if(phase == 0) {
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Attack")) {
- phase = 1;
- }
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Item")) {
- phase = 2;
- }
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 250,140,20), "Run")) {
- phase = 3;
- }
- }
- //attack selection
- if(phase == 1) {
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Slice")) {
- turn = 2;
- phase = 0;
- }
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Back")) {
- phase = 0;
- }
- }
- if(phase == 2) {
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Health Potion")) {
- turn = 2;
- phase = 0;
- }
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Back")) {
- phase = 0;
- }
- }
- if(phase == 3) {
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 + 200,140,20), "Run Away")) {
- phase = 0;
- otherScript.inBattle = false;
- }
- if (GUI.Button (Rect (Screen.width / 2 - 600,Screen.height / 2 +225,140,20), "Back")) {
- phase = 0;
- }
- }
- }
- }
- }
- function Update () {
- //enemies turn
- if(turn == 2 && enemyTurnActivated == false) {
- enemyTurnActivated = true;
- enemyTurn();
- }
- }
- //After the player attacks then it's the enemy attack phase
- function enemyTurn () {
- Debug.Log("enemy 1 turn began");
- Debug.Log("enemy 1 attacked");
- enemyTurnActivated = false;
- turn = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement