Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Any level ideas?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class TimeFormatter : MonoBehaviour
{
    public static string FormattedText(float seconds)
    {
        if(seconds <= 0)
        {
            return "00:00";
        }
        string formattedText = "";
        string formattedHours = "";
        string formattedMins = "";
        string formattedSecs = "00";
        if(seconds == 0)
        {
            return "00:00";
        }
        if(seconds % 60 != 0)
        {
            float secs = seconds % 60;
            if(secs >= 10)
            {
                formattedSecs = Math.Truncate(secs).ToString();
            }
            else
            {
                formattedSecs = "0" + Math.Truncate(secs).ToString();
            }
        }
        if(seconds % 3600 != 0)
        {
            float cleanMins = seconds % 3600;
            float mins = cleanMins / 60;
            if(mins >= 10)
            {
                formattedMins = Math.Truncate(mins).ToString();
            }
            else
            {
                formattedMins = "0" + Math.Truncate(mins).ToString();
            }
        }
        if(seconds >= 3600)
        {
            float hours = seconds / 3600;
            formattedHours = Math.Truncate(hours).ToString();
        }
        if(formattedHours != "")
        {
            formattedText = formattedHours + ":" + formattedMins + ":" + formattedSecs;
        }
        else
        {
            formattedText = formattedMins + ":" + formattedSecs;
        }
        return formattedText;
    }
}

So I tried making a timer that saves the best time. Timer starts when you are loaded into the scene and stops when you touch a portal object. And the time which is the best is going in to the Main menu. For level1. 

Nice! Were you able to make it work ?

Nope 😅. My skils and Ai skils didnt get it to work. The time saving and loading didn't work.