Sorry, my english is a bit poor! Let me clarify then:
- PlantBase is as you describe, only I have the variables in the base class, not externalized in a Resource. I’ll do that!
- PlantAttack and PlantMoney both inherit from PlantBase. PlantBase has all the health methods, that both of them share. What I mean from different is their “skill”. PlantBase, aside from having health, shoots seeds to the enemies, while PlantMoney also has health but only collects money after a timer runs out.
class_name PlantAttack
extends PlantBase
var plant_attack_health := 100
func _init() -> void:
health = plant_attack_health
attack()
func attack()-> void:
# code here for the attack
class_name PlantMoney
extends PlantBase
var plant_money_health := 100
var time : float = 10
func _init() -> void:
health = plant_money_health
collect()
func collect()-> void:
# code here for collecting money every "time" seconds.
This is what I meant. The variables and init() are pretty similar, but the actions below them are different.
Right now i don’t know if PlantAttack and PlantMoney should be objects, nodes, resources or what. I want to send them to a scene called “PlantTemplate” that has code for reading and generating this plants.
Thanks for your reply!