clyde

Amateur Game Making Night

Recommended Posts

Have you considered having the control-gauge affect direction (actual I think I'm talking about velocity. I didn't take physics)? I wonder if tacking because you need a to shoot a bunch or are bracing for an attack would create cohesion or just be frustrating.

 

That's an interesting idea.

 

I wonder if it could work for a slightly different type of game, maybe a top-down shooter. Your stats would increase or decrease based on your movement relative to the enemy that you are currently targeting. For instance, your shields would increase if you were moving towards that enemy, your speed would increase if you were moving crosswise, and your attack would increase if you were moving away. Actually, for this type of game maybe speed wouldn't be a good variable to keep changing.

 

Maybe it would work better for a one-on-one multiplayer game, encouraging each player to move around each other in order to get the most advantageous relative position (sort of like naval combat in the wind-powered days.)

Share this post


Link to post
Share on other sites

Here's a little ball game I'm working on with a friend:

 

qVxh1uP.gif

 

DMOOmwX.gif

 

Designer and programmer feels that players chase the ball too much. This wouldn't be a problem if the stage was as small as it is in the first gif, but if the goals are sufficiently far apart the ball tends to stay in the middle. Outside of letting the ball kill you or putting a divider at the halfway point, we can't think of ways to naturally make the player guard their goal more. It's a weird thing to ask without giving a build of the game but any opinions?

 

EDIT: also those assets are super placeholder (64). I posted a mockup somewhere of all the stuff replaced with aztec/mayan tiles and characters

Share this post


Link to post
Share on other sites

Damn I want to make a game that does pretty much exactly that, but with a twist that is rad and awesome and also single-player and puzzle platformery. I think I posted the initial prototype here a while ago. Everyone's better at motivation than me.

Share this post


Link to post
Share on other sites

Currently learning why most buildings in games are Bigger on the Inside. I suppose it's because of the exaggerated movement capabilities (and expanded bubble of personal space) of FPS protagonists, but I made a one-room house that looks ordinary from the outside, and inside it feels like a closet! I don't want my buildings to be separate levels, so it looks like I'm going to have to experiment until I reach a reasonable balance. Anyone have any sweet tipz / linkz about this issue (not with fancy space-warping tricks I mean, just good interior design)? I might go play some DayZ or other games with seamless buildings that don't feel too constrained, to see if I can learn something.

Most buildings in games aren't really bigger on the inside, the entire scale is just kind of whack. It's not necessarily because of exaggerated movement capabilities or collision, but more a whole narrow-FOV thing making environments feel small and cramped when you make them to a real-world scale. Most games operate by some other weird scale whereby rooms are weirdly huge to make them feel right, and mostly folks don't notice as long as it's consistent. For instance, most people probably never noticed that Alyx Vance is not much more than half the height of most of the doorways you walk through in that game, and she's taller than Gordon. You notice the scale of the world being kind of crazy a lot more in VR. This is even more of a problem with third person games. There used to be a pretty helpful article floating about Max Payne 1's level design scale, where there were screenshots of Max's house perfectly in-scale to Max himself, and a comparison shot with the much vaster version they ended using. When the room was the correct scale it felt cramped and awful and the camera kept bumping into shit.

 

Oh here we go 

http://www.gamasutra.com/view/feature/131401/gdc_2002_realistic_level_design_.php?page=2

Share this post


Link to post
Share on other sites

Here's a little ball game I'm working on with a friend:

 

snip

 

Designer and programmer feels that players chase the ball too much. This wouldn't be a problem if the stage was as small as it is in the first gif, but if the goals are sufficiently far apart the ball tends to stay in the middle. Outside of letting the ball kill you or putting a divider at the halfway point, we can't think of ways to naturally make the player guard their goal more. It's a weird thing to ask without giving a build of the game but any opinions?

 

EDIT: also those assets are super placeholder (64). I posted a mockup somewhere of all the stuff replaced with aztec/mayan tiles and characters

 

One approach would be to empower the players such that it is just easy and fun for them to get back to their goal and guard it. The 'brute force' application of that might be to allow them to teleport or dash back in front of their goal with a button press. To avoid abuse you could put it on a cool down, or make it take a little bit of time. Actually thinking about it, a cool down might not be necessary if you look at it as replicating the effect of having a dedicated goalie in soccer.

 

