吸収演出調整

This commit is contained in:
kimura 2021-09-17 14:53:57 +09:00
parent 76d1d1473c
commit 9a05298a38
2 changed files with 18 additions and 9 deletions

View File

@ -1314,6 +1314,7 @@ MonoBehaviour:
harvestInsertPosition: {fileID: 895001959} harvestInsertPosition: {fileID: 895001959}
cornHarvester: {fileID: 282523124} cornHarvester: {fileID: 282523124}
counterView: {fileID: 1507187603938887411} counterView: {fileID: 1507187603938887411}
animationTarget: {fileID: 1373978114}
plantLines: plantLines:
- {fileID: 1656378502} - {fileID: 1656378502}
- {fileID: 1192216301} - {fileID: 1192216301}
@ -2468,6 +2469,12 @@ Transform:
m_Father: {fileID: 1501215306} m_Father: {fileID: 1501215306}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &1373978114 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1507187602806663289, guid: 21599f8e6d1104a07b0b14b49f8c1429,
type: 3}
m_PrefabInstance: {fileID: 1507187603938887410}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1433549139 --- !u!1 &1433549139
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -22,6 +22,7 @@ public class CornField : MonoBehaviour
[SerializeField] private Transform harvestInsertPosition; [SerializeField] private Transform harvestInsertPosition;
[SerializeField] private CornHarvester cornHarvester; [SerializeField] private CornHarvester cornHarvester;
[SerializeField] private HarvestedCounterView counterView; [SerializeField] private HarvestedCounterView counterView;
[SerializeField] private Transform animationTarget;
[Space] [Space]
[SerializeField] private List<PlantLine> plantLines = new List<PlantLine>(); [SerializeField] private List<PlantLine> plantLines = new List<PlantLine>();
private readonly List<PlantLine> availableLines = new List<PlantLine>(); private readonly List<PlantLine> availableLines = new List<PlantLine>();
@ -29,8 +30,11 @@ public class CornField : MonoBehaviour
private static readonly int minPeriod = 45; private static readonly int minPeriod = 45;
private static readonly int harvestedFrameInterval = 3; private static readonly int harvestedFrameInterval = 3;
private static readonly float harvestedDistance = .6f; private static readonly float harvestedDistance = .6f;
private static readonly int animationLimit = 100;
private static readonly float countThrottle = .6f; private static readonly float countThrottle = .6f;
private static readonly float animationStartDelay = .02f;
private static readonly float animationDuration = .3f;
private static readonly int animationDivisor = 3;
private static readonly int animationLimit = 100;
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
// Start is called before the first frame update // Start is called before the first frame update
@ -91,29 +95,27 @@ public class CornField : MonoBehaviour
// 間引かれた分は破棄 // 間引かれた分は破棄
var culledList = stayList.Except(animationList).ToList(); var culledList = stayList.Except(animationList).ToList();
var culledCount = 1; var culledCount = 1;
var divisor = Mathf.CeilToInt((float)culledList.Count / animationLimit); var culledDivisor = Mathf.CeilToInt((float)culledList.Count / animationLimit);
culledList.ForEach(c => Destroy(c.gameObject, .01f * Mathf.FloorToInt((float)culledCount++ / divisor))); culledList.ForEach(c => Destroy(c.gameObject, .01f * Mathf.FloorToInt((float)culledCount++ / culledDivisor)));
destroyList.ForEach(c => Destroy(c.gameObject, 2f)); destroyList.ForEach(c => Destroy(c.gameObject, 2f));
var j = 0; var j = 0;
animationList.ForEach(harvested => animationList.ForEach(harvested =>
{ {
this.CallWaitForSeconds(.01f * j, () => this.CallWaitForSeconds(animationStartDelay * Mathf.FloorToInt((float)j++ / animationDivisor), () =>
{ {
harvested.enabled = false; harvested.enabled = false;
var beginPos = harvested.transform.position; var beginPos = harvested.transform.position;
this.CallLerp(.3f, f => this.CallLerp(animationDuration, f =>
{ {
harvested.transform.position = Vector2.Lerp(beginPos, counterView.transform.position, f.EaseInQuadratic()); harvested.transform.position = Vector2.Lerp(beginPos, animationTarget.position, f.EaseInQuadratic());
}, () => }, () =>
{ {
// カウンター到着でDestroy
Destroy(harvested.gameObject); Destroy(harvested.gameObject);
counterView.PlayEffect(); counterView.PlayEffect();
}); });
}); });
j++;
}); });
this.CallWaitForSeconds(.01f * j + .3f, () => this.CallWaitForSeconds(animationDuration, () =>
{ {
counterView.SetHarvestedCount(count); counterView.SetHarvestedCount(count);
}); });