Update Turn Text

Is there any downside to adding the UpdateTurnText() as a listener to the endTurnBtn? I refactored my code to follow the course, but the below solution seemed cleaner to me than creating a new event between the two scripts.

    private void Start() {
        endTurnButton.onClick.AddListener(() => {
            TurnSystem.Instance.NextTurn();
            UpdateTurnText();
        });
    }

    private void UpdateTurnText() {
        int turnNumber = TurnSystem.Instance.GetTurnNumber();
        turnNumberText.text = $"TURN {turnNumber}";
    }
1 Like

You can do that but later on in the course when enemies are added the Enemy AI will be responsible for ending its own turn instead of a player click, so you’ll need the event then.

3 Likes

Ah, that makes sense. Thanks!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms