diff --git a/popcorn/Assets/MyGame/Resources/DontDestroyObject.prefab b/popcorn/Assets/MyGame/Resources/DontDestroyObject.prefab index bca45d96..dd90047b 100644 --- a/popcorn/Assets/MyGame/Resources/DontDestroyObject.prefab +++ b/popcorn/Assets/MyGame/Resources/DontDestroyObject.prefab @@ -27,6 +27,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5749156821563996369} m_Father: {fileID: 3667080857874733261} @@ -77,6 +78,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 746832001} m_RootOrder: 0 @@ -98,6 +100,7 @@ GameObject: - component: {fileID: 7743573513958854474} - component: {fileID: 7825871007626831899} - component: {fileID: 7297614168111566820} + - component: {fileID: 2346543539818410046} m_Layer: 0 m_Name: DontDestroyObject m_TagString: Untagged @@ -115,6 +118,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 3320409656134683753} - {fileID: 746832001} @@ -231,6 +235,20 @@ MonoBehaviour: m_EditorClassIdentifier: maskPrefab: {fileID: 5131953687285211373, guid: 1c993e9707f1a4fada56020be27dde28, type: 3} +--- !u!114 &2346543539818410046 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3459593390050872226} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5bdcdf66f82b40ef9d716e19a72f1aad, type: 3} + m_Name: + m_EditorClassIdentifier: + updateTiming: 2 + saveTiming: 10 --- !u!1 &8739647597683206087 GameObject: m_ObjectHideFlags: 0 @@ -261,6 +279,7 @@ Transform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 2507803949588325386} m_Father: {fileID: 3667080857874733261} @@ -421,15 +440,15 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 49f4b2509378048e7b7a5c6c0674be9f, type: 3} ---- !u!1 &8461447348824790522 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 1069859090919850344, guid: 49f4b2509378048e7b7a5c6c0674be9f, - type: 3} - m_PrefabInstance: {fileID: 8914311020904666258} - m_PrefabAsset: {fileID: 0} --- !u!4 &2507803949588325386 stripped Transform: m_CorrespondingSourceObject: {fileID: 6447040043672924312, guid: 49f4b2509378048e7b7a5c6c0674be9f, type: 3} m_PrefabInstance: {fileID: 8914311020904666258} m_PrefabAsset: {fileID: 0} +--- !u!1 &8461447348824790522 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1069859090919850344, guid: 49f4b2509378048e7b7a5c6c0674be9f, + type: 3} + m_PrefabInstance: {fileID: 8914311020904666258} + m_PrefabAsset: {fileID: 0} diff --git a/popcorn/Assets/MyGame/Scripts/PartTimerManager.cs b/popcorn/Assets/MyGame/Scripts/PartTimerManager.cs new file mode 100644 index 00000000..f94dd7ea --- /dev/null +++ b/popcorn/Assets/MyGame/Scripts/PartTimerManager.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace MyGame.Scripts +{ + public class PartTimerManager : SingletonMonoBehaviour + { + [SerializeField] private int updateTiming = 2; + [SerializeField] private int saveTiming = 10; + private float saveElapsed; + private List partTimerList; + private void Start() + { + /* + * 起動中の時間=バイト稼働時間とする仕組み + * データ更新は2秒保存は10秒ごと(updateTimingとsaveTimingで変更可能) + * 欠点、9秒時点でプレイヤーがタスクキルすると9秒間のバイト加算が無くなる(その間に他のプレイ要素でセーブが入れば加算される + * 受け取りが発生した場合、その都市のみ経過時間をリセット + */ + partTimerList = GetPartTimerList(); + Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(updateTiming)).Subscribe(_ => + { + foreach (var cityGameData in partTimerList) + { + // 兄弟が在庫を抱えている場合バイトは稼働しない + if (cityGameData.ShopStock.Count > 0) + { + continue; + } + cityGameData.PartTimerElapsed += updateTiming; + } + + saveElapsed += updateTiming; + if (saveTiming < saveElapsed) + { + return; + } + GameDataManager.SaveGameData(); + saveElapsed = 0f; + }).AddTo(this); + } + + public void UpdateList() + { + partTimerList = GetPartTimerList(); + } + + private static List GetPartTimerList() + { + var newList = GameDataManager.GameData.CityGameDataDict.Values.Where(data => data.IsFundingCompleted).ToList(); + if (newList.Count > 0) + { + newList.Add(GameDataManager.GameData); + } + return newList; + } + + public void ResetTimer() + { + saveElapsed = 0f; + } + } +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scripts/PartTimerManager.cs.meta b/popcorn/Assets/MyGame/Scripts/PartTimerManager.cs.meta new file mode 100644 index 00000000..7ad517bd --- /dev/null +++ b/popcorn/Assets/MyGame/Scripts/PartTimerManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5bdcdf66f82b40ef9d716e19a72f1aad +timeCreated: 1663830554 \ No newline at end of file