@@ -2,13 +2,11 @@
using System.Collections.Generic;
using UnityEngine.UI;


public class Human : MonoBehaviour
{
#region Outside Varables

private const int maxHealth = 100;
private const int maxMediumHealth = 80;
private const int maxLowHealth = 40;
public Text nameUI;

Community communityObj;
@@ -28,10 +26,10 @@ public class Human : MonoBehaviour

public bool dead = false;

private Hunger food;
private Thirst water;
private Temperature tempera;
private Pregnancy pregnant;
public Hunger food;
public Thirst water;
public Temperature tempera;
public Pregnancy pregnant;
public Age age;


@@ -55,10 +53,11 @@ public class Human : MonoBehaviour

#region Relations
private Human currentChild;
private Human dad;
private Human mum;
public Human dad;
public Human mum;
private Human partner;
private List<Human> children = new List<Human>();
public bool parents;
public List<Human> children = new List<Human>();
#endregion

#region Programming Info
@@ -94,14 +93,15 @@ public void StartHuman(int day, int year,Human theMum)
surname = theMum.surname;
mum = theMum;
dad = theMum.partner;
parents = true;
}
else // otherwise create a new surname for them
{
mum = null;
dad = null;
int numNames = System.Enum.GetNames(typeof(Surnames)).Length;
int rand = Random.Range(0, numNames);
surname = System.Enum.GetName(typeof(Surnames), rand);

SetSurname();
parents = false;
}
pregnant = new Pregnancy();
CanBePregnant();
@@ -114,7 +114,25 @@ public void StartHuman(int day, int year,Human theMum)
myMat = GetComponentInChildren<Renderer>().material;
}

private string GetWholeName()

void SetSurname()
{
bool test = true;

while (test)
{
int numNames = System.Enum.GetNames(typeof(Surnames)).Length;
int rand = Random.Range(0, numNames);
surname = System.Enum.GetName(typeof(Surnames), rand);
test = communityObj.SurnameUsed(surname);

}



}

public string GetWholeName()
{
return firstName + " " + surname;
}
@@ -146,11 +164,14 @@ private void CanBePregnant()
{
pregnant.canBePregnant = false;
}
}else if (sex == femaleS&& age.GetAgeType() >=ageType.adult) // if the person is female and is old enough then they can Be Pregnant
}
else if (sex == femaleS&& age.GetAgeType() >=ageType.adult) // if the person is female and is old enough then they can Be Pregnant
{
// Debug.Log("1");
// Debug.Log(Child);
//Debug.Log(Child!=null);


pregnant.SetChance(age.GetAgeType());


pregnant.canBePregnant = true;
}
}
@@ -463,8 +484,9 @@ public void StartHumanDay()
{
currentChild = communityObj.CreateBabyVillager(this);
children.Add(currentChild);
partner.children.Add(currentChild);
pregnant.GiveBirth();
Debug.Log(age.GetAgeType() + "Giving Birth ");
// Debug.Log(age.GetAgeType() + "Giving Birth ");
}


@@ -482,8 +504,7 @@ private void EndHumanDay()
{
// first check to see if the human will die from lack of food
if (dead || food.CheckHungerDeath() || water.CheckThirstDeath()|| age.CheckAgeDeath()||tempera.CheckColdDeath())
{

{
dead = true;
return;
}
@@ -14,6 +14,8 @@ public override void OnInspectorGUI()
{
Human theHuman = (Human)target;
EditorGUILayout.LabelField("Age", theHuman.age.CheckAge());


}


@@ -0,0 +1,37 @@
using UnityEngine;
using System.Collections;

[System.Serializable]
public class HumanHolder {

public Hunger food;
public Thirst water;
public Temperature tempera;
public Pregnancy pregnant;
public Age age;
public int shelterNum;
public string sex;
public string mumFirsName;
public string dadFirsName;
public int numChildren;
public string myName;


public HumanHolder( Hunger afood, Thirst awater,Temperature atempera, Pregnancy apregnant, Age aage, int ashelterNum, string asex, string amumFirsName, string adadFirsName, int anumChildren, string amyName)
{
food = afood;
water = awater;
tempera = atempera;
pregnant = apregnant;
age = aage;
shelterNum = ashelterNum;
sex = asex;
mumFirsName = amumFirsName;
dadFirsName = adadFirsName;
numChildren = anumChildren;
myName = amyName;

}


}
@@ -0,0 +1,36 @@
using UnityEngine;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

public class HumanTestData : MonoBehaviour {
public int a = 0;
public List<List<HumanHolder>> allHumans = new List<List<HumanHolder>>();

// Use this for initialization
void Start () {
// Debug.Log(Application.persistentDataPath);
GetAllHumans();
}

// Update is called once per frame
void Update () {
if (Input.GetKeyDown("j"))
{
GetAllHumans();

}
}

void GetAllHumans() // just for testing
{
if (File.Exists(Application.persistentDataPath + Community.fileName))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream fileOpen = File.Open(Application.persistentDataPath + Community.fileName, FileMode.Open);
allHumans = (List<List<HumanHolder>>)bf.Deserialize(fileOpen);
fileOpen.Close();
}

}
}
@@ -14,7 +14,6 @@ public bool PlacePersonNode(GameObject thePerson)
return false;
}


peopleList.Add(thePerson);
PlacePeople();
return true;
@@ -39,8 +38,6 @@ private void PlacePeople()
peopleList[i].transform.position = toPlace;
toPlace.x += peopleWidth;
}


}


