83 lines
2.0 KiB
C#
Executable File
83 lines
2.0 KiB
C#
Executable File
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class ShopScript : MonoBehaviour
|
|
{
|
|
public GameObject CoinMenu;
|
|
public GameObject GemsMenu;
|
|
public GameObject BuildMenu;
|
|
public string shopButtonName;
|
|
|
|
|
|
public void OnClickBuyCoins(int packNumber){
|
|
int coinGain =0;
|
|
int gemCost = 0;
|
|
switch(packNumber){
|
|
case 0:
|
|
coinGain=1000;
|
|
gemCost =10;
|
|
break;
|
|
case 1:
|
|
coinGain=6300;
|
|
gemCost =60;
|
|
break;
|
|
case 2:
|
|
coinGain=27600;
|
|
gemCost =120;
|
|
break;
|
|
case 3:
|
|
coinGain=57600;
|
|
gemCost =250;
|
|
break;
|
|
}
|
|
|
|
if(gemCost > DBmanager.Gems){
|
|
Debug.Log("Not enough gems!");
|
|
return;
|
|
}
|
|
|
|
DBmanager.SetCoins(DBmanager.Coins + coinGain);
|
|
DBmanager.SetGems(DBmanager.Gems - gemCost);
|
|
}
|
|
|
|
public void CheatGems(){
|
|
DBmanager.SetGems(DBmanager.Gems + 1000);
|
|
}
|
|
|
|
public void openShop()
|
|
{
|
|
shopButtonName = EventSystem.current.currentSelectedGameObject.name;
|
|
checkButton();
|
|
}
|
|
|
|
public void openBuildingShop()
|
|
{
|
|
BuildMenu.SetActive(true);
|
|
}
|
|
|
|
public void closeBuildingShop()
|
|
{
|
|
BuildMenu.SetActive(false);
|
|
}
|
|
|
|
public void checkButton()
|
|
{
|
|
switch (shopButtonName)
|
|
{
|
|
case "Button_Shop": CoinMenu.SetActive(true); break;
|
|
case "Coin": CoinMenu.SetActive(true); GemsMenu.SetActive(false); break;
|
|
case "Gem": GemsMenu.SetActive(true); CoinMenu.SetActive(false); break;
|
|
|
|
}
|
|
}
|
|
public void closeShop()
|
|
{
|
|
CoinMenu.SetActive(false);
|
|
GemsMenu.SetActive(false);
|
|
|
|
|
|
}
|
|
}
|