Alchemy game mechanics and components - MaxSimon95/gothelapfel GitHub Wiki
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)
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.
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.
ingredientTypes do not have any methods. They're always objects in other components' actors without them doing anything on their own really.
Add a new GameObject in the AlchemyEngine>IngredientTypes part of the scene and fill in all necessary information.
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).
- 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
- 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,
Add a new GameObject in the AlchemyEngine>AlchemyReactions part of the scene and fill in all necessary information.
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.
- List
IngredientTypes
- List
IngredientTypeAmounts
-
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 methodsMergeIdenticalIngredients()
,DeleteIngredientIfEmpty()
,SetToolTipText()
; -
AddIngredient(IngredientType ingredientType, int amount)
--> used to add a certain amount of an ingredientType into it -
AddIngredientAndUpdate(IngredientType ingredientType, int amount)
--> callsAddIngredient(IngredientType ingredientType, int amount)
andUpdateItemContent()
This is not necessary.
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.
- List
IngredientTypes
- List
IngredientTypeAmounts
- float temperature
-
UpdateContent()
It calls the private methodsMergeIdenticalIngredients()
,DeleteIngredientIfEmpty()
-
AddIngredient(IngredientType ingredientType, int amount)
--> used to add a certain amount of an ingredientType into it -
AddIngredientAndUpdate(IngredientType ingredientType, int amount)
--> callsAddIngredient(IngredientType ingredientType, int amount)
andUpdateItemContent()
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.
Changes need to be made in both the scene and the UI.
- UI: Duplicate an existing CanvasAlchemyContainerView (one that atleast closely resembles what you're going for with the new container) e.g. CanvasCauldronView
- UI: Rename all the copied GameObjects in this Canvas including the Canvas itself (--> CanvasFridgeView)
- UI: Go to ButtonTransferIntoContainer and assign the correct container gameObject in the inspector (--> PanelFridge)
- UI: Do the same for the ButtonTransferOutOfContainer
- Go to the ButtonStepBack component and assign the correct canvas gameObject in the inspector (--> CanvasFridgeView)
- 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
- Scene: Rename this scene object
- Scene: In the Inspector pull the newly created ui Canvas (CanvasFridgeView) into the containerCanvas field of this object.