リワードタイマーのフォアグラウンド復帰時対応
This commit is contained in:
		
							parent
							
								
									0e40f526da
								
							
						
					
					
						commit
						079d45c6b6
					
				|  | @ -5,7 +5,6 @@ using System.Linq; | ||||||
| using MyGame.Scenes.CornField.Scripts; | using MyGame.Scenes.CornField.Scripts; | ||||||
| using MyGame.Scripts; | using MyGame.Scripts; | ||||||
| using UniRx; | using UniRx; | ||||||
| using UniRx.Triggers; |  | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| using UnityEngine.UI; | using UnityEngine.UI; | ||||||
| using Random = UnityEngine.Random; | using Random = UnityEngine.Random; | ||||||
|  | @ -175,18 +174,27 @@ public class CornField : MonoBehaviour | ||||||
|         }).AddTo(this); |         }).AddTo(this); | ||||||
|          |          | ||||||
|         // 残り時間表示 |         // 残り時間表示 | ||||||
|  |         IDisposable timerDisposable = null; | ||||||
|         resetFertilizerTimer |         resetFertilizerTimer | ||||||
|             .Subscribe(x => |             .Subscribe(x => | ||||||
|             { |             { | ||||||
|  |                 timerDisposable?.Dispose(); | ||||||
|                 fertilizerButtonView.SetButtonActive(x <= 0); |                 fertilizerButtonView.SetButtonActive(x <= 0); | ||||||
|                 fertilizerButtonView.SetTime(x); |                 fertilizerButtonView.SetTime(x); | ||||||
|                 SetFertilizerTimer(x).AddTo(this); |                 timerDisposable = SetFertilizerTimer(x).AddTo(this); | ||||||
|             }).AddTo(this); |             }).AddTo(this); | ||||||
|          |          | ||||||
|         // 残り時間を取得 |         // 残り時間を取得 | ||||||
|         var remaining = (int)DateTime.FromBinary(gameData.fertilizerTime).Subtract(DateTime.UtcNow).TotalSeconds; |         var remaining = (int)DateTime.FromBinary(gameData.fertilizerTime).Subtract(DateTime.UtcNow).TotalSeconds; | ||||||
|         resetFertilizerTimer.OnNext(remaining); |         resetFertilizerTimer.OnNext(remaining); | ||||||
| 
 | 
 | ||||||
|  |         Observable.EveryApplicationPause() | ||||||
|  |             .Where(pause => !pause) | ||||||
|  |             .Subscribe(_ => | ||||||
|  |             { | ||||||
|  |                 resetFertilizerTimer.OnNext((int) DateTime.FromBinary(gameData.fertilizerTime).Subtract(DateTime.UtcNow).TotalSeconds); | ||||||
|  |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|         // 収穫カウンター+吸収演出 |         // 収穫カウンター+吸収演出 | ||||||
|         cornHarvester.FinishHarvested |         cornHarvester.FinishHarvested | ||||||
|             .Scan((list, newList) => (newList.count, list.colliders.Concat(newList.colliders).ToList())) |             .Scan((list, newList) => (newList.count, list.colliders.Concat(newList.colliders).ToList())) | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ public class MissionManager : MonoBehaviour | ||||||
|             timeLimitText.text = String.Format(TimeFormat, 0, 0, 0); |             timeLimitText.text = String.Format(TimeFormat, 0, 0, 0); | ||||||
|         } |         } | ||||||
|         Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) |         Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) | ||||||
|             .Select(x => limitTime.Add(TimeSpan.FromSeconds(-x))) |             .Select(x => gameData.GetDailyMissionLimitTime()) | ||||||
|             .TakeWhile(x => x.TotalSeconds > 0) |             .TakeWhile(x => x.TotalSeconds > 0) | ||||||
|             .Subscribe(x => |             .Subscribe(x => | ||||||
|             { |             { | ||||||
|  |  | ||||||
|  | @ -102,12 +102,14 @@ public class MarketManager : MonoBehaviour | ||||||
|             }); |             }); | ||||||
|         }).AddTo(this); |         }).AddTo(this); | ||||||
|          |          | ||||||
|  |         IDisposable timerDisposable = null; | ||||||
|         resetRefreshTimer |         resetRefreshTimer | ||||||
|             .Subscribe(time => |             .Subscribe(time => | ||||||
|             { |             { | ||||||
|  |                 timerDisposable?.Dispose(); | ||||||
|                 rewardButtonView.SetButtonActive(time <= 0); |                 rewardButtonView.SetButtonActive(time <= 0); | ||||||
|                 rewardButtonView.SetTime(time); |                 rewardButtonView.SetTime(time); | ||||||
|                 Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) |                 timerDisposable = Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(1f)) | ||||||
|                     .Select(x => (int)(time - x)) |                     .Select(x => (int)(time - x)) | ||||||
|                     .TakeWhile(x => x > 0) |                     .TakeWhile(x => x > 0) | ||||||
|                     .Subscribe(x => |                     .Subscribe(x => | ||||||
|  | @ -122,6 +124,13 @@ public class MarketManager : MonoBehaviour | ||||||
|         var remaining = (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds; |         var remaining = (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds; | ||||||
|         resetRefreshTimer.OnNext(remaining); |         resetRefreshTimer.OnNext(remaining); | ||||||
|          |          | ||||||
|  |         Observable.EveryApplicationPause() | ||||||
|  |             .Where(pause => !pause) | ||||||
|  |             .Subscribe(_ => | ||||||
|  |             { | ||||||
|  |                 resetRefreshTimer.OnNext((int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds); | ||||||
|  |             }).AddTo(this); | ||||||
|  | 
 | ||||||
|         market.IsPromotion.Subscribe(active => |         market.IsPromotion.Subscribe(active => | ||||||
|         { |         { | ||||||
|             if (active) |             if (active) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue