Saturday, June 30, 2018

30 June Updates - Item Definition / Database, Inventory, Ballistic, Camera Movement

Hi!

So, these are the updates so far since the last blog post. As of now, there isn't much UI design, but more to code design and development. That includes a simple event registry pattern for number of things in this update.

Inventory Design

This design is being abstract as possible so it share the same traits for other use, like island merchant inventory, ship inventory, ship side inventory (to store cannons). No UI to show yet, but it's done so far. 

Technically, an inventory only stores ItemEntity, a generic bag for quantity for specific item. At first, I had a dilemma on designing such thing, as different category has different structure of design. Like a Cannon category items have damage value, foods have consumption value and so on. 

This problem was tackled by having the definition (next subtopic) separately, as those values are item specific, and does not change over time. Plus, the inventory now only store a single object per item, as the only purpose is to store the quantity of the item. Which i am happy so far with the design.

Item Definition Design

Basically, this one became major prerequisite to most of the latest updates i've been doing (inventory design, ballistic [which consume cannon balls], side shooting mechanic and so on).

So far I managed to categorize the definition of the item to 7 at least that being :
- food
- livestock
- medicine
- firearm
- ammunition
- resource
- cannon

Bad Pirates is a singleplayer game that revolves around distance based trading. Most of the unique item will be marked as luxury. Luxury item only available at one place at a time (by which the location will be procedurally decided at the beginning of the game). Other than that food, medicine, ammunition are also a big part of your surviving adventure at the sea.

The game is generally inspired by uncharterd waters online. so you can see similar item categorization design there.

Item Database Management Web App

Not sure if this worthy of mention, but in order to cope or scale with the soon ever growing item database, i made a simple web app to add an items. Because doing so in json or plain is totally not fun at all, having different item structures.

Ballistic

The side shooting mechanic of a pirate game. My favorite development so far. So far what has been drafted and developed are like
- independent ballistic side design (so far there's only two sides, left and right. there'll be one more later like front for stern chaser cannons)
- shoot rate
- primary targeting (so your crews know where to shoot)
- accuracy 
  -  to be based on the angle of the side facing the opponent ship(s)). Bigger angle will cause your sailor to stray a lot.
  - the cannoneer type crew will increase this rate
- independent inventory
- rigidbody based projectile.

there'll more, as later we'll incorporate crews mechanic into this design. I am happy with this design so far.

Video is available at

Camera Movement

Was honestly afraid of this development as movement in quaternion, degrees, and angle, is totally not my forte. Tried to look for a youtube help, and some early tutorials, but mostly don't fit with the game. The idea is to be able to move the camera around, and to focus both you and your opponent (or target). Somehow today i managed to tackle the problem by having a basic understanding on how to get the vector of a direction, or apply angle etc. So far what've been developed are like :
- movement around the ship (by holding mouse 2)
- 2 kind of camera locking (focus both on player and target)
  - soft locking, but moving the camera (or using the hotkey) will break the lock
  - hard locking, by tapping the camera focusing hotkey. only allow height movement. pressing the hotkey to break the lock

this movement incorporate a reusable target design (a TargetEntity which is also used by the ballistic mechanic), and as later we'll have more kind of camera focusing. (like questing, island direction focusing and so on).

Video is available at

Event Registry Design Pattern (is there even such pattern?)

Not sure what to call it, maybe event delegation/handling design pattern.

By default most framework of language doesn't really show you a proper direction over how to do things, because I believe that things are mostly business/problem specific.

So far, i've been using such pattern for number of problem i've been facing. Especially in dealing with common events like trigger event and collision event. 

These are kind of registries (or delegator) i managed to design :
- ShipInteractionEventRegistry, to validate / handle the collision events like ballistic (cannon hits), and ship/objects collision, and trigger events like island/npc/etc interaction events.
- MouseSelectionEvent, to validate and handle mouse selection.
  - first event managed to be developed is ship selection event for ballistic primary targeting.
- ButtonPressEventRegistry. To handle numerous hotkey press event.
  - first implementation is the camera focus hotkey

Of course, we can just add a new method and do an if check on every kind of collision / trigger object event that the controller/script component gets, but the code will grow unmanageable, and maintenance will be so damn boring.

As you can see, we have two major methods for every registered event namely
- bool Validate(context), to validate the event (the if checking to be placed here)
- void Perform(context), to handle the event 

The only thing the controller needs to concern now is the registry(s), which only does one thing everytime there's an event (collision/trigger/mouse click/button press etc) by validating all handler. I first used such pattern for my php microframework, which you can find here :
https://github.com/Rosengate/exedra/blob/master/Exedra/Contracts/Routing/GroupHandler.php

=================================================

More progress information can be found by the public trello
https://trello.com/b/8aeV4DXA/bad-pirates

Until next time.
Thanks for anyone who actually read this lol :p

No comments:

Post a Comment