Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- //Script by Andriy Skyba
- public class ShopControll : MonoBehaviour
- {
- [SerializeField] private int Money;
- [SerializeField] private Text money_text;
- private void Start()
- {
- if (!PlayerPrefs.HasKey("Money"))
- {
- PlayerPrefs.SetInt("Money", 1000);
- }
- Money = PlayerPrefs.GetInt("Money");
- }
- private void Update()
- {
- money_text.text = "Монет : " + Money;
- PlayerPrefs.SetInt("Money", Money);
- }
- public void Item1(ItemInfo item)
- {
- if(Money >= item.cost)
- {
- Money -= item.cost;
- item.this_Item.interactable = false;
- item.this_Item.GetComponentInChildren<Text>().text = "Куплено";
- Debug.LogWarning("С вашего счёта было списано " + item.cost + " монет");
- Debug.Log("Вы купили предмет " + item._name);
- PlayerPrefs.SetInt(item._name, 1);
- } else if(Money < item.cost)
- {
- Debug.Log("У вас нет денег");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment