-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tomato.cs
56 lines (49 loc) 路 1.64 KB
/
Tomato.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using AdrianMiasik.Components.Base;
using AdrianMiasik.Components.Core.Containers;
using Unity.VectorGraphics;
using UnityEngine;
namespace AdrianMiasik.Components.Core.Items
{
/// <summary>
/// A <see cref="ThemeElement"/> image used to represent a tomato in two states: **Incomplete** (Hollow) or
/// **Complete** (Filled-in).
/// (Also see <see cref="TomatoCounter"/>)
/// </summary>
public class Tomato : ThemeElement
{
[Header("References")]
[SerializeField] private SVGImage m_body;
[SerializeField] private SVGImage m_stem;
[Header("Assets")]
[Header("Hollow")]
[SerializeField] private Sprite m_hollowCroppedBody;
[SerializeField] private Sprite m_hollowFullBody;
[Header("Complete")]
[SerializeField] private Sprite m_croppedBody;
[SerializeField] private Sprite m_fullBody;
[SerializeField] private Animation m_spawnTomato;
public override void Initialize(PomodoroTimer pomodoroTimer, bool updateColors = true)
{
base.Initialize(pomodoroTimer, updateColors);
Reset();
}
/// <summary>
/// Completes this tomato by filling it in.
/// </summary>
[ContextMenu("Complete")]
public void Complete()
{
m_body.sprite = m_croppedBody;
m_spawnTomato.Stop();
m_spawnTomato.Play();
}
/// <summary>
/// In-completes this tomato by hollowing it out.
/// </summary>
[ContextMenu("Reset")]
public void Reset()
{
m_body.sprite = m_hollowCroppedBody;
}
}
}