change: Switched the state controller and scene controller to a singleton class
This doesnt' change any of the logic, but simplifies a lot of the main game loop code. Many things still rely on the singleton class, but shouldn't so this will be fixed in a later commit
This commit is contained in:
@@ -26,31 +26,40 @@ public class DialogBoxes : MonoBehaviour
|
||||
textField.text = dialogMessages[0];
|
||||
backgroundImageObject.sprite = images[0];
|
||||
}
|
||||
|
||||
void OnAdvanceDialog() {
|
||||
|
||||
void OnAdvanceDialog()
|
||||
{
|
||||
messageCount += 1;
|
||||
if (messageCount < dialogMessages.Length) {
|
||||
if (messageCount < dialogMessages.Length)
|
||||
{
|
||||
textField.text = dialogMessages[messageCount];
|
||||
backgroundImageObject.sprite = images[messageCount];
|
||||
} else { // no more dialog messages, advance the scene
|
||||
GameObject.Find("SceneManager").GetComponent<SceneController>().NextScene();
|
||||
}
|
||||
else
|
||||
{ // no more dialog messages, advance the scene
|
||||
SceneController.Instance.NextScene();
|
||||
}
|
||||
}
|
||||
|
||||
void ReconfigureSpriteArray() {
|
||||
void ReconfigureSpriteArray()
|
||||
{
|
||||
// resize if need to
|
||||
if (images.Length != dialogMessages.Length) {
|
||||
if (images.Length != dialogMessages.Length)
|
||||
{
|
||||
Sprite[] newImagesArray = new Sprite[dialogMessages.Length];
|
||||
for (int i = 0; i < newImagesArray.Length; i++) {
|
||||
for (int i = 0; i < newImagesArray.Length; i++)
|
||||
{
|
||||
newImagesArray[i] = images[i];
|
||||
}
|
||||
images = newImagesArray;
|
||||
}
|
||||
|
||||
// update empty slots
|
||||
for (int i = 1; i < images.Length; i++) {
|
||||
if (images[i] == null ) {
|
||||
images[i] = images[i-1];
|
||||
for (int i = 1; i < images.Length; i++)
|
||||
{
|
||||
if (images[i] == null)
|
||||
{
|
||||
images[i] = images[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user