Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class GameManager1 : MonoBehaviour {
- public GameObject startfight;
- public GameObject Button1;
- public GameObject Button2;
- public GameObject Button3;
- public GameObject Button4;
- private int inputAttack;
- private GameObject[] buttons;
- Pokemon player;
- Pokemon enemy;
- bool waitingForPlayerInput;
- // Use this for initialization
- void Start () {
- player = PokemonFactory.CreateRandom();
- enemy = PokemonFactory.CreateRandom ();
- }
- // Update is called once per frame
- void Update () {
- }
- public void Startfight () {
- buttons = new GameObject[4];
- startfight.SetActive(false);
- Button1.gameObject.SetActive(true);
- Button2.gameObject.SetActive(true);
- Button3.gameObject.SetActive(true);
- Button4.gameObject.SetActive(true);
- buttons [0] = Button1;
- buttons [1] = Button2;
- buttons [2] = Button3;
- buttons [3] = Button4;
- Button1.GetComponent<Button> ().onClick.AddListener (delegate {
- waitingForPlayerInput = false;
- inputAttack = 0;
- });
- Button2.GetComponent<Button> ().onClick.AddListener (delegate {
- waitingForPlayerInput = false;
- inputAttack = 1;
- });
- Button3.GetComponent<Button> ().onClick.AddListener (delegate {
- waitingForPlayerInput = false;
- inputAttack = 2;
- });
- Button4.GetComponent<Button> ().onClick.AddListener (delegate {
- waitingForPlayerInput = false;
- inputAttack = 3;
- });
- for (int i = 0; i < player.moves.Count; i++) {
- buttons[i].GetComponentInChildren<Text>().text = player.moves[i].name;
- }
- StartCoroutine (FightLoop ());
- }
- public IEnumerator FightLoop(){
- //BEGIN FIGHT LOOP
- while (player.hp > 0 && enemy.hp > 0)
- {
- yield return null;
- //PRINT POSSIBLE MOVES
- Debug.Log("What move should we use?");
- foreach (Move pokemon in player.moves)
- {
- Debug.Log(pokemon.name);
- }
- //int move = -1;
- //string inputAttack = Console.ReadLine //få den til at læse input fra knapper();
- if (inputAttack == "0")
- {
- Debug.Log(player.name + " uses " + player.moves[move].name + ". " + enemy.name + " loses " + " HP");
- }
- if (inputAttack == "1")
- {
- Debug.Log(player.name + " uses " + player.moves[move].name + ". " + enemy.name + " loses " + " HP");
- }
- if (inputAttack == "2"){
- Debug.Log(player.name + " uses " + player.moves[move].name + ". " + enemy.name + " loses " + " HP");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement