ãUnity7ãFloorãã¢ã¤ãã ãä½æãããï¼ã2Dãã¼ã°ã©ã¤ã¯3ã
Unity5.0.0f4 Personal(2015å¹´5æ)
ååã®ç¶ãã§ããååã¯ãã¬ã¤ã¤ã¼ã¨æµãã£ã©ãä½ã£ãã®ã§ãä»åã¯æ®ãã®Floorãã¢ã¤ãã ãä½ã£ã¦ããã¾ãã
 Â
ãç®æ¨ãFloorãã¢ã¤ãã ãä½æããï¼
Â
2D Roguelike 3 of 14 : Tile Prefabs - YouTube
Â
ã課é¡ï¼ãFloorãã¬ãã¡ããä½æãã
ã¾ãã¯ç©ºãªãã¸ã§ã¯ããä½æãã¾ããHierarchyãã¥ã¼ããCreateï¼Create Emptyãé¸æããååãFloor1ã«ãã¦ä¸ããã
Â
空ãªãã¸ã§ã¯ã(Floor1)ä½æ
Â
次ã«Floor1ã«Sprite Rendererã³ã³ãã¼ãã³ããã¤ãã¾ããInspectorãã¥ã¼ããAdd Component>Rendering>Sprite Rendererãé¸æãã¾ãã
Â
Sprite Renderer
Â
ä¸çªä¸ã®Spriteã¨ããé ç®ã®å³å´ã«ããâãã¯ãªãã¯ããã·ã¼ãã®32ãé¸ã³ã¾ãã
Â
ã·ã¼ãçªå·32ãé¸æ
Â
次ã«Sorting LayerãFloorã«å¤æ´ãã¾ãã
Â
Sorting Layerå¤æ´
Â
ããã¾ã§ã§ãããFloor1ãªãã¸ã§ã¯ããPrefabsãã©ã«ãã¸å ¥ããPrefabåãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
Â
次ã«Hierarchyãã¥ã¼ã®Floor1ãªãã¸ã§ã¯ãã®ååãFloor2ã«å¤æ´ããSprite Rendererã®Spriteã32çªãã33çªã¸å¤æ´ãã¾ãã
Â
ååå¤æ´
Â
Spriteç»åã32çªãã33çªã¸å¤æ´
Â
å®äºããããFloor2ãªãã¸ã§ã¯ããPrefabsãã©ã«ãã¸ç§»ãPrefabåãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
Â
ãã®èª¿åã§Floor3ï¼Spriteç»å34çªï¼ãFloor4ï¼Spriteç»å35çªï¼ãFloor5ï¼Spriteç»å36çªï¼ãFloor6ï¼Spriteç»å37çªï¼ãFloor7ï¼Spriteç»å38çªï¼ãFloor8ï¼Spriteç»å39çªï¼ã¨ä½ã£ã¦ãã£ã¦ä¸ããã
Â
åãè¦é ã§FloorPrefabãè¨8åä½ã
Â
ã課é¡ï¼ãExitãã¬ãã¡ããä½æãã
次ã®ã¹ãã¼ã¸ã¸è¡ãExitãªãã¸ã§ã¯ããPrefabåãã¾ãã
Floor8ã®ååãExitã«å¤æ´ããSpriteã20çªã®ãã®ã«å¤æ´ãã¾ãã
Â
Â
次ã«BoxCollider2Dãä»ããIsTriggerãtrueã«ãã¾ãã
次ã«TagãExit,SortingLayerãItemsã«å¤æ´ãã¾ãã
Â
Exitãªãã¸ã§ã¯ãã®Inspectorè¨å®
Â
æå¾ã«Exitãªãã¸ã§ã¯ããPrefabsãã©ã«ãã¸ç§»ãPrefabåãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
Â
ã課é¡ï¼ãé£ã¹ç©ãã¬ãã¡ããä½æãã
次ã«ä½åãå復ããé£ã¹ç©ã®ãã¬ãã¡ããä½æãã¾ããã¾ãã¯ãã«ã¼ãããä½ã£ã¦ããã¾ããExitãªãã¸ã§ã¯ãã®ååãFoodã«å¤æ´ããSpriteç»åã19çªã«å¤æ´ãã¾ãã
Â
Â
次ã«TagãFoodã«å¤æ´ããPrefabåãã¾ãã
Â
Foodã®Inspectorè¨å®
Â
ãã©ãã°ï¼ããããï¼
Â
次ã«é£²ã¿ç©ãä½ãã¾ããããFoodãªãã¸ã§ã¯ãã®ååãSodaã«å¤æ´ããSprite
ç»åã18çªã«å¤æ´ãã¾ãã
Â
Â
Sodaã«ã¤ãã¦ã¯TagãSodaã«å¤æ´ããã ãã§å¤§ä¸å¤«ã§ãã
Â
Tagã®ã¿Sodaã«å¤æ´ããã以å¤ã¯Foodã¨ä¸ç·
Â
Prefabåãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
Â
ã課é¡ï¼ãå£ã®ãã¬ãã¡ããä½æãã
ç¶ãã¦å£ãä½ã£ã¦ããã¾ããã¾ãã¯å¤å£ããä½æãã¾ãã®ã§ãSodaãªãã¸ã§ã¯ãã®ååãOuterWall1ã«å¤æ´ããSpriteç»åã25çªã®ãã®ã«ãã¦ä¸ããã
Â
Â
å¤å£ã¯è¡çªãã¦æ¢ã¾ããããã®ã§ãBoxCollider2Dã®Is Triggerãfalseã«ãã¾ãã
TagãUntaggedãLayerãBlockingLayerãSortingLayerãFloorã«å¤æ´ããPrefabåãã¾ãã
Â
OuterWall1ã®Inspectorè¨å®
Â
ãã©ãã°ï¼ããããï¼
Â
Floorãããããä½ã£ãæã®ããã«ãOuterWall1ã®ååãOuterWall2ã«å¤ãSpriteç»åã26çªãååãOuterWall3ã«å¤ãSpriteç»åã28çªã«ããPrefabåãã¦ä¸ããã
Â
OuterWall1ã3ã®Prefabãä½æãã
Â
次ã«å å£ãä½ã£ã¦ããã¾ããå å£ã¯ã¤ãã©ã®ãããªå¤è¦ããã¦ãã¦ããã¬ã¤ã¤ã¼ããã§ããããã¨å£ãã¦ããæãã®å£ã§ãã
Â
OuterWall3ã®ååãWall1ã«å¤æ´ããSpriteç»åã21çªã«å¤æ´ãã¦ä¸ããã
Â
Â
Floorã®ä¸ã«è¡¨ç¤ºããã®ã§Sorting LayerãItemsã«å¤æ´ãã¾ãã
Â
Â
å®æãããåã³Prefabåãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
 åãè¦é ã§å å£ãè¨8åä½ã£ã¦ããã¾ããWall2ã¯Spriteç»å22çªãWall3ã¯Spriteç»å23çªãWall4ã¯Spriteç»å24çªãWall5ã¯Spriteç»å27çªãWall6ã¯Spriteç»å29çªãWall7ã¯Spriteç»å30çªãWall8ã¯Spriteç»å31çªã使ã£ã¦ä¸ããã
Â
Wallã¯1ã8ã¾ã§ä½æãã
Â
ä»åã¯ããã¾ã§ã§ãã
ãããã¨ããããã¾ããã
Â
ãUnityéçº7ãã¢ãã¡ã¼ã·ã§ã³ãä½ãããï¼ã2Dãã¼ã°ã©ã¤ã¯2ã
ãUnityéçº7ãFloorãã¢ã¤ãã ãä½æãããï¼ã2Dãã¼ã°ã©ã¤ã¯3ã
ãUnityéçº7ãBoardManagerãå¼ã³åºãGameManagerãä½æããã2Dãã¼ã°ã©ã¤ã¯5ã
ãUnityéçº7ãç ´å£å¯è½ãªå£(Wall)ãä½æãããï¼ããã¼ã°ã©ã¤ã¯7ã
ãUnityéçº7ããã¬ã¤ã¤ã¼ã®ã¢ãã¡ã¼ã¿ã¼ãè¨å®ãããï¼ããã¼ã°ã©ã¤ã¯8ã
ãUnityéçº7ããã¬ã¤ã¤ã¼ç¨ã®ã¹ã¯ãªãããè¨å®ãããï¼ããã¼ã°ã©ã¤ã¯9ã
ãUnityéçº7ãBGMã¨å¹æé³ãä»ããã2Dãã¼ã°ã©ã¤ã¯13ã
ãUnityéçº7ãã¿ããããã«ã«å¯¾å¿ããããï¼ã2Dãã¼ã°ã©ã¤ã¯14(Fin)ã
Â