update AutoCookProgressView.cs
This commit is contained in:
		
							parent
							
								
									013d922b13
								
							
						
					
					
						commit
						732d59b660
					
				|  | @ -1,4 +1,5 @@ | ||||||
| using System; | using System; | ||||||
|  | using System.Linq; | ||||||
| using UniRx; | using UniRx; | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| using UnityEngine.UI; | using UnityEngine.UI; | ||||||
|  | @ -24,6 +25,11 @@ namespace MyGame.Scenes.Main.Scripts | ||||||
| 
 | 
 | ||||||
|         private void Start() |         private void Start() | ||||||
|         { |         { | ||||||
|  |             var gameData = GameDataManager.GameData; | ||||||
|  |             var autoCookDataList = SpreadsheetDataManager.Instance.GetBaseDataList<AutoCookData>(Const.AutoCookDataSheet); | ||||||
|  |             var autoCookData = autoCookDataList.First(data => data.level == gameData.AutoCookLevel); | ||||||
|  |             var remainingTime = DateTime.FromBinary(gameData.AutoCookFinishTime).Subtract(DateTime.UtcNow); | ||||||
|  | 
 | ||||||
|             closeButton.OnClickAsObservable().Take(1).Subscribe(_ => |             closeButton.OnClickAsObservable().Take(1).Subscribe(_ => | ||||||
|             { |             { | ||||||
|                 LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke(); |                 LocalCacheManager.Load<Action>(CallbackTag, null)?.Invoke(); | ||||||
|  | @ -36,8 +42,7 @@ namespace MyGame.Scenes.Main.Scripts | ||||||
|                 }); |                 }); | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
| 
 | 
 | ||||||
|             var remainigTime = 0; |             ResetTimer((int) remainingTime.TotalSeconds, autoCookData.duration); | ||||||
|             ResetTimer((int) DateTime.FromBinary(remainigTime).Subtract(DateTime.UtcNow).TotalSeconds); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private void SetProgressImage(float value) |         private void SetProgressImage(float value) | ||||||
|  | @ -51,18 +56,18 @@ namespace MyGame.Scenes.Main.Scripts | ||||||
|             progressText.text = $"残り時間:{TimeSpan.FromSeconds(seconds):g}"; |             progressText.text = $"残り時間:{TimeSpan.FromSeconds(seconds):g}"; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         public void ResetTimer(int time) |         private void ResetTimer(int remainingTime, int duration) | ||||||
|         { |         { | ||||||
|             // タイマーの更新処理 |             // タイマーの更新処理 | ||||||
|             timerDisposable?.Dispose(); |             timerDisposable?.Dispose(); | ||||||
|             SetTime(time); |             SetTime(remainingTime); | ||||||
|             timerDisposable = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) |             timerDisposable = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) | ||||||
|                 .Select(x => (int)(time - x)) |                 .Select(x => (int)(remainingTime - x)) | ||||||
|                 .TakeWhile(x => x > 0) |                 .TakeWhile(x => x > 0) | ||||||
|                 .Subscribe(x => |                 .Subscribe(x => | ||||||
|                 { |                 { | ||||||
|                     SetTime(x); |                     SetTime(x); | ||||||
|                     SetProgressImage(1f - (float)x/time); |                     SetProgressImage(1f - (float)x/duration); | ||||||
|                 }, () => |                 }, () => | ||||||
|                 { |                 { | ||||||
|                     cookAnimator.enabled = false; |                     cookAnimator.enabled = false; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue