public override void Update() { if (stomach_bubbles_.Count < StomachLevel.MAX_STOMACH_BUBBLES) { Debug.Log("less stomach bubbles than max amount"); float new_bubble_chance = Random.value; if (new_bubble_chance > .5f) { Debug.Log("Creating a new bubble"); StomachBubble new_bubble = new StomachBubble(); stomach_bubbles_.Add(new_bubble); float x_pos = Random.value; float y_pos = Random.value; new_bubble.SetPosition(x_pos * bubble_container_size_.width + bubble_container_size_.xMin, y_pos * bubble_container_size_.height + bubble_container_size_.yMin); bubbles_container_.AddChild(new_bubble); } } for (int b = stomach_bubbles_.Count - 1; b >= 0; b--) { StomachBubble bubble = stomach_bubbles_[b]; if (bubble.Finished) { bubbles_container_.RemoveChild(bubble); stomach_bubbles_.Remove(bubble); } } }
public override void Update() { if(stomach_bubbles_.Count < StomachLevel.MAX_STOMACH_BUBBLES) { Debug.Log("less stomach bubbles than max amount"); float new_bubble_chance = Random.value; if(new_bubble_chance > .5f) { Debug.Log("Creating a new bubble"); StomachBubble new_bubble = new StomachBubble(); stomach_bubbles_.Add(new_bubble); float x_pos = Random.value; float y_pos = Random.value; new_bubble.SetPosition(x_pos*bubble_container_size_.width + bubble_container_size_.xMin, y_pos*bubble_container_size_.height + bubble_container_size_.yMin); bubbles_container_.AddChild(new_bubble); } } for(int b = stomach_bubbles_.Count-1; b >= 0; b--) { StomachBubble bubble = stomach_bubbles_[b]; if(bubble.Finished) { bubbles_container_.RemoveChild(bubble); stomach_bubbles_.Remove(bubble); } } }