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