| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- public class LocalGameScript : MonoBehaviour
- {
- public Transform content;
- public GameObject playerInfoPrefab;
- public Button startButton;
- public Button deleteButton;
- private int gameId;
- private string gameMode;
- private int questionsNeededToWin;
- private int answerTimer;
- private int numberOfPlayers;
- private string currentPlayer;
- private string currentPlayerName;
- private int round;
- private string startDate;
- private string lastPlayedDate;
- private string finishedDate;
- private List<KeyValuePair<string, int>> players;
- public string CurrentPlayerName { get => currentPlayerName; set => currentPlayerName = value; }
- public string CurrentPlayer { get => currentPlayer; set => currentPlayer = value; }
- public int NumberOfPlayers { get => numberOfPlayers; set => numberOfPlayers = value; }
- public int AnswerTimer { get => answerTimer; set => answerTimer = value; }
- public int QuestionsNeededToWin { get => questionsNeededToWin; set => questionsNeededToWin = value; }
- public string GameMode { get => gameMode; set => gameMode = value; }
- public int GameId { get => gameId; set => gameId = value; }
- public int Round { get => round; set => round = value; }
- public string StartDate { get => startDate; set => startDate = value; }
- public string LastPlayedDate { get => lastPlayedDate; set => lastPlayedDate = value; }
- public string FinishedDate { get => finishedDate; set => finishedDate = value; }
- public List<KeyValuePair<string, int>> Players { get => players; set => players = value; }
- private void Start() {
- startButton.onClick.AddListener(StartThisGame);
- deleteButton.onClick.AddListener(DeleteThisGame);
- }
- public void AddPlayer(string name, int points) {
- if (players == null) {
- players = new List<KeyValuePair<string, int>>();
- }
- KeyValuePair<string, int> p = new KeyValuePair<string, int>(name, points);
- Players.Add(p);
- GameObject go = Instantiate(playerInfoPrefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
- PlayerInfo playerInfo = go.GetComponent<PlayerInfo>();
- playerInfo.SetName(name);
- playerInfo.SetPoints(points);
- playerInfo.transform.SetParent(content);
- playerInfo.transform.SetSiblingIndex(0);
- }
- public void StartThisGame() {
- Debug.Log("CLicked button to start game");
- PlayerPrefs.SetInt("GameId", GameId);
- SceneManager.LoadSceneAsync("narKampen");
- }
- public void DeleteThisGame() {
- Debug.Log("CLicked button to delete game");
- }
- }
|