private void Awake() { controller = GameObject.Find("Controller"); gameController = controller.GetComponent <GameController>(); maincanvas = gameController.canvasclone; sceneChangeScript = maincanvas.transform.Find("DecayButton").GetComponent <SceneChangeScript>(); }
public void EndTurn() { /* Initiates sequence of events following end of turn. * Called whenever a turn-ending action is performed. */ // Update texts SetHandText(); SetCookButtonText(); SetStickButtonText(); SetScoreText(); // If decay has more than four cards in it, discard. if (Decay.Count == 4) { List <GameObject> DecayCopy = new List <GameObject>(Decay); foreach (GameObject card in DecayCopy) { Decay.Remove(card); Destroy(card); } } // Move a card to the decay and make sure it's inactive GameObject decayCard = Forest[Forest.Count - 1]; Decay.Add(decayCard); decayCard.SetActive(false); // Remove card from forest Forest.Remove(decayCard); // Deal a new card dealScript.MakeCard("Forest"); // Reposition cards in forest and decay Reposition(Forest, forestSpacing, posForest); Reposition(Decay, decaySpacing, posDecay); // Get access to SceneChangeScript // Make objects un-interactable sceneChangeScript = canvasclone.transform.Find("DecayButton").GetComponent <SceneChangeScript>(); sceneChangeScript.GetObjects(); sceneChangeScript.ToggleInteract(false, true, true, false); //canvasclone.transform.Find("DecayButton").GetComponent<Button>().enabled = true; // Turn back on button // Activate the turn button canvasclone.transform.Find("TurnButton").gameObject.SetActive(true); // Set text canvasclone.transform.Find("TurnButton").transform.Find("Text").GetComponent <Text>().text = "End Turn"; }
void Start() { rb = GetComponent <Rigidbody>(); Sc = SceneChanger.GetComponent <SceneChangeScript>(); //get the scene changer script }