From 9a05298a381c152657a24b0cbca6e98f5e18704f Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 17 Sep 2021 14:53:57 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=B8=E5=8F=8E=E6=BC=94=E5=87=BA=E8=AA=BF?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/CornField/CornField.unity | 7 +++++++ .../Scenes/CornField/Scripts/CornField.cs | 20 ++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity b/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity index 95672bfd..c9060c5e 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity +++ b/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity @@ -1314,6 +1314,7 @@ MonoBehaviour: harvestInsertPosition: {fileID: 895001959} cornHarvester: {fileID: 282523124} counterView: {fileID: 1507187603938887411} + animationTarget: {fileID: 1373978114} plantLines: - {fileID: 1656378502} - {fileID: 1192216301} @@ -2468,6 +2469,12 @@ Transform: m_Father: {fileID: 1501215306} m_RootOrder: 2 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 GameObject: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index 524a099e..804e418a 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -22,6 +22,7 @@ public class CornField : MonoBehaviour [SerializeField] private Transform harvestInsertPosition; [SerializeField] private CornHarvester cornHarvester; [SerializeField] private HarvestedCounterView counterView; + [SerializeField] private Transform animationTarget; [Space] [SerializeField] private List plantLines = new List(); private readonly List availableLines = new List(); @@ -29,8 +30,11 @@ public class CornField : MonoBehaviour private static readonly int minPeriod = 45; private static readonly int harvestedFrameInterval = 3; private static readonly float harvestedDistance = .6f; - private static readonly int animationLimit = 100; 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(); // Start is called before the first frame update @@ -91,29 +95,27 @@ public class CornField : MonoBehaviour // 間引かれた分は破棄 var culledList = stayList.Except(animationList).ToList(); var culledCount = 1; - var divisor = Mathf.CeilToInt((float)culledList.Count / animationLimit); - culledList.ForEach(c => Destroy(c.gameObject, .01f * Mathf.FloorToInt((float)culledCount++ / divisor))); + var culledDivisor = Mathf.CeilToInt((float)culledList.Count / animationLimit); + culledList.ForEach(c => Destroy(c.gameObject, .01f * Mathf.FloorToInt((float)culledCount++ / culledDivisor))); destroyList.ForEach(c => Destroy(c.gameObject, 2f)); var j = 0; animationList.ForEach(harvested => { - this.CallWaitForSeconds(.01f * j, () => + this.CallWaitForSeconds(animationStartDelay * Mathf.FloorToInt((float)j++ / animationDivisor), () => { harvested.enabled = false; 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); counterView.PlayEffect(); }); }); - j++; }); - this.CallWaitForSeconds(.01f * j + .3f, () => + this.CallWaitForSeconds(animationDuration, () => { counterView.SetHarvestedCount(count); });