feat: new rose spawn animation
This commit is contained in:
parent
b3996c6831
commit
1580910ec1
113 changed files with 6558 additions and 23 deletions
|
@ -14,10 +14,14 @@ namespace FramedAnimator {
|
|||
|
||||
private void Awake() {
|
||||
_renderer = GetComponent<SpriteRenderer>();
|
||||
_model = new AnimatorModel(animation.FrameRate, animation.FrameCount);
|
||||
if(animation)
|
||||
_model = new AnimatorModel(animation.FrameRate, animation.FrameCount);
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (!animation)
|
||||
return;
|
||||
|
||||
if (_model.RenderingFrame >= _model.FrameCount - 1)
|
||||
TryCallAnimationEnd();
|
||||
else
|
||||
|
|
|
@ -6,14 +6,10 @@ namespace Presenter {
|
|||
private readonly IScoreView _view;
|
||||
private readonly IRoseGrow _grow;
|
||||
private readonly IInputCallback _onInputReceived;
|
||||
private readonly IRoseSpawner _spawner;
|
||||
|
||||
private bool CanSpawn => _score.Value % (_score.GrowIterations * _score.SpawnRate) == 0;
|
||||
|
||||
public ExpressionClick(Score score, IScoreView view, IRoseSpawner spawner, IRoseGrow grow, IInputCallback inputCallback) {
|
||||
public ExpressionClick(Score score, IScoreView view, IRoseGrow grow, IInputCallback inputCallback) {
|
||||
_score = score;
|
||||
_view = view;
|
||||
_spawner = spawner;
|
||||
_grow = grow;
|
||||
_onInputReceived = inputCallback;
|
||||
}
|
||||
|
@ -23,12 +19,6 @@ namespace Presenter {
|
|||
_view.UpdateView(_score.Value);
|
||||
_onInputReceived.OnInputReceived();
|
||||
|
||||
if (CanSpawn) {
|
||||
if(_score.Roses > Score.InitialRosesThreshold)
|
||||
_spawner.SpawnRose();
|
||||
else
|
||||
_spawner.SpawnInitialRose();
|
||||
}
|
||||
if (_score.Value % _score.GrowIterations == 0)
|
||||
_grow.GrowStep();
|
||||
}
|
||||
|
|
20
Assets/Scripts/Presenter/SpawnRose.cs
Normal file
20
Assets/Scripts/Presenter/SpawnRose.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using Domain;
|
||||
|
||||
namespace Presenter {
|
||||
public class SpawnRose {
|
||||
private readonly Score _score;
|
||||
private readonly IRoseSpawner _spawner;
|
||||
|
||||
public SpawnRose(Score score, IRoseSpawner spawner) {
|
||||
_score = score;
|
||||
_spawner = spawner;
|
||||
}
|
||||
|
||||
public void Execute() {
|
||||
if(_score.Roses > Score.InitialRosesThreshold)
|
||||
_spawner.SpawnRose();
|
||||
else
|
||||
_spawner.SpawnInitialRose();
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Presenter/SpawnRose.cs.meta
Normal file
3
Assets/Scripts/Presenter/SpawnRose.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2872dccaf7a468a96087c0650cee656
|
||||
timeCreated: 1713734527
|
|
@ -16,6 +16,8 @@ namespace View {
|
|||
public SaveGame Saver { private set; get; }
|
||||
public LoadGame Loader { private set; get; }
|
||||
|
||||
public SpawnRose Spawner { private set; get; }
|
||||
|
||||
private void Awake() {
|
||||
Score = new Score(10, 10);
|
||||
|
||||
|
@ -28,7 +30,8 @@ namespace View {
|
|||
IInputCallback inputCallback = new InputCallbackCollection(new[] { visibility, growParticles });
|
||||
IRoseGrow growAnimation = FindObjectOfType<GrowAnimation>();
|
||||
|
||||
ExpressionClick = new ExpressionClick(Score, input, spawner, growAnimation, inputCallback);
|
||||
ExpressionClick = new ExpressionClick(Score, input, growAnimation, inputCallback);
|
||||
Spawner = new SpawnRose(Score, spawner);
|
||||
|
||||
CustomInput = new CustomInput();
|
||||
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using Animation = FramedAnimator.Animation;
|
||||
using Animator = FramedAnimator.Animator;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace View.Scene {
|
||||
public class GardenFlower : MonoBehaviour {
|
||||
[SerializeField] private SpriteRenderer sprite;
|
||||
|
||||
[SerializeField] private Sprite[] randomSprites;
|
||||
[SerializeField] private Animation[] randomAnimation;
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
private static readonly int WindOffset = Shader.PropertyToID("_WindOffset");
|
||||
|
||||
[SerializeField] private float randomRotation;
|
||||
[SerializeField] private float startRandomMaxDelay;
|
||||
|
||||
private void Awake() {
|
||||
sprite.sprite = randomSprites[Random.Range(0, randomSprites.Length)];
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, Random.Range(-randomRotation, randomRotation));
|
||||
}
|
||||
|
||||
private IEnumerator Start() {
|
||||
sprite.material.SetFloat(WindOffset, Random.Range(0f, 2f * Mathf.PI));
|
||||
animator.ChangeAnimation(randomAnimation[Random.Range(0, randomAnimation.Length)]);
|
||||
yield return new WaitForSeconds(Random.Range(0f, startRandomMaxDelay));
|
||||
animator.PlayUntil(1f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,10 +16,12 @@ namespace View.Scene {
|
|||
[SerializeField] private EventReference gloomEvent;
|
||||
|
||||
private Score _score;
|
||||
private SpawnRose _spawnRose;
|
||||
private bool _firstUpdate = true;
|
||||
|
||||
private void Start() {
|
||||
_score = FindObjectOfType<Dependencies>().Score;
|
||||
_spawnRose = FindObjectOfType<Dependencies>().Spawner;
|
||||
|
||||
animator.OnAnimationEnd += AnimationEnded;
|
||||
}
|
||||
|
@ -33,6 +35,7 @@ namespace View.Scene {
|
|||
}
|
||||
|
||||
if (animationName == "Rosa_End") {
|
||||
_spawnRose.Execute();
|
||||
animator.ChangeAnimation(growAnimation);
|
||||
animator.PlayUntil(_score.GrowPercentage);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue