Files
grass-cutters/Assets/Scripts/World/Soundscape.cs
Bonchellon 3ee5956694 Ending: the Director's call, flyovers into orbit, Earth turning green, credits
When the planet is mown the ending plays by itself: G.R.A.S.S.A. calls, the
camera skims the stubble into the base, circles it and rises without a cut
into orbit over the bald planet (title, the crew's results). Then a jump
across space to a scorched, dried-out Earth: a rocket from Herbaria-7 passes
the lens and lands in Africa, and the green spreads from there over the whole
globe (seed pods, a glowing front, clouds and blue air coming back). The
credits roll over the green Earth (PlayWay credited as publisher), then THE
END and a card to keep mowing, leave a review or go to the menu. Space, Enter
or Esc skips to the green Earth and the card.

- EndingCinematic, EndingEarth (globe, air shell, rocket, seeds), SpaceSky
  (split out of the intro), EarthGlobe/EarthAir shaders and Earth maps in
  Resources/Ending
- the far meadow shows as stubble once the planet is mown
- "all of it" mown now means no sector with grass left (MowMap.Left); mown
  area summed in double
- the crew's total pay and play time are counted and saved for the results
- the "ending" cheat; -ending previews it in a test world; the -ending bot
  shoots every stage
- loc for the new lines in all 11 languages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 01:52:24 +03:00

54 lines
2.0 KiB
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>
/// Wind by day and crickets by night where the camera is, and music that follows them: five tunes in turn by day, two quiet
/// ones in the dark, and a tense one while a storm is on.
/// </summary>
public class Soundscape : MonoBehaviour
{
const float Loud = 0.32f, TuneLength = 200f, Every = 2f;
AudioSource _wind, _crickets;
float _next, _tuneEnds;
bool _night;
int _day, _dark;
static readonly string[] Days = { "music_game_loop", "music_game3_loop", "music_game2_loop", "music_game4_loop", "music_game5_loop" };
static readonly string[] Nights = { "music_night_loop", "music_night2_loop" };
AudioSource Make(string clip)
{
var s = Sfx.Loop(clip, transform, 0f);
if (s) s.spatialBlend = 0f;
return s;
}
void Update()
{
if (!_wind)
{
if (!AssetBank.I) return;
_wind = Make("wind_meadow_loop");
_crickets = Make("night_crickets_loop");
if (!_wind) { enabled = false; return; }
}
float dark = DayNight.Dark;
_wind.volume = Loud * (1f - dark) * Sfx.SfxVolume;
if (_crickets) _crickets.volume = Loud * dark * Sfx.SfxVolume;
if (Time.time < _next || !UIRoot.I || !UIRoot.I.InGame) return;
_next = Time.time + Every;
if (_night ? dark < 0.3f : dark > 0.7f) _night = !_night;
if (Time.time >= _tuneEnds)
{
_tuneEnds = Time.time + TuneLength;
if (_night) _dark = (_dark + 1) % Nights.Length;
else _day = (_day + 1) % Days.Length;
}
// the ending plays its own tune under the planet
if (EndingCinematic.Running) return;
Sfx.Music(WeatherFx.Storm > 0.5f ? "music_storm_loop" : _night ? Nights[_dark] : Days[_day], 4f);
}
}
}