収穫アニメーション追加

This commit is contained in:
kimura 2021-07-21 13:58:40 +09:00
parent 2862cb0670
commit 5bdb1be1f8
4 changed files with 161 additions and 95 deletions

View File

@ -37,7 +37,8 @@ AnimatorState:
m_Name: seedling m_Name: seedling
m_Speed: 1 m_Speed: 1
m_CycleOffset: 0 m_CycleOffset: 0
m_Transitions: [] m_Transitions:
- {fileID: 1895822779947249615}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0} m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0 m_IKOnFeet: 0
@ -92,7 +93,7 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer
@ -131,3 +132,25 @@ AnimatorStateMachine:
m_ExitPosition: {x: 800, y: 120, z: 0} m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -7101647891082938139} m_DefaultState: {fileID: -7101647891082938139}
--- !u!1101 &1895822779947249615
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7101647891082938139}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.25
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1

View File

@ -170,7 +170,7 @@ Transform:
- {fileID: 1035142904} - {fileID: 1035142904}
- {fileID: 1466604291} - {fileID: 1466604291}
m_Father: {fileID: 1501215306} m_Father: {fileID: 1501215306}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &282523122 --- !u!1 &282523122
GameObject: GameObject:
@ -203,8 +203,14 @@ Transform:
- {fileID: 1793483901} - {fileID: 1793483901}
- {fileID: 998360038} - {fileID: 998360038}
m_Father: {fileID: 1501215306} m_Father: {fileID: 1501215306}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &371589523 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
m_PrefabInstance: {fileID: 1442510375}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &387414332 --- !u!1001 &387414332
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -606,6 +612,9 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
promoteGrowthButton: {fileID: 730756546} promoteGrowthButton: {fileID: 730756546}
harvestPrefab: {fileID: 8524901521850801684, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
harvestInsertPosition: {fileID: 895001959}
plantLines: [] plantLines: []
centerPlants: centerPlants:
- {fileID: 1059216306} - {fileID: 1059216306}
@ -717,6 +726,37 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1759900418} m_PrefabInstance: {fileID: 1759900418}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &895001958
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 895001959}
m_Layer: 0
m_Name: harvestInsertPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &895001959
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 895001958}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: -2.88, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 371589523}
m_Father: {fileID: 1501215306}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &960603096 --- !u!1 &960603096
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -748,7 +788,7 @@ Transform:
- {fileID: 823569402} - {fileID: 823569402}
- {fileID: 1580351168} - {fileID: 1580351168}
m_Father: {fileID: 1501215306} m_Father: {fileID: 1501215306}
m_RootOrder: 3 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &998360037 --- !u!1 &998360037
GameObject: GameObject:
@ -1031,12 +1071,80 @@ Camera:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1226867710} m_PrefabInstance: {fileID: 1226867710}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!4 &1425125887 stripped --- !u!1001 &1442510375
Transform: PrefabInstance:
m_CorrespondingSourceObject: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c, m_ObjectHideFlags: 0
type: 3} serializedVersion: 2
m_PrefabInstance: {fileID: 8524901521126273002} m_Modification:
m_PrefabAsset: {fileID: 0} m_TransformParent: {fileID: 895001959}
m_Modifications:
- target: {fileID: 8524901521850801684, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_Name
value: corn_harvest
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801684, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e642499b3643dab4ba05b02e8c6bde1c, type: 3}
--- !u!1001 &1466604290 --- !u!1001 &1466604290
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1165,10 +1273,10 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1989990598} - {fileID: 1989990598}
- {fileID: 895001959}
- {fileID: 282523123} - {fileID: 282523123}
- {fileID: 149181931} - {fileID: 149181931}
- {fileID: 960603097} - {fileID: 960603097}
- {fileID: 1425125887}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1663,82 +1771,3 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 90ea860c4ec589d4aab99bfc127949f4, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 90ea860c4ec589d4aab99bfc127949f4, type: 3}
--- !u!1001 &8524901521126273002
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1501215306}
m_Modifications:
- target: {fileID: 8524901521850801684, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_Name
value: corn_harvest
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801684, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901521850801685, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8524901522036686285, guid: e642499b3643dab4ba05b02e8c6bde1c,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e642499b3643dab4ba05b02e8c6bde1c, type: 3}

View File

@ -10,6 +10,9 @@ using Random = UnityEngine.Random;
public class CornField : MonoBehaviour public class CornField : MonoBehaviour
{ {
[SerializeField] private Button promoteGrowthButton; [SerializeField] private Button promoteGrowthButton;
[SerializeField] private GameObject harvestPrefab;
[SerializeField] private Transform harvestInsertPosition;
[Space]
[SerializeField] private List<PlantLine> plantLines = new List<PlantLine>(); [SerializeField] private List<PlantLine> plantLines = new List<PlantLine>();
[SerializeField] private List<CornSeedling> centerPlants = new List<CornSeedling>(); [SerializeField] private List<CornSeedling> centerPlants = new List<CornSeedling>();
private readonly List<CornSeedling> plants = new List<CornSeedling>(); private readonly List<CornSeedling> plants = new List<CornSeedling>();
@ -46,15 +49,27 @@ public class CornField : MonoBehaviour
for (int i = 0; i < plants.Count; i++) for (int i = 0; i < plants.Count; i++)
{ {
var period = 30 + Random.Range(0, 15); var period = 15 + Random.Range(0, 15);
var ii = i; var ii = i;
plants[ii].SetSeedlingGene(settings[ii], period, SeedlingRank.Rank1); plants[ii].SetSeedlingGene(settings[ii], period, SeedlingRank.Rank1);
plants[ii].Harvested.Subscribe(_ => plants[ii].Harvested.Subscribe(_ =>
{ {
// 収穫 // 収穫
Debug.Log($"harvested");
var harvest = Instantiate(harvestPrefab, plants[ii].transform);
this.CallWaitForSeconds(.5f, () =>
{
var beginPos = harvest.transform.position;
this.CallLerp(.4f, f =>
{
harvest.transform.position = Vector3.Lerp(beginPos, harvestInsertPosition.position, f.EaseInCubic());
}, () =>
{
Destroy(harvest);
});
});
// 新しい苗 // 新しい苗
period = 30 + Random.Range(0, 15); period = 15 + Random.Range(0, 15);
settings[ii] = DateTime.Now; settings[ii] = DateTime.Now;
plants[ii].SetSeedlingGene(settings[ii], period, SeedlingRank.Rank1); plants[ii].SetSeedlingGene(settings[ii], period, SeedlingRank.Rank1);
}).AddTo(compositeDisposable); }).AddTo(compositeDisposable);

View File

@ -103,7 +103,6 @@ public class CornSeedling : MonoBehaviour, IPointerEnterHandler
private SeedlingStage GetCurrentStage() private SeedlingStage GetCurrentStage()
{ {
var elapsed = DateTime.Now.Subtract(beginTime).TotalSeconds / period; var elapsed = DateTime.Now.Subtract(beginTime).TotalSeconds / period;
Debug.Log($"{elapsed:F2}");
if (elapsed >= stage3End) if (elapsed >= stage3End)
{ {
return SeedlingStage.Stage4; return SeedlingStage.Stage4;