private void UpdateFloods(float deltaTime) { if (currentFloodDuration > 0.0f) { currentFloodDuration -= deltaTime; switch (currentFloodType) { case FloodType.Minor: currentFloodState += deltaTime; //lerp the water surface in all hulls 50 units above the floor within 10 seconds foreach (Hull hull in Hull.hullList) { hull.DrawSurface = hull.Rect.Y - hull.Rect.Height + MathHelper.Lerp(0.0f, 50.0f, currentFloodState / 10.0f); } break; case FloodType.Major: currentFloodState += deltaTime; //create a full flood in 10 seconds foreach (Hull hull in Hull.hullList) { hull.DrawSurface = hull.Rect.Y - MathHelper.Lerp(hull.Rect.Height, 0.0f, currentFloodState / 10.0f); } break; case FloodType.HideFlooding: //hide water inside hulls (the player can't see which hulls are flooded) foreach (Hull hull in Hull.hullList) { hull.DrawSurface = hull.Rect.Y - hull.Rect.Height; } break; } return; } if (createFloodTimer < MathHelper.Lerp(maxFloodInterval, minFloodInterval, Strength / 100.0f)) { createFloodTimer += deltaTime; return; } //probability of a fake flood goes from 0%-100% if (Rand.Range(0.0f, 100.0f) < Strength) { if (Rand.Range(0.0f, 1.0f) < 0.5f) { currentFloodType = FloodType.HideFlooding; } else { currentFloodType = Strength < 50.0f ? FloodType.Minor : FloodType.Major; } currentFloodDuration = Rand.Range(20.0f, 100.0f); } createFloodTimer = 0.0f; }
private void UpdateFloods(float deltaTime) { if (currentFloodDuration > 0.0f) { currentFloodDuration -= deltaTime; switch (currentFloodType) { case FloodType.Minor: currentFloodState += deltaTime; //lerp the water surface in all hulls 15 units above the floor within 10 seconds foreach (Hull hull in Hull.hullList) { for (int i = hull.FakeFireSources.Count - 1; i >= 0; i--) { hull.FakeFireSources[i].Extinguish(deltaTime, 50.0f); } hull.DrawSurface = hull.Rect.Y - hull.Rect.Height + MathHelper.Lerp(0.0f, 15.0f, currentFloodState / 10.0f); } break; case FloodType.Major: currentFloodState += deltaTime; //create a full flood in 10 seconds foreach (Hull hull in Hull.hullList) { for (int i = hull.FakeFireSources.Count - 1; i >= 0; i--) { hull.FakeFireSources[i].Extinguish(deltaTime, 200.0f); } hull.DrawSurface = hull.Rect.Y - MathHelper.Lerp(hull.Rect.Height, 0.0f, currentFloodState / 10.0f); } break; case FloodType.HideFlooding: //hide water inside hulls (the player can't see which hulls are flooded) foreach (Hull hull in Hull.hullList) { hull.DrawSurface = hull.Rect.Y - hull.Rect.Height; } break; } return; } if (createFloodTimer < MathHelper.Lerp(MaxFloodInterval, MinFloodInterval, Strength / 100.0f)) { currentFloodType = FloodType.None; createFloodTimer += deltaTime; return; } //probability of a fake flood goes from 0%-100% if (Rand.Range(0.0f, 100.0f) < Strength) { if (Rand.Range(0.0f, 1.0f) < 0.5f) { currentFloodType = FloodType.HideFlooding; currentFloodType = FloodType.Minor; } else { //disabled Major flooding because it's too easy to tell it's fake currentFloodType = FloodType.Minor;// Strength < 50.0f ? FloodType.Minor : FloodType.Major; } currentFloodDuration = Rand.Range(20.0f, 100.0f); } createFloodTimer = 0.0f; }