Leaderboard show top 50

This commit is contained in:
Sewmina 2022-09-03 02:21:20 +05:30
parent d6ea2c2898
commit 7cdb3dc451
7 changed files with 33 additions and 10 deletions

View File

@ -193326,6 +193326,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 53edd1304ce7ec14fa61e457a4745d7a, type: 3}
m_Name:
m_EditorClassIdentifier:
Camera: {fileID: 0}
Rotate: 0
DecreaseCameraPanSpeed: 1
CameraUpperHeightBound: 0
CameraLowerHeightBound: 0
--- !u!4 &828023762
Transform:
m_ObjectHideFlags: 0
@ -218411,7 +218416,9 @@ MonoBehaviour:
- {fileID: 264333706}
- {fileID: 941017301}
metalTxt: {fileID: 1395822719}
trophiesTxt: {fileID: 851192027}
trophiesTxts:
- {fileID: 851192027}
- {fileID: 1067190027}
levelTxts:
- {fileID: 486719862}
- {fileID: 1906657801}
@ -536829,6 +536836,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
leaderboardItemsParent: {fileID: 3175187473382996676}
template: {fileID: 7097394028245726692}
--- !u!224 &5850637140524732208
RectTransform:
m_ObjectHideFlags: 0

View File

@ -20,7 +20,8 @@ public class BuildingData : ScriptableObject
public static class CollectablesData{
public enum ResourceType{
Metal,
Oxygen
Oxygen,
Gold
}
}

View File

@ -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;

View File

@ -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)
{

View File

@ -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);
}

View File

@ -37,7 +37,7 @@ MonoBehaviour:
xpGain: 5000
description: This structure is digging for gold 24/7.
collectable: 1
resourceType: 0
resourceType: 2
productinoRates:
- 100
- 150