{"id":1213,"date":"2012-10-14T12:43:57","date_gmt":"2012-10-14T09:43:57","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1213"},"modified":"2014-07-09T15:13:12","modified_gmt":"2014-07-09T12:13:12","slug":"rampart-prototype-seed-fill","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/10\/14\/rampart-prototype-seed-fill\/","title":{"rendered":"Rampart Prototype"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1214\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/14\/rampart-prototype-seed-fill\/seed_fill_unity\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/seed_fill_unity.jpg?fit=680%2C512&amp;ssl=1\" data-orig-size=\"680,512\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"seed_fill_unity\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/seed_fill_unity.jpg?fit=680%2C512&amp;ssl=1\" class=\"alignnone size-full wp-image-1214\" title=\"seed_fill_unity\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/seed_fill_unity.jpg?resize=680%2C512\" alt=\"\" width=\"680\" height=\"512\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/seed_fill_unity.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/seed_fill_unity.jpg?resize=300%2C225&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>Basic &#8220;<a title=\"http:\/\/www.oocities.org\/vladimir_levin\/palisaro_wall_tutorial\/\" href=\"http:\/\/www.oocities.org\/vladimir_levin\/palisaro_wall_tutorial\/\" target=\"_blank\">seed fill<\/a>&#8221; is now working (see the link for some info). Idea is to make small<a title=\"http:\/\/www.youtube.com\/watch?v=neoBQBRnSJ8\" href=\"http:\/\/www.youtube.com\/watch?v=neoBQBRnSJ8\" target=\"_blank\"> Rampart<\/a> style test game.<\/p>\n<p>&#8211; Using alexzzz&#8217;s c# fast floodfill (see previous post <a title=\"http:\/\/unitycoder.com\/blog\/2012\/10\/10\/flood-fill-algorithm\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/10\/10\/flood-fill-algorithm\/\" target=\"_blank\">comments section<\/a> for source)<br \/>\n&#8211; Area is now checked everytime you paint a pixel, if closed areas are founded, set their color to green.<\/p>\n<p><strong>#Update:1<\/strong><br \/>\n&#8211; Added script sample, added Image#3, Image#4, Webplayer v2.0<\/p>\n<p><strong>Done:<\/strong><br \/>\n&#8211; Use 3D view instead\u00a0 (see image#2 below) *done<br \/>\n&#8211; Add floodfill to that, for now: instantiate founded inside floor pieces as invidual blocks.. *done (later create single floor mesh by code?)<br \/>\n&#8211; Add diagonal fill? (not yet)<br \/>\n&#8211; Can place walls, cannons can be placed only on floor areas<br \/>\n&#8211; Flood gets added by flood fill<br \/>\n&#8211; Connect neighbour walls (change the mesh, when user adds new piece next to it) <em>*See image#5 below<\/em><br \/>\n&#8211; Create object[] array? (for checking what object is at the specific grid cell..or just raycast?) : Now using object[] array.<br \/>\n&#8211; Destruction? How? And how to remove floor when piece of wall is destroyed? : Objects are in array, easier to keep track..<br \/>\n&#8211; Basic enemies (for testing) : v3.0, added random wall destruction, now if wall is destroyed, you lose castle area..<br \/>\n&#8211; Added: Cannon gets destroyed, if its not inside castle.<\/p>\n<p><strong><br \/>\nTODO:<\/strong><br \/>\n&#8211; Cannons are not yet saved anywhere..(can place multiple at the same spot..)<br \/>\n&#8211; Optimization: Too many objects.. Each floor piece is invidual plane, walls are invidual blocks, build mesh instead?<br \/>\n&#8211; Resources? Have to mine ore \/ stone \/ gold?<br \/>\n&#8211; Better camera controls<br \/>\n&#8211; 3D grid? Could build higher walls..?<br \/>\n&#8211; More enemies (for testing, for example balls that roll toward your castle, you need to place cannons to destroy them)<br \/>\n&#8211; Cannons that shoot with physics or precalculated path?<br \/>\n<span style=\"color: #ffffff;\">.<\/span><\/p>\n<p><strong>Webplayer:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype_unity\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype_unity\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype_unity\/<\/a>\u00a0 (v1.0 : seedfill test)<br \/>\n<a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype2_unity\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype2_unity\/<\/a>\u00a0 (v2.0 : 3D scene test)<br \/>\n<a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype3\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype3\/<\/a>\u00a0 (v3.0 : can build, area is calculated, random walls are destroyed..)<\/p>\n<p><span style=\"color: #ffffff;\">.<\/span><br \/>\n<strong>Purchase Current Version Source (same features as v3.0 webplayer<\/strong><strong>)<\/strong><br \/>\n1eur [digishop id=&#8221;7&#8243;]<br \/>\n*Note: Has bugs, not too many comments included (feel free to ask), not finished etc.<br \/>\n**Note: If the download link is broken, email me and I&#8217;ll send a new one : <img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone\" title=\"email\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2011\/07\/mail.jpg?resize=169%2C15\" alt=\"\" width=\"169\" height=\"15\" \/><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#2<\/strong>: 3D view for placing the walls (current features: zoom in\/out, rotate view, place walls)<\/p>\n<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/Rampart_prototype2_unity\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1215\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/14\/rampart-prototype-seed-fill\/rampart_clone_unity\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_clone_unity.jpg?fit=680%2C391&amp;ssl=1\" data-orig-size=\"680,391\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"rampart_clone_unity\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_clone_unity.jpg?fit=680%2C391&amp;ssl=1\" class=\"alignnone size-full wp-image-1215\" title=\"rampart_clone_unity\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_clone_unity.jpg?resize=680%2C391\" alt=\"\" width=\"680\" height=\"391\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_clone_unity.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_clone_unity.jpg?resize=300%2C172&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>&#8212;<\/p>\n<p><strong>Script #1<\/strong>: When user inserts a new wall, check neighbour cells (above-right-bottom-left) and then place a prefab that connects to neighbours (v1.0).. Seems bit complicated and its still missing the neighbour cell updates, to make them connect to the new piece also)<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ get 'unique' value for all surrounding cells added together\r\nvar cells:int = walls&#x5B;x,y+1];\r\ncells += walls&#x5B;x+1,y]*4;\r\ncells += walls&#x5B;x,y-1]*8;\r\ncells += walls&#x5B;x-1,y]*16;\r\nvar wallIndex:int=0; \/\/ default wall\r\nswitch (cells)\r\n{\r\ncase 0: wallIndex = 9; break;\r\ncase 1: wallIndex = 13; break;\r\ncase 4: wallIndex = 14; break;\r\ncase 8: wallIndex = 15; break;\r\ncase 16: wallIndex = 12; break;\r\ncase 20: wallIndex = 10; break;\r\ncase 9: wallIndex = 11; break;\r\ncase 5: wallIndex = 6; break;\r\ncase 17: wallIndex = 4; break;\r\ncase 12: wallIndex = 8; break;\r\ncase 24: wallIndex = 2; break;\r\ncase 28: wallIndex = 1; break;\r\ncase 25: wallIndex = 3; break;\r\ncase 21: wallIndex = 5; break;\r\ncase 13: wallIndex = 7; break;\r\ncase 29: wallIndex = 0; break;\r\n}\r\n\/\/ create wall\r\nInstantiate(wallPrefabs&#x5B;wallIndex], gridPosition, wallPrefabs&#x5B;wallIndex].rotation);\r\n\/\/ TODO: change neighbour walls to connect this new wall\r\n\/\/ all 0-4 neighbour walls should do the same as above, check neighbour cell values\r\n\/\/ and then replace it with correct block that connects to all of them..?<\/pre>\n<p><strong>Image#3:<\/strong> Values received from the script above, when use inserts a wall in the middle, based on that value we pick what prefab to use..<br \/>\n<em>(# = wall, diagonal neighbours are not checked)<\/em><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1223\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/14\/rampart-prototype-seed-fill\/neighbour_cell_values\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/neighbour_cell_values.jpg?fit=408%2C404&amp;ssl=1\" data-orig-size=\"408,404\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"neighbour_cell_values\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/neighbour_cell_values.jpg?fit=408%2C404&amp;ssl=1\" class=\"alignnone size-full wp-image-1223\" title=\"neighbour_cell_values\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/neighbour_cell_values.jpg?resize=408%2C404\" alt=\"\" width=\"408\" height=\"404\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/neighbour_cell_values.jpg?w=408&amp;ssl=1 408w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/neighbour_cell_values.jpg?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/neighbour_cell_values.jpg?resize=300%2C297&amp;ssl=1 300w\" sizes=\"auto, (max-width: 408px) 100vw, 408px\" \/><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#4<\/strong>: Wall prefab wallIndex&#8217;es:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1230\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/14\/rampart-prototype-seed-fill\/wall_prefab_ids\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/wall_prefab_ids.jpg?fit=680%2C425&amp;ssl=1\" data-orig-size=\"680,425\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"wall_prefab_ids\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/wall_prefab_ids.jpg?fit=680%2C425&amp;ssl=1\" class=\"alignnone size-full wp-image-1230\" title=\"wall_prefab_ids\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/wall_prefab_ids.jpg?resize=680%2C425\" alt=\"\" width=\"680\" height=\"425\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/wall_prefab_ids.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/wall_prefab_ids.jpg?resize=300%2C187&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#5<\/strong>: Walls now connect to neighbour walls<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_walls_connect_unity.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1273\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/14\/rampart-prototype-seed-fill\/rampart_walls_connect_unity\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_walls_connect_unity.jpg?fit=680%2C300&amp;ssl=1\" data-orig-size=\"680,300\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"rampart_walls_connect_unity\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_walls_connect_unity.jpg?fit=680%2C300&amp;ssl=1\" class=\"alignnone size-full wp-image-1273\" title=\"rampart_walls_connect_unity\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_walls_connect_unity.jpg?resize=680%2C300\" alt=\"\" width=\"680\" height=\"300\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_walls_connect_unity.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_walls_connect_unity.jpg?resize=300%2C132&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basic &#8220;seed fill&#8221; is now working (see the link for some info). Idea is to make small Rampart style test game. &#8211; Using alexzzz&#8217;s c# fast floodfill (see previous post comments section for source) &#8211; Area is now checked everytime you paint a pixel, if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1215,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[331,324,106,333,140,330,329,332],"class_list":["post-1213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-area","tag-flood-fill","tag-game","tag-inside","tag-prototype","tag-rampart","tag-seed-fill","tag-walls"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/rampart_clone_unity.jpg?fit=680%2C391&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-jz","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1213"}],"version-history":[{"count":29,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1213\/revisions"}],"predecessor-version":[{"id":3082,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1213\/revisions\/3082"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1215"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}