When following simle driving coure evreything was going good and I even comleted the challange nathan gave on my own with minor mistake, But my energy doesnot seem to fill up, after that I followed nathan step by step and copied his code but it still seems my energy is not chaing from 0 to 5 after a minute
My code is attached along wth nathan, Not ure what I did wrong
I changed the AddMinute to number to test it and my score script is score Handeler
Compared it with 2 diffrent text compration tool and couldt find anything
code is also attached here
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.SocialPlatforms.Impl;
public class MainManu : MonoBehaviour
{
[SerializeField] private TMP_Text highscoreText;
[SerializeField] private TMP_Text energyText;
[SerializeField] private int maxEnergy;
[SerializeField] private int energyRechargeDuration;
private int energy;
private const string EnergyKey = "Energy";
private const string EnergyReadyKey = "EnergyReady";
private void Start()
{
int highScore = PlayerPrefs.GetInt(Scorehandeler.HighScoreKey, 0);
highscoreText.text = $"High Score: {highScore}";
energy = PlayerPrefs.GetInt(EnergyKey, maxEnergy);
if (energy == 0)
{
string energyReadyString = PlayerPrefs.GetString(EnergyReadyKey, string.Empty);
if (energyReadyString == string.Empty) { return; }
DateTime energyReady = DateTime.Parse(energyReadyString);
if (DateTime.Now > energyReady)
{
energy = maxEnergy;
PlayerPrefs.SetInt(EnergyKey, energy);
}
}
energyText.text = $"Play ({energy})";
}
public void Play()
{
if (energy < 1) { return; }
{
energy--;
PlayerPrefs.SetInt(EnergyKey, energy);
if (energy == 0)
{
DateTime energyReady = DateTime.Now.AddMinutes(1);
PlayerPrefs.SetString(EnergyReadyKey, energyReady.ToString());
}
SceneManager.LoadScene("Scene_Game");
}
}
}