Friday
This morning, I am accepting that I may not accomplish this week's goal. I'm having a hard time fully comprehending how my choice system will work. I think I've taken it far enough that I need to learn about how to write text-parsers that will instantiate the stuff I need. The reason I believe this is that as I try to figure out where in the dialogue I want my choices to direct to, I'm starting to think that I need discrete dialogues rather than one big page. If I use one big page and one single array for all of the dialogue, then I'll be concerned that one dialogue may overlap and replace a portion of another dialogue. My conclusion is that my dialogue system should essentially be a page of series of lines that you flip through (by clicking the mouse) that leads to a single choice menu that determines which loads a different page of a series of lines and so on. I'm going to watch this video and then try to do it that way.
Edit:
Then I watched this one.
Uh-oh, this guy's thoughtful pauses, patient thoroughness and general paternal pleasantness is going to encourage me to spend a good amount of my day just
. This is actually useful to me. When I started learning how to program, I wanted to make a game as soon as possible. That's understandable, but watching these makes me feel like I've skipped ahead too much. Now that I have a little bit of experience with which to relate to this information, I can get a lot out of it. Fundamentals!
2:44 P.M.
Watching that guys videos is making me want to organize my visual novel script. I'm trying to split it into multiple classes, but organization of this stuff is really difficult for me to visualize. What I'm doing currently is trying to put the new types, like Said and Option, into a separate script that the one that actually writes all the dialogue to the TextMesh of the textbox. But now I've realized that I might should further separate them, giving Option and Said their own scripts. It's fun, I think I'm learning.
5:53 P.M.
After watching a few of that dude's videos (he is fucking adorable to me), I decided to reorganize my code as I try to integrate his style into the way I script; this is also known as "I am fucking crazy."
Here's what I ended up with. I think I'm learning.
= line;
//Flips the page for next entry.
page = page + 1;
}
//Sprite used for the choiceBox
public GameObject choiceBox;
//Choices
//An array of all the options for this page's choice
ArrayList options= new ArrayList();
//This will be the method with which I add each option to an array of options[].
public void AddOption(Option option)
{
options.Add (option);
}
//Now a way to access the private variables of Choice
//It's only necessary when instantiating choiceBoxes.
//temporary GameObject for iteration
GameObject newBox;
//The method that will instantiate the choice boxes.
void ShowOptions()
{
//Temporary value
GameObject newBox;
//Iteration
for (int i=0; i<options.Count; i++)
{
//Not sure why I have to say "as GameObject" here, but i do because I get this error otherwise:
//Assets/Scripts/Conversation.cs(74,25): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
newBox=Instantiate(choiceBox, new Vector3(0,3-i,0), Quaternion.identity)as GameObject;
//I have to get the 3D text child
TextMesh textmesh=newBox.GetComponentInChildren<TextMesh>();
//Now assign the message part of the Option to the text
//Arraylist retrieval is "Type variable=(Type) arraylist[index];"
Option tempOption=(Option) options[i];
textmesh.text= tempOption.GetMessage ();
//Get the MakeChoice script attached to the gameobject
MakeChoice makeChoice=newBox.GetComponentInChildren<MakeChoice>();
//Assign the whatHappens part of the array to the conditional
makeChoice.jumpTo=tempOption.GetMessage();
}
}
//An bunch of characters that can be populated in the inspector.
//Eventually, I will need to find a way for these to fill out automatically
public GameObject narrator;
public GameObject character1;
public GameObject character2;
public GameObject character3;
void Awake () {
//Here we store the textbox GameObject
textbox = this.gameObject;
//Now we store the component for the textMesh
textMesh = textbox.GetComponent<TextMesh> ();
Say (character1, "Well Weblow");
Say (character2, "Miss guised");
Option fall = new Option ("Fall", "fell");
AddOption (fall);
Option hike = new Option ("Hike", "hiked");
AddOption (hike);
//Last line in Awake() will be resetting the page number back to 0 now that the dialogue array has been populated.
page = 0;
textMesh.text = dialogue
.GetWhatTheySay();
}
//Subscribe to MouseClick
void OnEnable(){
MouseClick.MouseSelects += Write;
}
void OnDisable(){
MouseClick.MouseSelects -= Write;
}
//This will be the method that moves the text along when the mouse is clicked on any item not taged "clickable"
void Write(GameObject clicked)
{
if (clicked==null)
{
//Flip the page
page=page+1;
Debug.Log (page);
if(dialogue
!=null)
{
textMesh.text=dialogue
.GetWhatTheySay();
}
else
{
ShowOptions();
}
}
}
}
using UnityEngine;
using System.Collections;
public class DialoguePage : MonoBehaviour
{
//This script will be placed on the textbox
//This stuff is for the actual textbox
GameObject textbox;
TextMesh textMesh;
//page number for the dialogue array
public int page=0;
//Dialogue array that stores Said(speaker, sentence) pairs
Said[] dialogue=new Said[500];
//This is a method so that I can easily create Said(speaker, sentence) pairs
void Say(GameObject whoSays, string whatTheySay)
{
//Creates an instance of the Said class
Said line = new Said (whoSays, whatTheySay);
//Stores it in the dialogue array at the current page
dialogue
= line;
//Flips the page for next entry.
page = page + 1;
}
//Sprite used for the choiceBox
public GameObject choiceBox;
//Choices
//An array of all the options for this page's choice
ArrayList options= new ArrayList();
//This will be the method with which I add each option to an array of options[].
public void AddOption(Option option)
{
options.Add (option);
}
//Now a way to access the private variables of Choice
//It's only necessary when instantiating choiceBoxes.
//temporary GameObject for iteration
GameObject newBox;
//The method that will instantiate the choice boxes.
void ShowOptions()
{
//Temporary value
GameObject newBox;
//Iteration
for (int i=0; i<options.Count; i++)
{
//Not sure why I have to say "as GameObject" here, but i do because I get this error otherwise:
//Assets/Scripts/Conversation.cs(74,25): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
newBox=Instantiate(choiceBox, new Vector3(0,3-i,0), Quaternion.identity)as GameObject;
//I have to get the 3D text child
TextMesh textmesh=newBox.GetComponentInChildren<TextMesh>();
//Now assign the message part of the Option to the text
//Arraylist retrieval is "Type variable=(Type) arraylist[index];"
Option tempOption=(Option) options[i];
textmesh.text= tempOption.GetMessage ();
//Get the MakeChoice script attached to the gameobject
MakeChoice makeChoice=newBox.GetComponentInChildren<MakeChoice>();
//Assign the whatHappens part of the array to the conditional
makeChoice.jumpTo=tempOption.GetMessage();
}
}
//An bunch of characters that can be populated in the inspector.
//Eventually, I will need to find a way for these to fill out automatically
public GameObject narrator;
public GameObject character1;
public GameObject character2;
public GameObject character3;
void Awake () {
//Here we store the textbox GameObject
textbox = this.gameObject;
//Now we store the component for the textMesh
textMesh = textbox.GetComponent<TextMesh> ();
Say (character1, "Well Weblow");
Say (character2, "Miss guised");
Option fall = new Option ("Fall", "fell");
AddOption (fall);
Option hike = new Option ("Hike", "hiked");
AddOption (hike);
//Last line in Awake() will be resetting the page number back to 0 now that the dialogue array has been populated.
page = 0;
textMesh.text = dialogue
.GetWhatTheySay();
}
//Subscribe to MouseClick
void OnEnable(){
MouseClick.MouseSelects += Write;
}
void OnDisable(){
MouseClick.MouseSelects -= Write;
}
//This will be the method that moves the text along when the mouse is clicked on any item not taged "clickable"
void Write(GameObject clicked)
{
if (clicked==null)
{
//Flip the page
page=page+1;
Debug.Log (page);
if(dialogue
!=null)
{
textMesh.text=dialogue
.GetWhatTheySay();
}
else
{
ShowOptions();
}
}
}
}
using UnityEngine;
using System.Collections;
public class DialoguePage : MonoBehaviour
{
//This script will be placed on the textbox
//This stuff is for the actual textbox
GameObject textbox;
TextMesh textMesh;
//page number for the dialogue array
public int page=0;
//Dialogue array that stores Said(speaker, sentence) pairs
Said[] dialogue=new Said[500];
//This is a method so that I can easily create Said(speaker, sentence) pairs
void Say(GameObject whoSays, string whatTheySay)
{
//Creates an instance of the Said class
Said line = new Said (whoSays, whatTheySay);
//Stores it in the dialogue array at the current page
dialogue
= line;
//Flips the page for next entry.
page = page + 1;
}
//Sprite used for the choiceBox
public GameObject choiceBox;
//Choices
//An array of all the options for this page's choice
ArrayList options= new ArrayList();
//This will be the method with which I add each option to an array of options[].
public void AddOption(Option option)
{
options.Add (option);
}
//Now a way to access the private variables of Choice
//It's only necessary when instantiating choiceBoxes.
//temporary GameObject for iteration
GameObject newBox;
//The method that will instantiate the choice boxes.
void ShowOptions()
{
//Temporary value
GameObject newBox;
//Iteration
for (int i=0; i<options.Count; i++)
{
//Not sure why I have to say "as GameObject" here, but i do because I get this error otherwise:
//Assets/Scripts/Conversation.cs(74,25): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
newBox=Instantiate(choiceBox, new Vector3(0,3-i,0), Quaternion.identity)as GameObject;
//I have to get the 3D text child
TextMesh textmesh=newBox.GetComponentInChildren<TextMesh>();
//Now assign the message part of the Option to the text
//Arraylist retrieval is "Type variable=(Type) arraylist[index];"
Option tempOption=(Option) options[i];
textmesh.text= tempOption.GetMessage ();
//Get the MakeChoice script attached to the gameobject
MakeChoice makeChoice=newBox.GetComponentInChildren<MakeChoice>();
//Assign the whatHappens part of the array to the conditional
makeChoice.jumpTo=tempOption.GetMessage();
}
}
//An bunch of characters that can be populated in the inspector.
//Eventually, I will need to find a way for these to fill out automatically
public GameObject narrator;
public GameObject character1;
public GameObject character2;
public GameObject character3;
void Awake () {
//Here we store the textbox GameObject
textbox = this.gameObject;
//Now we store the component for the textMesh
textMesh = textbox.GetComponent<TextMesh> ();
Say (character1, "Well Weblow");
Say (character2, "Miss guised");
Option fall = new Option ("Fall", "fell");
AddOption (fall);
Option hike = new Option ("Hike", "hiked");
AddOption (hike);
//Last line in Awake() will be resetting the page number back to 0 now that the dialogue array has been populated.
page = 0;
textMesh.text = dialogue
.GetWhatTheySay();
}
//Subscribe to MouseClick
void OnEnable(){
MouseClick.MouseSelects += Write;
}
void OnDisable(){
MouseClick.MouseSelects -= Write;
}
//This will be the method that moves the text along when the mouse is clicked on any item not taged "clickable"
void Write(GameObject clicked)
{
if (clicked==null)
{
//Flip the page
page=page+1;
Debug.Log (page);
if(dialogue
!=null)
{
textMesh.text=dialogue
.GetWhatTheySay();
}
else
{
ShowOptions();
}
}
}
}