void Update()
{
//if (GetComponent<Unit>().getInConstruction())
if(constructionOnGoing)
{
//Timer that changes the mesh of the building
//Debug.Log("Is revealer "+GetComponent<LOSEntity>().IsRevealer);
//Debug.Log(timer);
timer -= constructingUnits.Count * Time.deltaTime;
if(timer < 15 && phase==0)
{
GetComponent<MeshFilter>().mesh = progressMesh.GetComponent<MeshFilter>().sharedMesh;
phase = 1;
}
if(timer<=0 && phase == 1)
{
phase=2;
GetComponent<MeshFilter>().mesh = finalMesh;
foreach (var unit in constructingUnits) unit.GetComponent<Construct>().SetInConstruction(false);
constructingUnits.Clear();
//GetComponent<Unit>().SetInConstruction(false);
constructionOnGoing = false;
GetComponent<LOSEntity>().IsRevealer = (tag=="Ally");
GameController.Instance.updateInteractable();
GameController.Instance.addUnit(gameObject);
if(GameData.winConditions.Contains (Victory.Wonder) && GetComponent<Identity>().unitType == UnitType.Wonder){
if (gameObject.tag=="Ally") {
GameController.Instance.ToGameStatistics(gameObject.transform.position, Player.Player, Victory.Wonder);
/*GameController.Instance.hud.gameMenu.GetComponent<GameMenuBehaviour>().EndGameMenu(
gameObject.transform.position, true, "You built a Wonder"
);*/
} else if(gameObject.tag=="Enemy") {
GameController.Instance.ToGameStatistics(gameObject.transform.position, Player.CPU1, Victory.Wonder);
/*GameController.Instance.hud.gameMenu.GetComponent<GameMenuBehaviour>().EndGameMenu(
gameObject.transform.position, false, "Enemy Wonder was created"
);*/
}
}
}
}
else
{
if (constructingUnits.Count > 0)
{
foreach (var unit in constructingUnits) unit.GetComponent<Construct>().SetInConstruction(false);
constructingUnits.Clear();
}
}
}