- Home /
3 star time base system
hello, friend once again, I need your guidance. my typing game is almost near completion but there is a problem with my score system. the score is how little time you take to complete the level, 3 stars for more than 100, 2 stars for less than 100. the problem is basically, the star doesn't appear anywhere when the game ends. I used this video as my template but change how we get the score since this is a typing game and not a platformer. https://www.youtube.com/watch?v=H7M8sr6PsXw&t=459s&ab_channel=FastSolution here are my codes and If you have any suggestions please comment below. countdown timer and score
using System.Collections;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public class countdown : MonoBehaviour
{
public float timeLeft = 150.0f;
public Text startText; // used for showing countdown from 3, 2, 1
public GameObject[] stars;
public void Update()
{
timeLeft -= Time.deltaTime;
startText.text = (timeLeft).ToString("0");
if (timeLeft > 100)
{
print("alpha");
print(timeLeft);
}
else if (timeLeft < 100 && timeLeft > 51)
{
print("beta");
print(timeLeft);
}
else if (timeLeft < 51 && timeLeft >= 1)
{
print("gamma");
print(timeLeft);
}
else
{
print("delta");
print(timeLeft);
SceneManager.LoadScene("gameover");
}
//display(timeleft)
}
public void score()
{
if (timeLeft > 100)
{
//alpha
stars[0].SetActive(true);
stars[1].SetActive(true);
stars[2].SetActive(true);
}
else if (timeLeft < 100 && timeLeft > 51)
{
//beta
stars[0].SetActive(true);
stars[1].SetActive(true);
}
else if (timeLeft < 51 && timeLeft >= 1)
{
//gamma
stars[0].SetActive(true);
}
else
{
//delta
}
//display(timeleft)
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class uihandler : MonoBehaviour
{
public GameObject scorecanvas;
public Text LevelStatus;
public Text scoreText;
public static uihandler instance;
void Awake()
{
if (instance == null)
instance = this;
}
public void Showscorecanvas(string status, string scores)
{
GetComponent<countdown>().score();
scorecanvas.SetActive(true);
LevelStatus.text = status;
scoreText.text = scores;
}
}
wordbank for activate the score canvas
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.SceneManagement;
public class WordBank : MonoBehaviour
{
public GameObject scoreobject;
public static bool GameIsDone = false;
private List<string> originalWords = new List<string>()
{
" ", "cake" , "you" , "refugees" ,"school" ,"delete" ,"elevation","front","marry","fox", "hound", "brain","boss", "united","dreamer","money","harmony","harm","logical","kingdom","victory","original", "photography","history","decision","also","europe","knight" ,"king", "queen"
};
private List<string> workingWords = new List<string>();
private void Awake()
{
workingWords.AddRange(originalWords);
ConvertToLower(workingWords);
}
private void ConvertToLower(List<string> list)
{
for (int i = 0; i < list.Count; i++)
list[i] = list[i].ToLower();
}
public string GetWord()
{
string newWord = string.Empty;
if (workingWords.Count != 0)
{
newWord = workingWords.Last();
workingWords.Remove(newWord);
Time.timeScale = 1f;
}
return newWord;
}
public string Getscene()
{
string newWord = string.Empty;
if (workingWords.Count == 0)
{
PlayerPrefs.SetInt("levelAt", 2);
scoreobject.SetActive(true);
Time.timeScale = 0f;
GameIsDone = true;
}
return newWord;
}
}
I fixed your code formatting but you shouldnt be dumping huge code examples into your answers and expecting people to fix your problems.
If they are really necessary try using a 3rd party service like gists or pastebin and linking to them, or to the repo directly.
Please try to keep your questions atomic and succinct