@@ -52,17 +49,14 @@ public bool RemovePersonNode(GameObject thePerson)
return false;
}


for (int i = 0; i < peopleList.Count; i++)
{
if (peopleList[i] == thePerson)
{
//Debug.Log(peopleList[i]);
peopleList.RemoveAt(i);

i = peopleList.Count;
}

}

PlacePeople(); ;
@@ -14,7 +14,7 @@

// only adults can be pregnant ( old people might have a small chance at this later)


[System.Serializable]
public class Age
{
public const int oldAge = 40;
@@ -47,7 +47,7 @@ private void CheckAgeType()
{
if (ageYear > oldAge)
{
theAgeType = ageType.oldAge;
theAgeType = ageType.senior;
// GetComponentInChildren<Renderer>().material.color = Color.grey;
}
else if (ageYear > 16)
@@ -73,7 +73,7 @@ public Color CheckAgeColour()

if (ageYear > oldAge)
{
theAgeType = ageType.oldAge;
theAgeType = ageType.senior;
return Color.grey;
}
else if (ageYear > 16)
@@ -1,6 +1,6 @@
using UnityEngine;
using System.Collections;

[System.Serializable]
public class Hunger
{
int hunger; // the current hunger level
@@ -1,12 +1,13 @@
using UnityEngine;
using System.Collections;

[System.Serializable]
public class Pregnancy
{
bool pregnant;
int lengthofPregnancy;
public bool canBePregnant;
int countnopreg;
float chance =1;
// for now just handles if the mother will give birth but later on might also be used to check if the mother can work in currrent state
// and if the mother does work if it has any affect on the baby

@@ -75,14 +76,29 @@ public bool NewDay()
void RandomGetPreganant()
{
// Debug.Log("2");
int check = Random.Range(0, 100);
if (check<1)
float check = Random.Range(0.0f, 100.0f);
if (check< chance)
{
setPregnant();
}

}

public void SetChance(ageType age)
{
if(age== ageType.adult)
{
chance = 1;

}
else
{

chance =0.1f;
}


}


/// <summary>
@@ -1,7 +1,7 @@
using UnityEngine;
using System.Collections;


[System.Serializable]
//later on this will be more complex taking temp from the season's temp if the human is working clothes and the shelter
//for now just used to record days without fire in shelter and if would die
public class Temperature
@@ -1,6 +1,6 @@
using UnityEngine;
using System.Collections;

[System.Serializable]
public class Thirst {
int thirst; // the number of days without water

@@ -60,7 +60,7 @@ void newAssigement(List<Human> people)

unAssignedTeens.Add(h);
}
else if (h.age.GetAgeType() == ageType.oldAge)
else if (h.age.GetAgeType() == ageType.senior)
{

unAssignedOldAge.Add(h);
@@ -7,7 +7,7 @@ public class Farming : Task
public Farming()
{
payoff = JobPurpose.food;
jobProduction = 5; //farming for the day gives 5 food which is nearly enough for 2 people
jobProduction = 6; //farming for the day gives 5 food which is nearly enough for 2 people
}

}
@@ -7,6 +7,6 @@ public Logging()
{
payoff = JobPurpose.fuel;
//jobBaseCoverage = 5;
jobProduction = 3; //one tree gives 2-3 wood (for now just gives 3 wood but later make it random
jobProduction = 4; //one tree gives 2-3 wood (for now just gives 3 wood but later make it random
}
}
@@ -14,8 +14,11 @@ public class TheLand : MonoBehaviour {
public delegate void EndDayAction();
public static event EndDayAction EndDay;

public delegate void SaveHuamansAction();
public static event SaveHuamansAction SaveHumans;

private float startTime;
public const float dayLengthSecs = 0.001f;
public const float dayLengthSecs = 0.00000000000000000000000000000000000000000000000001f;
public int dayCount;
private bool first = false;
public bool timeRun = true;
@@ -29,16 +32,9 @@ public class TheLand : MonoBehaviour {
dayCount = 0;
setTimeUI();
first = true;

}

void setTimeUI()
{
float holdTime = ((float)dayCount / 365.0f);
int holdYears = Mathf.FloorToInt(holdTime);
float holdDays = Mathf.Floor((holdTime - holdYears) * 365);
timeRecord.text = "Year:" + Mathf.Floor(holdTime) + ", Day:" + holdDays;

}

// Update is called once per frame
void Update ()
@@ -49,18 +45,16 @@ void Update ()
first = false;
}
// need to make this time based instead of input later

/*
if (Input.GetKeyDown("g"))
{
StartEndDay();
dayCount++;
setTimeUI();
StartNewDay();
}



// /*
*/
if (startTime + dayLengthSecs <= Time.time && timeRun)
{
StartEndDay();
@@ -69,15 +63,28 @@ void Update ()
setTimeUI();
StartNewDay();
}
// */
//Debug.Log(Time.time);

if (dayCount >= 365*100)
{
SaveHumans();

Debug.Log("newLevel");
}


// going to make a day 24 seconds


}


void setTimeUI()
{
float holdTime = ((float)dayCount / 365.0f);
int holdYears = Mathf.FloorToInt(holdTime);
int holdDays = Mathf.FloorToInt((holdTime - holdYears) * 365);
timeRecord.text = "Year:" + Mathf.Floor(holdTime) + ", Day:" + holdDays;
}

private void StartNewDay()
{
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -17,7 +17,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
Policies = $0
$0.TextStylePolicy = $1
@@ -17,7 +17,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
Policies = $0
$0.TextStylePolicy = $1