public Cargo GetCargo() { if(cargo != null) { Cargo tmp = cargo; cargo = null; return tmp; } else { return null; } }
private void TryDropoff(City city) { if(cargo == null || cargo.city != city.city) { return; } GameDriver.Instance.CargoDelivered(cargo); Destroy(cargo.gameObject); cargo = null; AudioSource.PlayClipAtPoint(dropoffSound, Camera.main.transform.position); }
public void SpawnCargo() { isSpawning = false; CityName randCity; do { randCity = (CityName)City.CityNames.GetValue(Random.Range(0, numCities)); } while(randCity == city.city); cargo = (Instantiate(cargoPrefab.gameObject, SpawnPoint.position, Quaternion.identity) as GameObject) .GetComponent<Cargo>(); cargo.city = randCity; }
public void PickupCargo(CargoPickup pickup) { if(cargo != null) { return; // we already have cargo, don't pickup } cargo = pickup.GetCargo(); if(cargo == null) { return; // no cargo to pickup } cargo.transform.parent = cargoPoint; cargo.transform.localPosition = Vector3.zero; GameDriver.Instance.CargoPicked(cargo); AudioSource.PlayClipAtPoint(pickupSound, Camera.main.transform.position); }
public void CargoPicked(Cargo cargo) { SpawnRandomCargo(false); }
public void CargoDelivered(Cargo cargo) { score += cargoValue; }