Tutorial done
This commit is contained in:
@@ -9,10 +9,9 @@ public class ChestButton : MonoBehaviour
|
||||
public bool readFromTexts;
|
||||
public TMP_Text txtPrice;
|
||||
public TMP_Text txtChestName;
|
||||
public string ChestName => txtChestName.text;
|
||||
public ChestDataObject chestData;
|
||||
public int Price;
|
||||
public float minLuck = 0;
|
||||
public float maxLuck = 100;
|
||||
public bool overridePrice;
|
||||
public Button btnInfo;
|
||||
public Button adButton;
|
||||
[TextArea]
|
||||
@@ -27,11 +26,11 @@ public class ChestButton : MonoBehaviour
|
||||
|
||||
void OnClickedInfo()
|
||||
{
|
||||
MessageDialog.instance.ShowMessage(ChestName, $"This chest will drop following items.\n\n{getItemsProbability()}");
|
||||
MessageDialog.instance.ShowMessage(chestData.name, $"This chest will drop following items.\n\n{chestData.getInfo()}");
|
||||
}
|
||||
|
||||
void OnClick(){
|
||||
MessageDialog.instance.ShowQuestion("Are you sure?", $"Are you sure to purchase {ChestName} for {Price} Gems?", Buy,null);
|
||||
MessageDialog.instance.ShowQuestion("Are you sure?", $"Are you sure to purchase {chestData.name} for {Price} Gems?", Buy,null);
|
||||
}
|
||||
|
||||
void OnAdClicked(){
|
||||
@@ -46,7 +45,7 @@ public class ChestButton : MonoBehaviour
|
||||
}
|
||||
|
||||
DBmanager.SetGems(DBmanager.Gems - Price);
|
||||
ChestOpener.instance.OpenChest((int)minLuck, (int)maxLuck);
|
||||
ChestOpener.instance.OpenChest(chestData);
|
||||
}
|
||||
|
||||
public void BuyFree(){
|
||||
@@ -56,49 +55,20 @@ public class ChestButton : MonoBehaviour
|
||||
|
||||
IEnumerator buyFree(){
|
||||
yield return new WaitForSeconds(1);
|
||||
ChestOpener.instance.OpenChest((int)minLuck, (int)maxLuck);
|
||||
}
|
||||
|
||||
public string getItemsProbability()
|
||||
{
|
||||
string items = "Gold";
|
||||
|
||||
if (maxLuck > 50)
|
||||
{
|
||||
float probability = ((maxLuck - 50f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nGems : {probability.ToString("n1")}%";
|
||||
}
|
||||
|
||||
if (maxLuck > 70)
|
||||
{
|
||||
//some skins
|
||||
float probability = ((maxLuck - 70f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nCommon Skin : {probability.ToString("n1")}%";
|
||||
}
|
||||
if (maxLuck > 85)
|
||||
{
|
||||
float probability = ((maxLuck - 85f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nRare Skin : {probability.ToString("n1")}%";
|
||||
}
|
||||
if (maxLuck > 95)
|
||||
{
|
||||
float probability = ((maxLuck - 95f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nLegendary Skin : {probability.ToString("n1")}%";
|
||||
}
|
||||
|
||||
|
||||
return items;
|
||||
ChestOpener.instance.OpenChest(chestData);
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
infoTxt = getItemsProbability();
|
||||
|
||||
infoTxt = chestData.getInfo();
|
||||
if(!overridePrice){Price=chestData.Price;}
|
||||
txtPrice.text = Price.ToString();
|
||||
txtChestName.text = chestData.name;
|
||||
if (!readFromTexts) { return; }
|
||||
|
||||
if (txtPrice != null)
|
||||
{
|
||||
Price = int.Parse(txtPrice.text);
|
||||
}
|
||||
// if (txtPrice != null)
|
||||
// {
|
||||
// Price = int.Parse(txtPrice.text);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SpecialChest : MonoBehaviour
|
||||
|
||||
IEnumerator StartChestList(){
|
||||
for(int i=0; i< quantity; i++){
|
||||
ChestOpener.instance.OpenChest((int)chestButton.minLuck, (int)chestButton.maxLuck);
|
||||
ChestOpener.instance.OpenChest(chestButton.chestData);
|
||||
while(ChestOpener.instance.active){
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user