Exemplo n.º 1
0
    public void EndNight()                                      //gets called after closing the summary of the day to end the night
    {
        FindObjectOfType <DontDestroyFields>().transform.GetChild(0).gameObject.SetActive(true);

        Fields.Clear();                                                                         //clears all fields from the list to not get double entries
        foreach (FieldManager go in FieldManager.FindObjectsOfType(typeof(FieldManager)))       //finds all objects of type FieldManager
        {
            if (go.tag == "Field")                                                              //if the Tag of this object is "Field"
            {
                Fields.Add(go);                                                                 //add it to the List of Fields
            }
        }

        EndOfDayCardUI.SetActive(false);                               //Removes the summary of the previous day
        Player = GameObject.Find("Player");                            //Finds the Player

        StartCoroutine(Coroutine(0.2f, () =>                           //Lambda function: waits for 0.2 seconds before executing the following code (emergency solution to quick-fix a bug)
        {
            Player.GetComponent <PlayerMovement>().enabled = true;     //Enables the Movement of the player when ending the night
            Player.GetComponent <PlayerActions>().enabled  = true;
        }));

        animator.GetComponent <FadingManager>().SetFade(false);         //Fades in after the night

        for (int i = 0; i < Fields.Count; i++)                          //every field in the scene
        {
            Fields[i].UpdateFieldDays();                                //update their status (happens in FieldManager)
            int WeedChance = UnityEngine.Random.Range(1, 10);
            if (WeedChance == 1 && !Fields[i].IsWeeded())
            {
                Fields[i].SetWeedstate(true);
            }
        }
        FindObjectOfType <DontDestroyFields>().transform.GetChild(0).gameObject.SetActive(false);
    }