This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float GreaterRandom(float[] lttRate) | |
{ | |
float total = 0; | |
foreach (float elem in lttRate) | |
{ | |
total += elem; | |
} | |
float randomPoint = Random.value * total; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GenericSingletonClass<T> : MonoBehaviour where T : Component | |
{ | |
private static T instance; | |
public static T Instance { | |
get { | |
if (instance == null) { | |
instance = FindObjectOfType<T> (); | |
if (instance == null) { | |
GameObject obj = new GameObject (); | |
obj.name = typeof(T).Name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: Create interface | |
// Bước 1: Tạo interface | |
public interface IHealth | |
{ | |
void TakeDamage(int damage); | |
} | |
// Step 2: Implement in Victim | |
// Bước 2: nhét nó vào mồm thằng Player (Victim) | |
public class Player : IHealth |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void GetStreamingAssetsPath(string fileName) | |
{ | |
#if UNITY_EDITOR | |
dbPath = string.Format(@"Assets/StreamingAssets/{0}", fileName); | |
#else | |
// check if file exists in Application.persistentDataPath | |
var filepath = string.Format("{0}/{1}", Application.persistentDataPath, fileName); | |
if (!File.Exists(filepath)) |