バイト稼働処理追加

This commit is contained in:
kimura 2022-09-26 13:06:56 +09:00
parent 9781a126fb
commit aadd4e3f94
3 changed files with 95 additions and 6 deletions

View File

@ -27,6 +27,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5749156821563996369} - {fileID: 5749156821563996369}
m_Father: {fileID: 3667080857874733261} m_Father: {fileID: 3667080857874733261}
@ -77,6 +78,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 746832001} m_Father: {fileID: 746832001}
m_RootOrder: 0 m_RootOrder: 0
@ -98,6 +100,7 @@ GameObject:
- component: {fileID: 7743573513958854474} - component: {fileID: 7743573513958854474}
- component: {fileID: 7825871007626831899} - component: {fileID: 7825871007626831899}
- component: {fileID: 7297614168111566820} - component: {fileID: 7297614168111566820}
- component: {fileID: 2346543539818410046}
m_Layer: 0 m_Layer: 0
m_Name: DontDestroyObject m_Name: DontDestroyObject
m_TagString: Untagged m_TagString: Untagged
@ -115,6 +118,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 3320409656134683753} - {fileID: 3320409656134683753}
- {fileID: 746832001} - {fileID: 746832001}
@ -231,6 +235,20 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
maskPrefab: {fileID: 5131953687285211373, guid: 1c993e9707f1a4fada56020be27dde28, maskPrefab: {fileID: 5131953687285211373, guid: 1c993e9707f1a4fada56020be27dde28,
type: 3} 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 --- !u!1 &8739647597683206087
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -261,6 +279,7 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 2507803949588325386} - {fileID: 2507803949588325386}
m_Father: {fileID: 3667080857874733261} m_Father: {fileID: 3667080857874733261}
@ -421,15 +440,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 49f4b2509378048e7b7a5c6c0674be9f, type: 3} 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 --- !u!4 &2507803949588325386 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 6447040043672924312, guid: 49f4b2509378048e7b7a5c6c0674be9f, m_CorrespondingSourceObject: {fileID: 6447040043672924312, guid: 49f4b2509378048e7b7a5c6c0674be9f,
type: 3} type: 3}
m_PrefabInstance: {fileID: 8914311020904666258} m_PrefabInstance: {fileID: 8914311020904666258}
m_PrefabAsset: {fileID: 0} 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}

View File

@ -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<PartTimerManager>
{
[SerializeField] private int updateTiming = 2;
[SerializeField] private int saveTiming = 10;
private float saveElapsed;
private List<GameData> partTimerList;
private void Start()
{
/*
*
* 210(updateTimingとsaveTimingで変更可能)
* 99
*
*/
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<GameData> 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;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5bdcdf66f82b40ef9d716e19a72f1aad
timeCreated: 1663830554