public void MoveAnimationDone() { bot.ResetRound(); // update based on current state - kill/spawn fish based on ph-level Debug.Log(biotopes[direction].PhValue); float newFish = Mathf.Cos((biotopes[direction].PhValue / 2.5f) * Mathf.PI); BiotopeSettings settings = biotopes[direction].biotopeGO.GetComponent <BiotopeSettings>(); newFish -= settings.killFish; newFish = Mathf.Max(newFish, -0.9f); newFish = Mathf.Min(newFish, 0.9f); newFish *= swarmLogic.allFish.Count; newFish = Mathf.Min(newFish, 100f); // Debug.Log((biotopes[direction].PhValue) + " --> " + (biotopes[direction].PhValue / 2.5f) + " --> " + (int)newFish); if (newFish > 0) { for (int i = 0; i < newFish; i++) { swarmLogic.addFish(); } } else { for (int i = 0; i < -newFish; i++) { swarmLogic.removeFish(); } } // reset animation for next choice Animation ani = camRails.GetComponent <Animation>(); ani.Rewind(); ani.Stop(); camRails.transform.position = Vector3.zero; UpdateArrowAnimation(); pauseTimer = false; lastReset = Time.realtimeSinceStartup + resetAfter; ResetGL(); }
public void calculateNewPhValue() { BiotopeSettings settings = biotopeGO.GetComponent <BiotopeSettings>(); phValue = Random.Range(-2.0f, 2.0f); phValue = (PhValue < 0) ? PhValue - settings.phBoost : PhValue + settings.phBoost; phValue = Mathf.Min(Mathf.Max(PhValue, -2.5f), 2.5f); foreach (Transform child in phValueGO.transform) { if (child.gameObject.name == "Slider") { Vector3 pos = child.gameObject.transform.localPosition; pos.x = PhValue; child.gameObject.transform.localPosition = pos; break; } } }