using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Networking; using System.Linq; public class CurrentPlayerPicker : MonoBehaviour { public GameObject serverManager; public int numberOfPlayers; public Text textfield; public GameObject sorryTaken; public GameObject selectionPanel; public GameObject errorPanel; public GameObject connectingPanel; public GameObject nextPanel; private string currentPlayer; private float elapsed = 0.0f; private float period = 1.0f; private bool selectionComplete; private string finalPlayerNumber; // CARD STUFF CARD STUFF CARD STUFF CARD STUFF public RawImage goalCard; public RawImage personCard; public RawImage goalCardView; public RawImage personaCardView; public List goalCardImages; public List personCardImages; //for action card selection during game running public Button actionButton; public RawImage actionCard; public GameObject actionCardView; public List actionCardImages; //dictionary to map card images and unique IDs private Dictionary personCardIDs; private Dictionary goalCardIDs; private Dictionary actionCardIDs; //mapping character cards and goal cards private Dictionary> personToGoalCardMap; // Start is called before the first frame update void Start() { selectionComplete = false; finalPlayerNumber = "0"; // Initialize dictionaries and assign unique IDs personCardIDs = new Dictionary(); goalCardIDs = new Dictionary(); actionCardIDs = new Dictionary(); // Assign IDs to character cards for (int i = 0; i < personCardImages.Count; i++) { personCardIDs[personCardImages[i].name] = i + 1; // ID starts from 1 } // Assign IDs to goal cards for (int i = 0; i < goalCardImages.Count; i++) { goalCardIDs[goalCardImages[i].name] = i + 1; // ID starts from 1 } // Assign IDs to action cards for (int i = 0; i < actionCardImages.Count; i++) { actionCardIDs[actionCardImages[i].name] = i + 1; // ID starts from 1 } InitializePersonToGoalCardMap(); //initialize the character to goal cards //click actionButton to get the action card actionButton.onClick.AddListener(SelectActionCard); } // Update is called once per frame void Update() { if(selectionComplete) return; elapsed += Time.deltaTime; if (elapsed >= period) { elapsed = 0.0f; //Debug.Log("Inside"); string currentGame = serverManager.GetComponent().GetGameNumber(); // GET ALL ALREADY SELECTED PLAYERS FROM SERVER // SET BUTTONS TO NOT ACTIVE OF THOSE PLAYERS string serverUrl_check = "https://smarthubs.media.tuwien.ac.at/api/is_player_available/"+ currentGame+ "/"; for(int i = 1; i <= numberOfPlayers; i++) { //Debug.Log(i); StartCoroutine(AvaliablePlayers(serverUrl_check + i.ToString(), i.ToString())); } } } public void UpdatePlayerTexture(string clr) { this.gameObject.GetComponent().color = GameObject.Find("PlayerBtn" + clr).GetComponent