feat: load system

This commit is contained in:
Gerard Gascón 2024-04-17 00:37:39 +02:00
parent 5d470a57af
commit 60d20bfe4e
20 changed files with 421 additions and 67 deletions

View file

@ -1,6 +1,7 @@
using System;
using Domain;
using Presenter;
using Presenter.SaveSystem;
using UnityEngine;
using View.UI;
@ -10,6 +11,9 @@ namespace View {
public Score Score { private set; get; }
public CustomInput CustomInput { private set; get; }
public SaveGame Saver { private set; get; }
public LoadGame Loader { private set; get; }
private void Awake() {
Score = new Score(20, 5);
@ -22,6 +26,10 @@ namespace View {
ExpressionClick = new ExpressionClick(Score, inputCollections, spawner);
CustomInput = new CustomInput();
PlayerPrefsRepository repository = new();
Saver = new SaveGame(repository, Score);
Loader = new LoadGame(repository, Score, inputCollections);
}
}
}

View file

@ -8,9 +8,9 @@ namespace View {
_inputs = inputs;
}
public void UpdateView(int score) {
public void UpdateView(int score, float growPercentage) {
foreach (IExpressionInput input in _inputs)
input.UpdateView(score);
input.UpdateView(score, growPercentage);
}
}
}

View file

@ -0,0 +1,12 @@
using UnityEngine;
namespace View {
public class SaveLoad : MonoBehaviour {
private void Start() => LoadGame();
private void LoadGame() => FindObjectOfType<Dependencies>().Loader.Run();
private void SaveGame() => FindObjectOfType<Dependencies>().Saver.Run();
private void OnApplicationQuit() => SaveGame();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3c6dab5fe816434381b975fd75b667fc
timeCreated: 1713306082

View file

@ -11,13 +11,10 @@ namespace View.UI {
private ExpressionClick _click;
private CustomInput _customInput;
private Score _score;
[SerializeField] private FramedAnimator.FramedAnimator animator;
private void Start() {
_score = FindObjectOfType<Dependencies>().Score;
_click = FindObjectOfType<Dependencies>().ExpressionClick;
_customInput = FindObjectOfType<Dependencies>().CustomInput;
}
@ -26,8 +23,8 @@ namespace View.UI {
CheckInput();
}
public void UpdateView(int score) {
animator.PlayUntil(_score.GrowPercentage);
public void UpdateView(int score, float growPercentage) {
animator.PlayUntil(growPercentage);
text.text = score.ToString();
}

View file

@ -31,7 +31,7 @@ namespace View.UI {
}
}
public void UpdateView(int score) {
public void UpdateView(int score, float growPercentage) {
if (!_titleVisible) return;
_titleVisible = false;