I'm rather new to coding in C# and am trying to teach myself more. I've been trying to work on a simple rpg with stats from levels in RPG and have gotten stuck with trying to apply the damage to an enemy based on my characters stats.
When I thought I had solved the issue by splitting my stats script for the player into a second one for the enemy units, I unfortunately ran into the issue where the left-hand side of the assignment needing to be a variable property or indexer, and no matter how much I search for solutions I'm stumped. Would anyone be able to take a look at my scripts and point out any glaring errors I've made?
Please and thank you!
public void TakePhysicalDamage()
{
defaultStats.GetPhysicalDamage()-= armor; //This is the offending line
physicalDamage = Mathf.Clamp(physicalDamage, 0, int.MaxValue);
health -= (int)Math.Round(physicalDamage);
if(health <= 0)
{
health = 0;
Die();
}
}
void Die()
{
{
playerLevel.AddExperience(experience_reward);
}
Destroy(gameObject);
}
}
Here is the playerstats (defaultstats) script just for reference where I'm trying to get the physical damage from
[SerializeField] float strength = 5f; [SerializeField] float physicalDamage = 5f;
public float GetPhysicalDamage()
{
return physicalDamage += strength;
}
Sorry if this seems super basic, but please take a look if you're bored!