전에도 ν•œλ²ˆ μ§ˆλ¬Έν–ˆμ—ˆλŠ”λ° 해결이 μ•ˆλΌμ„œ....

ν΄λ¦¬μ»€κ²Œμž„μ„ λ§Œλ“€κ³  μžˆλŠ”λ°, κ°•μ’Œλ₯Ό 보고 κ²Œμž„μ„ 끄고 λ‚˜μ€‘μ— λ‹€μ‹œ μ ‘μ†ν•˜λ©΄ λ§ˆλ‚˜(돈)이 더 μ¦κ°€ν•˜κ²Œ λ§Œλ“œλŠ” μ½”λ“œλ₯Ό μ§°μ–΄.


using System;
using System.Text;


이것듀 μΆ”κ°€ν•˜κ³  λ‚˜μ„œ μ½”λ“œλ₯Ό


//μ‹œκ°„μ„ 체크
DateTime GetLastPlayDate()
{
if(!PlayerPrefs.HasKey("Time"))
{
return DateTime.Now;
}
string timeBinaryInString = PlayerPrefs.GetString("Time");
long timeBinaryInLong = Convert.ToInt64(timeBinaryInString);

return DateTime.FromBinary(timeBinaryInLong);
}

void UpdateLastPlayDate()
{
PlayerPrefs.SetString("Time",DateTime.Now.ToBinary().ToString());
}


private void OnApplicationQuit()
{
UpdateLastPlayDate();
}

//κ²Œμž„μ„ λ§ˆμ§€λ§‰μœΌλ‘œ λˆμ§€ μ–Όλ§ˆλ‚˜ λλŠ”μ§€ 계산
public int timeAfterLastPlay
{
get
{
DateTime currentTime = DateTime.Now;
DateTime lastPlayDate = GetLastPlayDate();

return (int)currentTime.Subtract(lastPlayDate).TotalSeconds;
}
}
void Start()
{
//κ²Œμž„μ„ 끈 ν›„ μ €μž₯된 λ§ˆλ‚˜λŸ‰ κ³„μ‚°ν•˜κ³  λ”ν•˜κΈ°
mana += GetManaPerSec() * timeAfterLastPlay;
InvokeRepeating("UpdateLastPlayDate", 0f, 5f);
}

μ΄λ ‡κ²Œ μ§°μ–΄.

그리고 μ—¬κΈ° μžˆλŠ” manaλ‚˜ GetManaPerSec 같은건 였λ₯˜ μ•ˆλ‚¨. 그리고 λ””λ²„κ·Έλ‘œκ·Έλ‘œ λ„μ›Œλ³΄λ‹ˆκΉŒ OnApplicationQuit도 μž‘λ™μ΄ 잘 λ˜κ³ μžˆμ–΄.
근데도 κ²Œμž„ 끄고 ν•œμ°Έ 이따가 듀어가도 λ§ˆλ‚˜λŠ” ν•˜λ‚˜λ„ μ˜¬λΌμžˆμ§€κ°€ μ•Šλ”λΌ.... λŒ€μ²΄ 뭐가 문제인걸까? 버전이 λ‹¬λΌμ„œ λͺ…λ Ήμ–΄κ°€ λ‹€λ₯Έκ±΄μ§€ λ‚΄κ°€ λ­”κ°€ μ‚λ—ν•œκ±΄μ§€....