| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections;
- 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(75, 50, 75, 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 enum Status {
- PENDING,
- OTHERS_TURN,
- YOUR_TURN,
- DECLINED
- }
- // Start is called before the first frame update
- void Start() {
- }
- // Update is called once per frame
- void Update() {
- }
- public void SetStatusColor(Status status) {
- if (status.Equals(Status.PENDING)) {
- this.GetComponent<Image>().color = statusColors[0];
- } else if (status.Equals(Status.OTHERS_TURN)) {
- this.GetComponent<Image>().color = statusColors[1];
- } else if (status.Equals(Status.YOUR_TURN)) {
- this.GetComponent<Image>().color = statusColors[2];
- } else if (status.Equals(Status.DECLINED)) {
- this.GetComponent<Image>().color = statusColors[3];
- }
- }
- public void SetTitleText(string text) {
- gameTitleText.text = text;
- }
- public void SetGameStatusText(string text) {
- gameStatusText.text = text;
- }
- 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;
- }
- }
|