- Home /
Syntax issue- only assignment, call, increment, decrement, and new object expressions can be used as statement
I have a list of status effects afflicting the player, and I'm trying to iterate through the list, remove any effects that've expired, and reduce the timer on any effects still active:
void ApplyBuffs(Character character){
//Iterate through buffs/debuffs, and apply them
for (int i = 0; i < character.passiveEffects.Count; i++) { //Iterate through list of passive effects, decrement timer, and remove effects that have expired
if (character.passiveEffects[i].permanent == false && character.passiveEffects[i].duration > 0)
character.passiveEffects[i].duration -= 1;
else
character.passiveEffects[i].Remove;
}
}
However, I'm getting an error on character.passiveEffects[i].Remove; , "Only assignment, call, increment, decrement, and new object expressions can be used as a statement". The code for Remove, from my status effect class, is currently blank:
public virtual void Remove (Character target){
}
My intent, once this works, is to extend the status effect class for each specific debuff, and override Apply and Remove to add and remove whatever specific status effects I want, but I can't see where my syntax is running into a wall here.
Answer by Kartik1607 · Dec 20, 2014 at 02:17 AM
Remove is a method and not a data member. Since "Remove" takes character as an argument, you should pass a Character type data in the method.
else
Remove(character, i);
//Your method
public virtual void Remove(Character target, int i){
//Remove chracter.passiveEffects[i] here.
}
Ack, I can't believe I didn't catch that, thank you!! :)