88 lines
2.3 KiB
C#
88 lines
2.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public static class Helpers
|
|
{
|
|
public static string numberToPosition(int val){
|
|
bool bypass =false;
|
|
string valString = val.ToString();
|
|
|
|
if(val> 10){
|
|
int lastTwoDigits = int.Parse(valString.Substring(valString.Length-2));
|
|
if(lastTwoDigits > 10 && lastTwoDigits < 20){
|
|
bypass = true;
|
|
}
|
|
}
|
|
|
|
if(bypass){
|
|
return $"{val}th";
|
|
}else{
|
|
int lastDigit = int.Parse(valString.Substring(valString.Length-1));
|
|
|
|
if(lastDigit == 1){
|
|
return $"{val}st";
|
|
}else if(lastDigit==2){
|
|
return $"{val}nd";
|
|
}else if(lastDigit==3){
|
|
return $"{val}rd";
|
|
}else{
|
|
return $"{val}th";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public static string secondsToTimerString(float timer){
|
|
int seconds = Mathf.FloorToInt(timer % 60);
|
|
int mins = Mathf.FloorToInt(timer/60f);
|
|
|
|
return $"{mins.ToString("00")}:{seconds.ToString("00")}";
|
|
}
|
|
|
|
public static string GetRandomCode(int length){
|
|
string pool = "qwertyuiopasdfghjklzxcvbnm1234567890";
|
|
string output = "";
|
|
for(int i=0; i < length; i++){
|
|
output += pool.ToCharArray()[UnityEngine.Random.Range(0,pool.Length)];
|
|
}
|
|
return output;
|
|
}
|
|
|
|
|
|
|
|
public static string[] battleTeamNames = {
|
|
"Shadow Reapers",
|
|
"Thunder Titans",
|
|
"Mystic Legends",
|
|
"Inferno Squadron",
|
|
"Frostbite Brigade",
|
|
"Solar Sentinels",
|
|
"Venom Vipers",
|
|
"Azure Knights",
|
|
"Ironclad Legion",
|
|
"Avalanche Alliance",
|
|
"Nova Vanguard",
|
|
"Storm Strikers",
|
|
"Phantom Phalanx",
|
|
"Dragon Fury",
|
|
"Avalanche Avengers",
|
|
"Crimson Commandos",
|
|
"Starfall Syndicate",
|
|
"Eclipse Elite",
|
|
"Celestial Crusaders",
|
|
"Rift Raiders"
|
|
};
|
|
|
|
public static string RandomTeamName {get{return battleTeamNames[UnityEngine.Random.Range(0,battleTeamNames.Length)];}}
|
|
|
|
}
|
|
|
|
|
|
public static class CustomExtensions{
|
|
public static void PurgeChildren(this Transform parent){
|
|
foreach(Transform child in parent.GetComponentsInChildren<Transform>()){
|
|
if(child == parent){continue;}
|
|
GameObject.Destroy(child.gameObject);
|
|
}
|
|
}
|
|
} |