• 04-04-2021, 23:20:45
    #1
    böyle bir market sistemi yaptım çalılşıyor ama para 0 ın altına iniyor onu nasıl düzelitirim

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using TMPro;
    public class shopmanager : MonoBehaviour
    {
    public int currentballındex = 0;
    public GameObject[] ballmodels;
    public ballblueprint[] balls;
    public Button buybutton;
    public altin al;
    // Start is called before the first frame update
    void Start()
    {
    foreach(ballblueprint ball in balls)
    {
    if (ball.price == 0)
    ball.isunlock = true;
    else
    ball.isunlock = PlayerPrefs.GetInt(ball.name, 0)==0? false: true;
    }

    currentballındex = PlayerPrefs.GetInt("selectedball", 0);
    foreach (GameObject ball in ballmodels)
    ball.SetActive(false);
    ballmodels[currentballındex].SetActive(true);


    }

    // Update is called once per frame
    void Update()
    {
    UpdateUI();

    }
    public void changenest()
    {
    ballmodels[currentballındex].SetActive(false);

    currentballındex++;
    if (currentballındex == ballmodels.Length)
    currentballındex = 0;

    ballmodels[currentballındex].SetActive(true);
    ballblueprint c = balls[currentballındex];
    if (!c.isunlock)
    return;
    PlayerPrefs.SetInt("selectedball", currentballındex);
    }
    public void changenest1()
    {
    ballmodels[currentballındex].SetActive(false);

    currentballındex--;
    if (currentballındex == -1)
    currentballındex = ballmodels.Length-1;

    ballmodels[currentballındex].SetActive(true);
    ballblueprint c = balls[currentballındex];
    if (!c.isunlock)
    return;
    PlayerPrefs.SetInt("selectedball", currentballındex);
    }
    public void Unlockball()
    {
    ballblueprint c = balls[currentballındex];
    PlayerPrefs.SetInt(c.name, 1);
    PlayerPrefs.SetInt("selectedball", currentballındex);
    c.isunlock = true;
    PlayerPrefs.SetInt("altınsayısıs", PlayerPrefs.GetInt("altınsayısıs", 0) - c.price);

    }
    private void UpdateUI()
    {
    ballblueprint c = balls[currentballındex];
    if (c.isunlock)
    {
    buybutton.gameObject.SetActive(false);
    }
    else
    {
    buybutton.gameObject.SetActive(true);
    buybutton.GetComponent<TextMeshProUGUI>().text = "Buy-" + c.price;
    if (c.price < PlayerPrefs.GetInt("altınsayısıs", 0))
    {
    buybutton.interactable = true;
    }
    else
    {
    buybutton.interactable = false;
    }
    }
    }
    }
  • 04-04-2021, 23:23:55
    #2
    Bence direk visual studiodan SS al hocam böyle hangi method nerede bitiyor belli değil. Eziyet resmen
  • 04-04-2021, 23:24:00
    #3
    işlem sonucundaki değeri bir değişkene aktar eğer değer 0'ın altındaysa yeterince altınınız yok gibi bir ifade kullan
  • 05-04-2021, 01:39:29
    #4
    mecerak48 adlı üyeden alıntı: mesajı görüntüle
    Bence direk visual studiodan SS al hocam böyle hangi method nerede bitiyor belli değil. Eziyet resmen
    doğru diyorsunuz