Alchemy game mechanics and components - MaxSimon95/gothelapfel GitHub Wiki

What's what

Generally there are a number of core components that work together to portrait alchemy as a game mechanic:

  • IngredientTypes: The (al)chemical substances, e.g. silver, blood, sulfuric acid.
  • AlchemyReactions: Describe how and under which conditions IngredientTypes can come to transform into new ingredientTypes.
  • InventoryItems: used to make ingredienttypes accessible to the player in the UI
  • AlchemyContainers: locations besides the inventoryitems where ingredients can be placed inside and reactions can take place (e.g. cauldron, freezer, pentagram)

IngredientTypes

The (al)chemical substances. This includes both very elemental substances such as coal, goldpowder, sulfur as well as things like cat whiskers, tomato soup and whatever becoems necessary. The relations ingredienttypes have to other ingredienttypes is being described by AlchemyReactions.

Attributes

Every ingredient has a number of attributes to it.

Already implemented

  • String name e.g. "EXMPL_0001" MUST BE UNIQUE
  • String ingredientName e.g. "Water"
  • Color color can be used for all sorts of effects
  • Image inventorySprite square image used to represent the ingredientType

Not yet implemented / ideas

  • Float meltingTemperature
  • Float seethingTemperature
  • Float ignitionTemperature
  • up to 3 different names for 3 different physical states
  • up to 3 different spriteImages for 3 different physical states
  • List effectsOnWorld (you could throw all sort of things in there: toxicity, bad smell, magic effects, whatever effect the ingredienttype can have on the gameworld gets portrayed there.

Methods

ingredientTypes do not have any methods. They're always objects in other components' actors without them doing anything on their own really.

How to Add another IngredientType

Add a new GameObject in the AlchemyEngine>IngredientTypes part of the scene and fill in all necessary information.


AlchemyReactions (partly implemented)

AlchemyReactions tell us how ingredienttypes relate to each other. Every AlchemyReaction describes exactly one possible way how a group of input ingredientTypes (e.g. 4x unicorn blood, 2x salt, 3x Dr.Pepper) can transform into a group of output ingredientTypes (1x Health Potion, 2x Ash). Furthermore each of these alchemyReactions also explains under which conditions the alchemyreaction can take place. As long as all of these are met and the necessary ingredients are present, the alchemyReaction can take place anytime and anywhere (both in inventoryItems and in AlchemyContainers).

Attributes:

  • String name e.g. "REACT_001" MUST BE UNIQUE
  • int reactionPriority --> it is possible that multiple reactions could trigger at the same time. this attribute can be used to decide which one is more important and should take place first
  • List inputIngredients
  • List inputIngredientAmounts --> tells us how much of the ingredientTypes is necessary to trigger the reaction
  • List outputIngredients
  • List outputIngredientAmounts

Vague ideas for conditions for alchemyReactions

  • IMPLEMENTED: min temperature
  • IMPLEMENTED: max temperature
  • pressure: irrelevant / increased pressure
  • inside a specific alchemyContainer
  • active moonphase
  • exposed to light: darkness / irrelevant / sunshine / moonlight
  • exposed to specific weather condition
  • specific time of the day/week/year
  • demonic presence/curse (requires a certain amount of occult energy present in the house): irrelevant/none/slight/strong/extreme
  • ventilation: RECUCED_AIR, REGULAR_AIR, INCREASED_AIR,

How to Add another AlchemyReaction

Add a new GameObject in the AlchemyEngine>AlchemyReactions part of the scene and fill in all necessary information.


InventoryItems

InventoryItems serve to make ingredientTypes accessible and moveable by the player. Each inventory item has two elemental informations: Which ingredientTypes are in this inventoryItem and how many of each.

Attributes

  • List IngredientTypes
  • List IngredientTypeAmounts

Public Methods

  • UpdateItemContent() --> its useful to call this method when something (might have) changed to the inventoryItem and all it's content and attributes need a round of being updated. It calls the private methods MergeIdenticalIngredients(), DeleteIngredientIfEmpty(), SetToolTipText();
  • AddIngredient(IngredientType ingredientType, int amount) --> used to add a certain amount of an ingredientType into it
  • AddIngredientAndUpdate(IngredientType ingredientType, int amount) --> calls AddIngredient(IngredientType ingredientType, int amount) and UpdateItemContent()

How to Add another InventoryItem

This is not necessary.


AlchemyContainers

AlchemyContainers are locations besides the inventoryitems where ingredients can be placed inside and reactions can take place (e.g. cauldron, freezer, pentagram). In many ways AlchemyContainers are very similar to InventoryItems, which reflects in their attributes and methods.

Attributes

  • List IngredientTypes
  • List IngredientTypeAmounts

Not yet implemented

  • float temperature

Public Methods

  • UpdateContent() It calls the private methods MergeIdenticalIngredients(), DeleteIngredientIfEmpty()
  • AddIngredient(IngredientType ingredientType, int amount) --> used to add a certain amount of an ingredientType into it
  • AddIngredientAndUpdate(IngredientType ingredientType, int amount) --> calls AddIngredient(IngredientType ingredientType, int amount) and UpdateItemContent()

UI involvement

Things get more complete when looking at how AlchemyContainers are attached to other UI elements and corresponding methods:

  • TransferIntoContainer --> Method used to transfer IngredientTypes out of an InventoryItem into an AlchemyContainer
  • TransferOutOfContainer --> Method used to transfer IngredientTypes out of the AlchemyContainer into an existing InventoryItem or into an empty InventorySlot and thereby creating a new InventoryItem inside it.

How to add a new AlchemyContainer (e.g. a fridge)

Changes need to be made in both the scene and the UI.

  1. UI: Duplicate an existing CanvasAlchemyContainerView (one that atleast closely resembles what you're going for with the new container) e.g. CanvasCauldronView
  2. UI: Rename all the copied GameObjects in this Canvas including the Canvas itself (--> CanvasFridgeView)
  3. UI: Go to ButtonTransferIntoContainer and assign the correct container gameObject in the inspector (--> PanelFridge)
  4. UI: Do the same for the ButtonTransferOutOfContainer
  5. Go to the ButtonStepBack component and assign the correct canvas gameObject in the inspector (--> CanvasFridgeView)
  6. Scene: Duplicate an Existing object in the scene that opens an alchemy container view (e.g. the cauldron image) and move it whereever you want
  7. Scene: Rename this scene object
  8. Scene: In the Inspector pull the newly created ui Canvas (CanvasFridgeView) into the containerCanvas field of this object.
⚠️ **GitHub.com Fallback** ⚠️