mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-11-11 04:22:40 +00:00
Started individual char popup
This commit is contained in:
1 parent
6af09046ce
commit
aa987078b6
2 files changed
+93
-24
No files matched your search
@@ -6,17 +6,24 @@ using TMPro;
|
||||
public class Dialogue : MonoBehaviour
|
||||
{
|
||||
public TMP_Text textbox;
|
||||
List<string> pages;
|
||||
int curPage;
|
||||
public List<string> pages = new List<string>();
|
||||
int curPage = 0;
|
||||
public bool isOpen = true;
|
||||
//test object
|
||||
//used to activate/deactivate test object
|
||||
//activate through outside means probably
|
||||
public GameObject textTest;
|
||||
//used to print the first x letters of the text
|
||||
int cCount = 0;
|
||||
//changes the pace at which chars appear
|
||||
float pace = 10.0f;
|
||||
float elapsed = 0f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//pages to scroll through
|
||||
pages = new List<string>();
|
||||
curPage = 0;
|
||||
if(pages.Count > 0)
|
||||
{
|
||||
textbox.text = pages[0];
|
||||
}
|
||||
}
|
||||
|
||||
//Adds a page of text
|
||||
@@ -32,18 +39,42 @@ public class Dialogue : MonoBehaviour
|
||||
{
|
||||
//pause
|
||||
Movement.pause = true;
|
||||
// if(Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0 || Input.GetKeyDown(KeyCode.Return))
|
||||
// {
|
||||
// //scroll through textbox using any movement key
|
||||
// if(curPage >= pages.Count - 1)
|
||||
// {
|
||||
// isOpen = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// textbox.text = pages[++curPage];
|
||||
// }
|
||||
// }
|
||||
//checks if all of the characters are on the page
|
||||
if(cCount >= pages[curPage].Length)
|
||||
{
|
||||
elapsed = 0;
|
||||
if(Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.DownArrow) ||
|
||||
Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
//scroll through textbox using any movement key
|
||||
if(curPage >= pages.Count - 1)
|
||||
{
|
||||
isOpen = false;
|
||||
Movement.pause = false;
|
||||
textTest.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
++curPage;
|
||||
cCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
if(elapsed % pace == 0)
|
||||
{
|
||||
textbox.text = pages[curPage].Substring(0, ++cCount);
|
||||
}
|
||||
if(Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.DownArrow) ||
|
||||
Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
cCount = pages[curPage].Length;
|
||||
textbox.text = pages[curPage];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//unpause
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user