// Update is called once per frame void Update() { lightingStrikeTimer -= Time.deltaTime; if (lightingStrikeTimer <= 0) { SetRandomLightingStrikeTimer(); SetOffRandomLighting(); } this.transform.position += direction * speed * Time.deltaTime; if (Vector3.Distance(this.transform.position, endPosition) < 1 && !killed) { speed = 0; Destroy(this.gameObject); popController.KillPercentOfPopulation(30); if (UnityEngine.Random.Range(0f, 1f) > 0.3f) { Array type = eBuildingTypes.GetValues(typeof(eBuildingTypes)); eBuildingTypes buildingType = (eBuildingTypes)type.GetValue(UnityEngine.Random.Range(0, type.Length)); GameObject building = buildingController.GetRandomBuilding(buildingType); if (building != null) { Instantiate <GameObject>(explosionPrefab, building.transform.position, Quaternion.identity); buildingController.RemoveBuilding(buildingType, building); } else { Debug.Log("There were no buildings to destroy"); } } killed = true; } }
// Update is called once per frame void Update() { this.transform.position += direction * speed * Time.deltaTime; if (Vector3.Distance(this.transform.position, endPosition) < 1 && !killed) { speed = 0; smokeParticleSys.Play(); Invoke("RemoveSpriteRenderer", 0.7f); Destroy(this.gameObject, 3); popController.KillPercentOfPopulation(50); killed = true; } }