I think real-world sports have generally solved this issue by having multiple players. But then there's one-on-one basketball which only has one basket and I believe allows players to switch to offense by taking the ball and running back a certain distance. Maybe you could take some inspiration there.

Share this post


Link to post
Share on other sites

Why do you want to keep the players near their goals Blambo? Are you trying to make it feel more like an air-hockey type of game where players trade shots? Or is it that there is boring back&forth if players get close?

Share this post


Link to post
Share on other sites

We're actually trying to avoid the air hockey thing by allowing the players to cross over into the other side to play offense, but we want to create the dynamic where pushing up to the goal is a dangerous commitment. Actually the players already do have a dash, ihavefivehat, but players were mostly using it to rush up to the ball.

Share this post


Link to post
Share on other sites

What if size of your goal changed depending on how far away you are from it? Focusing into a small, easily defensible point when you're near it and going wide open if you're at the opponent's goal. That way there would at least be a risk involved in going into your opponent's territory and a bonus for defending yours (which sounds like a subobtimal strategy right now).

Share this post


Link to post
Share on other sites

Man that is a cool-looking game Blambo. From the looks of those GIFs the feel is already really slick.

 

And SpennyDubz please keep on making that game, I've been dying to play/make a submarine game for forever.

 

I'm working on a game myself currently, it's a 2D adventure game based on aboriginal mythology and KRZ/True Detective. I'm hoping to have a demo ready in a few weeks to submit to Gamescom, so I will share it with you here then also. In the meantime I plan to blog a bit about the development here.

 

 

p.s. Lacabra, is the guy in your avatar that fucking guy from Interstate '76? Best game.

Share this post


Link to post
Share on other sites

My sequencer is coming along.

 

https://mtc.cdn.vine.co/r/videos/0F86C993F91071475929534136320_16e512d804e.4.8.11821297446244831725.mp4?versionId=p8CorlMpA12lY825JkOudDKyf2kWZJ1Q

 

 

It's scalable too, I'd like to make a build where the player can determine the grid height and width. Pitches are determined by taking an arbitrary number (baseNote) and dividing the row number by it. 

 

                float rowFloat = (float)row;
		float pitch = rowFloat/baseNote;
		this.audio.pitch = pitch;

It won't be like this in the finished sequencer, but it's pretty cool so I want to make a build before it changes. It was really fun making a micro-tonal instrument by increasing the grid height to 100. It's actual grid Height will be much closer to 12 (if that).

Share this post


Link to post
Share on other sites

Man that is a cool-looking game Blambo. From the looks of those GIFs the feel is already really slick.

 

And SpennyDubz please keep on making that game, I've been dying to play/make a submarine game for forever.

 

I'm working on a game myself currently, it's a 2D adventure game based on aboriginal mythology and KRZ/True Detective. I'm hoping to have a demo ready in a few weeks to submit to Gamescom, so I will share it with you here then also. In the meantime I plan to blog a bit about the development here.

 

 

p.s. Lacabra, is the guy in your avatar that fucking guy from Interstate '76? Best game.

I like the look of your blog. Also, True Detective influenced adventure game is definitely something I'l have to pay attention to. 

Share this post


Link to post
Share on other sites

Progress report for Week #12

 

What were my goals for this week?

 

What are my goals for week #12?

-I'm becoming progressively interested in programming a sequencer. I'd like to move towards that. I've already conceptualized the basics, a loop that assigns pitch based on the y-value of the grid and assigns an int between 1-16 based on the x-value as it instantiates all the cubes. Then I'll need to write a script that does a public count from 1-16 over and over again so that all the cubes know when to play their audio-file. Then I'll do some OnMouseDown() magic to assign samples to individual cubes. 

-I should probably finish the match-three tutorial too. I actually really enjoy this tutorial and I don't know why. I think video-tutorials are heavily influenced by the personality of the tutor. 

 

What challenges may I face and how can I prepare for them. 

-Time. I'm just not going to have much free-time this week. I guess the best way for me to prepare for that challenge is to just get used to the idea that I will only be working in one to two hour pockets. Just because I can only work for a short period of time, that should not discourage me. 

 

Which of my goals did I accomplish?

-I programmed much more of a musical sequencer than I expected to be able to do.

Accomplished!

 

-I did not finish the Match-three tutorial, but I did watch a few more of the videos in it.

Progress!

 

What happened?

- The match-three tutorial is great, but it's long. It's like 20 videos or something. I was more interested in making the sequencer. After using the grid-making method from the match-three tutorial, I used static variables as a clock. Each instance of the cube store a value of which column it belongs to and when the clock matches the column, the cube plays its sound. I plan to add some visual flourish at some point. I spent an hour or so playing chime, harmonium, Ever Extend Extra Extreme, and Gyromancer to get an idea of what visual effects would be cool. It was interesting to see how much simple effects, such as how to highlight a menu selection, create a game's overall style. I still haven't added that though.

I eventually added a menu scene where players can edit the grid dimensions before reloading the sequencer. They can also determine tempo (though it is currently lacking the ability to finesse) and how many times an octave is evenly divided to create a scale. I put this stuff in because it's what I've had the most fun experimenting with. I found some pretty good audio samples of instruments, but the volumes were low so I had to amplify them with Audacity. I did not know that when you amplify with Audacity, the default value is the maximum volume before clipping occurs; that is excellent design. 

I won't lie, I've spent a while just making pretty pictures and listening to the weird melodies of a 100 note scale. It's very enjoyable. Not only was I adjusting the grid dimensions, tempo, and octave divisions in Unity's inspector, but I was also depending on the ability to move the camera so that I could explore the expanded grid. So today I put in a script that scrolls the camera when the mouse approaches the edge of the screen. I was super hoping to publish a build tonight but technology is not being cooperative. The Web Player build has broken OnMouseDown again (I found out that my fix from earlier this week was only temporary. I need to find out why this happens with the web player specifically). I made a PC build that works if you use the proper aspect ratio, but now Dropbox isn't letting me upload anything. Maybe my rural internet is slow tonight.

Anyway, I'm pleased with my progress. Tonight I didn't accomplish much. I was just rushing to get the menu up and running so I could include a build with my progress report. I shouldn't have done that. I missed an opportunity to watch an episode of Master's Sun with Capt. Hastings because I was making a bunch of stuff I'm planning on replacing in order to have a product by tonight that I do not have. Hopefully I have learned my lesson.

 

Goals for Week #12

-Right now I'm kind of frustrated with the flawed web player version. I have a hard time thinking of goals beyond fixing that. Oh wait.

-I want to add Keys on the top of the first eight columns that are represented with q w e r u i o p. When  one of those is pressed, the clock value will change to that column so that it's audio will play. I think that will be a neat way to play with the orchestration. 

 

What challenges may I face and how can I prepare for them?

-I was confused about why something would work in one type of build and not another, but it's even stranger that it doesn't work again. I guess I'll have to retrace my steps. Luckily, part of my troubleshooting for this problem earlier this week was importing all the scripts and organizing a duplicate scene in a separate project. I can go back to that one and slowly add stuff until the web player no longer allows onMouseDown to work. Maybe I shouldn't waste my time and just use the raycast thingy that people keep saying should be used instead on the UnityAnswer forums. 

-I'm pretty confident that I can add the keys for a manual playing of columns. That shouldn't be hard. 

 

 

Let's see if dropbox has managed to do it's thing while I typed this.

Oh fuck, I'm too tired to figure out how zip a file tonight. Looks like you'll have to wait. Here was my excitement when I thought it was working:

Looks like it did! 

Make sure to use an aspect ratio such as 1280x720. The squarish ratios don't currently work because the menu buttons aren't related to screen dimensions yet.

 

The current Build of the Sequencer (PC only currently, sorry).

Share this post


Link to post
Share on other sites

Nevermind

 

I still haven't fixed the problem really, but while troubleshooting, I created a build that seems to mostly work.

 

https://dl.dropboxusercontent.com/u/92741283/Sequencer/test%20ortho.html

 

Ok, I'm stumped. I'll submit a question to UnityAnswers tommorow.

OnMouseDown() and a raycasting alternative that I scripted work in the PC build and the Unity editor, but not in the web-player version. Also odd is that OnMouseOver does work in the web-build.  I'm learning stuff as I try to figure it out, but I am truly baffled.

 

Edit:

