I have a very basic (well i think so ) script. That let the player allocate some stats to his character
and i also have create a Canvas with button that let met Add (the + sign) and Remove (the - sign) Stats to the Character
And finnally here is my C# script that assigne those value to the Static GameInformation script (so those variable can be access anywhere in the futur)
public void SetAttackDamage(int amount)
{
if(amount > 0 && GameInformation.StatsPointsToAllocate > 0)
{
GameInformation.AttackDamage += amount;
GameInformation.StatsPointsToAllocate--;
}
else if(amount < 0 )//&& GameInformation.AttackDamage > GameInformation.PlayerClass.AttackDamage)//ont peut pas descendre plus bas que la class
{
GameInformation.AttackDamage += amount;
GameInformation.StatsPointsToAllocate++;
}
IndividualStatsUpdate(damagetext, GameInformation.AttackDamage);
StatsToAllocate();
}
public void SetAttackSpeed(int amount)
{
if(amount > 0 && GameInformation.StatsPointsToAllocate > 0)
{
GameInformation.AttackSpeed += amount;
GameInformation.StatsPointsToAllocate--;
}
else if(amount < 0)//&& GameInformation.AttackDamage > GameInformation.PlayerClass.AttackDamage)//ont peut pas descendre plus bas que la class
{
GameInformation.AttackSpeed += amount;
GameInformation.StatsPointsToAllocate++;
}
IndividualStatsUpdate(attackSpeedText, GameInformation.AttackSpeed);
StatsToAllocate();
}
and so on for all the Character Stats available.
Is there a way to make this better ? like a public void SetStats(int amount, string nameoftheStats…
? Thank you !
ps: the code is working great and doing what it is suppose to do … but im pretty sure it can be better
pss: sorry for my bad english i am a french canadien in the learning process ^^