From 9b5cb584dea109975c99591aa6b632e2a7c71c28 Mon Sep 17 00:00:00 2001 From: davidmfinol Date: Sun, 25 Feb 2018 00:43:07 -0600 Subject: [PATCH] Select the hosts card game when joining --- .../{NetPlayer.prefab => CGSNetPlayer.prefab} | 3 +- ...r.prefab.meta => CGSNetPlayer.prefab.meta} | 0 Assets/Scenes/DeckEditor.unity | 6 +-- Assets/Scenes/PlayMode.unity | 8 ++-- Assets/Scripts/CardGameManager.cs | 31 ++++++------- Assets/Scripts/CardModel.cs | 20 +++++--- Assets/Scripts/MainMenu/GameSelectionMenu.cs | 2 +- Assets/Scripts/MainMenu/MainMenu.cs | 2 +- .../{LocalNetManager.cs => CGSNetManager.cs} | 30 +++--------- ...tManager.cs.meta => CGSNetManager.cs.meta} | 0 .../{NetPlayer.cs => CGSNetPlayer.cs} | 46 +++++++++++++++---- ...NetPlayer.cs.meta => CGSNetPlayer.cs.meta} | 0 Assets/Scripts/Multiplayer/LobbyMenu.cs | 6 +-- Assets/Scripts/PlayMode/PlayMode.cs | 6 +-- Assets/Scripts/PlayMode/PointsCounter.cs | 20 +++----- ProjectSettings/GraphicsSettings.asset | 1 - docs/ROADMAP.md | 2 - 17 files changed, 94 insertions(+), 89 deletions(-) rename Assets/Prefabs/PlayMode/{NetPlayer.prefab => CGSNetPlayer.prefab} (98%) rename Assets/Prefabs/PlayMode/{NetPlayer.prefab.meta => CGSNetPlayer.prefab.meta} (100%) rename Assets/Scripts/Multiplayer/{LocalNetManager.cs => CGSNetManager.cs} (79%) rename Assets/Scripts/Multiplayer/{LocalNetManager.cs.meta => CGSNetManager.cs.meta} (100%) rename Assets/Scripts/Multiplayer/{NetPlayer.cs => CGSNetPlayer.cs} (56%) rename Assets/Scripts/Multiplayer/{NetPlayer.cs.meta => CGSNetPlayer.cs.meta} (100%) diff --git a/Assets/Prefabs/PlayMode/NetPlayer.prefab b/Assets/Prefabs/PlayMode/CGSNetPlayer.prefab similarity index 98% rename from Assets/Prefabs/PlayMode/NetPlayer.prefab rename to Assets/Prefabs/PlayMode/CGSNetPlayer.prefab index a4f373271..8a3c429b7 100644 --- a/Assets/Prefabs/PlayMode/NetPlayer.prefab +++ b/Assets/Prefabs/PlayMode/CGSNetPlayer.prefab @@ -22,7 +22,7 @@ GameObject: - component: {fileID: 114797580129434228} - component: {fileID: 114416027808059046} m_Layer: 0 - m_Name: NetPlayer + m_Name: CGSNetPlayer m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -52,6 +52,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a88bd459dba0be449622f9c07ed8e64, type: 3} m_Name: m_EditorClassIdentifier: + Points: 0 --- !u!114 &114797580129434228 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/PlayMode/NetPlayer.prefab.meta b/Assets/Prefabs/PlayMode/CGSNetPlayer.prefab.meta similarity index 100% rename from Assets/Prefabs/PlayMode/NetPlayer.prefab.meta rename to Assets/Prefabs/PlayMode/CGSNetPlayer.prefab.meta diff --git a/Assets/Scenes/DeckEditor.unity b/Assets/Scenes/DeckEditor.unity index 8245b1488..5e85ebf03 100644 --- a/Assets/Scenes/DeckEditor.unity +++ b/Assets/Scenes/DeckEditor.unity @@ -629,7 +629,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -0.000045558307, y: 0} + m_AnchoredPosition: {x: 0.00005602201, y: 0} m_SizeDelta: {x: 0, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &179835150 @@ -722,7 +722,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0.000046195815, y: 0} + m_AnchoredPosition: {x: -0.000012394135, y: 0} m_SizeDelta: {x: 0, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &196520020 @@ -2598,7 +2598,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -0.000060282364, y: 0} + m_AnchoredPosition: {x: -0.000031949905, y: 0} m_SizeDelta: {x: 0, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &836546758 diff --git a/Assets/Scenes/PlayMode.unity b/Assets/Scenes/PlayMode.unity index 96e31fb16..1281d1de8 100644 --- a/Assets/Scenes/PlayMode.unity +++ b/Assets/Scenes/PlayMode.unity @@ -2906,7 +2906,7 @@ MonoBehaviour: m_OnlineScene: m_SpawnPrefabs: [] m_CustomConfig: 1 - m_MaxConnections: 4 + m_MaxConnections: 5 m_ConnectionConfig: m_PacketSize: 1440 m_FragmentSize: 500 @@ -3019,8 +3019,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 100} + m_AnchoredPosition: {x: 5, y: 0} + m_SizeDelta: {x: -10, y: 100} m_Pivot: {x: 0.5, y: 0} --- !u!114 &1284800461 MonoBehaviour: @@ -3054,7 +3054,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: + m_Text: --- !u!222 &1284800462 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CardGameManager.cs b/Assets/Scripts/CardGameManager.cs index 3d14d501d..b0c552a80 100644 --- a/Assets/Scripts/CardGameManager.cs +++ b/Assets/Scripts/CardGameManager.cs @@ -25,7 +25,7 @@ public class CardGameManager : MonoBehaviour public const int PixelsPerInch = 100; public static string GamesFilePathBase => Application.persistentDataPath + "/games"; - public static string CurrentGameName { get; private set; } = Set.DefaultCode; + public static CardGame Current { get; private set; } = new CardGame(); public static bool IsMultiplayer { get; set; } public static bool IsQuitting { get; private set; } @@ -59,7 +59,8 @@ void Awake() string gameName = gameDirectory.Substring(GamesFilePathBase.Length + 1); AllCardGames [gameName] = new CardGame(gameName, string.Empty); } - CurrentGameName = PlayerPrefs.GetString(PlayerPrefGameName, FirstGameName); + CardGame currentGame; + Current = AllCardGames.TryGetValue(PlayerPrefs.GetString(PlayerPrefGameName, FirstGameName), out currentGame) ? currentGame : new CardGame(); Application.logMessageReceived += HandleLog; SceneManager.sceneLoaded += OnSceneLoaded; @@ -85,19 +86,20 @@ public IEnumerator DownloadCardGame(string gameUrl) { //Messenger.Show("Game download has started"); CardGame newGame = new CardGame(Set.DefaultCode, gameUrl) {AutoUpdate = true}; + Current = newGame; yield return newGame.Download(); - if (string.IsNullOrEmpty(newGame.Error)) { - AllCardGames [newGame.Name] = newGame; - SelectCardGame(newGame.Name); - } else + if (string.IsNullOrEmpty(newGame.Error)) + AllCardGames[newGame.Name] = newGame; + else Debug.LogError(GameLoadErrorMessage + newGame.Error); + SelectCardGame(newGame.Name); //Messenger.Show("Game download has finished"); } public void SelectCardGame(string gameName, string gameUrl) { if (string.IsNullOrEmpty(gameName) || !AllCardGames.ContainsKey(gameName)) { - DownloadCardGame(gameUrl); + StartCoroutine(DownloadCardGame(gameUrl)); return; } SelectCardGame(gameName); @@ -107,12 +109,13 @@ public void SelectCardGame(string gameName) { if (string.IsNullOrEmpty(gameName) || !AllCardGames.ContainsKey(gameName)) { Debug.LogError(InvalidGameSelectionMessage); - CurrentGameName = Set.DefaultCode; Selector.Show(); return; } - CurrentGameName = gameName; + CardGame currentGame; + Current = AllCardGames.TryGetValue(gameName, out currentGame) ? currentGame : new CardGame(); + DoGameSceneActions(); } @@ -133,7 +136,7 @@ public void DoGameSceneActions() if (!string.IsNullOrEmpty(Current.Error)) Debug.LogError(GameLoadErrorMessage + Current.Error); else - PlayerPrefs.SetString(PlayerPrefGameName, CurrentGameName); + PlayerPrefs.SetString(PlayerPrefGameName, Current.Name); if (BackgroundImage != null) BackgroundImage.sprite = Current.BackgroundImageSprite; @@ -150,7 +153,7 @@ public void DeleteGame() { try { Directory.Delete(Current.FilePathBase, true); - AllCardGames.Remove(CurrentGameName); + AllCardGames.Remove(Current.Name); SelectCardGame(AllCardGames.Keys.First()); Selector.Show(); } catch (Exception ex) { @@ -182,12 +185,6 @@ public static CardGameManager Instance { } } - public static CardGame Current { - get { CardGame currentGame; - return Instance.AllCardGames.TryGetValue(CurrentGameName, out currentGame) ? currentGame : new CardGame(); - } - } - public GameSelectionMenu Selector { get { if (_selector != null) return _selector; diff --git a/Assets/Scripts/CardModel.cs b/Assets/Scripts/CardModel.cs index c3ddbbebf..f3bfdf750 100644 --- a/Assets/Scripts/CardModel.cs +++ b/Assets/Scripts/CardModel.cs @@ -25,9 +25,9 @@ public class CardModel : NetworkBehaviour, IPointerDownHandler, IPointerUpHandle public static readonly Vector2 OutlineHighlightDistance = new Vector2(10, 10); public bool IsOnline => NetworkManager.singleton != null && NetworkManager.singleton.isNetworkActive - && transform.parent == ((LocalNetManager)NetworkManager.singleton).playController.playAreaContent; + && transform.parent == ((CGSNetManager)NetworkManager.singleton).playController.playAreaContent; public bool IsProcessingSecondaryDragAction => PointerPositions.Count > 1 - || (CurrentPointerEventData != null && CurrentPointerEventData.button == PointerEventData.InputButton.Right); + || (CurrentPointerEventData != null && CurrentPointerEventData.button == PointerEventData.InputButton.Right && CurrentPointerEventData.button == PointerEventData.InputButton.Middle); public CardStack ParentCardStack => transform.parent.GetComponent(); public bool DoesCloneOnDrag { get; set; } @@ -78,7 +78,8 @@ void Start() public void OnPointerDown(PointerEventData eventData) { - DidSelectOnDown = eventData.button != PointerEventData.InputButton.Right && CardInfoViewer.Instance.SelectedCardModel != this && CardInfoViewer.Instance.WasVisible; + DidSelectOnDown = eventData.button != PointerEventData.InputButton.Right && eventData.button != PointerEventData.InputButton.Middle + && CardInfoViewer.Instance.SelectedCardModel != this && CardInfoViewer.Instance.WasVisible; if (DidSelectOnDown) EventSystem.current.SetSelectedGameObject(gameObject, eventData); @@ -90,7 +91,9 @@ public void OnPointerDown(PointerEventData eventData) public void OnPointerUp(PointerEventData eventData) { - if (CurrentPointerEventData != null && CurrentPointerEventData.pointerId == eventData.pointerId && eventData.button != PointerEventData.InputButton.Right && !eventData.dragging && !DraggedClones.ContainsKey(eventData.pointerId)) { + if (CurrentPointerEventData != null && CurrentPointerEventData.pointerId == eventData.pointerId && !eventData.dragging + && eventData.button != PointerEventData.InputButton.Right && eventData.button != PointerEventData.InputButton.Middle + && !DraggedClones.ContainsKey(eventData.pointerId)) { if (!DidSelectOnDown && EventSystem.current.currentSelectedGameObject == gameObject && DoubleClickAction != null) DoubleClickAction(this); else if (PlaceHolder == null) @@ -180,7 +183,10 @@ public void OnEndDrag(PointerEventData eventData) if (cardModel.SecondaryDragAction != null && cardModel.IsProcessingSecondaryDragAction) cardModel.SecondaryDragAction(); - Vector2 removedOffset = (Vector2)cardModel.transform.position - eventData.position - cardModel.PointerDragOffsets[eventData.pointerId]; + Vector2 removedOffset = Vector2.zero; + Vector2 pointerDragOffset; + if (cardModel.PointerDragOffsets.TryGetValue(eventData.pointerId, out pointerDragOffset)) + removedOffset = (Vector2)cardModel.transform.position - eventData.position - pointerDragOffset; cardModel.PointerPositions.Remove(eventData.pointerId); cardModel.PointerDragOffsets.Remove(eventData.pointerId); Vector2 otherOffset; @@ -215,7 +221,7 @@ public static CardModel GetPointerDrag(PointerEventData eventData) public void UpdatePosition() { #if (!UNITY_ANDROID && !UNITY_IOS) || UNITY_EDITOR - if (Input.GetMouseButton(1) || Input.GetMouseButtonUp(1)) + if (Input.GetMouseButton(1) || Input.GetMouseButtonUp(1) || Input.GetMouseButton(2) || Input.GetMouseButtonUp(2)) return; #endif bool isOnline = IsOnline; @@ -292,7 +298,7 @@ void CmdUnspawnCard() { RpcUnspawn(); NetworkServer.UnSpawn(gameObject); - LocalNetManager.Instance.UnSpawnCard(gameObject); + CGSNetManager.Instance.UnSpawnCard(gameObject); } [ClientRpc] diff --git a/Assets/Scripts/MainMenu/GameSelectionMenu.cs b/Assets/Scripts/MainMenu/GameSelectionMenu.cs index 7288ca868..067ae1e13 100644 --- a/Assets/Scripts/MainMenu/GameSelectionMenu.cs +++ b/Assets/Scripts/MainMenu/GameSelectionMenu.cs @@ -51,7 +51,7 @@ public void Show() { gameObject.SetActive(true); transform.SetAsLastSibling(); - Rebuild(CardGameManager.Instance.AllCardGames.Keys.ToList(), SelectGame, CardGameManager.CurrentGameName); + Rebuild(CardGameManager.Instance.AllCardGames.Keys.ToList(), SelectGame, CardGameManager.Current.Name); } public void SelectGame(bool isOn, string gameName) diff --git a/Assets/Scripts/MainMenu/MainMenu.cs b/Assets/Scripts/MainMenu/MainMenu.cs index f079a31a9..eb4fc54b6 100644 --- a/Assets/Scripts/MainMenu/MainMenu.cs +++ b/Assets/Scripts/MainMenu/MainMenu.cs @@ -55,7 +55,7 @@ void Update() public void UpdateCurrentGameText() { if (currentGameText != null) - currentGameText.text = CardGameManager.CurrentGameName; + currentGameText.text = CardGameManager.Current.Name; } public void GoToMainMenu() diff --git a/Assets/Scripts/Multiplayer/LocalNetManager.cs b/Assets/Scripts/Multiplayer/CGSNetManager.cs similarity index 79% rename from Assets/Scripts/Multiplayer/LocalNetManager.cs rename to Assets/Scripts/Multiplayer/CGSNetManager.cs index b306e3167..94bee763c 100644 --- a/Assets/Scripts/Multiplayer/LocalNetManager.cs +++ b/Assets/Scripts/Multiplayer/CGSNetManager.cs @@ -1,10 +1,10 @@ using UnityEngine; using UnityEngine.Networking; -public class LocalNetManager : NetworkManager +public class CGSNetManager : NetworkManager { - public static LocalNetManager Instance => (LocalNetManager)singleton; - public NetPlayer LocalPlayer { get; set; } + public static CGSNetManager Instance => (CGSNetManager)singleton; + public CGSNetPlayer LocalPlayer { get; set; } public PlayMode playController; public GameObject cardModelPrefab; @@ -38,14 +38,14 @@ public override void OnStartHost() public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) { base.OnServerAddPlayer(conn, playerControllerId); - //Debug.Log("CGSNet: Host adds player: " + playerControllerId); + playController.netText.text = NetworkServer.connections.Count.ToString(); } public override void OnStartClient(NetworkClient netClient) { base.OnStartClient(netClient); ClientScene.RegisterSpawnHandler(cardModelPrefab.GetComponent().assetId, SpawnCard, UnSpawnCard); - playController.netText.text = ""; + playController.netText.text = netClient.serverIp; } public GameObject SpawnCard(Vector3 position, NetworkHash128 assetId) @@ -66,28 +66,16 @@ public void UnSpawnCard(GameObject spawned) Destroy(spawned); } - public override void OnStopHost() - { - base.OnStopHost(); - Debug.Log("Host Stopped"); - } - public override void OnServerError(NetworkConnection conn, int errorCode) { //base.OnServerError(conn, errorCode); Debug.Log("Server error:" + errorCode); } - public override void OnStopServer() - { - base.OnStopServer(); - Debug.Log("Server Stopped"); - } - public override void OnServerDisconnect(NetworkConnection conn) { //base.OnServerDisconnect(conn); - Debug.Log("Server disconnected"); + Debug.Log("Player disconnected"); } public override void OnClientError(NetworkConnection conn, int errorCode) @@ -96,12 +84,6 @@ public override void OnClientError(NetworkConnection conn, int errorCode) Debug.Log("Client error:" + errorCode); } - public override void OnStopClient() - { - base.OnStopClient(); - Debug.Log("Client Stopped"); - } - public override void OnClientDisconnect(NetworkConnection conn) { //base.OnClientDisconnect(conn); diff --git a/Assets/Scripts/Multiplayer/LocalNetManager.cs.meta b/Assets/Scripts/Multiplayer/CGSNetManager.cs.meta similarity index 100% rename from Assets/Scripts/Multiplayer/LocalNetManager.cs.meta rename to Assets/Scripts/Multiplayer/CGSNetManager.cs.meta diff --git a/Assets/Scripts/Multiplayer/NetPlayer.cs b/Assets/Scripts/Multiplayer/CGSNetPlayer.cs similarity index 56% rename from Assets/Scripts/Multiplayer/NetPlayer.cs rename to Assets/Scripts/Multiplayer/CGSNetPlayer.cs index 4432a9a74..3dc4f8526 100644 --- a/Assets/Scripts/Multiplayer/NetPlayer.cs +++ b/Assets/Scripts/Multiplayer/CGSNetPlayer.cs @@ -1,18 +1,48 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.Networking; -public class NetPlayer : NetworkBehaviour +public class CGSNetPlayer : NetworkBehaviour { public const string DeckLoadPrompt = "Would you like to join the game with your own deck?"; + [SyncVar] + public float Points; + public override void OnStartLocalPlayer() { base.OnStartLocalPlayer(); - LocalNetManager.Instance.LocalPlayer = this; + CGSNetManager.Instance.LocalPlayer = this; + Points = CardGameManager.Current.GameStartPointsCount; if (!isServer) - CardGameManager.Instance.Messenger.Ask(DeckLoadPrompt, RequestHand, LocalNetManager.Instance.playController.ShowDeckMenu); + RequestCardGame(); + } + + public void RequestCardGame() + { + CmdSelectCardGame(); + } + + [Command] + public void CmdSelectCardGame() + { + TargetSelectCardGame(connectionToClient, CardGameManager.Current.Name, CardGameManager.Current.AutoUpdateUrl); + } + + [TargetRpc] + public void TargetSelectCardGame(NetworkConnection target, string gameName, string gameUrl) + { + CardGameManager.Instance.SelectCardGame(gameName, gameUrl); + StartCoroutine(WaitToRequestHand()); + } + + public IEnumerator WaitToRequestHand() + { + while(CardGameManager.Current.IsDownloading) + yield return null; + CardGameManager.Instance.Messenger.Ask(DeckLoadPrompt, RequestHand, CGSNetManager.Instance.playController.ShowDeckMenu); } public void RequestHand() @@ -23,7 +53,7 @@ public void RequestHand() [Command] public void CmdDealHand() { - List cards = LocalNetManager.Instance.playController.PopDeckCards(CardGameManager.Current.GameStartHandCount); + List cards = CGSNetManager.Instance.playController.PopDeckCards(CardGameManager.Current.GameStartHandCount); TargetDealCards(connectionToClient, cards.Select(card => card.Id).ToArray()); } @@ -31,7 +61,7 @@ public void CmdDealHand() public void TargetDealCards(NetworkConnection target, string[] cardIds) { List cards = cardIds.Select(cardId => CardGameManager.Current.Cards[cardId]).ToList(); - LocalNetManager.Instance.playController.AddCardsToHand(cards); + CGSNetManager.Instance.playController.AddCardsToHand(cards); } public void MoveCardToServer(CardStack cardStack, CardModel cardModel) @@ -46,8 +76,8 @@ public void MoveCardToServer(CardStack cardStack, CardModel cardModel) [Command] public void CmdSpawnCard(string cardId, Vector3 localPosition, Quaternion rotation, bool isFacedown) { - PlayMode controller = LocalNetManager.Instance.playController; - GameObject newCard = Instantiate(LocalNetManager.Instance.cardModelPrefab, controller.playAreaContent); + PlayMode controller = CGSNetManager.Instance.playController; + GameObject newCard = Instantiate(CGSNetManager.Instance.cardModelPrefab, controller.playAreaContent); CardModel cardModel = newCard.GetComponent(); cardModel.Value = CardGameManager.Current.Cards[cardId]; cardModel.transform.localPosition = localPosition; diff --git a/Assets/Scripts/Multiplayer/NetPlayer.cs.meta b/Assets/Scripts/Multiplayer/CGSNetPlayer.cs.meta similarity index 100% rename from Assets/Scripts/Multiplayer/NetPlayer.cs.meta rename to Assets/Scripts/Multiplayer/CGSNetPlayer.cs.meta diff --git a/Assets/Scripts/Multiplayer/LobbyMenu.cs b/Assets/Scripts/Multiplayer/LobbyMenu.cs index c3cfb1d4e..91505b27d 100644 --- a/Assets/Scripts/Multiplayer/LobbyMenu.cs +++ b/Assets/Scripts/Multiplayer/LobbyMenu.cs @@ -38,8 +38,8 @@ public void Show() SelectedHost = string.Empty; Rebuild(HostNames, SelectHost, SelectedHost); - LocalNetManager.Instance.Discovery.lobby = this; - LocalNetManager.Instance.SearchForHost(); + CGSNetManager.Instance.Discovery.lobby = this; + CGSNetManager.Instance.SearchForHost(); } public void DisplayHosts(List hostNames) @@ -68,7 +68,7 @@ public void Host() public IEnumerator WaitToShowDeckLoader() { yield return null; - LocalNetManager.Instance.playController.ShowDeckMenu(); + CGSNetManager.Instance.playController.ShowDeckMenu(); } public void SelectHost(bool isOn, string hostName) diff --git a/Assets/Scripts/PlayMode/PlayMode.cs b/Assets/Scripts/PlayMode/PlayMode.cs index 45d0f9288..5f2c39e66 100644 --- a/Assets/Scripts/PlayMode/PlayMode.cs +++ b/Assets/Scripts/PlayMode/PlayMode.cs @@ -171,7 +171,7 @@ public void AddCardsToHand(List cards) public void AddCardToPlay(CardStack cardStack, CardModel cardModel) { if (NetworkManager.singleton.isNetworkActive) - LocalNetManager.Instance.LocalPlayer.MoveCardToServer(cardStack, cardModel); + CGSNetManager.Instance.LocalPlayer.MoveCardToServer(cardStack, cardModel); else SetPlayActions(cardStack, cardModel); } @@ -189,12 +189,12 @@ public void PromptBackToMainMenu() public void BackToMainMenu() { - if (NetworkManager.singleton.isNetworkActive || LocalNetManager.Instance.Discovery.running) { + if (NetworkManager.singleton.isNetworkActive || CGSNetManager.Instance.Discovery.running) { if (NetworkServer.active) NetworkManager.singleton.StopHost(); else if (NetworkManager.singleton.IsClientConnected()) NetworkManager.singleton.StopClient(); - LocalNetManager.Instance.Discovery.StopBroadcast(); + CGSNetManager.Instance.Discovery.StopBroadcast(); } SceneManager.LoadScene(MainMenu.MainMenuSceneIndex); diff --git a/Assets/Scripts/PlayMode/PointsCounter.cs b/Assets/Scripts/PlayMode/PointsCounter.cs index 506c34d9f..d1b369beb 100644 --- a/Assets/Scripts/PlayMode/PointsCounter.cs +++ b/Assets/Scripts/PlayMode/PointsCounter.cs @@ -1,19 +1,11 @@ using System.Globalization; -using UnityEngine.Networking; +using UnityEngine; using UnityEngine.UI; -public class PointsCounter : NetworkBehaviour +public class PointsCounter : MonoBehaviour { public Text pointsText; - [SyncVar] - private float _points; - - void Start() - { - Count = CardGameManager.Current.GameStartPointsCount; - } - public void Decrement() { Count--; @@ -24,11 +16,11 @@ public void Increment() Count++; } - public float Count { - get { return _points; } + protected float Count { + get { return CGSNetManager.Instance.LocalPlayer.Points; } set { - _points = value; - pointsText.text = _points.ToString(CultureInfo.InvariantCulture); + CGSNetManager.Instance.LocalPlayer.Points = value; + pointsText.text = CGSNetManager.Instance.LocalPlayer.Points.ToString(CultureInfo.InvariantCulture); } } } diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index bd131f47c..6e7e2d976 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -37,7 +37,6 @@ GraphicsSettings: - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 08ed7d942..28042a043 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -1,8 +1,6 @@ # Roadmap ## General Features -- Select (and download if needed) the host's selected card game when joining a game session in *Play Mode* -- Show connected players in the bottom-left corner of *Play Mode* - Synchronize dice across all connected players in *Play Mode* - Synchronize points across all connected players in *Play Mode* - Catch cards that would be deleted in *Play Mode* and instead add them to the Discard Zone