In an interesting turn, I discover that everything works fine in Internet Explorer (I've been using Chrome).

 

Second later:

Bonus surprise, it works in Chrome if I go ahead and select "Always run Unity Web-player from this site" and then reload it. I would think that probably narrows the problem down a bit.

 

So yeah, feel free to try out the link in the spoiler because it mostly works. The menu buttons work too, though they don't show the values yet. I just click on them a bunch to change things up.

 

 

Minutes later:

I'm enjoying your game Dualhammers.

Share this post


Link to post
Share on other sites

Thanks everyone. This was my first game so I am fairly happy with how it turned out. Much to learn though.

Share this post


Link to post
Share on other sites

Here's a little ball game I'm working on with a friend:

 

 

 

Designer and programmer feels that players chase the ball too much. This wouldn't be a problem if the stage was as small as it is in the first gif, but if the goals are sufficiently far apart the ball tends to stay in the middle. Outside of letting the ball kill you or putting a divider at the halfway point, we can't think of ways to naturally make the player guard their goal more. It's a weird thing to ask without giving a build of the game but any opinions?

 

EDIT: also those assets are super placeholder (64). I posted a mockup somewhere of all the stuff replaced with aztec/mayan tiles and characters

 

 

Have each player attached to a bungee that is connected to their goal side. Going out in to the middle would stretch the bungee which would kind of make movement in the middle trickier. i think it would feel pretty cool for the player, control wise.

Share this post


Link to post
Share on other sites

Progress Report for Week #13

 

What were my goals for this week?

 

Goals for Week #12

-Right now I'm kind of frustrated with the flawed web player version. I have a hard time thinking of goals beyond fixing that. Oh wait.

-I want to add Keys on the top of the first eight columns that are represented with q w e r u i o p. When  one of those is pressed, the clock value will change to that column so that it's audio will play. I think that will be a neat way to play with the orchestration. 

 

Which of my goals did I accomplish?

- I narrowed the web-player bug down and it also has been the inspiration for my current curriculum, but I did not fix the problem. 

Failed

 

- I didn't even start to put the keys on top of columns.

Failed

 

What happened?

- Well, I quickly figured out that the OnMouseDown not working was Chrome specific, and only when I hit the button pop-up to run the Unity Web Player and then don't reload the page. I had a hard time maintaining motivation to fix the bug because it was in such a specific use-case, but I'm a beginner, this is a bad time to adopt poor form. I had already been interested in how OnMouseDown worked and I wanted to get more familiar with raycasting. A question on these here forums led me to find out that delegates and events were involved. This puts me squarely in the intermediate area of Unity's tutorial pages, which I am not wholly comfortable with. I feel like the learning curve has sloped back up after a nice roll down; learning to make games is like playing Tiny Wings (kinda not really). I spent a day at work reading through the c# documentation for generics, delegates,and events just to start getting familiar. Then I found this tutorial that is pretty much exactly what I'm trying to do, so I've been tried to read it a few times, but I've had a really hard time accepting that something is difficult again after I had such an easy time for a while. I can accept this, but first I have to admit it. I also found out that I had some adware installed while trying to troubleshoot the Chrome-bug. I took care of that. I also spent extra time at my job and having fun doing other drek. 

 

- I just didn't even start to work on putting keys on top of columns, I want to put dynamic numbers in the menu first anyway, and I didn't even start to do that. I was not operating at high capacity this week.

 

What are my goals for Week #13?

- I'm going to learn about delegates and events. 

 

What challenges may I face and what can I do to prepare for them?

-I think I went through most of the challenges this week, and have now prepared for them by putting on my big-boy pants and deciding that I'm just going to learn it instead of telling myself that I'm just a beginner so I shouldn't have to. My plan is to go through the Unity videos on the subject; type out the tutorial verbatim that I linked above (this is what I did when I had just started scripting and it helped, I feel like I'm in a similar position now); and try to do some experiments with it; and possibly watch some youtube videos on the subject. 

Share this post


Link to post
Share on other sites

Progress Report for Week #14

What were my goals for this week?

What are my goals for Week #13?

- I'm going to learn about delegates and events.

What challenges may I face and what can I do to prepare for them?

