protected override void Update()
{
base.Update();
if (!rotating && !moving)// && !idle)
{
if (harvesting || emptying)
{
if (harvesting)
{
Collect();
if (currentLoad >= capacity || resourceDeposit.isEmpty())
{
//make sure that we have a whole number to avoid bugs
//caused by floating point numbers
currentLoad = Mathf.Floor(currentLoad);
harvesting = false;
emptying = true;
//foreach (Arms arm in arms) arm.renderer.enabled = false;
//StartMove(resourceStore.transform.position, resourceStore.gameObject);
StartMove(resourceStore.spawnPoint, resourceStore.gameObject);
}
}
else
{
Deposit();
if (currentLoad <= 0)
{
emptying = false;
//foreach (Arms arm in arms) arm.renderer.enabled = false;
if (!resourceDeposit.isEmpty())
{
harvesting = true;
StartMove(resourceDeposit.transform.position, resourceDeposit.gameObject);
}
}
}
}
if (building && currentProject && currentProject.UnderConstruction())
{
amountBuilt += buildSpeed * Time.deltaTime;
int amount = Mathf.FloorToInt(amountBuilt);
if (amount > 0)
{
amountBuilt -= amount;
currentProject.Construct(amount);
if (!currentProject.UnderConstruction())
{
building = false;
//idle = true;
}
}
}
}
}