diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 5325de6..8151420 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -3264,13 +3264,13 @@ MonoBehaviour: - {fileID: 1226310186} - {fileID: 600562791} - {fileID: 34188331} + EmptyPos: {fileID: 21300000, guid: dad99cc115f7ec143b4dec916337800f, type: 3} + CardSleeve: {fileID: 21300000, guid: 4e91445daa38b914b8cafafc0c273166, type: 3} CardPrefab: {fileID: 8949091621847208831, guid: e47e610d005bb014f978fe27600fb47f, type: 3} DeckButton: {fileID: 2065622092} TripsOnDisplay: [] DeckCard: [] DisCardPile: [] - _emptyPos: {fileID: 21300000, guid: dad99cc115f7ec143b4dec916337800f, type: 3} - _cardSleeve: {fileID: 21300000, guid: 4e91445daa38b914b8cafafc0c273166, type: 3} --- !u!4 &1618202105 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Script/ManagerCard.cs b/Assets/Script/ManagerCard.cs index ac636f7..fc453ea 100644 --- a/Assets/Script/ManagerCard.cs +++ b/Assets/Script/ManagerCard.cs @@ -2,16 +2,17 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -using UnityEngine.Assertions; using static System.Linq.Enumerable; -using static UnityEngine.Quaternion; using static UnityEngine.GameObject; +using static UnityEngine.Quaternion; public sealed class ManagerCard : MonoBehaviour { public Sprite[] FaceCard; public GameObject[] PosTops; public GameObject[] PosBots; + public Sprite EmptyPos; + public Sprite CardSleeve; public GameObject CardPrefab; public GameObject DeckButton; @@ -36,9 +37,6 @@ public sealed class ManagerCard : MonoBehaviour private int _trips; private int _tripsRemainder; - [SerializeField] private Sprite _emptyPos; - [SerializeField] private Sprite _cardSleeve; - private void Start() => Bots = new List[] { _bot0, _bot1, _bot2, _bot3, _bot4, _bot5, _bot6 }; public void DealCard() @@ -112,7 +110,7 @@ public IEnumerator DealFromDeck() if (_deckLocation >= _trips) { - Find("DeckCard").GetComponent().sprite = _emptyPos; + Find("DeckCard").GetComponent().sprite = EmptyPos; } } else @@ -179,7 +177,7 @@ private void SortDeckIntoTrips() { _trips = DeckCard.Count / 3; _tripsRemainder = DeckCard.Count % 3; - //DeckTrips.Clear(); + DeckTrips.Clear(); var index = 0; @@ -200,10 +198,14 @@ private void SortDeckIntoTrips() private void RestackTopDeck() { - Find("DeckCard").GetComponent().sprite = _cardSleeve; DeckCard.Clear(); DeckCard.AddRange(DisCardPile); DisCardPile.Clear(); SortDeckIntoTrips(); + + if (DeckCard.Any()) + { + Find("DeckCard").GetComponent().sprite = CardSleeve; + } } } diff --git a/Assets/Script/ManagerGame.cs b/Assets/Script/ManagerGame.cs index af837e3..32a0c3c 100644 --- a/Assets/Script/ManagerGame.cs +++ b/Assets/Script/ManagerGame.cs @@ -50,6 +50,7 @@ public void BtnNewGame() } FindObjectOfType().DealCard(); + Find("DeckCard").GetComponent().sprite = FindObjectOfType().CardSleeve; _isTime = true; _countTime = default; IsPlay = default;