コーン吸収時のOrderinLayer変更/吸収時間の調整できるようにした/機械アニメーション対応
This commit is contained in:
parent
a61d9dc051
commit
1fd5cd7573
|
|
@ -1,5 +1,30 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1101 &-4416317230206967596
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Wait
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 7950701208893946301}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-1170333374138995968
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
|
|
@ -10,7 +35,8 @@ AnimatorState:
|
|||
m_Name: Machine_putOut
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_Transitions:
|
||||
- {fileID: -4416317230206967596}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
|
|
@ -34,7 +60,19 @@ AnimatorController:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: machine_a
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters: []
|
||||
m_AnimatorParameters:
|
||||
- m_Name: Wait
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
- m_Name: PutOut
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
|
|
@ -64,7 +102,8 @@ AnimatorStateMachine:
|
|||
m_State: {fileID: -1170333374138995968}
|
||||
m_Position: {x: 270, y: 180, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: 6777862587695130275}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
|
|
@ -73,6 +112,31 @@ AnimatorStateMachine:
|
|||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 7950701208893946301}
|
||||
--- !u!1101 &6777862587695130275
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: PutOut
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -1170333374138995968}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.75
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &7950701208893946301
|
||||
AnimatorState:
|
||||
serializedVersion: 5
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@ MonoBehaviour:
|
|||
harvestedPrefab: {fileID: 2111766585493962378, guid: d52f3514ed7fd461b8ab77a202c122c6,
|
||||
type: 3}
|
||||
thrust: 40
|
||||
machineAnimator: {fileID: 2138129849}
|
||||
--- !u!1001 &387414332
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1028,6 +1029,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: dadd48ac419c440959ddb48337e48d9f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
animationDuration: 0.3
|
||||
promoteGrowthButton: {fileID: 730756546}
|
||||
upgradeButton: {fileID: 1992043646}
|
||||
harvestPrefab: {fileID: 8524901521850801684, guid: e642499b3643dab4ba05b02e8c6bde1c,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ public enum CornFieldRank
|
|||
|
||||
public class CornField : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float animationDuration = .3f;
|
||||
[Space]
|
||||
[SerializeField] private Button promoteGrowthButton;
|
||||
[SerializeField] private Button upgradeButton;
|
||||
[SerializeField] private GameObject harvestPrefab;
|
||||
|
|
@ -33,7 +35,6 @@ public class CornField : MonoBehaviour
|
|||
private static readonly float harvestedDistance = .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;
|
||||
|
||||
|
|
@ -111,6 +112,7 @@ public class CornField : MonoBehaviour
|
|||
this.CallWaitForSeconds(animationStartDelay * Mathf.FloorToInt((float)j++ / animationDivisor), () =>
|
||||
{
|
||||
harvested.enabled = false;
|
||||
harvested.GetComponentInChildren<SpriteRenderer>().sortingOrder = 40;
|
||||
var beginPos = harvested.transform.position;
|
||||
this.CallLerp(animationDuration, f =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,10 +9,14 @@ using Random = UnityEngine.Random;
|
|||
|
||||
public class CornHarvester : MonoBehaviour
|
||||
{
|
||||
private static readonly int Wait = Animator.StringToHash("Wait");
|
||||
private static readonly int PutOut = Animator.StringToHash("PutOut");
|
||||
[SerializeField] private Transform harvestedSpawnTransform;
|
||||
[SerializeField] private GameObject harvestedPrefab;
|
||||
[SerializeField] private float thrust = 100f;
|
||||
[SerializeField] private Animator machineAnimator;
|
||||
private int maxCorn = 100; // 収穫演出で出るコーンの数を制限
|
||||
private int runningCount;
|
||||
|
||||
private readonly ReactiveProperty<int> count = new ReactiveProperty<int>(0);
|
||||
private readonly Subject<(int count, List<Collider2D> colliders)> finishHarvested = new Subject<(int count, List<Collider2D> colliders)>();
|
||||
|
|
@ -27,8 +31,15 @@ public class CornHarvester : MonoBehaviour
|
|||
.Pairwise()
|
||||
.Subscribe(x =>
|
||||
{
|
||||
machineAnimator.SetTrigger(PutOut);
|
||||
runningCount++;
|
||||
StartCoroutine(Harvested(Mathf.Min(maxCorn, x.Current - x.Previous), (list) =>
|
||||
{
|
||||
runningCount--;
|
||||
if (runningCount == 0)
|
||||
{
|
||||
machineAnimator.SetTrigger(Wait);
|
||||
}
|
||||
finishHarvested.OnNext((x.Current, list));
|
||||
}));
|
||||
}).AddTo(this);
|
||||
|
|
|
|||
Loading…
Reference in New Issue