Added the ability for a mode to fire based on if you entered a scene at day or nighttime.
In the computer game, if you enter a scene in the day, characters might be out and about to talk with you.
At night, those characters will not be available to chat - but only if you entered the scene at that time (they go off to sleep or eat or whatever).
If you remain in the screen through the day cycle and into night, the characters that are out remain out. They don't just vanish.
I wanted the pinball to operate in the same way.
To understand how this functions, I might have to explain how the modes are added to my game:
There are five main modes on each screen - Walk, Look, Take, Talk, and Use.
Those are added to the stack based on the selection made in the IconSelectionMode, which is running at a slightly higher priority than the scene mode (probably not necessary, but I wanted to make sure they could always be moved and took precedence over any other uses of the buttons and handlers mapped in that mode).
As you move through, the game will add/remove the modes surrounding if it detects they are active/inactive. Pushing the button to change to Look will deactivate the Walk mode (and all children) if that makes sense...
So within each of the main modes, there are child modes - these are what I call the 'shot' modes. My modes are named by scene, so AlleyWalkShotMode would be one... within these shot modes are event handlers that catch specific switch hits, and then push them to methods that will cause some kind of graphical interaction and/or disable the shotmode, etc. As the shot modes are enabled, the corresponding shot indicators appear in the GUI.
Typically, the shot modes will either move you through the game (walking), or enable a callout to play, add something to your inventory, or use an item.
In the instance of these day/night cycle changes - my mode structure still works, but I need to pass a different variable - when you enter the scene, a private var is set on ModeStart that sets if it was day or night. Obviously this has to happen -after- the day/night cycle loader has finished its work, but before the 'icon' modes become active.
I had to add two event handlers (one on the mode side, and one on the GUI side) to handle setting or checking that variable, and then I added an event handler to enable/disable day/night versions of each type of icon shot in the GUI (the physical, or mode, side is already taken care of by the branching tree structure I mentioned earlier).
So basically, when you enter the scene, your current state is loaded including the current part of the cycle in day/night. Then it does a quick check - is this nighttime? If so, when each of the modes are called for the icons, the fact that it's night comes through and it won't activate the daytime shots. If not, it does the opposite.
If it sounds complicated, well, it is I guess. I'm trying to structure things in a way that won't make me tear my hair out.
With the village scenes that I already have written I have a really good handle on the structure of pretty much everything in the game, with the following exceptions:
1) Combat - I'm going to make this a mini-game. Should be fun!
2) Scene-specific pinball modes. These are different than the normal shot handlers - they will be minigames like combat that interact with the ball in different ways. A multiball or two in here.
3) Call and response shots. I have one coming up in the bar that I have yet to write. That should be interesting, but the principle is the same as any other dialog mode - you hit a shot to qualify, then another to ask your question. In this case, when the callout is finished it will start a throwaway mode that asks for a call/response at a higher priority, then kill it off automatically when you hit a shot.
Otherwise, I have not been posting as much because I am wiring up all of these separate icon modes and shots for every screen. Quite a lot of work, but nothing really exciting to show and, as always, I'm sure my structure could be improved, but that's how it works!