dronkowitz

SaveSlot.cs

Jul 14th, 2021 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using UnityEngine.UI;
  6. public class SaveSlot : MonoBehaviour
  7. {
  8.     public TMP_Text timeText, livesText, scoreText, emeraldsText;
  9.     public Image teamImage;
  10.     int slotNumber = 0;
  11.  
  12.     public void SetSlot(int slot)
  13.     {
  14.         if (SaveLoad.Load(slot))
  15.         {
  16.             slotNumber = slot;
  17.  
  18.             SaveData data = SaveLoad.SavedGame;
  19.             float minutes = Mathf.Floor(data.TotalTime / 60);
  20.             float seconds = (data.TotalTime % 60);
  21.             float hours = Mathf.Floor(data.TotalTime / 3600);
  22.             float miliseconds = data.TotalTime - Mathf.Floor(data.TotalTime);
  23.             miliseconds = Mathf.RoundToInt(miliseconds * 100);
  24.  
  25.             if (hours > 0)
  26.             {
  27.                 timeText.text = hours.ToString("00") + minutes.ToString("00") + seconds.ToString("00");
  28.  
  29.             }
  30.             else
  31.             {
  32.                 timeText.text = minutes.ToString("00") + seconds.ToString("00") + miliseconds.ToString("00");
  33.             }
  34.  
  35.             livesText.text = data.Lives.ToString("000");
  36.             scoreText.text = data.Score.ToString("000");
  37.             emeraldsText.text = data.EmeraldsCount.ToString("0");
  38.  
  39.         }
  40.         else GetComponent<Button>().interactable = false;
  41.     }
  42.  
  43.     public void SelectSlot()
  44.     {
  45.  
  46.     }
  47. }
  48.  
Add Comment
Please, Sign In to add comment