shawn's blog

Rebuilding and Custom Editors

Posted in Tone Def, Unity by Shawn on February 24, 2012

So, the web build of Tone Def has come and gone. I did receive a bit of feedback, which I found useful, and have implemented/will plan to implement in the new and improved desktop build. It doesn’t seem like too many people took interest in it, which is okay. I have future plans for a desktop build, and hopefully it does better. But in order for this to be better, I need the code behind the game to improve.

There’s a lot that I’ve been doing behind the scenes. A lot of code has been deleted, and a lot of odd work has taken place. A god portion was me experimenting with different implementations, looking for better places to put code, and other places to delete code that is just plain foolish…and there appears to be a lot of that unfortunately.

One of the (more important) elements that was reworked was the Enemy Spawner. Originally, the spawner managed spawning in a ‘step’ format. Now, however, the enemy spawner is managed by a curve. The rate of enemy’s spawning continues to drop until the it reaches the minimum that I set for that level. The harder levels with have a lower wait time until an enemy spawns.

Enemy Spawner Collapsed

This is the new enemy spawner. This spawner has everything collapsed, and right now, spawning is disabled. It’ll be disabled on particular levels, which are puzzle levels, or levels where players are just allowed to mess around. Here is the spawner with spawning enabled:

The Spawer, and some of its information

The six slots are reserved for the different types of enemies that will be spawning for a particular level. Each slot is hooked up to a percentage, and the bot in the first slot has the highest percentage of being spawned, with the percentage lowering as you move down in slots. This isn’t finalized, as I really want to change the percentage controls, and make them easier to adjust on the fly.

Underneath the “Spawning Management” section, you can see the curve and the “Max Spawn Amount”. The max spawn amount caps the number of enemies that can be spawned at one point in time. This first worked as ‘damage control’, keeping the game from getting out of hand, but it would also assist in the learning curve for players who are potentially having a difficult time with the game. Finally, you can see the curve, which is an animation curve. Instead of moving an object with this curve, I’m evaluating the curve at certain points to handle the spawning. This way, the spawning is more gradual, as opposed to staged. It’s also better suited to allow me to have ‘burst’, akin to Plants vs Zombies, my main source of inspiration to for this game actually. (Imagine a zombie from that game showed up in mine as an enemy…….that’d be…..interesting……)

I also have two aptly named Conductors for the game. One conductor controls the level, and the other controls the musical aspects.

Do conductors tell them when to play?

Now, this custom inspector wasn’t actually necessary. However, it does make things easier to look at, and easier to organize. I can hide the Main Beat Lanes, so I’m not looking at everything all at once. Also, I have a set of lanes that play on the ‘ands’. Currently, it’s disabled (the Enable OffBeat toggle), but when it’s enabled, you’ll see another set of lanes, along with the parameter which ask how many lanes are valid. The number of lanes will be adjusted when there’s a level that has a different Time Signature. My latest build only has a 4/4 songs, but I have a few ideas for some 3/4 (and even 5/4) songs.

The Level conductor has a number of things behind scenes, but at face value, it has this:

A few things in a 'normal' stage

It’s pretty simple, and still in the works. However, changing the type of stage will also change the variables exposed:

Less is More?

There will eventually be more added, but this is what is available for now.

Here’s a fun one! The Note Selector:

Choosing Notes

The note selector holds the notes that a specific instrument will play. If the is more than one sound present, the instrument will cycle from the sound in the first slot down to the last slot. The plus/minus buttons help you quickly add or remove a slot. This was actually the first custom inspector script I wound up writing, with the help of many different online resources. While there’s a lot of documentation this stuff, sometimes, I feel as if the docs could use a bit more in the example field. Still, they are very useful.

Now, the actual first editor script I wrote and used frequently one to manage the save data. There are a number of things that I am saving via PlayerPrefs, and I needed a simple way to access them. This is another script in progress, but as of now, this is all I need for this game:

Saving some Prefs

This allows me to search for some save data, as well as set values for other pieces of information. The two larger buttons do what they say, and delete either the Player Pref in the name field, or delete all the prefs. And, no worries, there are layers of warnings before it’s actually done, it’s not a one click and “Oh jeeze, I’ve accidentally deleted everything again…”. This is actually a less complex version of the one I have set for Mr. Condyle’s Escape. That one showed the pref name/value underneath all the buttons, which was great for that type of game. There are a number of collectibles in the game, and I would hate to need to beat the game every time I want to actually a specific number of collectibles, or unlock a level. I also didn’t want to constantly update code and write “Set level x unlocked!”. With my luck, I’d forget to lock the level, and a certain level would be unlocked from the get go, causing some sort of problem somewhere.

This allows me to avoid these problems, letting me choose the value for the save data, delete individual pieces of information, and so on and so forth. Very handy!

But that’s it for now. I’m actually quite tired, and need to get up for work in the morning. Then get back home and work more on setting up my project. Maybe, in the future, and if someone really wants to know somethings, I’ll actually dive into the code of how some of this is done. However, this is really just meant to show some of the things I’ve been doing this past week. Everything but the Player Pref Window was done this past week in between day job and sleeping. Speaking of sleep…

Tagged with: , , ,

Comments Off on Rebuilding and Custom Editors

MCE – End of Iteration 10

Posted in MCE, Music, Unity by Shawn on November 28, 2011

So what happened this iteration?

Well, unfortunately, not as much as I would have liked. This past Thursday was Thanksgiving Day, so I do understand why some things may have slowed down. But, while I did not do as much as I would have like to, (I don’t have as many assorted tasks as usual since it’s mostly grinding out levels),  the work that was completed will make future work much easier.

I spent a lot of time messing with the Custom Editor API that Unity provides, and wrote a few things to help me out. My last Redmine instance crashed, and my data with it. On that machine, I had the solutions for the games levels. For play testing, I need the solutions, and rather not spend most of my time trying to beat levels over again, as I forget solutions all the time. So, having easy access to the solutions is key. They are written down in two notebooks, but the notes are very sloppy, and the levels are not in the right order. Sometimes, when searching through the book for a level’s solution, it felt like it’d be easier to just try and solve the level rather than search through the scribbles in my notes.

Anyway, in regards to the custom editor scripts, aside from making an easy list to spawn tools I need, I’m not documenting my solutions on an external file. Very simple, but still very cool. Basically, every time I beat a level, I save the solution to the level. Easier than writing them down, not as messy, and allows me to save time when play testing consecutive levels.

I also have a new song for MCE! I’m not sure where this song will go though. I was thinking this would be set for world 3, but I’m not fully sure what world 3 will be yet. World One is ‘TheCity’ and world two is ‘TheForest’, and I have a slight idea of where I should go next.

Speaking of more musical things, I set up a SoundCloud profile, featuring ‘Less’ and another piece that I worked on some time last year. I do plan to upload more MCE work on SoundCloud for easier sharing/access etc, but two for now will suffice.

But that’s it for now. I have to seriously think of what I’m doing for the next world. And make some more music.

Comments Off on MCE – End of Iteration 10