Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date. Images, audio, models and binaries go through Git LFS (.gitattributes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
45
Assets/Scripts/Gameplay/Treats.cs
Normal file
45
Assets/Scripts/Gameplay/Treats.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
public enum TreatId : byte { Beer = 0, Cigar = 1 }
|
||||
|
||||
/// <summary>
|
||||
/// What the two vending machines on the deck sell for a kilo of grass, and the boost each one gives the one who had it.
|
||||
/// Personal and kept on this machine only: everyone buys their own, and a boost is gone when the match ends.
|
||||
/// </summary>
|
||||
public static class Treats
|
||||
{
|
||||
public const float CostKg = 1f;
|
||||
public const float Seconds = 150f;
|
||||
/// <summary>Grass Beer: the blade cuts this much wider.</summary>
|
||||
public const float BeerMow = 1.4f;
|
||||
/// <summary>Herb Cigar: you walk and run this much faster.</summary>
|
||||
public const float CigarMove = 1.3f;
|
||||
|
||||
static float _beerUntil = -1f, _cigarUntil = -1f;
|
||||
|
||||
public static event Action<TreatId> Started;
|
||||
|
||||
public static float Left(TreatId t) => Mathf.Max(0f, (t == TreatId.Beer ? _beerUntil : _cigarUntil) - Time.time);
|
||||
public static bool On(TreatId t) => Left(t) > 0f;
|
||||
public static float MowMul => On(TreatId.Beer) ? BeerMow : 1f;
|
||||
public static float MoveMul => On(TreatId.Cigar) ? CigarMove : 1f;
|
||||
|
||||
public static string Name(TreatId t) => t == TreatId.Beer ? Loc.T("Grass Beer") : Loc.T("Herb Cigar");
|
||||
public static string Boost(TreatId t) => t == TreatId.Beer ? Loc.T("Liquid Courage") : Loc.T("Second Wind");
|
||||
public static string Effect(TreatId t) => t == TreatId.Beer ? Loc.T("+40% cutting width") : Loc.T("+30% walking speed");
|
||||
public static string Icon(TreatId t) => t == TreatId.Beer ? "icon_treat_beer" : "icon_treat_cigar";
|
||||
|
||||
/// <summary>The boost starts (or starts over: a second can doesn't stack, it tops the clock back up).</summary>
|
||||
public static void Begin(TreatId t)
|
||||
{
|
||||
if (t == TreatId.Beer) _beerUntil = Time.time + Seconds;
|
||||
else _cigarUntil = Time.time + Seconds;
|
||||
Started?.Invoke(t);
|
||||
}
|
||||
|
||||
public static void Clear() { _beerUntil = _cigarUntil = -1f; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user