Hold Your Colour [Game]

So I’m finally finished :]. Yay.
It’s a horror game with walls of text and some audio to make the mood. I hope you’ll enjoy it, and I’m very eager to hear your thoughts about it.
http://www.sharemygame.com/share/bfe5cbc8-d4f3-421b-aa24-84849f7e7ecc

1 Like

I’ve implemented some mechanics that were not in the original Rick’s design, so I thought I’d share what I did and how I did it. It’s not super elegant, and probably not the optimal either, but it works at this scope.

  1. Modifiers
    So the idea here was to add the most rudimentary inventory/health system, that would be invisible to the player, but would create some hidden branches if they pick up stuff along the way (which translates to: visiting certain screen).
    The thing is – I didn’t want to brute force it into a million state files, since I had more than 1 item, and I’ve used these items many states later. So I stared into the code for a day and came up with a solution that’s not very elegant and doesn’t scale well, but which allows me to implement this fairly smoothly.

To put is simply: for every state option on a state asset I have 7 “mirror states” options that are accessed if certain conditions are met. And instead of adding states to nextstates 0,1,2 I add them to 0,8,16. So pressing 1 can land you in a state from 0 - 7, depending on which modifiers are on.

To put this in code:

a) I’ve added more return type public functions in state.cs, but this time they were booleans. Something like:

public bool Weapon()
{
return weapon;
}

So if I want to add weapon I just click the box at certain state.

b) I’ve created similar booleans in adventure.cs and a CheckForChange method that checks if the current state changed their value:

if (weapon == false)
{
weapon = state.Weapon();
}

This allows me to keep the modifier even though the state that had it changed, since I store it on a variable in Adventure.cs

c) I’ve changed how states are managed: keyinput sets the value of a “value” variable (instead of nextstates [0], [1], [2] it’s nextstates [value] and calls for another method:ModifyStates.

private void ManageState()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
value = 0;
ModifyStates(nextStates);
AudioManager();
}

ModifyStates calls state with “value” number if no modifier is engaged. If any modifiers are engaged, then it goes into the long set of else ifs:

private void ModifyStates(State[] nextStates)

if (brooch == false && chant == false && weapon == false && maim == false)
{
state = nextStates[value];
ChangeModifiers();
}
else if (brooch == true && chant == false && weapon == false && maim == false)
{
state = nextStates[value + 1];
ChangeModifiers();

d) ChangeModifiers method is for the Wounds system (2 wounds = maim on), for clearing certain modifiers if you lose them and for clearing all modifiers on death, so you start with clean stat.

  1. Audio
    Here I used some of the knowledge from the 3d course (I’m doing them side by side) and I’ve searched the internet to get some more knowledge. Basics are similar to other modifiers: State.cs have an Audioclip method and another boolean called NewMusic. And then there is this function added to the Adventure.cs:

private void AudioManager()
{
newMusic = state.NewMusic();
if (newMusic == true)
{
audiosource.Stop();
audiosource.clip = state.AudioClip();
audiosource.Play();
newMusic = false;
}
}
With this it always checks if there’s any new clip attached to a state and if it is, it stops the music, moves the clip to the audiosource and plays the new clip.

So basicly my whole idea for this was to get more functionality out of states. And it worked, but only because the scope of the game was small. Everytime I add an item that can be kept at the same time as other items, I have to add more else ifs, so probably it would be unmanagable at 4-5 options. I’ve already reused it a little, since a punishment for getting “maim” modifier occurs late in the game, when the other modifiers are no longer relevant, which is why I wiped them all clean at this point and used Maim at the same slot as on of them.

1 Like

Privacy & Terms