-I think I went through most of the challenges this week, and have now prepared for them by putting on my big-boy pants and deciding that I'm just going to learn it instead of telling myself that I'm just a beginner so I shouldn't have to. My plan is to go through the Unity videos on the subject; type out the tutorial verbatim that I linked above (this is what I did when I had just started scripting and it helped, I feel like I'm in a similar position now); and try to do some experiments with it; and possibly watch some youtube videos on the subject.

Which of my goals did I accomplish?

-I did in fact learn about delegates and events and feel somewhat confident in using them now.

Accomplished!

What happened?

-Early in the week, I watched a few videos on events and delegates and looked at the written tutorial I've already mentioned. I'm sure that I had absorbed some amount of understanding from week #12, when I watched

, it largely came together for me. Armed with a decent understanding of what I was doing, I combined the parts I liked from the video and the previously mentioned written tutorial in the sequencer game; specifically, I used it for the mouse click's ability to select GameObjects. I saw that it was successful, and it led me to clean up some of the code a little bit. I hadn't cleaned up the sequencer code much yet. Because of the written tutorial, I started feeling like I knew what singletons were for and I realized that I could make the class that kept the sequencer's information such as gridHeight and clockSpeed a static class and then make all those values non-static (before, I had it so that all of those values were statics). Seemed like a good idea. Really, I just wanted an excuse to try and make a singleton because everyone is like "singleton this" and "singleton that". The point here, is that I think I understand statics and singletons a bit more.
using UnityEngine;
using System.Collections;

public class SettingsValues : MonoBehaviour {

	public static SettingsValues settingsValues;
	
	public int gridWidth=16;
	public int gridHeight=12;
	public float clockSpeed=1;
	public int octaveDivision=4;
	public int beginningOctave=1;

	//Singleton
	void Awake(){
				if (settingsValues != null) {
						Destroy (this);
				} else {
						settingsValues = this;
				}
				DontDestroyOnLoad (this);
		}
}

Then for the rest of the week I played Shadowrun Returns with my computer-time. Oh, except the part when I made gridHeight and gridWidth display dynamically in the settings menu (which I did by subscribing the assignment of textMesh.text to the mouseClick event by the way).

using UnityEngine;
using System.Collections;

public class SetText : MonoBehaviour {

	GameObject textObject;

	TextMesh textMesh;


	void OnEnable(){
		MouseClick.MouseSelects += Select;
	}
	
	void OnDisable(){
		MouseClick.MouseSelects -= Select;
	}

	// Use this for initialization
	void Start () {
		textObject = this.gameObject;
		textMesh = textObject.GetComponent<TextMesh> ();
		textMesh.text = SettingsValues.settingsValues.gridHeight.ToString () + " X " + SettingsValues.settingsValues.gridWidth.ToString ();
	
	}
	
	void Select(GameObject g){
		textMesh.text = SettingsValues.settingsValues.gridHeight.ToString () + " X " + SettingsValues.settingsValues.gridWidth.ToString ();
		}
}

What I really like about events is that I don't have to put everything in Update with conditional bools anymore. I don't know why I care about that, but it just feels more direct this way. I hope it is more efficient.

Also, I realized that I think I fully understand how to save components as local variables now. At some point I was getting a frame-rate drop from 70 to 20 every time I clicked something and I said to myself "Oh that is probably because I didn't store the component as a local variable" and I stored the component as a local variable and then the frame-rate stayed at 70. This is good because I've been struggling with understanding that one, and the experience made me think that I've integrated the knowledge into my process. I still don't understand why storing the address of a component can make that much of a difference since I feel like I'm telling it exactly where to look with GetComponent<> anyway, but one way obviously works better and I know when to use it so that's a step forward.

I'm really glad I make progress reports because when I sat down to write this, I thought I had just watched a couple of videos and the slacked off and played Shadowrun all week. This makes me look like I actually did something.

What are my goals for Week #14?

-Make a visual-novel template.

Shadowrun is making me want to work on something more narrative based. The sequencer isn't done, but I want to work on progressing toward narrative games. It's been a while since I worked on my visual-novel template, and it's going to be a lot of work to figure out what I was doing with the cameras. I'm just going to rip some of the methods out of that project and make a new visual-novel template. I'm choosing "Make a visual-novel template" as my goal even though it sounds ambitious because I just want something that I can kind of work with by week #15. If I end up with something that is just a background and a couple of GUI.Buttons then fine. I can make something more complex later, I just want to be able to make a little story during week 15 and right now I have a broken weird thing that lerps in and out.

