Last active
March 13, 2024 22:38
-
-
Save bruchmann/a2f5ee09ee2254f616b046a78f9eb17e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name Damage extends Resource | |
enum Type { | |
MAGICAL, | |
PHYSICAL, | |
} | |
@export | |
var type: Type; | |
@export_range(1, 1000, 1) | |
var amount: int = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name Actor extends CharacterBody3D | |
# […] | |
func take_damage(damage: Damage) -> void: | |
match damage.type: | |
Damage.Type.MAGICAL: | |
_compute_magical_damage(damage.amount); | |
Damage.Type.PHYSICAL: | |
_compute_physical_damage(damage.amount); | |
func _compute_magical_damage(amount: int) -> void: | |
if self.is_magic_shield_activated(): | |
amount -= 1; | |
self.health -= amount; | |
func _compute_physical_damage(amount: int) -> void: | |
if self.has_shield_in_front_of_body(): | |
amount -= 1; | |
self.health -= amount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment