Files
grass-cutters/Assets/Scripts/UI/SpaceSky.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

70 lines
2.8 KiB
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>
/// Out in space for the films: a black sky and a shell of stars round the eye instead of the day's blue. The opening film
/// goes up into it once; the ending stays there.
/// </summary>
public static class SpaceSky
{
static ParticleSystem s_stars;
static CameraClearFlags s_clear;
static Color s_clearColour;
public static bool On { get; private set; }
public static void Set(bool on, Vector3 eye)
{
var cam = CameraFx.Cam;
if (!cam || on == On) return;
On = on;
if (on)
{
s_clear = cam.clearFlags;
s_clearColour = cam.backgroundColor;
cam.clearFlags = CameraClearFlags.SolidColor;
cam.backgroundColor = new Color(0.008f, 0.012f, 0.03f);
if (!s_stars)
{
var go = new GameObject("SpaceStars");
Object.DontDestroyOnLoad(go);
s_stars = go.AddComponent<ParticleSystem>();
s_stars.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
var main = s_stars.main;
main.playOnAwake = false; main.loop = false;
main.startLifetime = 600f; main.startSpeed = 0f;
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.maxParticles = 2000;
var em = s_stars.emission; em.enabled = false;
var sh = s_stars.shape; sh.enabled = false;
var r = go.GetComponent<ParticleSystemRenderer>();
r.sharedMaterial = AssetBank.I.Mat("FX_Sparkle") ?? AssetBank.I.Mat("FX_Soft");
r.maxParticleSize = 0.02f;
r.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
s_stars.Play();
}
s_stars.Clear();
for (int i = 0; i < 1400; i++)
{
var d = Random.onUnitSphere;
float far = 30000f;
var ep = new ParticleSystem.EmitParams
{
position = eye + d * far,
startSize = far * Random.Range(0.0012f, 0.0034f),
startColor = Color.Lerp(new Color(0.75f, 0.85f, 1f), new Color(1f, 0.92f, 0.8f), Random.value) * Random.Range(0.55f, 1f),
applyShapeToPosition = false,
};
s_stars.Emit(ep, 1);
}
}
else
{
cam.clearFlags = s_clear;
cam.backgroundColor = s_clearColour;
if (s_stars) s_stars.Clear();
}
}
}
}