autocookProgress追加
This commit is contained in:
		
							parent
							
								
									2687f553b5
								
							
						
					
					
						commit
						e1b0ca0990
					
				|  | @ -1380,7 +1380,7 @@ GameObject: | ||||||
|   serializedVersion: 6 |   serializedVersion: 6 | ||||||
|   m_Component: |   m_Component: | ||||||
|   - component: {fileID: 534902213} |   - component: {fileID: 534902213} | ||||||
|   - component: {fileID: 534902214} |   - component: {fileID: 534902215} | ||||||
|   m_Layer: 5 |   m_Layer: 5 | ||||||
|   m_Name: Window |   m_Name: Window | ||||||
|   m_TagString: Untagged |   m_TagString: Untagged | ||||||
|  | @ -1408,7 +1408,7 @@ RectTransform: | ||||||
|   m_AnchoredPosition: {x: 0, y: 200} |   m_AnchoredPosition: {x: 0, y: 200} | ||||||
|   m_SizeDelta: {x: 800, y: 570} |   m_SizeDelta: {x: 800, y: 570} | ||||||
|   m_Pivot: {x: 0.5, y: 0.5} |   m_Pivot: {x: 0.5, y: 0.5} | ||||||
| --- !u!114 &534902214 | --- !u!114 &534902215 | ||||||
| MonoBehaviour: | MonoBehaviour: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
|   m_CorrespondingSourceObject: {fileID: 0} |   m_CorrespondingSourceObject: {fileID: 0} | ||||||
|  | @ -1417,11 +1417,16 @@ MonoBehaviour: | ||||||
|   m_GameObject: {fileID: 534902212} |   m_GameObject: {fileID: 534902212} | ||||||
|   m_Enabled: 1 |   m_Enabled: 1 | ||||||
|   m_EditorHideFlags: 0 |   m_EditorHideFlags: 0 | ||||||
|   m_Script: {fileID: 11500000, guid: 7ac380b2956543a6a6b17c6150b154c0, type: 3} |   m_Script: {fileID: 11500000, guid: 3e8c4262dcaf40dcb5ece1963e468cdd, type: 3} | ||||||
|   m_Name:  |   m_Name:  | ||||||
|   m_EditorClassIdentifier:  |   m_EditorClassIdentifier:  | ||||||
|   backgroundAnimator: {fileID: 1090969545} |   backgroundAnimator: {fileID: 1090969545} | ||||||
|   closeButton: {fileID: 288409570} |   closeButton: {fileID: 288409570} | ||||||
|  |   progressText: {fileID: 1546017217} | ||||||
|  |   cookAnimator: {fileID: 156549606} | ||||||
|  |   progressImage: {fileID: 662005411} | ||||||
|  |   minProgressYPos: -56 | ||||||
|  |   maxProgressYPos: 9.5 | ||||||
| --- !u!1 &582907704 | --- !u!1 &582907704 | ||||||
| GameObject: | GameObject: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
|  | @ -1440,7 +1445,7 @@ GameObject: | ||||||
|   m_Icon: {fileID: 0} |   m_Icon: {fileID: 0} | ||||||
|   m_NavMeshLayer: 0 |   m_NavMeshLayer: 0 | ||||||
|   m_StaticEditorFlags: 0 |   m_StaticEditorFlags: 0 | ||||||
|   m_IsActive: 0 |   m_IsActive: 1 | ||||||
| --- !u!224 &582907705 | --- !u!224 &582907705 | ||||||
| RectTransform: | RectTransform: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
|  | @ -1473,7 +1478,7 @@ MonoBehaviour: | ||||||
|   m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} |   m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} | ||||||
|   m_Name:  |   m_Name:  | ||||||
|   m_EditorClassIdentifier:  |   m_EditorClassIdentifier:  | ||||||
|   m_ShowMaskGraphic: 1 |   m_ShowMaskGraphic: 0 | ||||||
| --- !u!114 &582907707 | --- !u!114 &582907707 | ||||||
| MonoBehaviour: | MonoBehaviour: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
|  | @ -1487,7 +1492,7 @@ MonoBehaviour: | ||||||
|   m_Name:  |   m_Name:  | ||||||
|   m_EditorClassIdentifier:  |   m_EditorClassIdentifier:  | ||||||
|   m_Material: {fileID: 0} |   m_Material: {fileID: 0} | ||||||
|   m_Color: {r: 1, g: 1, b: 1, a: 0.003921569} |   m_Color: {r: 1, g: 1, b: 1, a: 1} | ||||||
|   m_RaycastTarget: 1 |   m_RaycastTarget: 1 | ||||||
|   m_Maskable: 1 |   m_Maskable: 1 | ||||||
|   m_OnCullStateChanged: |   m_OnCullStateChanged: | ||||||
|  | @ -1804,7 +1809,7 @@ RectTransform: | ||||||
|   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} | ||||||
|   m_AnchorMin: {x: 0.5, y: 0.5} |   m_AnchorMin: {x: 0.5, y: 0.5} | ||||||
|   m_AnchorMax: {x: 0.5, y: 0.5} |   m_AnchorMax: {x: 0.5, y: 0.5} | ||||||
|   m_AnchoredPosition: {x: 0, y: 9.5} |   m_AnchoredPosition: {x: 0, y: 6.2} | ||||||
|   m_SizeDelta: {x: 734, y: 608} |   m_SizeDelta: {x: 734, y: 608} | ||||||
|   m_Pivot: {x: 0.5, y: 0.5} |   m_Pivot: {x: 0.5, y: 0.5} | ||||||
| --- !u!114 &662005412 | --- !u!114 &662005412 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,77 @@ | ||||||
|  | using System; | ||||||
|  | using UniRx; | ||||||
|  | using UnityEngine; | ||||||
|  | using UnityEngine.UI; | ||||||
|  | 
 | ||||||
