using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ResourceManager : MonoBehaviour
{
// setting all resources
private float resourceTroops;
private float resourceArmour;
private float resourceAircraft;
private float resourceVL;
//remember to put victory resource
public TextMeshProUGUI troopText;
public TextMeshProUGUI ArmourText;
public TextMeshProUGUI AircraftText;
// the following sets popups
private bool changeResources;
private bool _toggleDefPopup;
public GameObject defaultPopup;
public GameObject negPopup;
public GameObject posPopup;
public GameObject notPopup;
public GameObject vicPopup;
public GameObject losPopup;
public GameObject imagePopup;
private bool _toggleCommanderPopup;
public GameObject HeinzG;
public GameObject OttoD;
public GameObject ErichVM;
private bool _togglePlatforms;
// this is victory/lose gameobjects
public GameObject vic1;
public GameObject vic2;
public GameObject vic3;
public GameObject vic4;
public GameObject vic5;
public GameObject los1;
public GameObject los2;
public GameObject los3;
public GameObject los4;
public GameObject los5;
private int digit;
// images list
public List<GameObject> images;
public int imageSelector;
private int randomValue;
void Start() {
resourceTroops = 100;
resourceArmour = 15;
resourceAircraft = 120;
troopText.text = ""+ resourceTroops;
ArmourText.text = "" + resourceArmour;
AircraftText.text = "" + resourceAircraft;
resourceVL = 0;
}
/*
// these will be parametres for loss atk
int armourAL = 12;
int troopAL = 80;
// these will be parametres for win atk
int armourAW = 8;
int troopAW = 50;
// these will be parametres for win reorg
int troopR = 220;
int armourR = 30;
int aircraftR = 50;
// these will be parametres for loss reorg
int troopRL = 20;
int armourRL = 5;
int aircraftRL = 10;
*/
[SerializeField]
private void Update()
{
// this is victory/lose gameobject
if (resourceVL >= 5) {
vic1.SetActive(true);
los1.SetActive(false);
los2.SetActive(false);
los3.SetActive(false);
los4.SetActive(false);
if (resourceVL >= 10) {
vic2.SetActive(true);
if (resourceVL >= 15) {
vic3.SetActive(true);
if (resourceVL >= 20) {
vic4.SetActive(true);
if (resourceVL >= 25) {
vic5.SetActive(true);
vicPopup.SetActive(true);
defaultPopup.SetActive(true);
}
}
}
}
} else {
if (resourceVL <= -5) {
los1.SetActive(true);
vic1.SetActive(false);
vic2.SetActive(false);
vic3.SetActive(false);
vic4.SetActive(false);
if (resourceVL <= -10) {
los2.SetActive(true);
if (resourceVL <= -15) {
los3.SetActive(true);
if (resourceVL <= -20) {
los4.SetActive(true);
if (resourceVL <= -25) {
los5.SetActive(true);
losPopup.SetActive(true);
defaultPopup.SetActive(true);
}
}
}
}
}
}
// this is for attack popups
if(Input.GetKeyDown(KeyCode.A))
{
changeResources = !changeResources;
defaultPopup.SetActive(true);
digit = Random.Range(0, 101);
if (resourceTroops >= 50) {
// images
imagePopup.SetActive(true);
int randomValue = Random.Range(0, images.Count);
int imageSelector = randomValue;
GameObject selectedimage = images[imageSelector];
selectedimage.SetActive(true);
if(digit <= 50/(resourceArmour*0.2)){
// play negative screen and resource loss
negPopup.SetActive(true);
resourceArmour = resourceArmour*0.4f;
resourceTroops = resourceTroops*0.4f;
ArmourText.text = "" + (resourceArmour);
troopText.text = "" + (resourceTroops);
resourceVL = resourceVL - 5;
} else {
// play positive screen and resource loss
posPopup.SetActive(true);
resourceArmour = resourceArmour*0.5f;
resourceTroops = resourceTroops*0.5f;
ArmourText.text = "" + (resourceArmour);
troopText.text = "" + (resourceTroops);
resourceVL = resourceVL + 3;
}
} else {
notPopup.SetActive(true);
}
}
if(Input.GetKeyDown(KeyCode.Return))
{
changeResources = !changeResources;
posPopup.SetActive(false);
negPopup.SetActive(false);
notPopup.SetActive(false);
vicPopup.SetActive(false);
losPopup.SetActive(false);
imagePopup.SetActive(false);
}
// this is for reorgansise popup
if(Input.GetKeyDown(KeyCode.R))
{
changeResources = !changeResources;
defaultPopup.SetActive(true);
digit = Random.Range(0, 101);
if(digit <= 70){
// play negative screen and resource loss
negPopup.SetActive(true);
resourceArmour = resourceArmour + 5;
resourceTroops = resourceTroops + 50;
resourceAircraft = resourceAircraft + 10;
ArmourText.text = "" + (resourceArmour);
troopText.text = "" + (resourceTroops);
AircraftText.text = "" + (resourceAircraft);
resourceVL = resourceVL - 1;
} else {
// play positive screen and resource loss
posPopup.SetActive(true);
resourceArmour = resourceArmour + 15;
resourceTroops = resourceTroops + 80;
resourceAircraft = resourceAircraft + 40;
ArmourText.text = "" + (resourceArmour);
troopText.text = "" + (resourceTroops);
AircraftText.text = "" + (resourceAircraft);
}
}
// Air strike
if(Input.GetKeyDown(KeyCode.S))
{
changeResources = !changeResources;
defaultPopup.SetActive(true);
digit = Random.Range(0, 101);
if (resourceAircraft >= 60) {
if(digit <= 50/(resourceAircraft*0.4)){
// play negative screen and resource loss
negPopup.SetActive(true);
resourceAircraft = resourceAircraft*0.3f;
AircraftText.text = "" + (resourceAircraft);
resourceVL = resourceVL - 2;
} else {
// play positive screen and resource loss
posPopup.SetActive(true);
resourceAircraft = resourceAircraft*0.5f;
AircraftText.text = "" + (resourceAircraft);
resourceVL = resourceVL + 3;
}
} else {
notPopup.SetActive(true);
}
}
}
}