Advertisement
Guest User

Untitled

a guest
May 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class GameManager1 : MonoBehaviour {
  7.  
  8. public GameObject startfight;
  9. public GameObject Button1;
  10. public GameObject Button2;
  11. public GameObject Button3;
  12. public GameObject Button4;
  13. private int inputAttack;
  14.  
  15. private GameObject[] buttons;
  16.  
  17. Pokemon player;
  18. Pokemon enemy;
  19.  
  20. bool waitingForPlayerInput;
  21.  
  22.  
  23. // Use this for initialization
  24. void Start () {
  25. player = PokemonFactory.CreateRandom();
  26. enemy = PokemonFactory.CreateRandom ();
  27. }
  28.  
  29. // Update is called once per frame
  30. void Update () {
  31.  
  32. }
  33. public void Startfight () {
  34. buttons = new GameObject[4];
  35.  
  36. startfight.SetActive(false);
  37.  
  38. Button1.gameObject.SetActive(true);
  39. Button2.gameObject.SetActive(true);
  40. Button3.gameObject.SetActive(true);
  41. Button4.gameObject.SetActive(true);
  42.  
  43. buttons [0] = Button1;
  44. buttons [1] = Button2;
  45. buttons [2] = Button3;
  46. buttons [3] = Button4;
  47.  
  48. Button1.GetComponent<Button> ().onClick.AddListener (delegate {
  49. waitingForPlayerInput = false;
  50. inputAttack = 0;
  51.  
  52. });
  53.  
  54. Button2.GetComponent<Button> ().onClick.AddListener (delegate {
  55. waitingForPlayerInput = false;
  56. inputAttack = 1;
  57. });
  58. Button3.GetComponent<Button> ().onClick.AddListener (delegate {
  59. waitingForPlayerInput = false;
  60. inputAttack = 2;
  61. });
  62. Button4.GetComponent<Button> ().onClick.AddListener (delegate {
  63. waitingForPlayerInput = false;
  64. inputAttack = 3;
  65. });
  66.  
  67. for (int i = 0; i < player.moves.Count; i++) {
  68. buttons[i].GetComponentInChildren<Text>().text = player.moves[i].name;
  69. }
  70. StartCoroutine (FightLoop ());
  71. }
  72.  
  73. public IEnumerator FightLoop(){
  74.  
  75.  
  76.  
  77. //BEGIN FIGHT LOOP
  78.  
  79. while (player.hp > 0 && enemy.hp > 0)
  80. {
  81. yield return null;
  82. //PRINT POSSIBLE MOVES
  83. Debug.Log("What move should we use?");
  84.  
  85.  
  86. foreach (Move pokemon in player.moves)
  87. {
  88. Debug.Log(pokemon.name);
  89. }
  90.  
  91.  
  92.  
  93.  
  94. //int move = -1;
  95.  
  96. //string inputAttack = Console.ReadLine //få den til at læse input fra knapper();
  97.  
  98. if (inputAttack == "0")
  99. {
  100.  
  101.  
  102. Debug.Log(player.name + " uses " + player.moves[move].name + ". " + enemy.name + " loses " + " HP");
  103.  
  104.  
  105.  
  106. }
  107.  
  108. if (inputAttack == "1")
  109. {
  110.  
  111. Debug.Log(player.name + " uses " + player.moves[move].name + ". " + enemy.name + " loses " + " HP");
  112.  
  113.  
  114. }
  115. if (inputAttack == "2"){
  116.  
  117.  
  118.  
  119.  
  120. Debug.Log(player.name + " uses " + player.moves[move].name + ". " + enemy.name + " loses " + " HP");
  121. }
  122.  
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement