カウンター動作を追加

This commit is contained in:
kimura 2021-10-29 16:51:08 +09:00
parent 5f84e67316
commit 376d3713a4
4 changed files with 74 additions and 28 deletions

View File

@ -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

View File

@ -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<PlantLine> plantLines = new List<PlantLine>();
@ -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<SpriteRenderer>().sortingOrder = 40;
var spriteRenderer = harvested.GetComponentInChildren<SpriteRenderer>();
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)

View File

@ -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)

View File

@ -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<Unit> playEffectObserve = new Subject<Unit>();
@ -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()