using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Blok_Manager : MonoBehaviour
{ ///MAHKUM KAPASITESI YAPILACAK
public Buy_Trigger BuyTrigger;
private void Start()
{
Start_Void_Blok_Canvas();
Start_Void_Mahkum_Sistemi();
}
private void Update()
{
Update_Void_Blok_Canvas();
Mahkum_Sistemi_Update();
TV_Material_Check_Update_Void();
Yatak_Objeleri_Update();
}
#region BLOK CANVAS
#region BLOK CANVAS COMPONENTS
[Space(20)]
[Header("INFO")]
#region INFO PANEL
[Space(20)]
[Header("BLOK CANVAS")]
public string Blok_Name;
public float Blok_Money_Rate;
public float Blok_Energy_Rate;
public float Blok_Water_Rate;
public TextMeshProUGUI Blok_Name_TXT;
public TextMeshProUGUI Blok_Money_Rate_TXT;
public TextMeshProUGUI Blok_Energy_Rate_TXT;
public TextMeshProUGUI Blok_Water_Rate_TXT;
#endregion
#region UPGRADE PANEL
[Space(20)]
[Header("UPGRADE")]
public Image Upgrade_ICON;
public Sprite[] Icons;
public Button Upgrade_Button;
public int Upgrade_Price;
public float Upgrade_Time_Rate;
public float Upgrade_Money_Rate;
public float Upgrade_Shower_Rate;
public float Upgrade_Happy_Rate;
public int Upgrade_Bed_Level; //YATAK LEVELI EĞER 0 ISE KAPASITE 1 OLUR, EĞER 1 ISE KAPASITE 2 OLUR EĞER 2 ISE KAPASITE 3 OLUR. MAX LEVEL 3
public int Upgrade_Toilet_Level; // TUVALET LEVELI EĞER 1 ISE HIJYEN 2 OLUR, LEVEL 2 İSE HIJYEN 4 OLSUN, LEVEL 3 ISE HIJYEN 6 OLSUN, LEVEL 4 ISE HIJYEN 8 OLSUN, LEVEL 5 ISE HIJYEN 10 OLSUN. MAX LEVEL 5
public int Upgrade_TV_Level; // TELEVIZYON LEVELI EGER 1 ISE MUTLULUK GENEL MUTLULUK ORANI 4 EKLENİR , LEVEL 2 ISE GENEL MUTLULUK 8 EKLENIR, LEVEL 3 ISE GENEL MUTLULUK 12 EKLENIR, LEVEL 4 ISE GENEL MUTLULUK 16 EKLENIR, LEVEL 5 ISE GENEL MUTLULUK 20 EKLENIR.
public TextMeshProUGUI Upgrade_Header_TXT;
public TextMeshProUGUI Upgrade_Description_TXT;
public TextMeshProUGUI Upgrade_Button_TXT;
public TextMeshProUGUI Upgrade_Price_TXT;
public TextMeshProUGUI[] Upgrade_Time_Rate_TXT;
public TextMeshProUGUI[] Upgrade_Money_Rate_TXT;
public TextMeshProUGUI[] Upgrade_Shower_Rate_TXT;
public TextMeshProUGUI[] Upgrade_Happy_Rate_TXT;
#endregion
#region SELECT PANEL
[Space(20)]
[Header("SELECT")]
public Image Select_Bed_Image;
public Image Select_Toilet_Image;
public Image Select_TV_Image;
public GameObject Bed_Info_Station;
public GameObject Toilet_Info_Station;
public GameObject TV_Info_Station;
public Color Selected_Color;
public Color Unselected_Color;
#endregion
#region SETTINGS
[Header("SETTINGS")]
[Space(20)]
public int Which_State; //Eğer 1 ise YATAK, Eğer 2 ise TUVALET, Eğer 3 ise TELEVIZYON
#endregion
#endregion
#region BLOK CANVAS VOIDS
public void Update_Void_Blok_Canvas()
{
#region BLOK CANVAS UPDATE
#region PLAYER PREFS
//INFO
Blok_Money_Rate = PlayerPrefs.GetFloat(Blok_Name + "Money_Rate");
Blok_Energy_Rate = PlayerPrefs.GetFloat(Blok_Name + "Energy_Rate");
Blok_Water_Rate = PlayerPrefs.GetFloat(Blok_Name + "Water_Rate");
//UPGRADE
Upgrade_Bed_Level = PlayerPrefs.GetInt(Blok_Name + "Bed_Level");
Upgrade_Toilet_Level = PlayerPrefs.GetInt(Blok_Name + "Toilet_Level");
Upgrade_TV_Level = PlayerPrefs.GetInt(Blok_Name + "TV_Level");
#endregion
#region PLAYER PREFS UPDATE
if (PlayerPrefs.GetInt(Blok_Name + "Bed_Level") > 1)
{
PlayerPrefs.SetInt(Blok_Name + "Bed_Level", 1);
}
if (PlayerPrefs.GetInt(Blok_Name + "Toilet_Level") > 2)
{
PlayerPrefs.SetInt(Blok_Name + "Toilet_Level", 2);
}
if (PlayerPrefs.GetInt(Blok_Name + "TV_Level") > 3)
{
PlayerPrefs.SetInt(Blok_Name + "TV_Level", 3);
}
#endregion
#region INT TO TEXT
Blok_Name_TXT.text = Blok_Name.ToString();
//BLOK RATE
Blok_Money_Rate_TXT.text = Blok_Money_Rate.ToString();
Blok_Energy_Rate_TXT.text = Blok_Energy_Rate.ToString();
Blok_Water_Rate_TXT.text = Blok_Water_Rate.ToString();
#endregion
#region STATE UPDATE
if (Which_State == 0) //YATAK BUTONU
{
Upgrade_ICON.sprite = Icons[0];
Upgrade_Header_TXT.text = "BED";
Upgrade_Button_TXT.text = "UPGRADE";
Upgrade_Description_TXT.text = "Prisoners can regenerate energy by sleeping!";
if (Upgrade_Bed_Level == 0)
{
Upgrade_Price = 250;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
//MONEY RATE
Upgrade_Money_Rate = 1.50f;
Upgrade_Money_Rate_TXT[0].text = Upgrade_Money_Rate.ToString() + "+0.50";
//TIME RATE
Upgrade_Time_Rate = 6f;
Upgrade_Time_Rate_TXT[0].text = Upgrade_Time_Rate.ToString() + "-0.50";
//HAPPY RATE
Upgrade_Happy_Rate = 2f;
Upgrade_Happy_Rate_TXT[0].text = Upgrade_Happy_Rate.ToString() + "+1";
} //LEVEL 1
if (Upgrade_Bed_Level == 1)
{
Upgrade_Price_TXT.text = "MAX";
Upgrade_Price = 0;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
//MONEY RATE
Upgrade_Money_Rate = 2f;
Upgrade_Money_Rate_TXT[0].text = Upgrade_Money_Rate.ToString();
//TIME RATE
Upgrade_Time_Rate = 5.5f;
Upgrade_Time_Rate_TXT[0].text = Upgrade_Time_Rate.ToString();
//HAPPY RATE
Upgrade_Happy_Rate = 3f;
Upgrade_Happy_Rate_TXT[0].text = Upgrade_Happy_Rate.ToString();
} //LEVEL 2 MAX LEVEL
#region Automatic On/Off
Bed_Info_Station.SetActive(true);
Toilet_Info_Station.SetActive(false);
TV_Info_Station.SetActive(false);
Select_Bed_Image.color = Selected_Color;
Select_Toilet_Image.color = Unselected_Color;
Select_TV_Image.color = Unselected_Color;
#endregion
}
if (Which_State == 1) //TUVALET BUTONU
{
Upgrade_ICON.sprite = Icons[1];
Upgrade_Header_TXT.text = "TOILET";
Upgrade_Description_TXT.text = "It is very important for prisoners to meet their needs and gain energy!";
Upgrade_Button_TXT.text = "UPGRADE";
if (Upgrade_Toilet_Level == 0)
{
Upgrade_Price = 150;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
//MONEY RATE
Upgrade_Money_Rate = 0.5f;
Upgrade_Money_Rate_TXT[1].text = Upgrade_Money_Rate.ToString() + "+0.50";
//TIME RATE
Upgrade_Time_Rate = 6f;
Upgrade_Time_Rate_TXT[1].text = Upgrade_Time_Rate.ToString() + "-0.50";
//SHOWER RATE
Upgrade_Shower_Rate = 4.5f;
Upgrade_Shower_Rate_TXT[0].text = Upgrade_Shower_Rate.ToString() + "+1";
} //LEVEL 1
if (Upgrade_Toilet_Level == 1)
{
Upgrade_Price = 300;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
//MONEY RATE
Upgrade_Money_Rate = 1f;
Upgrade_Money_Rate_TXT[1].text = Upgrade_Money_Rate.ToString() + "+1";
//TIME RATE
Upgrade_Time_Rate = 5.5f;
Upgrade_Time_Rate_TXT[1].text = Upgrade_Time_Rate.ToString() + "-0.50";
//SHOWER RATE
Upgrade_Shower_Rate = 5.5f;
Upgrade_Shower_Rate_TXT[0].text = Upgrade_Shower_Rate.ToString() + "+1.5";
} //LEVEL 2
if (Upgrade_Toilet_Level == 2)
{
Upgrade_Price_TXT.text = "MAX";
Upgrade_Price = 0;
//MONEY RATE
Upgrade_Money_Rate = 2f;
Upgrade_Money_Rate_TXT[1].text = Upgrade_Money_Rate.ToString();
//TIME RATE
Upgrade_Time_Rate = 5f;
Upgrade_Time_Rate_TXT[1].text = Upgrade_Time_Rate.ToString();
//SHOWER RATE
Upgrade_Shower_Rate = 7f;
Upgrade_Shower_Rate_TXT[0].text = Upgrade_Shower_Rate.ToString();
} //LEVEL 3 MAX LEVEL
#region Automatic On/Off
Bed_Info_Station.SetActive(false);
Toilet_Info_Station.SetActive(true);
TV_Info_Station.SetActive(false);
Select_Bed_Image.color = Unselected_Color;
Select_Toilet_Image.color = Selected_Color;
Select_TV_Image.color = Unselected_Color;
#endregion
}
if (Which_State == 2)
{
Upgrade_ICON.sprite = Icons[2];
Upgrade_Header_TXT.text = "TV";
Upgrade_Description_TXT.text = "The Best tool to boost prisoners' morale!";
tvSecili = true;
if (Upgrade_TV_Level == 0)
{
Upgrade_Price = 100;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
Upgrade_Button_TXT.text = "BUY";
//MONEY RATE
Upgrade_Money_Rate = 0.5f;
Upgrade_Money_Rate_TXT[2].text = Upgrade_Money_Rate.ToString() + "+0.50";
//TIME RATE
Upgrade_Time_Rate = 5f;
Upgrade_Time_Rate_TXT[2].text = Upgrade_Time_Rate.ToString() + "-0.50";
//HAPPY RATE
Upgrade_Happy_Rate = 2f;
Upgrade_Happy_Rate_TXT[1].text = Upgrade_Happy_Rate.ToString() + "+1";
} //LEVEL 0 LOCKED
if (Upgrade_TV_Level == 1)
{
Upgrade_Price = 200;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
Upgrade_Button_TXT.text = "UPGRADE";
//MONEY RATE
Upgrade_Money_Rate = 0.5f;
Upgrade_Money_Rate_TXT[2].text = Upgrade_Money_Rate.ToString() + "+0.50";
//TIME RATE
Upgrade_Time_Rate = 6f;
Upgrade_Time_Rate_TXT[2].text = Upgrade_Time_Rate.ToString() + "-0.50";
//HAPPY RATE
Upgrade_Happy_Rate = 3f;
Upgrade_Happy_Rate_TXT[1].text = Upgrade_Happy_Rate.ToString() + "+1";
} //LEVEL 1
if (Upgrade_TV_Level == 2)
{
Upgrade_Price = 500;
Upgrade_Price_TXT.text = Upgrade_Price.ToString();
Upgrade_Button_TXT.text = "UPGRADE";
//MONEY RATE
Upgrade_Money_Rate = 1f;
Upgrade_Money_Rate_TXT[2].text = Upgrade_Money_Rate.ToString() + "+1";
//TIME RATE
Upgrade_Time_Rate = 5.5f;
Upgrade_Time_Rate_TXT[2].text = Upgrade_Time_Rate.ToString() + "-0.50";
//HAPPY RATE
Upgrade_Happy_Rate = 4f;
Upgrade_Happy_Rate_TXT[1].text = Upgrade_Happy_Rate.ToString() + "+1";
} //LEVEL 2
if (Upgrade_TV_Level == 3)
{
Upgrade_Button_TXT.text = "UPGRADE";
Upgrade_Price_TXT.text = "MAX";
Upgrade_Price = 0;
//MONEY RATE
Upgrade_Money_Rate = 2f;
Upgrade_Money_Rate_TXT[2].text = Upgrade_Money_Rate.ToString();
//TIME RATE
Upgrade_Time_Rate = 5f;
Upgrade_Time_Rate_TXT[2].text = Upgrade_Time_Rate.ToString();
//HAPPY RATE
Upgrade_Happy_Rate = 5f;
Upgrade_Happy_Rate_TXT[1].text = Upgrade_Happy_Rate.ToString();
} //LEVEL 3 MAX LEVEL
#region Automatic On/Off
Bed_Info_Station.SetActive(false);
Toilet_Info_Station.SetActive(false);
TV_Info_Station.SetActive(true);
Select_Bed_Image.color = Unselected_Color;
Select_Toilet_Image.color = Unselected_Color;
Select_TV_Image.color = Selected_Color;
#endregion
}
else
{
tvSecili = false;
}
#endregion
#region UPGRADE BUTTON DEACTIVE ACTIVE
if (PlayerPrefs.GetFloat("Money") < Upgrade_Price)
{
Upgrade_Button.interactable = false;
}
else
{
Upgrade_Button.interactable = true;
}
if (Upgrade_Price == 0)
{
Upgrade_Button.interactable = false;
}
#endregion
#endregion
}
public void State_Bed()
{
Which_State = 0;
}
public void State_Toilet()
{
Which_State = 1;
}
public void State_TV()
{
Which_State = 2;
}
private void Start_Void_Blok_Canvas()
{
#region BLOK CANVAS
#region PLAYER PREFS
//INFO
Blok_Money_Rate = PlayerPrefs.GetFloat(Blok_Name + "Money_Rate");
Blok_Energy_Rate = PlayerPrefs.GetFloat(Blok_Name + "Energy_Rate");
Blok_Water_Rate = PlayerPrefs.GetFloat(Blok_Name + "Water_Rate");
//UPGRADE
Upgrade_Bed_Level = PlayerPrefs.GetInt(Blok_Name + "Bed_Level");
Upgrade_Toilet_Level = PlayerPrefs.GetInt(Blok_Name + "Toilet_Level");
Upgrade_TV_Level = PlayerPrefs.GetInt(Blok_Name + "TV_Level");
#endregion
#endregion
}
public void UpgradeItem()
{
if (Which_State == 0) //YATAK
{
if (PlayerPrefs.GetFloat("Money") > Upgrade_Price + -1f)
{
PlayerPrefs.SetFloat("Money", PlayerPrefs.GetFloat("Money") - Upgrade_Price);
PlayerPrefs.SetInt(Blok_Name + "Bed_Level", PlayerPrefs.GetInt(Blok_Name + "Bed_Level") + 1);
AddCapacity();
}
if (Upgrade_Bed_Level == 0)
{
PlayerPrefs.SetFloat(Blok_Name + "Money_Rate", PlayerPrefs.GetFloat(Blok_Name + "Money_Rate") + 0.5f);
PlayerPrefs.SetFloat("Money_Rate", PlayerPrefs.GetFloat("Money_Rate") + 0.5f);
}
}
if (Which_State == 1) //TUVALET
{
if (PlayerPrefs.GetFloat("Money") > Upgrade_Price + -1f)
{
PlayerPrefs.SetFloat("Money", PlayerPrefs.GetFloat("Money") - Upgrade_Price);
PlayerPrefs.SetInt(Blok_Name + "Toilet_Level", PlayerPrefs.GetInt(Blok_Name + "Toilet_Level") + 1);
}
if (Upgrade_Toilet_Level == 0)
{
PlayerPrefs.SetFloat(Blok_Name + "Money_Rate", PlayerPrefs.GetFloat(Blok_Name + "Money_Rate") + 0.5f);
PlayerPrefs.SetFloat("Money_Rate", PlayerPrefs.GetFloat("Money_Rate") + 0.5f);
}
if (Upgrade_Toilet_Level == 1)
{
PlayerPrefs.SetFloat(Blok_Name + "Money_Rate", PlayerPrefs.GetFloat(Blok_Name + "Money_Rate") + 1f);
PlayerPrefs.SetFloat("Money_Rate", PlayerPrefs.GetFloat("Money_Rate") + 1f);
}
}
if (Which_State == 2) //TV
{
if (PlayerPrefs.GetFloat("Money") > Upgrade_Price + -1f)
{
PlayerPrefs.SetFloat("Money", PlayerPrefs.GetFloat("Money") - Upgrade_Price);
PlayerPrefs.SetInt(Blok_Name + "TV_Level", PlayerPrefs.GetInt(Blok_Name + "TV_Level") + 1);
}
if (Upgrade_TV_Level == 0)
{
PlayerPrefs.SetFloat(Blok_Name + "Money_Rate", PlayerPrefs.GetFloat(Blok_Name + "Money_Rate") + 0.5f);
PlayerPrefs.SetFloat("Money_Rate", PlayerPrefs.GetFloat("Money_Rate") + 0.5f);
}
if (Upgrade_TV_Level == 1)
{
PlayerPrefs.SetFloat(Blok_Name + "Money_Rate", PlayerPrefs.GetFloat(Blok_Name + "Money_Rate") + 0.5f);
PlayerPrefs.SetFloat("Money_Rate", PlayerPrefs.GetFloat("Money_Rate") + 0.5f);
}
if (Upgrade_TV_Level == 2)
{
PlayerPrefs.SetFloat(Blok_Name + "Money_Rate", PlayerPrefs.GetFloat(Blok_Name + "Money_Rate") + 1f);
PlayerPrefs.SetFloat("Money_Rate", PlayerPrefs.GetFloat("Money_Rate") + 1f);
}
}
}
#endregion
#endregion
#region MAHKUM SISTEMI
#region MAHKUM COMPONENTLER
[Header("OBJECTS")]
[Space(10)]
[Header("MAHKUM SISTEMI")]
[Space(30)]
public TextMeshPro Prisoner_Count_TXT;
public GameObject Mahkum_Prefab;
public Toilet_Manager toiletManager;
[Header("SPAWN POSITIONS")]
[Space(10)]
public Transform Mahkum_Spawn_Pos_1;
public Transform Mahkum_Spawn_Pos_2;
[Header("SETTINGS & VARIABLES")]
[Space(10)]
public int Current_Prisoner;
public int Max_Prisoner_Capacity;
public bool capacityFull;
[Header("AI POINTS")]
public Transform Toilet_Position;
public Transform Toilet_Waiting_Point_1;
public Transform Toilet_Waiting_Point_2;
public Transform Bed_Level_1_Position;
public Transform Bed_Level_2_Position;
[Header("WAITING POINT CHECK SYSTEM")]
public bool Toilet_Waiting_Point_1_isOnline;
[Header("BED CHECK SYSTEM")]
public bool Bed_1_Online;
#endregion
#region MAHKUM SISTEMI VOIDS
public void Start_Void_Mahkum_Sistemi()
{
Mahkum_Prefab = Resources.Load("Prisoner") as GameObject;
if (PlayerPrefs.GetInt(Blok_Name + "Capacity") == 0)
{
PlayerPrefs.SetInt(Blok_Name + "Capacity", PlayerPrefs.GetInt(Blok_Name + "Capacity") + 1); //KAPASITE ARTTIR
}
if (PlayerPrefs.GetInt(Blok_Name + "Current_Prisoner") == 1)
{
GameObject newPrisoner = Instantiate(Mahkum_Prefab, Mahkum_Spawn_Pos_1.position, Mahkum_Spawn_Pos_1.rotation);
newPrisoner.GetComponent().blokManager = gameObject.GetComponent();
}
else if (PlayerPrefs.GetInt(Blok_Name + "Current_Prisoner") == 2)
{
GameObject newPrisoner1 = Instantiate(Mahkum_Prefab, Mahkum_Spawn_Pos_1.position, Mahkum_Spawn_Pos_1.rotation);
GameObject newPrisoner2 = Instantiate(Mahkum_Prefab, Mahkum_Spawn_Pos_2.position, Mahkum_Spawn_Pos_2.rotation);
newPrisoner1.GetComponent().blokManager = gameObject.GetComponent();
newPrisoner2.GetComponent().blokManager = gameObject.GetComponent();
}
}
public void Mahkum_Sistemi_Update()
{
#region PLAYER PREFS
Current_Prisoner = PlayerPrefs.GetInt(Blok_Name + "Current_Prisoner");
Max_Prisoner_Capacity = PlayerPrefs.GetInt(Blok_Name + "Capacity");
if(Current_Prisoner > PlayerPrefs.GetInt(Blok_Name+ "Capacity"))
{
PlayerPrefs.SetInt(Blok_Name + "Current_Prisoner", PlayerPrefs.GetInt(Blok_Name + "Capacity"));
}
#endregion
#region FULL CHECK
if (Current_Prisoner == Max_Prisoner_Capacity)
{
capacityFull = true;
}
else
{
capacityFull = false;
}
#endregion
#region CANVAS UPDATE
Prisoner_Count_TXT.text = Current_Prisoner + "/" + Max_Prisoner_Capacity;
#endregion
}
public void AddPrisoner()
{
if (capacityFull == false)
{
PlayerPrefs.SetInt(Blok_Name + "Current_Prisoner", PlayerPrefs.GetInt(Blok_Name + "Current_Prisoner") + 1); //MAHKUM ARTTIR
PlayerPrefs.SetInt("Prisoner_Rate", PlayerPrefs.GetInt("Prisoner_Rate") + 1); //MAHKUM ARTTIR ANALIZ
}
}
public void AddCapacity()
{
PlayerPrefs.SetInt(Blok_Name + "Capacity", PlayerPrefs.GetInt(Blok_Name + "Capacity") + 1); //KAPASITE ARTTIR
PlayerPrefs.SetInt("Capacity_Rate", PlayerPrefs.GetInt("Capacity_Rate") + 1); //KAPASITE ARTTIR ANALIZ
}
#endregion
#endregion
#region TV SISTEMI
#region TV Componentler
[Header("TV SYSTEM")]
public MeshRenderer TV_Screen_Model;
public MeshRenderer TV_Squad_Model;
public Material[] Tv_Materials;
bool tvSecili;
#endregion
public void TV_Material_Check_Update_Void()
{
if (Upgrade_TV_Level == 0)
{
TV_Squad_Model.material = Tv_Materials[0];
TV_Screen_Model.material = Tv_Materials[1];
if (tvSecili)
{
TV_Squad_Model.enabled = true;
TV_Screen_Model.enabled = true;
}
else
{
TV_Squad_Model.enabled = false;
TV_Screen_Model.enabled = false;
}
}
else
{
TV_Squad_Model.material = Tv_Materials[2];
TV_Screen_Model.material = Tv_Materials[3];
tvSecili = true;
}
}
public void Tv_Kapat()
{
tvSecili = false;
}
#endregion
#region YATAK SISTEMI
[Header("YATAK OBJELERI")]
public GameObject Yatak_Level_2;
public void Yatak_Objeleri_Update()
{
if (Upgrade_Bed_Level == 0)
{
Yatak_Level_2.SetActive(false);
}
if (Upgrade_Bed_Level == 1)
{
Yatak_Level_2.SetActive(true);
}
}
#endregion
}