Rules, Threads and Raycasts lend me your ears.

Two of those Legions aren't like the others..

I now have (bar from fleet movement and some Legion resurrection)) a fully working turn system up and running and it is now possible to play test the game. It is also like I have opened a bag of crisps and randomly thrown them all over my desk.

Rules 

I mentioned in the first post, the interpretation of the rules has been questionable. Now I have a working version, I am having to re go back over those rules with a fine toothcomb as the balance of the game is certainly not right with my current definitions.

To give an example; The idea of the game is to change all the tribes status to one of the three statuses to the right in the picture above. This can be achieved either through diplomacy or through military action. Now in the rules, when it comes to diplomacy there is the following modifiers.


If he is successful the Tribe's Status will rise by one grade, e.g. H to N or P to A. If
he is unsuccessful there is a possibility that the tribe will have taken offence and their
status will actually become more hostile.
It therefore behoves the Player to back himself up with an appropriate level of
support with modifiers to his die roll. This can be done by offering a Trade Franchise
at the same time (+1), having Legions in neighbouring areas (+1 per Legion) or using
his own diplomatic skill (+1 if the Player is a Diplomat). There is also a +1 modifier for
each level of Colonisation on the Track. e.g. +1 for Status F, +2 for R and +3 for T.

The point I want to draw your attention to :

"having Legions in neighbouring areas (+1 per Legion) ". 

At the start of the game, the player starts with their five legions along the Rhine border, which if you treat Gaul as a region, that means you have a plus five advantage in diplomacy from the outset with all the neighbouring regions. This cannot be right, so I have now changed it so Legions in Gaul (and Frissii) do not count in diplomatic negotiations.

The nail-biting diplomacy turns
A post for another day in regards to the games balance: There is a tribal hostility phase in the game which determines the relationships between the tribes. This is based on dice rolls, but those early dice roles at the start of the game, can make the game a very different experience in terms of difficulty - it is, in my mind too random. But this raises another question( hence the crisps on the desk). I challenged myself to write a computer game version of the board game. So, do I make it 100% faithful to the original, or do I sneak in some changes? Thoughts for another day.

Threads

I've mentioned on my other blogs, that I do have a programming background but not in games, and my coding skills are very rusty and out of date. However, this caught us out the other day with Unity. I am going to write some psuedeo code, but in my game, there is the battle phase.

The logic, any tribe which is neutral, hostile, or in open war with Rome that the player has moved Legions into, will go into battle when the player presses the end turn button.


 for i = 1 to Settlements.count   
 {  
 if (settlement[i].Status = Hostile, etc etc )   
  {  
   if (settlements[i].LegionCount >0 )  
    {  
 FightBattle()   
    }  
 }  

Now, if we were in something like Visual Basic, that code would execute exactly how I would expect. If I was in something like C++ i=I could address how I wanted that code to run.  Either as a single thread (does everything one at time) or multithread ( go through the loop and at the same time kick of the fight battles) . With Unity ( and please correct me if I am wrong) it appears the default behavior is multithread and there is no way to change that.

So my first thought on discovering this, was I'll know. I'll just make my UI canvas that displays the results modal (force an action to be completed before returning back to the loop). Surely that would be a fairly simple thing to achieve.   Ho-ho-ho!

One of the lesser known roman battles. 
Yes it is possible, but I would have to make some major changes in the approach/direction I have taken with my game overall. So in the end, I have cheated and resolved all the battles in advance and stored them in a list. Then all the form does is loop through  and display the results one at a time. I don't think anyone will care.

Raycasts 

What the computer sees, what you see


If you asked me a few months ago, what is a Raycast. I would probably have replied either a pair of knock-off ray bans or that soul singer who had that one hit wonder, you know the one. The one with the song about night trains or something.

Raycasts are brilliant. In my Into the Eagles Nest project, they are the backbone of the enemy AI. In this game, they are the backbone to everything that happens on the map. I will do a longer more in-depth post on this, but to put simply. When you move the mouse(or click) over the map an invisible line (the raycast) is shot into the B&W image above. The BW map has each of the regions in the game shaded with a different color of grey. This raycasts return the RGB Value and I am able to look that up and carry out the correct actions for the corresponding phase in the game. It is all working very well.

I mention this for two reasons. The first to sing the praises of Unity. I have said before, I think unity is brilliant in the fact, that if you ever wanted to make a game. There is everything you need on a plate to make your game. There is no excuse.

but
.
.
.


and here it comes

In my opinion and based on my knowledge and experience of Unity so far. It all becomes a bit embarrassing when it comes to the UI Tools. I am really trying to avoid a rant, but what were they smoking / rushed out the door on a Friday afternoon/given to the work experience kid to do? thinking ?

With the aforementioned Raycasting, out of the box so to speak, it will continue to work even if you have the mouse over a UI element. So instead of clicking the button that you want, you can have unwanted behavior. Now, this is far from an uncommon scenario so you would have thought, that when designing the tools for the UI, they would make it as easy as possible for the developer to address?

I know the solution is with IsPointerOverGameobject , and I am picking on raycasting in particular but a lot of the UI tools seems to be backward in approach, it doesn't quite gel with the rest of the toolsuite. Maybe its just me.

Next steps


  • Re do the entire Map ( there is a reason stay tuned) 
  • Get fleet mechanics working 
  • Debug to make sure all rules are working correctly 
  • Ongoing, UI Tidy up 
  • Ongoing, Graphics tidy up.










Comments