Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

I never win in this game

here is a link for workspace https://w.trhou.se/7xxyabl9fw

I keep lost in the game.

it suspect 2 out of 3 tower is not working.

I shot and hit the enemy like 3 times and miss once or twice.

And then neutralise one. and the other enemy reaches tower and I just lose.

I always lose.

I am lost what is wrong in my code.

https://w.trhou.se/7xxyabl9fw

1 Answer

Steven Parker
Steven Parker
231,110 Points

A better way to share code that would facilitate analysis would be to make a snapshot of your workspace and post the link to it here.

In the meantime, you might try making more verbose messages to indicate exactly which towers were firing on which invaders. This could help pin down a possible logic error.

I could fix this error by rewatching the video from the beginning. in the FireOnInvaders function, I used "break;" after foreach loop. I should've used "continue" so that the turret change the target once it neutralise the invader. But now, I always win..LOL

Steven Parker
Steven Parker
231,110 Points

Congratulations on resolving your issue! :+1: Your debugging skills will serve you well!