using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ShopManagerScript : MonoBehaviour
{
public int[,] peopleNames = new int[4, 4];
public float crops;
public Text CropsTxt;
public static int goldObtained = 0;
// public float Gold;
// public Text gold;
void Start()
{
CropsTxt.text = "Crops:" + crops.ToString();
//people
peopleNames[1, 1] = 1;
peopleNames[1, 2] = 2;
peopleNames[1, 3] = 3;
//demands
peopleNames[2, 1] = 10;
peopleNames[2, 2] = 20;
peopleNames[2, 3] = 30;
//payment
peopleNames[3, 1] = 0;
peopleNames[3, 2] = 0;
peopleNames[3, 3] = 0;
}
public void Sell()
{
GameObject ButtonRef = GameObject.FindGameObjectWithTag("Events").GetComponent<EventSystem>().currentSelectedGameObject;
if (crops >= peopleNames[2, ButtonRef.GetComponent<ButtonInfo>().PersonID])
{
crops -= peopleNames[2, ButtonRef.GetComponent<ButtonInfo>().PersonID];
peopleNames[3, ButtonRef.GetComponent<ButtonInfo>().PersonID]++;
CropsTxt.text = "Crops:" + crops.ToString();
ButtonRef.GetComponent<ButtonInfo>().PaymentTxt.text = peopleNames[3, ButtonRef.GetComponent<ButtonInfo>().PersonID].ToString();
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Gold : MonoBehaviour
{
public static int goldObtained = 0;
public TMP_Text textNoCollected;
public int goldAmount;
// Start is called before the first frame update
public void addGold()
{
ShopManagerScript.goldObtained += goldAmount;
textNoCollected.text = "Gold : " + ShopManagerScript.goldObtained;
if (ShopManagerScript.crops <1 )
{
goldAmount = 0;
}
}
// Update is called once per frame
void Update()
{
}
}