Sprint 4: Environmental Effects - UQdeco2800/2021-studio-6 GitHub Wiki
Motivation
The development of level environment involves the creation of the game space of which the player explores. It has a crucial component to the game; the design and integration of elements should evoke the aesthetics, architecture and lore of the world.
One idea that adds another dimensional to gameplay is obstacles. They can choose to simply ignore and walk around, or if they choose to, interact by walking over the obstacle (within the obstacle's hitbox). If they do, they might be penalized with some sort of status effect.
Overview
Originally proposed as one component, the
EntityEffectsComponent
, this is now split up into multiple components, each handling a particular status effect.
Obstacles are static objects on the map that, when the player interacts / collides within the hitbox, cause status modifiers to be inflicted on the player. Two core status modifiers are implemented in the game;
- Damage (implemented by HurtEffectComponent), inflicts a specified amount of damage on the player.
- Slowness (implemented by SlowEffectComponent), slows the player's movement.
The desired component is attached to an existing entity (ie. tree, bush), and the entity effect component handles the implementation of it's particular status effect. If desired, multiple components can be attached to inflict multiple status effects at once.
HurtEffectComponent
<entity object>
.addComponent(new HurtEffectComponent(PhysicsLayer.PLAYER, <damage (hitpoints)>, <delay time (ms)>))
...
The HurtEffectComponent
inflicts a specified amount of damage when the player collides with the specified obstacle. It has a in-built repeat timer with the delay specified on component creation, such that if the player is still on the obstacle, the player gets damaged multiple times.
Gameplay, it forces the player to quickly vacate the obstacle, else they might unnecessarily lose health or die.
Obstacles that currently use this component is the thorn bush, which deals 1 hitpoint every 2 seconds.
SlowEffectComponent
<entity object>
.addComponent(new HurtEffectComponent(PhysicsLayer.PLAYER, <speed multiplier (%)>))
...
The SlowEffectComponent
on collision, slows the player's movement by a specified multiplier. The player's typical walking speed (determined by their health), is multiplied with this multiplier to result in a new speed. Typically in the range from 10% (hard limit) to 100%, this multiplier can also be > 100% to increase the speed of the player.
Obstacles that currently use this component is the cobweb, which slows the player by 50%.