Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
Typewriter.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class Typewriter : MonoBehaviour
4{
5 private UIText text;
6
7 private float timer;
8
9 private bool isStarted;
10
11 private string current;
12
13 private string original;
14
15 private int index;
16
17 public float speed;
18
19 public SoundData sound;
20
21 public bool IsFinished
22 {
23 get
24 {
25 if (isStarted)
26 {
27 return index >= original.Length;
28 }
29 return false;
30 }
31 }
32
33 private void Awake()
34 {
35 text = GetComponent<UIText>();
36 }
37
38 public void OnSetText()
39 {
40 original = text.text;
41 current = "";
42 text.text = "";
43 index = 0;
44 timer = 0f;
45 isStarted = true;
46 }
47
48 public void Skip()
49 {
50 if (isStarted)
51 {
52 text.text = original;
53 index = original.Length;
54 }
55 }
56
57 private void Update()
58 {
59 if (!isStarted)
60 {
61 return;
62 }
63 timer -= Time.unscaledDeltaTime;
64 if (!(timer > 0f) && index < original.Length)
65 {
66 string text = original.Substring(index, 1);
67 current += text;
68 index++;
69 this.text.text = current;
70 float num = speed;
71 if (text == "_comma".lang())
72 {
73 num *= 3f;
74 }
75 if (text == "_period".lang())
76 {
77 num *= 6f;
78 }
79 timer += num;
80 if ((bool)sound)
81 {
82 sound.Play();
83 }
84 }
85 }
86}
void Update()
Definition: Typewriter.cs:57
void Awake()
Definition: Typewriter.cs:33
float speed
Definition: Typewriter.cs:17
string current
Definition: Typewriter.cs:11
void Skip()
Definition: Typewriter.cs:48
string original
Definition: Typewriter.cs:13
UIText text
Definition: Typewriter.cs:5
bool IsFinished
Definition: Typewriter.cs:22
SoundData sound
Definition: Typewriter.cs:19
void OnSetText()
Definition: Typewriter.cs:38
float timer
Definition: Typewriter.cs:7
bool isStarted
Definition: Typewriter.cs:9
Definition: UIText.cs:6