Monday, March 22, 2021

Working on the wall system

The bulk of this system is already done, I just need to add variable wall height and optimize the UI interface.
There are a couple more stuff I want to add, like connecting the wall to nearby terrain (like it does other walls and some buildings) to act as a bracing wall and building a roof to provide extra protection (Abwurfach??? imma just gonna go with "roof" on this one) but I don't know if I'll get to it now.

Right now walls are just a fixed height above the terrain they're on, first thing to do is add a variable to the wall class for the actual height, I'll be using a byte for this.
Change the constant wall height to a minimum height (the height walls start from at 0 height), add a constant for how much each physical height each level adds(I'm thinking half the terrain step elevation) and a constant for the maximum height steps a wall can have (I don't think I'll be using the full 128 values a byte has, a couple dozen top)



Hmmm.. on second thought, maybe I should start on the UI, it'll make testing everything much easier and I always end up getting to it last and cutting corners because I don't like doing UI.

Currently the interface is very wonky, it takes up too much space and requires more clicking than actually needed.
you can see the edge selector on the right, the group of buttons on the bottom are the controls for the entire wall segments and the group on top are for the selected edge.




To remedy all of these problems I'm going to compact everything (and the new height control) into the area the edge selector currently takes and make everything a one-click operation.
What I did is place a small hex in a big hex and connect the corners - creating a central hex for the global controls with six trapezoids extensions, one for each edge.
Now I can place all the buttons on the appropriate areas, all accessible all the time.

Here's what it looked like during the design, you can see the seven segments (center + six edges), the letters are where all the buttons are gonna go and the red circle mark the safe area for placing the center buttons (the graphic is spinning with the camera to align the edges to the view and the center buttons don't rotate)




This is the button legend:
  • CR - crenellations (either edge or all)
  • MC - machicolations (edge or all)
  • G - gate
  • L - lock gate (edge or all)
  • ST - stairs
  • MH - murderhole
  • (-) - decrease height
  • 99 - current height
  • (+) - increase height
  • R - roof

After settling on the layout I made it a bit prettier (but it still needs another pass! 😅), got it into Unity and added all the other elements to it(they don't have fancy graphics yet), this is how it looks now:




I like it, still needs more polish and the buttons are still jarringly ugly - but that'll come in due time.
I want to make the buttons flip when upside down, but I think i'm gonna hold off on that, see if I can make some icons that are easily legible from all angles first.



Now back to my safe space the code, first to make a few adjustments to accommodate how the new UI works, this is also a great opportunity to refactor all this code over to the InputMaster class. (it didn't exists when the old UI code was created)
Redoing all the UI code and wiring it up was pretty repetitive work, it took an hour or two, to finish,
Next step is to make the walls actually have variable height, this turned out to be way simpler than I thought - lucky I over engineered it when I first created it!
I changed around some of the constants to work with the new per-wall math, instead of using a constant "wallHeight" for everything I used the new height(that is on the wall) multiplied a constant "wallStepHeight".
Then it was just a simple matter of copy-pasting(only made four errors!) the new math where the old constant value was in the triangulation code, and it actually worked!
I made some other changes like disallowing gateways on wall lower then a height of six units, the gates are still a constant height, I'm thinking of maybe changing it a bit later on - maybe big entities can't pass though the small gate? we'll see.

Oh, and texturing them might be a good idea also - totally planned on it and forgot.
We can just pretend it's a very good whitewash for now. 😳

Anyway, here's a screenshot of the finished product, you can see an arrow pointing to the selected wall segment, the outer part of the inspector is rotating to match the actual orientation but the center doesn't spin.




I'll be working on a showcase video soon, so come back for more!
Thanks for reading.

No comments:

Post a Comment