Jeu pas tout a fait terminer

This commit is contained in:
unknown 2015-08-16 23:17:52 -04:00
parent 4abd161d59
commit 1caf4fa7ff
23 changed files with 2038 additions and 1133 deletions

View File

@ -19,13 +19,13 @@ public class FarmStatsController : MonoBehaviour {
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
UpdateView();
} }
private void UpdateView() private void UpdateView()
{ {
textNbMaison.text = "Nb Maisons : " + stats.AmountHumanHouse; textNbMaison.text = "# Human houses : " + stats.AmountHumanHouse;
textNbHuman.text = "Nb Humans : " + stats.AmountOfHumans; textNbHuman.text = "# Humans : " + stats.AmountOfHumans;
textNbMaxHuman.text = "Max Humans : " + stats.AmountHumanHouse * 10; textNbMaxHuman.text = "Max Humans : " + stats.AmountHumanHouse * 10;
} }
} }

View File

@ -8,14 +8,18 @@ public class RessourceController{
Text viewRock; Text viewRock;
Text viewCorpse; Text viewCorpse;
Text viewMeat; Text viewMeat;
Text viewHuman;
Text viewZombie;
public RessourceController(Stats stats, Text viewW, Text viewR, Text viewC, Text viewM) public RessourceController(Stats stats, Text viewW, Text viewR, Text viewC, Text viewM,Text viewH,Text viewZ)
{ {
this.stats = stats; this.stats = stats;
this.viewCorpse = viewC; this.viewCorpse = viewC;
this.viewWood = viewW; this.viewWood = viewW;
this.viewRock = viewR; this.viewRock = viewR;
this.viewMeat = viewM; this.viewMeat = viewM;
this.viewHuman = viewH;
this.viewZombie = viewZ;
} }
public void setRock(int nbRock){ public void setRock(int nbRock){
@ -48,6 +52,16 @@ public class RessourceController{
{ {
return stats.AmountOfMeat; return stats.AmountOfMeat;
} }
public int getHumans()
{
return stats.AmountOfHumans;
}
public int getZombies()
{
return stats.AmountOfZombies;
}
public void UpdateView() public void UpdateView()
{ {
@ -55,6 +69,8 @@ public class RessourceController{
viewMeat.text = "" + getMeat() + ""; viewMeat.text = "" + getMeat() + "";
viewWood.text = "" + getWood() + ""; viewWood.text = "" + getWood() + "";
viewCorpse.text = "" + getCorpse() + ""; viewCorpse.text = "" + getCorpse() + "";
viewHuman.text = "" + getHumans() + "";
viewZombie.text = "" + getZombies() + "";
} }
} }

View File

@ -17,12 +17,12 @@ public class VillageStatsController : MonoBehaviour {
// Update is called once per frame // Update is called once per frame
void Update () { void Update () {
UpdateView();
} }
private void UpdateView(){ private void UpdateView(){
textNbMaison.text = "Nb Maisons : " + stats.AmountZombieHouse; textNbMaison.text = "# of Zombie Houses : " + stats.AmountZombieHouse;
textNbZombie.text = "Nb Zombies : " + stats.AmountOfZombies; textNbZombie.text = "# of Zombies : " + stats.AmountOfZombies;
textNbMaxZombie.text = "Max Zombies : " + stats.AmountZombieHouse * 10; textNbMaxZombie.text = "Max Zombies : " + stats.AmountZombieHouse * 10;
} }
} }

View File

@ -41,7 +41,6 @@ public class WorkerControllerWood : MonoBehaviour{
{ {
AddButton.enabled = true; AddButton.enabled = true;
} }
if (stats.NbZombieAssigneWood <= 0) if (stats.NbZombieAssigneWood <= 0)
{ {
RemoveButton.enabled = false; RemoveButton.enabled = false;

View File

@ -24,14 +24,15 @@ public class ZombieEatController : MonoBehaviour {
{ {
stats.addZombieAvail(); stats.addZombieAvail();
stats.NbZombieAssigneEat--; stats.NbZombieAssigneEat--;
stats.AmountOfCorpse--; stats.AmountOfCorpse++;
UpdateView(); UpdateView();
} }
private void UpdateView() private void UpdateView()
{ {
stats.NbOfHungerByCoprseEat = 10;
zombieAvailable.text = "Zombie Available : " + stats.AmountOfZombiesAvail + "/" + stats.AmountOfZombies; zombieAvailable.text = "Zombie Available : " + stats.AmountOfZombiesAvail + "/" + stats.AmountOfZombies;
nbRessourceExpected.text = "Zombie Expected : " + stats.NbZombieAssigneEat * stats.NbOfHungerByCoprseEat; nbRessourceExpected.text = "Hunger Quenched : " + stats.NbZombieAssigneEat * stats.NbOfHungerByCoprseEat;
nbWorker.text = "" + stats.NbZombieAssigneEat; nbWorker.text = "" + stats.NbZombieAssigneEat;
nbCorpseAvailable.text = "Corpse : " + stats.AmountOfCorpse; nbCorpseAvailable.text = "Corpse : " + stats.AmountOfCorpse;

View File

@ -0,0 +1,70 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ZombieKillController : MonoBehaviour {
public Text nbWorker;
public Text zombieAvailable;
public Text nbRessourceExpected;
public Text nbHumanAvailable;
public Button AddButton;
public Button RemoveButton;
private Stats stats;
public void AddWorker()
{
stats.removeZombieAvail();
stats.NbZombieAssigneKillHuman++;
//stats.AmountOfCorpse++;
stats.AmountOfHumans--;
UpdateView();
}
public void LessWorker()
{
stats.addZombieAvail();
stats.NbZombieAssigneKillHuman--;
//stats.AmountOfCorpse--;
stats.AmountOfHumans++;
UpdateView();
}
private void UpdateView()
{
zombieAvailable.text = "Zombie Available : " + stats.AmountOfZombiesAvail + "/" + stats.AmountOfZombies;
nbRessourceExpected.text = "Corpse made : " + stats.NbZombieAssigneKillHuman;
nbWorker.text = "" + stats.NbZombieAssigneKillHuman;
nbHumanAvailable.text = "Humans: " + stats.AmountOfHumans;
if (stats.AmountOfZombiesAvail <= 0 || stats.AmountOfHumans <= 0)
{
AddButton.enabled = false;
}
else
{
AddButton.enabled = true;
}
if (stats.NbZombieAssigneKillHuman <= 0)
{
RemoveButton.enabled = false;
}
else
{
RemoveButton.enabled = true;
}
}
// Use this for initialization
void Start()
{
stats = GameObject.Find("Stats").gameObject.GetComponent<Stats>();
}
// Update is called once per frame
void Update()
{
UpdateView();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f82f689191c436c4ca41043188b36171
timeCreated: 1439772273
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Music.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a078c32ba07555c41a95da0b3fd927c4
folderAsset: yes
timeCreated: 1439777937
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: 9375ef8363fd94341930cf8053db537f
timeCreated: 1439777959
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,21 @@
fileFormatVersion: 2
guid: fead9f6d3aea9cb4990e4407a6fd4aff
timeCreated: 1439777960
licenseType: Free
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -51,7 +51,7 @@ SpriteRenderer:
m_AutoUVMaxAngle: 89 m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingOrder: 0 m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 302d9e41e10a7994b985172b1fe118ce, type: 3} m_Sprite: {fileID: 21300000, guid: 302d9e41e10a7994b985172b1fe118ce, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
--- !u!1001 &100100000 --- !u!1001 &100100000
@ -60,7 +60,11 @@ Prefab:
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: [] m_Modifications:
- target: {fileID: 0}
propertyPath: m_SortingOrder
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 0} m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 107150} m_RootGameObject: {fileID: 107150}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
using UnityEngine;
using System.Collections;
public class BuildHuman : MonoBehaviour {
private GameObject[] Grid;
public GameObject humanHouse;
private Stats stats;
public void onClick()
{
stats = GameObject.Find("Stats").gameObject.GetComponent<Stats>();
if (stats.AmountOfWood >= 6 && stats.AmountOfRock>=3) {
stats.removeWood(6);
stats.removeRock(3);
stats.displayStats();
stats.AmountHumanHouse ++;
Grid = GameObject.FindGameObjectsWithTag ("Human");
Instantiate (humanHouse, Grid[Grid.Length-1].transform.position, Grid[Grid.Length-1].transform.rotation);
DestroyObject (Grid[Grid.Length-1]);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 07e71c05ee812b04b8152ed42e929bdd
timeCreated: 1439755661
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
using UnityEngine;
using System.Collections;
public class BuildZombie: MonoBehaviour {
private GameObject[] Grid;
public GameObject zombieHouse;
private Stats stats;
public void onClick()
{
stats = GameObject.Find("Stats").gameObject.GetComponent<Stats>();
if (stats.AmountOfCorpse >= 6) {
stats.removeCorpse(6);
stats.AmountZombieHouse++;
Grid = GameObject.FindGameObjectsWithTag ("Zombie");
Instantiate (zombieHouse, Grid[Grid.Length-1].transform.position, Grid[Grid.Length-1].transform.rotation);
DestroyObject (Grid[Grid.Length-1]);
stats.displayStats();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d604aa01ad301564a89d0cf016ba90ce
timeCreated: 1439757355
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ public class Stats : MonoBehaviour
#region constants #region constants
private readonly int HOUSE_SUPPLY_CAP = 10; private readonly int HOUSE_SUPPLY_CAP = 10;
private readonly int HUMANS_PER_HOUSE = 2; private readonly int HUMANS_PER_HOUSE = 10;
private readonly int HUNGER_PER_ZOMBIE = 100; private readonly int HUNGER_PER_ZOMBIE = 100;
private readonly int HUNGER_PER_HUMAN = 100; private readonly int HUNGER_PER_HUMAN = 100;
private readonly int HUNGER_DEDUCT_PER_DAY_H = 25; private readonly int HUNGER_DEDUCT_PER_DAY_H = 25;
@ -42,6 +42,7 @@ public class Stats : MonoBehaviour
private int nbZombieAssigneCorpse; private int nbZombieAssigneCorpse;
private int nbZombieAssigneEat; private int nbZombieAssigneEat;
private int nbZombieAssigneMakeEatHuman; private int nbZombieAssigneMakeEatHuman;
private int nbZombieAssigneKillHuman;
private int nbHumanHouses; private int nbHumanHouses;
private int nbZombieHouses; private int nbZombieHouses;
@ -96,7 +97,11 @@ public class Stats : MonoBehaviour
get { return nbZombieAssigneMakeEatHuman; } get { return nbZombieAssigneMakeEatHuman; }
set { nbZombieAssigneMakeEatHuman = value; } set { nbZombieAssigneMakeEatHuman = value; }
} }
public int NbZombieAssigneKillHuman
{
get { return nbZombieAssigneKillHuman; }
set { nbZombieAssigneKillHuman = value; }
}
@ -264,8 +269,80 @@ public class Stats : MonoBehaviour
{ {
amountOfZombiesAvail--; amountOfZombiesAvail--;
} }
public void addCorpse(int nb)
{
amountOfCorpse+=nb;
}
public void addWood(int nb)
{
amountOfWood+=nb;
}
public void addMeat(int nb)
{
amountOfMeat+=nb;
}
public void addRock(int nb)
{
amountOfRock+=nb;
}
public void addZombie(int nb)
{
amountOfZombies+=nb;
}
public void addHuman(int nb)
{
amountOfHumans+=nb;
}
public void addZombieAvail(int nb)
{
amountOfZombiesAvail+=nb;
}
public void removeCorpse(int nb)
{
amountOfCorpse-=nb;
}
public void removeWood(int nb)
{
amountOfWood-=nb;
}
public void removeMeat(int nb)
{
amountOfMeat-=nb;
}
public void removeRock(int nb)
{
amountOfRock-=nb;
}
public void removeZombie(int nb)
{
amountOfZombies-=nb;
}
public void removeHuman(int nb)
{
amountOfHumans-=nb;
}
public void removeZombieAvail(int nb)
{
amountOfZombiesAvail-=nb;
}
#endregion #endregion
/* /*
public Stats(int nbRock, int nbWood, int nbCorpse, int nbMeat, int nbHumans, int nbZombies) public Stats(int nbRock, int nbWood, int nbCorpse, int nbMeat, int nbHumans, int nbZombies)
{ {
@ -348,10 +425,13 @@ public class Stats : MonoBehaviour
string descEvent = applyStatModifications(); string descEvent = applyStatModifications();
calculateHunger(); calculateHunger();
advanceTurn(); advanceTurn();
feed();
return descEvent; return descEvent;
} }
private void feed()
{
AmountOfZHunger += NbOfHungerByCoprseEat * nbZombieAssigneEat;
}
private void calculateHunger() private void calculateHunger()
{ {
AmountOfHHunger -= HUNGER_DEDUCT_PER_DAY_H * AmountOfHumans; AmountOfHHunger -= HUNGER_DEDUCT_PER_DAY_H * AmountOfHumans;
@ -403,6 +483,7 @@ public class Stats : MonoBehaviour
body += AmountOfMeat + "\n" + "\n"; body += AmountOfMeat + "\n" + "\n";
body += AmountOfCorpse + "\n" + "\n"; body += AmountOfCorpse + "\n" + "\n";
return body; return body;
} }
@ -423,11 +504,13 @@ public class Stats : MonoBehaviour
{ {
Evenement evenement = new Evenement(); Evenement evenement = new Evenement();
evenement.GetEventForThisRound(NbTurns); evenement.GetEventForThisRound(NbTurns);
float r = UnityEngine.Random.value;
AmountOfWood = AmountOfWood + NbZombieAssigneWood * NbOfWoodByZombie * evenement.MultiWood/10; AmountOfWood = AmountOfWood + NbZombieAssigneWood * NbOfWoodByZombie * evenement.MultiWood/10;
AmountOfRock = AmountOfRock + NbZombieAssigneRock * NbOfRockByZombie * evenement.MutliRock/10; AmountOfRock = AmountOfRock + NbZombieAssigneRock * NbOfRockByZombie * evenement.MutliRock/10;
AmountOfCorpse = AmountOfCorpse + NbZombieAssigneCorpse * NbOfCorpseByZombie * evenement.MultiCorps/10; AmountOfCorpse = AmountOfCorpse + nbZombieAssigneKillHuman * 4 * evenement.MultiCorps/10;
AmountOfHumans = Mathf.RoundToInt( HUMANS_PER_HOUSE * ((AmountHumanHouse==0)?1:AmountHumanHouse)*r) ;
AmountOfZHunger += NbOfHungerByCoprseEat * nbZombieAssigneEat;
AmountOfZombies += NbZombieAssigneCorpse;
setMaxHungerHumans(); setMaxHungerHumans();
setMaxHungerZombies(); setMaxHungerZombies();
@ -442,7 +525,10 @@ public class Stats : MonoBehaviour
NbZombieAssigneCorpse = 0; NbZombieAssigneCorpse = 0;
NbZombieAssigneWood = 0; NbZombieAssigneWood = 0;
NbZombieAssigneRock =0; NbZombieAssigneRock =0;
NbZombieAssigneEat = 0;
nbZombieAssigneMakeEatHuman =0; nbZombieAssigneMakeEatHuman =0;
nbZombieAssigneKillHuman = 0;
nbZombieAssigneCorpse = 0;
AmountOfZombiesAvail = AmountOfZombies; AmountOfZombiesAvail = AmountOfZombies;
} }

View File

@ -30,7 +30,7 @@ TextureImporter:
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
filterMode: -1 filterMode: -1
aniso: -1 aniso: 16
mipBias: -1 mipBias: -1
wrapMode: 1 wrapMode: 1
nPOTScale: 0 nPOTScale: 0
@ -43,7 +43,7 @@ TextureImporter:
alignment: 0 alignment: 0
spritePivot: {x: .5, y: .5} spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100 spritePixelsToUnits: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
textureType: 8 textureType: 8
buildTargetSettings: [] buildTargetSettings: []

View File

@ -30,7 +30,7 @@ TextureImporter:
maxTextureSize: 2048 maxTextureSize: 2048
textureSettings: textureSettings:
filterMode: -1 filterMode: -1
aniso: -1 aniso: 16
mipBias: -1 mipBias: -1
wrapMode: 1 wrapMode: 1
nPOTScale: 0 nPOTScale: 0
@ -43,7 +43,7 @@ TextureImporter:
alignment: 0 alignment: 0
spritePivot: {x: .5, y: .5} spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100 spritePixelsToUnits: 1
alphaIsTransparency: 1 alphaIsTransparency: 1
textureType: 8 textureType: 8
buildTargetSettings: [] buildTargetSettings: []

View File

@ -9,17 +9,18 @@ public class RessourceView: MonoBehaviour{
public Text rockText; public Text rockText;
public Text woodText; public Text woodText;
public Text meatText; public Text meatText;
public Text zombieText;
public Text humanText;
void Start() void Start()
{ {
Stats stats = GameObject.Find("Stats").gameObject.GetComponent<Stats>(); Stats stats = GameObject.Find("Stats").gameObject.GetComponent<Stats>();
rc = new RessourceController(stats, corpseText, rockText, woodText, meatText); rc = new RessourceController(stats, woodText, rockText, corpseText, meatText,humanText,zombieText);
} }
void Update() void Update()
{ {
rc.UpdateView(); rc.UpdateView();
} }
} }

View File

@ -5,7 +5,7 @@ TagManager:
serializedVersion: 2 serializedVersion: 2
tags: tags:
- Zombie - Zombie
- Humain - Human
- Champ - Champ
layers: layers:
- Default - Default