Leaderboard show top 50
This commit is contained in:
@@ -20,7 +20,8 @@ public class BuildingData : ScriptableObject
|
||||
public static class CollectablesData{
|
||||
public enum ResourceType{
|
||||
Metal,
|
||||
Oxygen
|
||||
Oxygen,
|
||||
Gold
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@ public class CollectBtn : MonoBehaviour
|
||||
DBmanager.SetMetal(DBmanager.Metal + (int)collectableAmount);
|
||||
break;
|
||||
|
||||
case CollectablesData.ResourceType.Gold:
|
||||
DBmanager.SetCoins(DBmanager.Coins + (int)collectableAmount);
|
||||
break;
|
||||
|
||||
// case CollectablesData.ResourceType.Oxygen:
|
||||
// DBmanager.SetOxygen(DBmanager.Trophies + (int)collectableAmount);
|
||||
// break;
|
||||
|
||||
@@ -16,7 +16,7 @@ public class GameManager : MonoBehaviour
|
||||
public TMP_Text[] gemsTxt;
|
||||
public TMP_Text metalTxt;
|
||||
// public TMP_Text oxygenTxt;
|
||||
public TMP_Text trophiesTxt;
|
||||
public TMP_Text[] trophiesTxts;
|
||||
public TMP_Text[] levelTxts;
|
||||
public Slider[] levelSliders;
|
||||
public TMP_Text[] levelProgressTxts;
|
||||
@@ -85,7 +85,9 @@ public class GameManager : MonoBehaviour
|
||||
txt.text = DBmanager.Gems.ToString();
|
||||
}
|
||||
metalTxt.text = DBmanager.Metal.ToString();
|
||||
trophiesTxt.text = DBmanager.Trophies.ToString();
|
||||
foreach(TMP_Text trophiesTxt in trophiesTxts){
|
||||
trophiesTxt.text = DBmanager.Trophies.ToString();
|
||||
}
|
||||
// oxygenTxt.text = DBmanager.Trophies.ToString();
|
||||
foreach (TMP_Text levelTxt in levelTxts)
|
||||
{
|
||||
|
||||
@@ -5,16 +5,24 @@ using UnityEngine;
|
||||
public class GlobalLeaderboard : MonoBehaviour
|
||||
{
|
||||
public Transform leaderboardItemsParent;
|
||||
public LeaderboardItem template;
|
||||
public async void Show(){
|
||||
List<LeaderboardUserData> leaderboard = await DBmanager.GetLeaderboard();
|
||||
for(int i =0; i < leaderboardItemsParent.childCount; i++){
|
||||
if(i > leaderboard.Count-1){
|
||||
leaderboardItemsParent.GetChild(i).gameObject.SetActive(false);
|
||||
template.gameObject.SetActive(true);
|
||||
//Clear currentItems
|
||||
for(int i=0; i < leaderboardItemsParent.childCount; i++){
|
||||
if(leaderboardItemsParent.GetChild(i) == template.transform){
|
||||
continue;
|
||||
}
|
||||
leaderboardItemsParent.GetChild(i).gameObject.SetActive(true);
|
||||
leaderboardItemsParent.GetChild(i).GetComponent<LeaderboardItem>().Set(leaderboard[i]);
|
||||
|
||||
Destroy(leaderboardItemsParent.GetChild(i).gameObject);
|
||||
}
|
||||
for(int i =0; i < leaderboard.Count; i++){
|
||||
LeaderboardItem newItem = Instantiate(template.gameObject, leaderboardItemsParent).GetComponent<LeaderboardItem>();
|
||||
newItem.Set(leaderboard[i]);
|
||||
}
|
||||
|
||||
template.gameObject.SetActive(false);
|
||||
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user