diff --git a/Assets/Scripts/DialogBoxes.cs b/Assets/Scripts/DialogBoxes.cs index 7d7dd61..bcd9938 100644 --- a/Assets/Scripts/DialogBoxes.cs +++ b/Assets/Scripts/DialogBoxes.cs @@ -22,10 +22,11 @@ public class DialogBoxes : MonoBehaviour // Start is called before the first frame update - void Start() + void Awake() { textField = this.gameObject.GetComponent(); ReconfigureSpriteArray(); + print("reconfigured"); textField.text = dialogMessages[0]; backgroundImageObject.sprite = images[0]; } @@ -35,6 +36,8 @@ public class DialogBoxes : MonoBehaviour messageCount += 1; if (messageCount < dialogMessages.Length) { + print("looking at message " + messageCount); + print("messages: " + dialogMessages.Length + ", images: " + images.Length); textField.text = dialogMessages[messageCount]; backgroundImageObject.sprite = images[messageCount]; } @@ -50,13 +53,19 @@ public class DialogBoxes : MonoBehaviour void ReconfigureSpriteArray() { + print("attempting to reconfigure"); // resize if need to if (images.Length != dialogMessages.Length) { + print("resizing"); Sprite[] newImagesArray = new Sprite[dialogMessages.Length]; for (int i = 0; i < newImagesArray.Length; i++) { - newImagesArray[i] = images[i]; + if (i < images.Length) { + newImagesArray[i] = images[i]; + } else { + newImagesArray[i] = null; + } } images = newImagesArray; } @@ -69,6 +78,7 @@ public class DialogBoxes : MonoBehaviour images[i] = images[i - 1]; } } + print(images.Length); } } diff --git a/Assets/Scripts/EnemyPatrol.cs b/Assets/Scripts/EnemyPatrol.cs index f915a41..055f76d 100644 --- a/Assets/Scripts/EnemyPatrol.cs +++ b/Assets/Scripts/EnemyPatrol.cs @@ -47,7 +47,7 @@ public class EnemyPatrol : MonoBehaviour { void Update() { if (!pinned) { if (isHorizontal) { - if (transform.position.x >= xRight || transform.position.x <= xLeft) { + if (transform.position.x > xRight || transform.position.x < xLeft) { movementVectorHorizontal = -movementVectorHorizontal; GetComponent().flipX = !GetComponent().flipX; }