mirror of
https://github.com/ConjureETS/Human-Farm-Tycoon.git
synced 2026-03-24 02:11:07 +00:00
Added the panel for ending the turn that notifies the changes you're about to make to your game (still needs some functionality like cancel).
Added some functions in Stats.
This commit is contained in:
parent
f1d0093b5d
commit
1e59b9fb12
File diff suppressed because it is too large
Load Diff
23
Assets/Script/ConfirmStatsScript.cs
Normal file
23
Assets/Script/ConfirmStatsScript.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ConfirmStatsScript : MonoBehaviour {
|
||||
|
||||
public Text currentValues;
|
||||
public Text addedValues;
|
||||
public Text alertTitle;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
Stats stats = GameObject.Find("Stats").gameObject.GetComponent<Stats>();
|
||||
currentValues.text = stats.displayCurrentStats();
|
||||
addedValues.text = stats.displayAddingStats();
|
||||
alertTitle.text = "DAY " + stats.NbTurns;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Script/ConfirmStatsScript.cs.meta
Normal file
12
Assets/Script/ConfirmStatsScript.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c11185c2efdb07f4ea21f9c01b32dedb
|
||||
timeCreated: 1439482178
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,9 +1,13 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
public class Stats : MonoBehaviour
|
||||
{
|
||||
#region attributes
|
||||
|
||||
private int nbTurns;
|
||||
|
||||
private int amountOfRock;
|
||||
private int amountOfWood;
|
||||
private int amountOfCorpse;
|
||||
@ -23,6 +27,36 @@ public class Stats : MonoBehaviour
|
||||
private int nbZombieAssigneCorpse;
|
||||
private int nbZombieAssigneMeat;
|
||||
|
||||
private int nbHumanHouses;
|
||||
private int nbZombieHouses;
|
||||
|
||||
private int humanHunger;
|
||||
private int zombieHunger;
|
||||
|
||||
public int AmountOfZHunger
|
||||
{
|
||||
get { return zombieHunger; }
|
||||
set { zombieHunger = value; }
|
||||
}
|
||||
|
||||
public int AmountOfHHunger
|
||||
{
|
||||
get { return humanHunger; }
|
||||
set { humanHunger = value; }
|
||||
}
|
||||
|
||||
public int AmountHumanHouse
|
||||
{
|
||||
get { return nbHumanHouses; }
|
||||
set { nbHumanHouses = value; }
|
||||
}
|
||||
|
||||
public int AmountZombieHouse
|
||||
{
|
||||
get { return nbZombieHouses; }
|
||||
set { nbZombieHouses = value; }
|
||||
}
|
||||
|
||||
public int NbZombieAssigneMeat
|
||||
{
|
||||
get { return nbZombieAssigneMeat;}
|
||||
@ -112,6 +146,11 @@ public class Stats : MonoBehaviour
|
||||
set { amountOfZombiesAvail = value; }
|
||||
}
|
||||
|
||||
public int NbTurns
|
||||
{
|
||||
get { return nbTurns; }
|
||||
set { nbTurns = value; }
|
||||
}
|
||||
|
||||
public void addCorpse()
|
||||
{
|
||||
@ -184,7 +223,6 @@ public class Stats : MonoBehaviour
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public Stats(int nbRock, int nbWood, int nbCorpse, int nbMeat, int nbHumans, int nbZombies)
|
||||
{
|
||||
resetStats(nbRock, nbWood, nbCorpse, nbMeat, nbHumans, nbZombies, 5, 5, 5, 5);
|
||||
@ -208,11 +246,97 @@ public class Stats : MonoBehaviour
|
||||
NbZombieAssigneCorpse = 0;
|
||||
NbZombieAssigneMeat = 0;
|
||||
AmountOfZombiesAvail = AmountOfZombies;
|
||||
AmountOfHHunger = 250 * AmountOfHumans;
|
||||
AmountOfZHunger = 500 * AmountOfZombies;
|
||||
}
|
||||
|
||||
private void applyStatModifications()
|
||||
{
|
||||
AmountOfCorpse += (NbZombieAssigneCorpse * NbOfCorpseByZombie);
|
||||
AmountOfMeat += (NbZombieAssigneMeat * NbOfMeatByZombie);
|
||||
AmountOfRock += (NbZombieAssigneRock * NbOfRockByZombie);
|
||||
AmountOfWood += (NbZombieAssigneWood * NbOfWoodByZombie);
|
||||
}
|
||||
|
||||
private void advanceTurn()
|
||||
{
|
||||
nbTurns++;
|
||||
}
|
||||
|
||||
private bool isHumanMaxCapacity()
|
||||
{
|
||||
int cap = nbHumanHouses * 10;
|
||||
if (AmountOfHumans > cap)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool isZombieMaxCapacity()
|
||||
{
|
||||
int cap = nbZombieHouses * 10;
|
||||
if (AmountOfZombies > cap)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void endTurn()
|
||||
{
|
||||
if (!isHumanMaxCapacity())
|
||||
AmountOfHumans += (2 * AmountHumanHouse);
|
||||
if (isZombieMaxCapacity())
|
||||
AmountOfZombies -= AmountOfZombies % (AmountZombieHouse * 10);
|
||||
applyStatModifications();
|
||||
calculateHunger();
|
||||
advanceTurn();
|
||||
}
|
||||
|
||||
private void calculateHunger()
|
||||
{
|
||||
AmountOfHHunger -= 10 * AmountOfHumans;
|
||||
AmountOfZHunger -= 50 * AmountOfZombies;
|
||||
}
|
||||
|
||||
public String displayStats()
|
||||
{
|
||||
//TODO: Needs completion and formatting
|
||||
String body = "";
|
||||
body += "Wood: " + AmountOfWood + "\n";
|
||||
body += "Meat: " + AmountOfMeat + "\n";
|
||||
body += "Corpses: " + AmountOfCorpse + "\n";
|
||||
body += "Rock: " + AmountOfRock + "\n";
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
public String displayAddingStats()
|
||||
{
|
||||
//TODO: Needs completion and formatting
|
||||
String body = "";
|
||||
body += "+" + NbZombieAssigneWood * NbOfWoodByZombie + "\n" + "\n";
|
||||
body += "+" + NbZombieAssigneRock * NbOfRockByZombie + "\n" + "\n";
|
||||
body += "+" + NbZombieAssigneMeat * NbOfMeatByZombie + "\n" + "\n";
|
||||
body += "+" + NbZombieAssigneCorpse * NbOfCorpseByZombie + "\n" + "\n";
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
public String displayCurrentStats()
|
||||
{
|
||||
String body = "";
|
||||
body += AmountOfWood + "\n" + "\n";
|
||||
body += AmountOfRock + "\n" + "\n";
|
||||
body += AmountOfMeat + "\n" + "\n";
|
||||
body += AmountOfCorpse + "\n" + "\n";
|
||||
|
||||
return body;
|
||||
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
resetStats(0, 0, 0, 0, 4, 1, 5, 5, 5, 5);
|
||||
resetStats(3, 6, 7, 8, 4, 1, 5, 5, 5, 5);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user