feat: Rose grow animation

This commit is contained in:
Gerard Gascón 2024-04-15 19:13:30 +02:00
parent f8a29f1501
commit 438b16fc6e
9 changed files with 186 additions and 4 deletions

View file

@ -371,6 +371,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
text: {fileID: 379057222} text: {fileID: 379057222}
animator: {fileID: 902566664}
--- !u!225 &311490074 --- !u!225 &311490074
CanvasGroup: CanvasGroup:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -784,6 +785,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 902566663} - component: {fileID: 902566663}
- component: {fileID: 902566662} - component: {fileID: 902566662}
- component: {fileID: 902566664}
m_Layer: 0 m_Layer: 0
m_Name: Rosa_Grow_0100 m_Name: Rosa_Grow_0100
m_TagString: Untagged m_TagString: Untagged
@ -858,6 +860,120 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &902566664
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 902566661}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 944498bf314d45ceb21a77b6ec4b0cfb, type: 3}
m_Name:
m_EditorClassIdentifier:
sprites:
- {fileID: 21300000, guid: 9190f771caed674408c4b6d4b619af7e, type: 3}
- {fileID: 21300000, guid: 4305000b02bb3244ab7e653f2096e8e7, type: 3}
- {fileID: 21300000, guid: 4c72de7119f4b114aaf27e98b8531352, type: 3}
- {fileID: 21300000, guid: 38f2244be57ae8540915e0c66e99ccf4, type: 3}
- {fileID: 21300000, guid: 87d581b3173446e4f8f308ee6208294a, type: 3}
- {fileID: 21300000, guid: e9f75af2061de0742aae14ae7b7bcfb4, type: 3}
- {fileID: 21300000, guid: a6853c381f47f1b42946753773f0e083, type: 3}
- {fileID: 21300000, guid: c83b1d637c48bf64b8205321d65c135f, type: 3}
- {fileID: 21300000, guid: 0c29dc61bbb6bc7499e9fef0860c1bd4, type: 3}
- {fileID: 21300000, guid: f818ddb8852f6954e9620a39fe0a0d7d, type: 3}
- {fileID: 21300000, guid: 4cea7721cb49ca246bc4d4ff21b14a1b, type: 3}
- {fileID: 21300000, guid: fcb8c41f682883042b092d77d2a4a2a1, type: 3}
- {fileID: 21300000, guid: 647f92dd48bd6874c84ab3aa2a202fcc, type: 3}
- {fileID: 21300000, guid: 655c501960891c148b6a93ec7b007015, type: 3}
- {fileID: 21300000, guid: be22f017d3dfce545b197774a3bc5845, type: 3}
- {fileID: 21300000, guid: a3e6dbfeb31266948a76975b08112ddd, type: 3}
- {fileID: 21300000, guid: 5cb50f2c825a53340bb64a1b27f6ddc6, type: 3}
- {fileID: 21300000, guid: 91d97a611301b494da22ae71390bd3fb, type: 3}
- {fileID: 21300000, guid: 6c0b3ea4152744c48af17391e9175994, type: 3}
- {fileID: 21300000, guid: 89141fbea6f0551458b6fae81499ad02, type: 3}
- {fileID: 21300000, guid: 7558dad6ffe5f384385b4ef93e1f3235, type: 3}
- {fileID: 21300000, guid: 551ad6ce9a8873f40b09dd6cd83f6915, type: 3}
- {fileID: 21300000, guid: cb97e734ffa85ce439efa792c96e82a6, type: 3}
- {fileID: 21300000, guid: 6032676d8a6eeef4688a1bdf45628792, type: 3}
- {fileID: 21300000, guid: a32bf851b411ed649b88c3a6e1850b29, type: 3}
- {fileID: 21300000, guid: 489caafea6830b541b24c2db5e688ee3, type: 3}
- {fileID: 21300000, guid: 3d31c75e9aa977c47b0dacf7c67bc392, type: 3}
- {fileID: 21300000, guid: e47736b575aade249a5a81ebdc2542d5, type: 3}
- {fileID: 21300000, guid: 78fba0ef5844c5b45b8c133484a59646, type: 3}
- {fileID: 21300000, guid: 697518de047a39a4ea7e91331bcc4e49, type: 3}
- {fileID: 21300000, guid: 448f6fcee173bbb4bb12abed31621cab, type: 3}
- {fileID: 21300000, guid: 6e71b7936f662e349a5cdcd0b2f18de2, type: 3}
- {fileID: 21300000, guid: 1bb8845d2c74f4f4bbb28c8c38c5dba6, type: 3}
- {fileID: 21300000, guid: 8accaec53b8dea74cb03af94567a73ba, type: 3}
- {fileID: 21300000, guid: 43e02439b22f0f24f98b49c758ba0dcc, type: 3}
- {fileID: 21300000, guid: cde2a09d175ea1349833acf61ed217f4, type: 3}
- {fileID: 21300000, guid: c08bb1b0e1cacc74cbd7a7d2701ab650, type: 3}
- {fileID: 21300000, guid: a582c05a7217d5548ba1752ae3aabbfc, type: 3}
- {fileID: 21300000, guid: d3981ca02cfa31d4899b8eeaf08c03ee, type: 3}
- {fileID: 21300000, guid: 37da164ed151ad649b1823afda7b9c0d, type: 3}
- {fileID: 21300000, guid: 22b31ef573b61ea45bc99000e19f30e9, type: 3}
- {fileID: 21300000, guid: 9af50b22fab836345ae34af41bed3f3d, type: 3}
- {fileID: 21300000, guid: f32f480d2a198644fb1559c97db68516, type: 3}
- {fileID: 21300000, guid: e1199f23a03597843bf09a8822afc563, type: 3}
- {fileID: 21300000, guid: 127759e6f382dd74bb2bc6b989f0738b, type: 3}
- {fileID: 21300000, guid: 32c01dcca82fc3d489b7cbf934191efd, type: 3}
- {fileID: 21300000, guid: bb15ed37bdbfbc64cb76191b8d4dabf1, type: 3}
- {fileID: 21300000, guid: 10759bdcd9d980f448227885d4775b19, type: 3}
- {fileID: 21300000, guid: 9d31e6e883cc89a4099cff644d48bc45, type: 3}
- {fileID: 21300000, guid: 816f284660cc13041bee5ab4f3d68d10, type: 3}
- {fileID: 21300000, guid: 2736d6ac198733a40a2fa80ec5b9a683, type: 3}
- {fileID: 21300000, guid: c217c315d33c840418c3a98357ad8dbc, type: 3}
- {fileID: 21300000, guid: 01ea171c818823244ae9f312eb704b19, type: 3}
- {fileID: 21300000, guid: 9004cd5d300b2be4f8534e693ce19d2a, type: 3}
- {fileID: 21300000, guid: 7dce3a5b433833144a2ccb8bbfb16d61, type: 3}
- {fileID: 21300000, guid: 528665d3b68c74044bd34eb43f725302, type: 3}
- {fileID: 21300000, guid: 81b13ff174d760a4bad1ebde947de13d, type: 3}
- {fileID: 21300000, guid: ddd221a2d129bb04c912cb190649ac8e, type: 3}
- {fileID: 21300000, guid: 3f2a7a54522fc7a408e24d80e4016033, type: 3}
- {fileID: 21300000, guid: ddbdc15d9f9cd7040819883a9f877ef5, type: 3}
- {fileID: 21300000, guid: eac8023fdc1cc15409987fa4f1b9bdc1, type: 3}
- {fileID: 21300000, guid: 10b8324ec6aa97f468698b467e9281b5, type: 3}
- {fileID: 21300000, guid: fecdb8c34a0afbc4281d99845e530624, type: 3}
- {fileID: 21300000, guid: 8a6059052901b6944864f3d2d99c098c, type: 3}
- {fileID: 21300000, guid: a3c020cc6820121458ae272291801632, type: 3}
- {fileID: 21300000, guid: 9cc091592409d1a43a586e55e329b7ab, type: 3}
- {fileID: 21300000, guid: 82e6f8f20e89bc54ba435d35937c2c1f, type: 3}
- {fileID: 21300000, guid: 3c250b5f57f97e44db8b9668139c1aa4, type: 3}
- {fileID: 21300000, guid: 9e27c44fd133e5747bdd9e4b4a4eec4d, type: 3}
- {fileID: 21300000, guid: 3095d0ac7adaa8d4a9eadf765ee12c9a, type: 3}
- {fileID: 21300000, guid: 59f9ee260afa0d24ca0dfe120eb7467c, type: 3}
- {fileID: 21300000, guid: 9ae42b479e34ea24b8be551bfeae0cce, type: 3}
- {fileID: 21300000, guid: 66b5fbee66a77bd45bfca10006287757, type: 3}
- {fileID: 21300000, guid: 2d51752c304bf7b4c993302ad54c0081, type: 3}
- {fileID: 21300000, guid: 9e7453792e996b7428b816a246732ba3, type: 3}
- {fileID: 21300000, guid: cb0a240512a69864ba1606766f9deb10, type: 3}
- {fileID: 21300000, guid: 4dca6fbfca5af2b4fac07db68bd5bbdd, type: 3}
- {fileID: 21300000, guid: 1014a69970d8d8b49ba667e25c323b99, type: 3}
- {fileID: 21300000, guid: 866032e1cd3260b419b2af9ca3c18e40, type: 3}
- {fileID: 21300000, guid: 45d20a530a7f7254a96c3d11e8c00cdb, type: 3}
- {fileID: 21300000, guid: 98e93756a8387b845a18607c8a874c25, type: 3}
- {fileID: 21300000, guid: d4624b52a4bdad04d8662c4bde45778c, type: 3}
- {fileID: 21300000, guid: 46ba55feb933a7a45b67e5ae7eef63dd, type: 3}
- {fileID: 21300000, guid: e5161b9195d9e9748a0e6447d9d205a7, type: 3}
- {fileID: 21300000, guid: a109fbbe4ad3d544fb0e0560df6080cb, type: 3}
- {fileID: 21300000, guid: aea7eec1f9f7a2c4c916045ef9a3ddfc, type: 3}
- {fileID: 21300000, guid: ca8540ffccf70e74bbe764d57604e18a, type: 3}
- {fileID: 21300000, guid: 3683d009d631e2b41b333742acc75aec, type: 3}
- {fileID: 21300000, guid: 6d83336659bc7b9498a76ceffaf9e8c6, type: 3}
- {fileID: 21300000, guid: 565565b521b3ad24981d94491eb3b97f, type: 3}
- {fileID: 21300000, guid: b470033148672634c923bcdab418ef98, type: 3}
- {fileID: 21300000, guid: 4a3537d0d59f78546a236b43496a8411, type: 3}
- {fileID: 21300000, guid: f8cb3c3fc08f28e46be5232e3f84df69, type: 3}
- {fileID: 21300000, guid: f7f91decd8f9dd44c951a571d3d51b55, type: 3}
- {fileID: 21300000, guid: 860f4ae72765dad488cef3a7fe5989c7, type: 3}
- {fileID: 21300000, guid: 69bb244c7d6a8cc4e878738799aba81b, type: 3}
- {fileID: 21300000, guid: b31fba318bc33274093bcfb492b2efc1, type: 3}
- {fileID: 21300000, guid: faa6f71733d7aa64fa38b9de75fdd7f0, type: 3}
- {fileID: 21300000, guid: 1636b6aaec9fbc74ead2dac6cc7c8eeb, type: 3}
- {fileID: 21300000, guid: 8bf485ced708a3743b05e49780fcf878, type: 3}
frameRate: 20
--- !u!1 &1050150008 --- !u!1 &1050150008
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -2,19 +2,19 @@
public class Model { public class Model {
public int Score { private set; get; } public int Score { private set; get; }
private readonly int _spawnRate; public readonly int SpawnRate;
private bool _needsToSpawn; private bool _needsToSpawn;
public Model(int spawnRate) : this(0, spawnRate) { } public Model(int spawnRate) : this(0, spawnRate) { }
public Model(int score, int spawnRate) { public Model(int score, int spawnRate) {
Score = score; Score = score;
_spawnRate = spawnRate; SpawnRate = spawnRate;
} }
public void AddScore() { public void AddScore() {
Score++; Score++;
if (Score % _spawnRate == 0) if (Score % SpawnRate == 0)
_needsToSpawn = true; _needsToSpawn = true;
} }

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d81a90acdb9fe6e4a87e77d9d47f5042
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
using System;
using UnityEngine;
namespace FramedAnimator {
[RequireComponent(typeof(SpriteRenderer))]
public class FramedAnimator : MonoBehaviour {
[SerializeField] private Sprite[] sprites;
[SerializeField] private float frameRate;
private float _currentFrame;
private int _renderingFrame;
private int _limit;
private SpriteRenderer _renderer;
private void Awake() {
_renderer = GetComponent<SpriteRenderer>();
}
private void Update() {
if (_renderingFrame >= _limit)
return;
_currentFrame += Time.deltaTime * frameRate;
_renderingFrame = Mathf.Clamp(Mathf.FloorToInt(_currentFrame), 0, _limit);
_renderer.sprite = sprites[_renderingFrame];
}
public void PlayUntil(float fraction) {
_limit = Mathf.RoundToInt(sprites.Length * Mathf.Clamp(fraction, 0, 1));
_limit = Mathf.Clamp(_limit, 0, sprites.Length - 1);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 944498bf314d45ceb21a77b6ec4b0cfb
timeCreated: 1713199370

View file

@ -0,0 +1,3 @@
{
"name": "SantJordi.FramedAnimator"
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 246088dd927065946b1746223fef2142
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -6,7 +6,8 @@
"GUID:d9011953b32919841a6c357880a50fb3", "GUID:d9011953b32919841a6c357880a50fb3",
"GUID:6055be8ebefd69e48b49212b09b47b2f", "GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:1220ccfff01d26041a9bb8cd7ae584af", "GUID:1220ccfff01d26041a9bb8cd7ae584af",
"GUID:58f2f98b0cec4e74998cb65ad59190b4" "GUID:58f2f98b0cec4e74998cb65ad59190b4",
"GUID:246088dd927065946b1746223fef2142"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

View file

@ -3,14 +3,21 @@ using Domain.Input;
using Presenter; using Presenter;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
namespace View.UI { namespace View.UI {
public class ExpressionInput : MonoBehaviour, IExpressionInput { public class ExpressionInput : MonoBehaviour, IExpressionInput {
[SerializeField] private TMP_Text text; [SerializeField] private TMP_Text text;
private ExpressionClick _click; private ExpressionClick _click;
private CustomInput _customInput; private CustomInput _customInput;
private Model _model;
[SerializeField] private FramedAnimator.FramedAnimator animator;
private void Start() { private void Start() {
_model = FindObjectOfType<Dependencies>().Model;
_click = FindObjectOfType<Dependencies>().ExpressionClick; _click = FindObjectOfType<Dependencies>().ExpressionClick;
_customInput = FindObjectOfType<Dependencies>().CustomInput; _customInput = FindObjectOfType<Dependencies>().CustomInput;
} }
@ -43,6 +50,9 @@ namespace View.UI {
} }
public void UpdateView(int score) { public void UpdateView(int score) {
int frameDifference = score % _model.SpawnRate;
animator.PlayUntil(frameDifference / (float)_model.SpawnRate);
text.text = score.ToString(); text.text = score.ToString();
} }
} }