Quantcast
Viewing all articles
Browse latest Browse all 131

replacing instance of class from within itself

Hello Friends, This one is a bit weird I feel :) I have a class which defines goals for a level. Mostly checks on multiple counters. As the system allows for quests to be chained, every LevelGoal has a ChildGoal. This looks like following: public class LevelGoal { private bool isFullfilled; private int goalIndex; private int amount = 0; private LevelGoal childGoal; [...] when a goal is fullfilled, I update the hud and everything. But what I would like to do is override the current instance of the LevelGoal with its child if not null - this way, all other game components wouldn't have to care whether there is a child task or not. basically, what I'm looking for is a "legal" and safe way to say: if (isFullfilled) { hud.resolveGoal (goalIndex); if (childGoal != null) this = childGoal; else return true; } hud works fine, childGoals work but I have to access the childGoals manually to check the progress instead of letting it replace the parent. Any tipps/followup readings and comments are very welcome! Thanks a lot, Georg

Viewing all articles
Browse latest Browse all 131

Trending Articles