| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class OnlineGameScript : MonoBehaviour {
- // Status color Pending, not your turn, your turn, declined
- List<Color32> statusColors = new List<Color32>() { new Color32(234, 164, 17, 100), new Color32(255, 255, 24, 175), new Color32(0, 255, 0, 100), new Color32(219, 12, 65, 100) };
- public Text gameStatusText;
- public Text gameTitleText;
- private int id;
- private int winNumber;
- private int answerTimer;
- private int roundTimeLimit;
- private string currentPlayer;
- private int round;
- private string startDate;
- private string LastPlayedDate;
- private string finishedDate;
- public int Id { get => id; set => id = value; }
- public int WinNumber { get => winNumber; set => winNumber = value; }
- public int AnswerTimer { get => answerTimer; set => answerTimer = value; }
- public int RoundTimeLimit { get => roundTimeLimit; set => roundTimeLimit = value; }
- public string CurrentPlayer { get => currentPlayer; set => currentPlayer = value; }
- public int Round { get => round; set => round = value; }
- public string StartDate { get => startDate; set => startDate = value; }
- public string LastPlayedDate1 { get => LastPlayedDate; set => LastPlayedDate = value; }
- public string FinishedDate { get => finishedDate; set => finishedDate = value; }
- public string GameStatus {
- get { return gameStatus; }
- set {
- gameStatus = value;
- SetColor(gameStatus);
- }
- }
- private string PENDING = "ONLINE_GAME_STATUS_VALUE_PENDING";
- private string OTHERS_TURN = "ONLINE_GAME_STATUS_VALUE_OTHERS_TURN";
- private string DECLINED = "ONLINE_GAME_STATUS_VALUE_DECLINED";
- private string YOUR_TURN = "ONLINE_GAME_STATUS_VALUE_YOUR_TURN";
- // behövs nog en partialy declined status också, om en av fyra tackar nej kanske man viss spela ändå.
- // behövs också en med dina inbjudningar.
- public string gameStatus;
- // Start is called before the first frame update
- void Start() {
-
- }
- // Update is called once per frame
- void Update() {
- }
- private void SetColor(string status) {
- Image image = this.GetComponent<Image>();
- Debug.Log(status);
- if ("PENDING".Equals(status)) {
- image.color = statusColors[0];
- } else if ("YOUR_TURN".Equals(status)) {
- image.color = statusColors[1];
- } else if ("OTHERS_TURN".Equals(status)) {
- image.color = statusColors[2];
- } else if ("DECLINED".Equals(status)) {
- image.color = statusColors[3];
- } else {
- image.color = new Color32(100, 100, 100, 100);
- }
- }
- public void SetTitleText(string text) {
- gameTitleText.text = text;
- }
- public void SetGameStatusText() {
- SetGameStatusText("");
- }
- public void SetGameStatusText(string extraInfo) {
- if ("PENDING".Equals(GameStatus)) {
- gameStatusText.text = LocalizationManager.Instance.GetText(PENDING);
- } else if ("YOUR_TURN".Equals(GameStatus)) {
- gameStatusText.text = LocalizationManager.Instance.GetText(YOUR_TURN);
- } else if ("OTHERS_TURN".Equals(GameStatus)) {
- string message = LocalizationManager.Instance.GetText(OTHERS_TURN);
- gameStatusText.text = String.Format(message, extraInfo);
- } else if ("DECLINED".Equals(GameStatus)) {
- gameStatusText.text = LocalizationManager.Instance.GetText(DECLINED);
- } else {
- gameStatusText.text = "SOMETHING WRONG WITH STATUS TITLE FROM TEXT " + GameStatus;
- }
- }
- public void SetId(string id) {
- Int32.TryParse(id, out int intId);
- Id = intId;
- }
- public void SetWinNumber(string winNumber) {
- Int32.TryParse(winNumber, out int intWinNumber);
- WinNumber = intWinNumber;
- }
- public void SetAnswerTimer(string answerTimer) {
- Int32.TryParse(answerTimer, out int intAnswerTimer);
- AnswerTimer = intAnswerTimer;
- }
- public void SetRoundTimeLimit(string roundTimeLimit) {
- Int32.TryParse(roundTimeLimit, out int intRoundTimelimit);
- RoundTimeLimit = intRoundTimelimit;
- }
- public void SetRound(string round) {
- Int32.TryParse(round, out int intRound);
- Round = intRound;
- }
- public void SetGameStatus(string status) {
- GameStatus = status;
- }
- }
|