first version of enitites damageables weapons item and effects workflow
This commit is contained in:
1
scripts/Entites/Enemie.gd
Normal file
1
scripts/Entites/Enemie.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name Enemie extends Entity
|
||||
70
scripts/Entites/Entity.gd
Normal file
70
scripts/Entites/Entity.gd
Normal file
@@ -0,0 +1,70 @@
|
||||
class_name Entity extends Node3D
|
||||
|
||||
|
||||
var stats: EntityStats
|
||||
var equipments: Array[Equipment]
|
||||
signal died_event(entity: Entity)
|
||||
|
||||
func init_entity(stats: EntityStats):
|
||||
self.stats = stats;
|
||||
|
||||
func equip(newEquipment: Equipment)-> void:
|
||||
equipments.append(newEquipment)
|
||||
|
||||
func unequip(equipmentToRemove: Equipment)-> void:
|
||||
equipments.erase(equipmentToRemove)
|
||||
|
||||
|
||||
func get_health()->int:
|
||||
return stats.health.value
|
||||
|
||||
func get_shield()->int:
|
||||
return stats.shield.value
|
||||
|
||||
func reduce_shield(damage: int):
|
||||
stats.shield.value -= damage
|
||||
if stats.shield.value <= 0:
|
||||
stats.shield.value = 0
|
||||
|
||||
func increase_health(additional_health: int):
|
||||
stats.health.value += additional_health
|
||||
if stats.health.value > get_max_health():
|
||||
stats.health.value = get_max_health()
|
||||
|
||||
func reduce_health(damage: int):
|
||||
stats.health.value -= damage
|
||||
if stats.health.value <= 0:
|
||||
died()
|
||||
|
||||
func died():
|
||||
died_event.emit(self)
|
||||
|
||||
func get_max_health()->int:
|
||||
var max_health = stats.max_health
|
||||
for equipment in equipments:
|
||||
max_health += equipment.get_max_health()
|
||||
return max_health
|
||||
|
||||
func get_armor()->int:
|
||||
var armor = stats.armor
|
||||
for equipment in equipments:
|
||||
armor += equipment.get_armor()
|
||||
return armor
|
||||
|
||||
func get_max_Shield()->int:
|
||||
var shield = stats.shield
|
||||
for equipment in equipments:
|
||||
shield += equipment.get_max_shield()
|
||||
return shield
|
||||
|
||||
func get_movement_speed()->int:
|
||||
var movement_speed = stats.movement_speed
|
||||
for equipment in equipments:
|
||||
movement_speed += equipment.get_evement_speed()
|
||||
return movement_speed
|
||||
|
||||
func get_damage()->int:
|
||||
var damage = 0
|
||||
for equipment in equipments:
|
||||
damage += equipment.get_damage()
|
||||
return damage
|
||||
19
scripts/Entites/PlayerCharacter.gd
Normal file
19
scripts/Entites/PlayerCharacter.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
class_name PlayerCharacter extends Entity
|
||||
|
||||
var mech: Mech
|
||||
|
||||
func init_player_character(stats: EntityStats, mech: Mech):
|
||||
init_entity(stats)
|
||||
self.mech = mech;
|
||||
|
||||
func get_max_health() -> int:
|
||||
return super() + mech.get_max_health()
|
||||
|
||||
func get_armor() -> int:
|
||||
return super() + mech.get_armor()
|
||||
|
||||
func get_max_Shield() -> int:
|
||||
return super() + mech.get_shield()
|
||||
|
||||
func get_movement_speed() -> int:
|
||||
return super() + mech.get_movement_speed()
|
||||
Reference in New Issue
Block a user