void Update() { if (!ending_ && current_flowers_[current_flower_index_].IsBroken()) { int next_flower_index = (current_flower_index_ + 1) % maxFlowers; FlowerGrower current_flower = current_flowers_[current_flower_index_]; FlowerGrower next_flower = current_flowers_[next_flower_index]; current_flower.RemoveStump(); if (next_flower != null && !next_flower.IsGrabbed()) { next_flower.Die(); } if (current_flower.IsStumpClear() && (next_flower == null || next_flower.IsDead())) { if (next_flower != null) { Destroy(next_flower.gameObject); } FlowerGrower flower = Instantiate(flowerModels[next_flower_model_index_]) as FlowerGrower; current_flower_index_ = next_flower_index; current_flowers_[current_flower_index_] = flower; flower.gameObject.SetActive(true); next_flower_model_index_ = (next_flower_model_index_ + 1) % flowerModels.Length; } } }
private void Update() { if (isTimer) { instanceTime += Time.deltaTime; if (instanceTime > dieTime) { fg = GameObject.FindGameObjectWithTag("Flower").GetComponent <FlowerGrower>(); flowerPos = fg.transform.position; fg.Die(); } } if (fg && fg.IsDead()) { GameObject[] currentFlowers = GameObject.FindGameObjectsWithTag("Flower"); foreach (GameObject flower in currentFlowers) { Destroy(flower); } instanceTime = 0; isTimer = false; Instantiate(flower, flowerPos, Quaternion.identity); } }
void Start() { FlowerGrower flower = Instantiate(flowerModels[next_flower_model_index_]) as FlowerGrower; current_flowers_ = new FlowerGrower[maxFlowers]; current_flowers_[current_flower_index_] = flower; flower.gameObject.SetActive(true); next_flower_model_index_ = (next_flower_model_index_ + 1) % flowerModels.Length; }