Added experience gain while idle

- Might be off, could understand radians better
- Add popup for displaying idle exp gained
This commit is contained in:
Shaun Reed 2017-09-03 21:46:47 -04:00
parent 90948610cd
commit ea55db656d
2 changed files with 40 additions and 9 deletions

View File

@ -18,19 +18,15 @@ public class GameManager : MonoBehaviour {
public float requirement;
public float speed;
public float increment;
public DateTime currentTime;
}
// Update is called once per frame
void Update () {
// Update is called once per frame
void Update () {
}
// Use this for initialization
void Start () {
Load();
}
void OnEnable()
{
Load();
@ -63,6 +59,7 @@ public class GameManager : MonoBehaviour {
data.requirement = currentRequirement;
data.speed = currentSpeed;
data.increment = currentIncrement;
data.currentTime = DateTime.Now;
bf.Serialize(file, data);
file.Close();
@ -83,7 +80,42 @@ public class GameManager : MonoBehaviour {
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentLevel = data.level;
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentExp = data.experience;
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentRequirement = data.requirement;
DateTime loadTime = DateTime.Now;
int secondsPassed = GetIdleRewards(data.currentTime, loadTime);
float radianSpeed = GameObject.FindGameObjectWithTag("Player").GetComponent<SpinningCube>().currentSpeed * Mathf.Deg2Rad;
float idleExp = radianSpeed * secondsPassed;
GameObject.FindGameObjectWithTag("ExpGained").GetComponent<ExperienceBar>().currentExp += idleExp;
Debug.Log("Loaded");
Debug.Log("idleExp: " + idleExp);
}
}
public int GetIdleRewards(DateTime saveTime, DateTime loadTime)
{
int daysPassed = 0;
int hoursPassed = 0;
int minutesPassed = 0;
int secondsPassed = 0;
for (int monthSaved = saveTime.Month; monthSaved < loadTime.Month; ++monthSaved)
{
daysPassed += 30;
}
daysPassed += loadTime.Day - saveTime.Day;
hoursPassed = daysPassed * 24;
hoursPassed += loadTime.Hour - saveTime.Hour;
minutesPassed = hoursPassed * 60;
minutesPassed += loadTime.Minute - saveTime.Minute;
secondsPassed = minutesPassed * 60;
secondsPassed += loadTime.Second - saveTime.Second;
Debug.Log("Seconds Passed: " + secondsPassed);
return secondsPassed;
}
}

View File

@ -8,7 +8,6 @@ public class SpinningCube : MonoBehaviour
public float currentSpeed = 20f;
public float currentIncrement = 10f;
private string RotationDirection = "Up";
private Vector3 m_RotationDirection = Vector3.up;
private Vector3 rotationOrigin;