tag:blogger.com,1999:blog-8967321114965538903.post3462366352900683826..comments2023-05-13T09:33:56.238+01:00Comments on Lane Defence: Tutorial 8 : Waves (Featuring Tower Modifications)FireFlyhttp://www.blogger.com/profile/08398015936723710602noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-8967321114965538903.post-42182198047528807982013-03-12T17:46:00.280+00:002013-03-12T17:46:00.280+00:00everything works great except for in Wave.cs in th...everything works great except for in Wave.cs in the Draw method<br />enemy.Draw(spriteBatch)<br />has an error: No overload for method 'Draw' takes 1 arguments<br />its inheriting the Sprite.Draw method and wants a spriteBatch and a color. im not sure if i did something wrong or if there was something left out.<br />any help would be great!Anonymoushttps://www.blogger.com/profile/00302092148252765023noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-76058508448068753192012-11-16T14:21:57.451+00:002012-11-16T14:21:57.451+00:00I'm sorry I haven't completed the tutorial...I'm sorry I haven't completed the tutorial.. and I changed the size of the map, so mine is much bigger, but this doesn't really effect this line, does it?<br /><br />it just tells me that i = 0<br /><br />i dont know if this really helps..<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-75508491034453356622012-11-16T13:47:59.712+00:002012-11-16T13:47:59.712+00:00When you get the error and visual studio pops up, ...When you get the error and visual studio pops up, try hovering your mouse over each individual field name, e.g hover the mouse over where it says bullet and it should tell you if it's null. <br /><br />Does this error still occur once you have completed the tutorial? Have you compared your code to the sample code?<br /><br />What the first line says is, if the distance between the bullet and the enemy is less than some distance, a collision happens.<br /><br />In this case I set that distance to twelve as the radius of the enemy is 8 and the radius of the bullet is 4. (4 + 8 = 12)<br /><br />Let me know if that helps!FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-42666107310493088842012-11-16T11:57:26.557+00:002012-11-16T11:57:26.557+00:00first of all great tutorial!!
But I have a proble...first of all great tutorial!!<br /><br />But I have a problem and i just can't find out why.. I'm getting an error all the time.. the round starts, I build a few towers and ERROR.. just when a shoot is going to hit an enemy.. in this line:<br /><br />if (Vector2.Distance(bullet.Center, target.Center) < 12)<br /> {<br /> target.CurrentHealth -= bullet.Damage;<br /> bullet.Kill();<br /> }<br /><br />it writes NullReference Exception, but I don't know what is null and what the 12 stands for.. I am a beginner at programming sth with C# so it's just a little mistake.. but i hope u can help me!! ^^<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-45332229466190854592012-08-05T04:05:57.632+01:002012-08-05T04:05:57.632+01:00Hello FireFly, FIrst of all,thank's for your t...Hello FireFly, FIrst of all,thank's for your tutorial,its a good starting point to work on,now i have a question,what's about animating the enemy's?i mean, i have tryed to use instead of using a single image,would be nice to make the enemie's moving,IE like an animated car and so on,i have splitted your Sprite class away from the enemy class,and worked a bit over it, right now i can import and make the sprite work,but the problem comes with the enemy spawn, the first enemy its ok,it's anymated and everything, but as soon as the second enemy spawns,the first one disappear,under debugging i can see the enemy count, and its ok, but on the screen, i can see only one enemy,do you have any hint?<br />thank's again for your time,and sorry for the long post :)Omarnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-16158551750901468122012-06-21T21:56:02.293+01:002012-06-21T21:56:02.293+01:00how do i get infinty waveshow do i get infinty wavesAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-22518374651071907452012-04-13T22:33:34.003+01:002012-04-13T22:33:34.003+01:00Ah cool i'm glad you fixed that, but I'm n...Ah cool i'm glad you fixed that, but I'm not sure what you are now struggling with, did you add the two different types of monster to the list?FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-69506113934024373582012-04-13T22:18:39.354+01:002012-04-13T22:18:39.354+01:00After editing the RoundOver property from:
...After editing the RoundOver property from:<br /><br /> public bool RoundOver<br /> {<br /> get <br /> {<br /> return monsters.Count == 0 && monstersSpawned == numOfMonsters ; <br /> }<br /> }<br /><br />to:<br /><br /> public bool RoundOver<br /> {<br /> get <br /> {<br /> return monsters.Count == 0 && monstersToSpawn.Count == 0 ; <br /> }<br /> }<br /><br />My waves will now go past number 2 (The first wave in which I added my fast monsters)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-45224053333205726042012-04-13T22:10:22.851+01:002012-04-13T22:10:22.851+01:00I've got it working with the fast monsters, bu...I've got it working with the fast monsters, but now after the 2nd wave the game stops and waves won't continue...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-75629934844596699442012-04-13T20:47:06.552+01:002012-04-13T20:47:06.552+01:00well.. after 2 days of programming, i still couldn...well.. after 2 days of programming, i still couldn't figure it out what should I do.zokyyyhttps://www.blogger.com/profile/04045668296952395296noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-83587335237233550922012-04-12T12:42:33.533+01:002012-04-12T12:42:33.533+01:00Oh ok I understand. Then what I would do is store ...Oh ok I understand. Then what I would do is store a new list of enemies in the Wave class and call it something like enemiesToSpawn. In the wave constructor fill this list with all of the different enemies you would like to spawn:<br /><br />for(int i = 0; i < numberOfFastEnemiesToSpawn)<br />{<br />enemiesToSpawn.Add(new Enemy(enemyTextureFast, level.Waypoints.Peek(), 30, 1, 2.5));<br />}<br /><br />for(int i = 0; i < numberOfBossEnemiesToSpawn)<br />{<br />enemiesToSpawn.Add(new Enemy(enemyTextureBoss, level.Waypoints.Peek(), 300, 10, 0.2));<br />}<br /><br />Then instead of creating a new enemy in the AddEnemy method, you would change it to something like:<br /><br />Enemy enemy = enemiesToSpawn[0];<br />enemiesToSpawn.RemoveAt(0);<br /><br />If you do it this way you will need to change this in the Update() method:<br /><br />if (enemiesSpawned == numOfEnemies)<br /> spawningEnemies = false;<br /><br />To something like:<br /><br />if (enemiesToSpawn.Count <= 0)<br /> spawningEnemies = false;<br /><br />I hope that helps!FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-78253992836607729442012-04-12T11:45:11.068+01:002012-04-12T11:45:11.068+01:00Thax for quick response, but i think that we don&#...Thax for quick response, but i think that we don't think same. <br />Well.. I would like to have two different types of enemys in one wave. <br />Something like this:<br />Enemy enemy = new Enemy(enemyTexture, level.Waypoints.Peek(), 50, 1, 0.5f);<br />Enemy enemyTWO= new Enemy(enemyTextureTWO, level.Waypoints.Peek(), 30, 1, 2.5);<br /><br /><br />I hope that this is more understandable.<br />And by the way, great work ;)<br />Thanxzokyyyhttps://www.blogger.com/profile/04045668296952395296noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-39995400034707944362012-04-11T22:07:34.278+01:002012-04-11T22:07:34.278+01:00Then you will wish to change the AddEnemy() method...Then you will wish to change the AddEnemy() method in Wave.cs. The enemy constructor takes both speed and health as input values.<br /><br />For example if you wanted the enemies of wave 4 to be faster you could do something like:<br /><br />Enemy enemy = new Enemy(enemyTexture,<br /> level.Waypoints.Peek(), 50, 1, 0.5f);<br /><br />if (waveNumber == 4)<br />{<br /> enemy = new Enemy(enemyTexture,<br /> level.Waypoints.Peek(), 50, 1, 2.5f);<br />}<br /><br />I hope that helps!FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-18524690047735698692012-04-11T20:01:38.219+01:002012-04-11T20:01:38.219+01:00Hello FireFly!
I have one question.. i want to cr...Hello FireFly!<br /><br />I have one question.. i want to create more different types of enemies (example: enemy1 and enemy2). Enemy1 will have speed 0.5f, enemy2 will have only 50 health...<br />I think that I've tried everything, but I've always failed. All help will be very usefull.<br />Thanx!zokyyyhttps://www.blogger.com/profile/04045668296952395296noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-48521707645235538342012-03-19T18:32:26.985+00:002012-03-19T18:32:26.985+00:00You could also check this out : http://forums.crea...You could also check this out : http://forums.create.msdn.com/forums/t/90241.aspx<br /><br />Although it should be the same as yours.FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-33372569964004953442012-03-19T17:27:19.493+00:002012-03-19T17:27:19.493+00:00in case anyone else needs it, here is my solution:...in case anyone else needs it, here is my solution:<br /><br />public void GetTarget(List enemies,Vector2 goal)<br /> {<br /> target = null;<br /> float smallestRange = 100000;<br /> List targets = new List();<br /> foreach (Enemy enemy in enemies)<br /> {<br /> if (Vector2.Distance(center, enemy.Center) < radius)<br /> {<br /> targets.Add(enemy);<br /> }<br /> }<br /> foreach (Enemy enemy in targets)<br /> {<br /> if (Vector2.Distance(center, goal) < smallestRange)<br /> {<br /> smallestRange = Vector2.Distance(center, goal);<br /> target = enemy;<br /> }<br /> } <br /> }Ben Burchnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-4628195369002335462012-03-17T15:52:31.500+00:002012-03-17T15:52:31.500+00:00im trying to find a way to make GetClosestEnemy to...im trying to find a way to make GetClosestEnemy to select the closest enemy to the goal that is in range. instead of just the closest. any ideas?Ben Burchnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-18128028178626699742011-08-27T13:20:25.666+01:002011-08-27T13:20:25.666+01:00I also experienced the whole "towers targetti...I also experienced the whole "towers targetting dead mobs" problem and while Somber's fix does fix the visual problem, the mob is still following the waypoint. I fixed that by opening up Enemy.cs and in the update changing:<br /><br />if (waypoints.Count > 0)<br /><br />To:<br /><br />if (waypoints.Count > 0 && alive)<br /><br />Other than that, great job! :)Didshttps://www.blogger.com/profile/03238473336908086119noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-2533137723202912512011-02-22T20:18:27.937+00:002011-02-22T20:18:27.937+00:00Huh I'm not sure why the tower is still follow...Huh I'm not sure why the tower is still following the dead enemy, I just downloaded the source at the end of the tutorial and this doesn't happen to me so maybe you missed something? <br /><br />But anyway that's a good fix and I can't see it affecting anything later on!FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-24697092936901781812011-02-22T01:08:51.651+00:002011-02-22T01:08:51.651+00:00Made a quick change to the Tower.CS that was buggi...Made a quick change to the Tower.CS that was bugging me. Towers were facing dead enemies after they 'disappeared'. (Note, I'm just starting this tutorial, so I'm not sure if this will conflict with the WAVES code at all.)<br /><br />if (target != null) //Target?<br />{<br /> if (!target.IsDead) //Is it Alive?<br /> FaceTarget(); //Face it<br /><br /> if (!IsInRange(target.Center)|| target.IsDead)<br /> {<br /> target = null;<br /> bulletTimer = 0;<br /> }<br /><br />}Somber Sundayhttps://www.blogger.com/profile/12714214863889774651noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-80974128318523600742010-12-17T15:43:52.890+00:002010-12-17T15:43:52.890+00:00Thanks for pointing that out - FixedThanks for pointing that out - FixedFireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-23881466539188377792010-10-31T13:27:51.653+00:002010-10-31T13:27:51.653+00:00i thingk, in the last section you are missing:
pl...i thingk, in the last section you are missing: <br />player.Update(gameTime, wave.Enemies);<br />best regards,<br />hannesAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-41073635138243358342010-10-29T12:25:46.237+01:002010-10-29T12:25:46.237+01:00Check out my latest tutorial :)Check out my latest tutorial :)FireFlyhttps://www.blogger.com/profile/08398015936723710602noreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-4515146425734026582010-10-27T12:19:26.178+01:002010-10-27T12:19:26.178+01:00sorted it thanks :-)sorted it thanks :-)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8967321114965538903.post-64700267335274518712010-10-26T20:07:13.535+01:002010-10-26T20:07:13.535+01:00how can i create more waves?
thanks :-)how can i create more waves?<br />thanks :-)Anonymousnoreply@blogger.com