// Use this for initialization void Awake() { // Only call this part of Awake once (even through scene changes) if (!created) { created = true; // Don't destroy object on scene changes DontDestroyOnLoad(this.gameObject); // Initialize card lists Hand1 = new List <GameObject>(); Hand2 = new List <GameObject>(); Forest = new List <GameObject>(); Decay = new List <GameObject>(); SelectedCards = new List <GameObject>(); Hand1.Clear(); Hand2.Clear(); Forest.Clear(); Decay.Clear(); SelectedCards.Clear(); // Initialize variables turn = true; score1 = 0; score2 = 0; basketCount1 = 0; basketCount2 = 0; panCount1 = 1; panCount2 = 1; handLimit1 = 8; handLimit2 = 8; stickCount1 = 0; stickCount2 = 0; // Set up variables such that Player 1 starts by default SwitchPlayer("Player1"); // Instantiate a day-deck, shuffle the deck and deal the initial hand. daydeckclone = Instantiate(daydeck, daydeck.transform.position, Quaternion.identity); dealScript = daydeckclone.GetComponent <DealScript>(); dealScript.Shuffle(); dealScript.Deal(); // Instantiate a night-deck, shuffle the deck but do NOT deal. GameObject nightdeckclone; nightdeckclone = Instantiate(nightdeck, nightdeck.transform.position, Quaternion.identity); nightScript = nightdeckclone.GetComponent <DealScript>(); nightScript.Shuffle(); // Instantiate buttons and text canvasclone = Instantiate(maintextcanvas, maintextcanvas.transform.position, Quaternion.identity); cookButtonText = canvasclone.transform.Find("Cook Text").GetComponent <Text>(); stickButtonText = canvasclone.transform.Find("Stick Text").GetComponent <Text>(); scoreText = canvasclone.transform.Find("Score Text").GetComponent <Text>(); cardDisplayText = canvasclone.transform.Find("Card Name").GetComponent <Text>(); handText = canvasclone.transform.Find("Hand Text").GetComponent <Text>(); SetCookButtonText(); SetStickButtonText(); SetHandText(); SetCardDisplayText("", 0, 0); } }
private void Start() { // Scripts and objects daydeck = GameObject.Find("DayDeck(Clone)"); nightdeck = GameObject.Find("NightDeck(Clone)"); Controller = GameObject.Find("Controller"); gameController = Controller.GetComponent <GameController>(); dealScript = daydeck.GetComponent <DealScript>(); nightScript = nightdeck.GetComponent <DealScript>(); // Get access to variables: hand spacing, forest spacing, posForest, and posHand handSpacing = gameController.handSpacing; forestSpacing = gameController.forestSpacing; posForest = gameController.posForest; posHand = gameController.posHand; }