public void Update() { if (woodRequired == 0) { progress = 1; } else { progress = Mathf.Min( progress + Time.deltaTime / woodRequired / buildingTime, woodProvided / (float)woodRequired); var newDepth = (int)(model.MaxDepth() * progress); if (newDepth != modelDepth) { modelDepth = newDepth; UpdateModel(); } } }
public void Start() { pos = WorldGrid.instance.GridPos(transform.position); WorldGrid.instance.AddBuilding(this); model = GetComponent <VoxelModel>(); progress = woodRequired > 0 ? woodProvided / (float)woodRequired : 1; modelDepth = (int)(model.MaxDepth() * progress); UpdateModel(); }