What challenges might I face and how can I prepare for them.

-I'll get ambitious for sure. What I'm going to do tomorrow is write down everything that I want and then order it by priority. On Wednesday I'll start with the highest priority.

Also, I think I'll write more than the Monday progress report. A couple of weeks in a row, I've been nervous about writing this on Monday when I'm tired, and confused about what it is I did in the week prior. More frequent reports may be what I need to stay motivated throughout the week and remember what my process of learning has been. I feel irresponsible about just saying my goal was "learn delegates and events" and then coming back a week later and saying "I learned delegates and events!" Reporting on the iteration may be more useful.

Share this post


Link to post
Share on other sites

And so the week begins.

Tuesday

I listed my priorites for the visual-novel template.

http://instagram.com/p/n8BlT1x-d4/

Wednesday

Trying to work out the specifics of stage 1 (text-boxes and choices).

http://instagram.com/p/n_Nezjx-Xa/

http://instagram.com/p/n_Nsh1R-Xw/

http://instagram.com/p/n_N6oLx-YE/

I'm starting to think that I'll be learning about classes and constructors and function members all day tommorow. I'm thinking that I'll want to make a class called "Choice" which will have a destination page number and a message to display? Possibly a couple of values that can change? I don't know. This is harder than I thought it would be, but I'm trying to avoid using GUI.Button

Share this post


Link to post
Share on other sites

Thursday 

 

This morning, I'm trying to understand how to access variables from a class or something. It's not working. I keep getting null exception errors. 

using UnityEngine;
using System.Collections;

public class Experiment : MonoBehaviour {

	public class Zoo
	{
		public string lion;
		public string tiger;
		public string ape;

		public Zoo(string l, string t, string a){
			lion = l;
			tiger = t;
			ape = a;
		}
	}
	// Use this for initialization
	void Start () {

		Zoo myZoo = new Zoo ("Harrelson", "Tony", "Mike");

		Debug.Log (myZoo.tiger);
	
	}

}


NullReferenceException: Object reference not set to an instance of an object

Experiment.Start () (at Assets/Scripts/Experiment.cs:23)
 
 
Edit:
[Moments later]
 
I cut

 

 Zoo myZoo = new Zoo ("Harrelson", "Tony", "Mike");
 

 

and pasted it outside of the Start(), ran it, it worked, moved it back into the Start() and now it works fine even though it is exactly the same as the script I posted above. This is worrisome; my faith in the supposed constant that the computer is never wrong and that it's always human-error has been cracked. 

 

 

Edit:

2:31 P.M.

 

I think I may need to take a nap. 

I'm stumbling around with classes and constructors today now that I have an idea of what they do, but the choice menu is causing me additional trouble. 

I had made each choice menu its own instance of a class called Choice whose fields were populated with the display messages of each choice. The idea was that by making them a class, I could easily put them into an array and then reference which ever choice menu I needed when I reached the proper page. But now that I'm planning to iterate through the fields of each instance of the Choice class when it is time (in order to put text on each choice box and somehow record which choice is made), I'm realizing that it's much harder than iterating through an array of values. I need to take a nap and come back with fresh eyes that may be willing to make massive changes to what I've done this morning.

 

Edit:

6:40 P.M.

 

It has been a successful day. Some stuff kind of works. I need to stop for the day because it's becoming more and more difficult to focus. I'm going to upload the scripts as they are (not finished)

using UnityEngine;
using System.Collections;

public class Conversation : MonoBehaviour {

	//This script will be placed on the textbox


	//This stuff is for the actual textbox
	GameObject textbox;
	TextMesh textMesh;

	//This stuff is to write dialogue and to put it into an array
	//First, I'm declaring a class called Said that will have two fields, a speaker and a sentence.
	public class Said
	{
		public GameObject speaker;
		public string sentence;
		//Here is the constructor
		public Said(GameObject who, string whatTheySay)
		{
			speaker=who;
			sentence=whatTheySay;
		}
	}

	//An bunch of characters that can be populated in the inspector.
	public GameObject character1;
	public GameObject character2;
	public GameObject character3;

