Fixed end of game trigger on subsequent game. Fixed score not being saved after not entering name.
This commit is contained in:
parent
a0ec711c4a
commit
64c08d6459
10 changed files with 395 additions and 108 deletions
|
|
@ -21,6 +21,8 @@ public class EndGameController : MonoBehaviour
|
|||
private VisualElement _diamondImageBox;
|
||||
private VisualElement _healthImageBox;
|
||||
private TextField _nameField;
|
||||
private Button _save;
|
||||
private Button _close;
|
||||
|
||||
private int _score;
|
||||
|
||||
|
|
@ -28,10 +30,10 @@ public class EndGameController : MonoBehaviour
|
|||
{
|
||||
VisualElement root = GetComponent<UIDocument>().rootVisualElement;
|
||||
|
||||
Button save = root.Q<Button>("Save");
|
||||
save.clicked += HandleSaveClicked;
|
||||
Button close = root.Q<Button>("Close");
|
||||
close.clicked += HandleCloseClicked;
|
||||
_save = root.Q<Button>("Save");
|
||||
_save.clicked += HandleSaveClicked;
|
||||
_close = root.Q<Button>("Close");
|
||||
_close.clicked += HandleCloseClicked;
|
||||
_diamondPoints = root.Q<Label>("PointsFromDiamond");
|
||||
_pointsFromHealth = root.Q<Label>("PointsFromHealth");
|
||||
_scoreSum = root.Q<Label>("ScoreSum");
|
||||
|
|
@ -40,6 +42,7 @@ public class EndGameController : MonoBehaviour
|
|||
_title = root.Q<Label>("Title");
|
||||
_message = root.Q<Label>("Message");
|
||||
_nameField = root.Q<TextField>("NameField");
|
||||
_nameField.RegisterCallback<ChangeEvent<string>>(evt => { nameEdited(evt.newValue); });
|
||||
|
||||
Image diamondImage = new Image();
|
||||
diamondImage.image = diamondSprite.texture;
|
||||
|
|
@ -80,4 +83,16 @@ public class EndGameController : MonoBehaviour
|
|||
SaveScoreClicked?.Invoke(_nameField.value, _score);
|
||||
LeaveDungeonClicked?.Invoke();
|
||||
}
|
||||
|
||||
private void nameEdited(string text)
|
||||
{
|
||||
if (text == String.Empty)
|
||||
{
|
||||
_save.SetEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_save.SetEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue