private void Update() { if (gameOver) { return; } uiGoldResource.SetValue(island.GetResourceAmount(Island.ResourceType.Gold)); uiAmmoResource.SetValue(island.GetResourceAmount(Island.ResourceType.Ammo)); uiSoldiersResource.SetValue(island.GetResourceAmount(Island.ResourceType.Soldier)); if (currentBuilding) { var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); currentBuilding.transform.position = new Vector3(pos.x, pos.y, currentBuilding.transform.position.z); island.HighlightCellsForConstructible(currentBuilding); } if (Input.GetMouseButtonDown(0) && currentBuilding != null) { if (island.CanBuildConstructible(currentBuilding) && island.CanUseResource(Island.ResourceType.Gold, currentPrice)) { island.BuildConstructible(currentBuilding); island.UseResource(Island.ResourceType.Gold, currentPrice); } else { DestroyObject(currentBuilding); } currentBuilding = null; island.UnhighlightAll(); } if (Input.GetButtonDown("Cancel") && currentBuilding != null) { DestroyObject(currentBuilding); currentBuilding = null; island.UnhighlightAll(); } timeBeforeNextWave -= Time.deltaTime; statusBar.SetWave(wave); statusBar.SetNextWaveIn(timeBeforeNextWave); statusBar.SetShipsBoarded(shipsBoarded, maxShipsBoarding); shipSpawnDelay -= Time.deltaTime; if (!waveEnded && shipSpawnDelay < 0.0f && shipsLeftToSpawn > 0) { SpawnShip(); shipSpawnDelay = shipSpawnInterval; shipsLeftToDestroy++; shipsLeftToSpawn--; } }