///<summary>Restart Game by clearing lists, destroy Instantiated Cards and reset Positions</summary> public void RestartGame() { //Make sure that nothing is clickable or started till RestartGame is finished complettly //clear all lists deck.Clear(); discardPile.Clear(); cardsOfRacetrack.Clear(); //destroy all instantiated cards foreach (Transform child in discardPilePos) { if (child.CompareTag("Card")) { Destroy(child.gameObject); } } foreach (Transform child in deckPilePos) { if (child.CompareTag("Card")) { Destroy(child.gameObject); } } foreach (GameObject child in cardsOfRacetrackPos) { foreach (Transform trans in child.transform) { if (trans.CompareTag("Card")) { Destroy(trans.gameObject); } } } foreach (GameObject child in horsePos) { foreach (Transform trans in child.transform) { if (trans.CompareTag("Horse")) { Destroy(trans.gameObject); } } } //reset Horse Position horsePos[0].transform.position = new Vector3(-19.0f, 5.5f, 0.0f); horsePos[1].transform.position = new Vector3(-19.0f, 1.0f, 0.0f); horsePos[2].transform.position = new Vector3(-19.0f, -3.5f, 0.0f); horsePos[3].transform.position = new Vector3(-19.0f, -8.0f, 0.0f); //reset trackCard booleans foreach (GameObject card in cardsOfRacetrackPos) { TrackCard tmp = card.GetComponent <TrackCard>(); tmp.RestartTrackCards(); } //start game StartGame(); }
private void TrackCard_OnTriggerEnterTrackcard(TrackCard obj) { if (obj.Counter == 4) { obj.Counter = 0; TurnFaceofTrackCard(); } }