Click to See Complete Forum and Search --> : Multiplying Values in a STRUCT


bixel
September 10th, 2008, 11:54 PM
I find Structs a little intimidating, and I am unsure how to approach this problem.

I have a Struct of ints called StatisticsValue
it hold stuff like
int Hitpoints
int MagicPoints
int Strength....etc

I have a Spell and spells affect 1 or more values in the StatisticsValue

this gathers them
StatisticsValue statEffect = spell.TargetEffectValue;

but I need to multiply those statEffects by a modifier and doing it directly doesn't work.

int modifiedEffect = Math.Abs(statEffect * ARCmodifier);

My question is how do I multiply all of the possible values the Spell is effecting by the modifer int. And how do I know it doesn't modify all of the values in StatisticsValue???

for instance a spell might alter Strength and Hitpoints, but ignore everything else.

boudino
September 11th, 2008, 02:54 AM
First ensure, that you understood the semantic difference between value types (struct) and reference types (class); look e.g. here (http://www.albahari.com/value%20vs%20reference%20types.html).