Ive been trying to figure this power up thing for breakout.
Supposed I have a power up that will lengthen my paddle. The power up class contain a duration variable.
This duration will be updated and decrease overtime. This is just one power up. I am havent thought of any other power ups yet.
Problem I got is I am stuck on figuring out how can you reset the duration of the power up if my paddle get another power up lengthen?
I am using a list for each power Ups
if(PowerUpses.Count > 0)
{
timer += (float)gameTime.ElapsedGameTime.TotalSeconds;
timeConter += (int)timer;
if (timer >= 1.0F) timer = 0F;
foreach (var powerUpse in PowerUpses)
{
if (timeConter >= 1)
{
powerUpse.TTL -= timeConter;
timeConter = 0;
}
if(powerUpse.power == Powers.lengthen)
{
powerUpse.reset(powerUpse.power);
Debug.WriteLine(powerUpse.TTL);
}
}
}
if(powers == Powers.lengthen )
{
if(originalWidth == width)
{
this.width += 20;
}
}
I am really having a hard time with keeping the duration back to the for example value of 10 if the paddle receives another lengthen power up. Even If I put a triger for that, maintaining the duration is kinda really confusing. I dont want the paddle to get more than 1 power up with the same type. I just want to reset it. But since it is already power.lengthen it will keep reseting to 10 because it is being called in the Update()