#```using System Collections
1 messages · Page 1 of 1 (latest)
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using HutongGames.PlayMaker;
[System.Serializable]
public class MainLoop : MonoBehaviour
{
// Start is called before the first frame update
public TMP_Text Seconds;
public TMP_Text SecondsTotal;
public Button button;
public DataManager gameData;
//public int TimeTotal;
//public int SecondsPerClick;
//public int TimePerTick;
public float TimeMath;
public int timeTotal;public int secondsPerClick;public int timePerTick;
void Awake()
{
}
void Start()
{
gameData = new DataManager();
gameData.Load();
button.onClick.AddListener(GatherSeconds);
timeTotal = (int) gameData.data.TimeTotal;
secondsPerClick = (int) gameData.data.SecondsPerClick;
timePerTick = (int) gameData.data.TimePerTick;
}
public void Update()
{
float MyTime;
MyTime = Time.deltaTime;
TimeMath = MyTime * timePerTick;
timeTotal += (int) TimeMath;
int SecondsGathered;
SecondsGathered = (int) timeTotal;
double SecondsGatheredRounded = Mathf.Round(SecondsGathered);
var SecondsGatheredString = SecondsGatheredRounded.ToString();
Seconds.SetText("Seconds Gathered: " + SecondsGatheredString);
}
void GatherSeconds(){
timeTotal += secondsPerClick;
}
}