|  | namespace MyGame.Scenes.Main.Scripts | ||||||
|  | { | ||||||
|  |     public class AutoCookProgressView : MonoBehaviour | ||||||
|  |     { | ||||||
|  |         private static readonly string CallbackTag = "AutoCoolProgressCallback"; | ||||||
|  |         private static readonly int OpenTrigger = Animator.StringToHash("OpenTrigger"); | ||||||
|  |         private static readonly int CloseTrigger = Animator.StringToHash("CloseTrigger"); | ||||||
|  | 
 | ||||||
|  |         [SerializeField] private Animator backgroundAnimator; | ||||||
|  |         [SerializeField] private Button closeButton; | ||||||
|  |          | ||||||
|  |         [SerializeField] private Text progressText; | ||||||
|  |         [SerializeField] private Animator cookAnimator; | ||||||
|  |         [SerializeField] private Transform progressImage; | ||||||
|  |         [SerializeField] private float minProgressYPos; | ||||||
|  |         [SerializeField] private float maxProgressYPos; | ||||||
|  |          | ||||||
|  |         private IDisposable timerDisposable; | ||||||
|  | 
 | ||||||
|  |         private void Start() | ||||||
|  |         { | ||||||
|  |             closeButton.OnClickAsObservable().Take(1).Subscribe(_ => | ||||||
|  |             { | ||||||
|  |                 LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke(); | ||||||
|  |                 LocalCacheManager.Remove(CallbackTag); | ||||||
|  |                 transform.parent.SetLocalScale(0); | ||||||
|  |                 backgroundAnimator.SetTrigger(CloseTrigger); | ||||||
|  |                 this.CallWaitForSeconds(.25f, () => | ||||||
|  |                 { | ||||||
|  |                     TransitionManager.Instance.UnloadScene(GameScenes.AutomaticCookingConfirmation); | ||||||
|  |                 }); | ||||||
|  |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|  |             var remainigTime = 0; | ||||||
|  |             ResetTimer((int) DateTime.FromBinary(remainigTime).Subtract(DateTime.UtcNow).TotalSeconds); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void SetProgressImage(float value) | ||||||
|  |         { | ||||||
|  |             var yPos = Mathf.Lerp(minProgressYPos, maxProgressYPos, value); | ||||||
|  |             progressImage.localPosition = progressImage.localPosition.SetY(yPos); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void SetTime(int seconds) | ||||||
|  |         { | ||||||
|  |             progressText.text = $"残り時間:{TimeSpan.FromSeconds(seconds):g}"; | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         public void ResetTimer(int time) | ||||||
|  |         { | ||||||
|  |             // タイマーの更新処理 | ||||||
|  |             timerDisposable?.Dispose(); | ||||||
|  |             SetTime(time); | ||||||
|  |             timerDisposable = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) | ||||||
|  |                 .Select(x => (int)(time - x)) | ||||||
|  |                 .TakeWhile(x => x > 0) | ||||||
|  |                 .Subscribe(x => | ||||||
|  |                 { | ||||||
|  |                     SetTime(x); | ||||||
|  |                     SetProgressImage(1f - (float)x/time); | ||||||
|  |                 }, () => | ||||||
|  |                 { | ||||||
|  |                     cookAnimator.enabled = false; | ||||||
|  |                 }).AddTo(this); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         public static void ShowDialog(Action onClose = null){ | ||||||
|  |             LocalCacheManager.Save(CallbackTag, onClose); | ||||||
|  |             TransitionManager.Instance.LoadSceneAdditive(GameScenes.AutomaticCookingConfirmation); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | fileFormatVersion: 2 | ||||||
|  | guid: 3e8c4262dcaf40dcb5ece1963e468cdd | ||||||
|  | timeCreated: 1649824003 | ||||||
		Loading…
	
		Reference in New Issue