	//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 who, string whatTheySay)
	{
		//Creates an instance of the Said class
		Said line = new Said (who, whatTheySay);
		//Stores it in the dialogue array at the current page
		dialogue 
using UnityEngine;
using System.Collections;

public class MouseClick : MonoBehaviour {

	//Declare what parameters and return-types these events will accept
	public delegate void Delegate_GameObject(GameObject g);
	//Declare a Method that meets the return-Type and parameters of the delegate
	public static event Delegate_GameObject MouseSelects;

	//Declare the gameObject that event will pass
	GameObject target;
	//I don't really know much about Raycasts
	RaycastHit hit;



	void Update () {
		if (Input.GetMouseButtonDown(0)){
			if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit)) {
				GameObject target = hit.transform.gameObject;
				//Make sure to check that there is a method assigned to the delegate to prevent crashing
				if (MouseSelects!=null){
					//MouseClick methods in other scripts get passed the gameObject that has been clicked.
					MouseSelects(target);
				}
				
			}
			else{
				if (MouseSelects!= null){
					MouseSelects (null);
				}
			}
		}
		
	}
}
using System.Collections;

public class MakeChoice : MonoBehaviour {

//I need to include a jump to page or a value change of some type in the choices, not just their names. 
//I might need to re write this because it's harder to iterate through the fields of a class than it is to do so through an array.


	//Listen to MouseClick events
	void OnEnable()
	{
		MouseClick.MouseSelects += Select;
	}
	void OnDisable()
	{
		MouseClick.MouseSelects -= Select;
	}

	GameObject me;
	//This gets assigned by Conversation.ShowChoices() when it instantiates this gameObject
	public string whatHappens;

	void Select(GameObject g)
	{
		if (g == me) 
		{
			//THis is where this objects specific whatHappens string is assigned to some variable.
			Debug.Log (whatHappens);
		}
	}
	// Use this for initialization
	void Start () {
			me=this.transform.parent.gameObject;
		//Debug.Log (me);
		//Debug.Log (whatHappens);

	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

 


 = line;
		//Flips the page for next entry.
		page = page + 1;

	}





	//Choices

	//This array will temprorarily store choices and their consequences qhich the GameObject choiceboxes are instantiated. 
	//Thirty choices with a message and a conditional each.
	public string[,] choices=new string[30,2];
	public int index;
	
	public void Choice(string choice="...", string whatHappens="nothing")
	{
		choices [index, 0] = choice;
		choices [index, 1] = whatHappens;
		index = index + 1;
	}
	
	//Now I need to make it so the choices are instantiated as gameObjects
	public GameObject choiceBox;
	GameObject newBox;
	void ShowChoices()
	{
		for (int i=0; choices[i,0]!=null; 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 array to the text
			textmesh.text=choices[i,0];
			//Get the MakeChoice script attached to the gameobject
			MakeChoice makeChoice=newBox.GetComponentInChildren<MakeChoice>();
			//Assign the whatHappens part of the array to the conditional
			makeChoice.whatHappens=choices[i,1];

		}
	}

	//Subscribe to MouseClick
	void OnEnable(){
		MouseClick.MouseSelects += Write;
	}
	void OnDisable(){
		MouseClick.MouseSelects -= Write;
	}

	// Use this for initialization
	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");
		Choice ("Go swimming", "You get wet");
		Choice ("Eat bannanas", "YOu get bananna-mouth");
		ShowChoices ();

		//Last line in Awake() will be resetting the page number back to 0 now that the dialogue array has been populated.
		page = 0;

		//These are all Debugs I did while writing this script

		//Step3
		//Say (character1, "first");
		//Say (character1, "second");
		//Say (character1, "third");
		//Debug.Log (dialogue [2].sentence);

		//Step2
		//Say (character1, "My my, I wonder if this will work or if page will have to go public.");
		//Debug.Log (dialogue [0].sentence);

		//Step 1
		//Said example = new Said (character1, "Why hello there!");
		//Debug.Log (example.sentence);
		//Debug.Log (example.speaker);



	
	}

	//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)
	{
		//Debug.Log (clicked);
//I'll have to figure out how not to let the page advance if they click on nothing when making a choice
		if (clicked==null) 
		{
			//Debug.Log (page);
			//Textbox text is the sentence from the current page's Said
		
			textMesh.text=dialogue

.sentence;
			//Flip the page
			page=page+1;

		}

	}

	void Start(){


	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now