From 376d3713a432c8cadeee155e78c8668044ba3964 Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 29 Oct 2021 16:51:08 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=82=A6=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E5=8B=95=E4=BD=9C=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/CornField/CornField.unity | 71 ++++++++++++++----- .../Scenes/CornField/Scripts/CornField.cs | 17 ++++- .../Scenes/CornField/Scripts/CornHarvester.cs | 7 +- .../CornField/Scripts/HarvestedCounterView.cs | 7 +- 4 files changed, 74 insertions(+), 28 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity b/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity index 7d55a05b..cc13094a 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity +++ b/popcorn/Assets/MyGame/Scenes/CornField/CornField.unity @@ -551,7 +551,6 @@ MonoBehaviour: harvestedSpawnTransform: {fileID: 1355152264} harvestedPrefab: {fileID: 2111766585493962378, guid: d52f3514ed7fd461b8ab77a202c122c6, type: 3} - harvestedSpawnTarget: {fileID: 0} thrust: 40 machineTarget: {fileID: 1491597820} cullCornRate: 0.9 @@ -756,10 +755,10 @@ RectTransform: m_Father: {fileID: 457045028} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 122.21785, y: -54} - m_SizeDelta: {x: 101.03571, y: 100} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &323920547 MonoBehaviour: @@ -1522,7 +1521,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: -32.99994, y: 15.999985} - m_SizeDelta: {x: 230.7357, y: 88} + m_SizeDelta: {x: 0, y: 88} m_Pivot: {x: 0, y: 1} --- !u!114 &457045029 MonoBehaviour: @@ -1906,7 +1905,7 @@ Camera: m_Depth: -1 m_CullingMask: serializedVersion: 2 - m_Bits: 23 + m_Bits: 4294967295 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -2306,6 +2305,7 @@ MonoBehaviour: m_EditorClassIdentifier: animationDuration: 0.5 fertilizerFinishWaitTime: 2.21 + cornSortingOrder: 40 uiVisibleController: {fileID: 1859409048} sideButtons: {fileID: 1735316554} promoteGrowthButton: {fileID: 730756546} @@ -2320,7 +2320,8 @@ MonoBehaviour: fertilizerButtonView: {fileID: 525465089} brotherFertilizerAnimation: {fileID: 715847677} counterView: {fileID: 1507187603938887411} - animationTarget: {fileID: 1373978114} + additionView: {fileID: 1106859982} + animationTarget: {fileID: 1881129199} plantLines: - {fileID: 1656378502} - {fileID: 1192216301} @@ -2673,9 +2674,9 @@ RectTransform: m_Father: {fileID: 457045028} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 39, y: -25} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 42} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &971086866 stripped @@ -3098,13 +3099,15 @@ GameObject: m_Component: - component: {fileID: 1106859980} - component: {fileID: 1106859981} + - component: {fileID: 1106859982} + - component: {fileID: 1106859983} m_Layer: 5 m_Name: StockCorn_addition_Animation m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1106859980 RectTransform: m_ObjectHideFlags: 0 @@ -3144,6 +3147,44 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 +--- !u!114 &1106859982 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1106859979} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 36e90b93a284494f950c1e35f9b68535, type: 3} + m_Name: + m_EditorClassIdentifier: + counterAnimator: {fileID: 1106859981} + counter: {fileID: 323920547} + triggerThrottle: 0.2 + countDuration: 0.5 + waitDisappeared: 3 +--- !u!223 &1106859983 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1106859979} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 2 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 1 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 39 + m_TargetDisplay: 0 --- !u!1 &1120224446 GameObject: m_ObjectHideFlags: 0 @@ -3747,12 +3788,6 @@ Transform: m_Father: {fileID: 282523123} m_RootOrder: 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 &1406886287 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 67d31657..48721e5c 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -20,6 +20,7 @@ public class CornField : MonoBehaviour { [SerializeField] private float animationDuration = .3f; [SerializeField] private float fertilizerFinishWaitTime = 1f; + [SerializeField] private int cornSortingOrder = 40; [Space] [SerializeField] private UIVisibleController uiVisibleController; [SerializeField] private GameObject sideButtons; @@ -33,6 +34,7 @@ public class CornField : MonoBehaviour [SerializeField] private FertilizerButtonView fertilizerButtonView; [SerializeField] private BrotherFertilizerAnimation brotherFertilizerAnimation; [SerializeField] private HarvestedCounterView counterView; + [SerializeField] private HarvestedAdditionView additionView; [SerializeField] private Transform animationTarget; [Space] [SerializeField] private List plantLines = new List(); @@ -88,6 +90,7 @@ public class CornField : MonoBehaviour TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); }).AddTo(this); counterView.Initialize(gameData.CornSeed); + additionView.Initialize(0); SetData(); // 畑リセット @@ -221,7 +224,10 @@ public class CornField : MonoBehaviour this.CallWaitForSeconds(animationStartDelay * Mathf.FloorToInt((float)j++ / animationDivisor), () => { harvested.enabled = false; - harvested.GetComponentInChildren().sortingOrder = 40; + var spriteRenderer = harvested.GetComponentInChildren(); + spriteRenderer.sortingOrder = cornSortingOrder; + // Layer 5:UI 決め打ち + spriteRenderer.gameObject.layer = 5; var beginPos = harvested.transform.position; this.CallLerp(animationDuration, f => { @@ -229,15 +235,20 @@ public class CornField : MonoBehaviour }, () => { Destroy(harvested.gameObject); - counterView.PlayEffect(); + additionView.PlayEffect(); }); }); }); this.CallWaitForSeconds(animationDuration, () => { - counterView.SetHarvestedCount(x.count); + additionView.AddHarvestedCount(x.count); }); }).AddTo(this); + additionView.EndObservable.Subscribe(x => + { + counterView.PlayEffect(); + counterView.SetHarvestedCount(gameData.CornSeed); + }).AddTo(this); } public void SetCornField(bool useFertilizer = false) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs index 6b056feb..783fdb63 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs @@ -13,10 +13,10 @@ public class CornHarvester : MonoBehaviour private static readonly int PutOut = Animator.StringToHash("PutOut"); [SerializeField] private Transform harvestedSpawnTransform; [SerializeField] private GameObject harvestedPrefab; - [SerializeField] private GameObject harvestedSpawnTarget; [SerializeField] private float thrust = 100f; [SerializeField] private Transform machineTarget; // 収穫演出で出るコーンの数を制限 + [Space] [SerializeField] private float cullCornRate = .8f; [SerializeField] private int firstCornLimit = 200; [SerializeField] private int secondCornLimit = 300; @@ -45,7 +45,7 @@ public class CornHarvester : MonoBehaviour { machineAnimator?.SetTrigger(Wait); } - finishHarvested.OnNext((x.Current, list)); + finishHarvested.OnNext((x.Current - x.Previous, list)); })); }).AddTo(this); } @@ -74,6 +74,9 @@ public class CornHarvester : MonoBehaviour yield return null; } callback?.Invoke(finishedList); +#if UNITY_EDITOR + Debug.Log($"now:{harvestedSpawnTransform.childCount}"); +#endif } public void AddCount(int value) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/HarvestedCounterView.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/HarvestedCounterView.cs index afd4cdc6..08a4bfd3 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/HarvestedCounterView.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/HarvestedCounterView.cs @@ -10,9 +10,7 @@ public class HarvestedCounterView : MonoBehaviour private static readonly int Add = Animator.StringToHash("Add"); [SerializeField] private Animator counterAnimator; [SerializeField] private TextWithCountUpInt counter; - private static readonly string harvestedCountFormat = "+{0}"; private static readonly string hasCountFormat = "{0}"; - private string hasCountText; private static readonly float duration = .5f; private readonly Subject playEffectObserve = new Subject(); @@ -29,13 +27,12 @@ public class HarvestedCounterView : MonoBehaviour public void Initialize(int count) { - hasCountText = string.Format(hasCountFormat, count.ToString()); - counter.ChangeValue(hasCountText, 0); + counter.ChangeValue(hasCountFormat, count); } public void SetHarvestedCount(int count) { - counter.CountUpAnimation($"{hasCountText}{harvestedCountFormat}", count, duration); + counter.CountUpAnimation(hasCountFormat, count, duration); } public void PlayEffect()