ºÇ½ª¹¹¿·¡§
orika_ex_miyako 2022ǯ03·î07Æü(·î) 16:20:00ÍúÎò
¡¡Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤¿ºÝ¤Ë¡¢Grid ¤ÎÄ̤·ÈÖ¹æ¤Î¾ðÊó¤ò GameManager ¥¹¥¯¥ê¥×¥È¦¤Ë°ú¿ô¤òÄ̤¸¤ÆÆϤ¯¤è¤¦¤Ë¤Ê¤ê¤Þ¤·¤¿¤Î¤Ç¡¢
¼¡¤Ï¡¢¤³¤Î¾ðÊó¤òÍøÍѤ·¤Æ¤½¤Î Grid ¤Ë¤Ï¡û¡ß¤Î°õ¤¬¤Ä¤¤¤Æ¤¤¤ë¤«¤É¤¦¤«¤òȽÄꤷ¡¢¤É¤Á¤é¤Î°õ¤â¤Ê¤¤¾ì¹ç¤Ë¤Ï¡»°õ¤ò¤Ä¤±¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡°Ê²¼¤ÎÆâÍƤǽçÈ֤˼ÂÁõ¤ò¿Ê¤á¤Æ¤¤¤¤Þ¤¹¡£
¼ê½ç£·¡¡¡¼¥×¥ì¥¤¥ä¡¼¤Î¡»°õ¤òÇÛÃÖ¤¹¤ë¡¼
£±£²¡¥GameManager ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢ÇÛÎóÆâ¤Î Grid ¾ðÊó¤È°ú¿ô¤Î¾ðÊó¤ò¾È¹ç¤·¡¢¡û¡ß°õ¤¬¤Ä¤¤¤Æ¤¤¤ë¤«¤ÎȽÄê¤ò¹Ô¤¦ £±£³¡¥GameManager ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¡û¡ß°õ¤¬¤Ä¤¤¤Æ¤¤¤Ê¤¤ Grid ¤Ë¡»°õ¤ò¤Ä¤±¤ë
¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£
¡¡¡¦ÇÛÎó¤Î¾ðÊó¤ÎÍøÍÑÊýË¡ ¡¡¡¦´ðÁù½Ê¸¤ò»È¤Ã¤¿¥í¥¸¥Ã¥¯¤ÎÁȤßΩ¤ÆÊý
£±£²¡¥GameManager ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢ÇÛÎóÆâ¤Î Grid ¾ðÊó¤È°ú¿ô¤Î¾ðÊó¤ò¾È¹ç¤·¡¢¡û¡ß°õ¤¬¤Ä¤¤¤Æ¤¤¤ë¤«¤ÎȽÄê¤ò¹Ô¤¦ ![](https://static.seesaawiki.jp/img/usr_second/common/icon_pen.gif)
¡¡Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤¿ºÝ¤Ë¡¢Grid ¤ÎÄ̤·ÈÖ¹æ¤Î¾ðÊó¤ò GameManager ¥¹¥¯¥ê¥×¥È¦¤Ë°ú¿ô¤òÄ̤¸¤ÆÆϤ¯¤è¤¦¤Ë¤Ê¤ê¤Þ¤·¤¿¤Î¤Ç¡¢
¼¡¤Ï¡¢¤³¤Î¾ðÊó¤òÍøÍѤ·¤Æ¤½¤Î Grid ¤Ë¤Ï¡û¡ß¤Î°õ¤¬¤Ä¤¤¤Æ¤¤¤ë¤«¤É¤¦¤«¤òȽÄꤷ¡¢¤É¤Á¤é¤Î°õ¤â¤Ê¤¤¾ì¹ç¤Ë¤Ï¡»°õ¤ò¤Ä¤±¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡¡¤³¤Î¥Ú¡¼¥¸¤Ç¤Ï¡¢£²²ó¤Î¼ê½ç¤Ëʬ¤±¤Æ¡¢¤³¤Î½èÍý¤Î¼ÂÁõ¤ò¹Í¤¨¤Þ¤¹¡£
¡¡¤Þ¤º¤Ï¡¢Grid ¤Ë¡»°õ¤ò¤Ä¤±¤é¤ì¤ë¤«¤É¤¦¤«¤òȽÄꤵ¤»¤ëµ¡Ç½¤ò¸¡Æ¤¤·¤Þ¤¹¡£
¤³¤Îµ¡Ç½¤¬Àµ¾ï¤ËÆ°ºî¤¹¤ë¤³¤È¤ò³Îǧ¤·¡¢¤½¤Î¸å¡¢¥¯¥ê¥Ã¥¯¤·¤¿ Grid ¤Ë¥×¥ì¥¤¥ä¡¼ÍѤΡ»°õ¤ò¤Ä¤±¤ë½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¡¡¤³¤Î£²¤Ä¤Îµ¡Ç½¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¤É¤Î¤è¤¦¤Ê½èÍý¤ÎÀ߷פ¬É¬Íפˤʤ뤫¤ò¹Í¤¨¤Æ¤¤¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£
¡¡GameManager ¥¹¥¯¥ê¥×¥È¤Ë¤Ï¡¢Á´ Grid ¤Î¾ðÊó¤¬ GridController ·¿¤ÎÇÛÎó¤ËÂåÆþ¤µ¤ì¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤³¤Î¾ðÊ󷲤ϡ¢¡Ö¤É¤Î¡×Grid ¤Ç¤¢¤ë¤«¤òÄ´¤Ù¤ëºÝ¤ËÍøÍѤǤ¤Þ¤¹¡£
¡¡¤¿¤À¤·¡¢¡Ö¤É¤Î¡×Grid ¤Ç¤¢¤ë¤«¤òÄ´¤Ù¤ë¤¿¤á¤Ë¤ÏÇÛÎóÆ⤫¤é Grid ¤ò¸«¤Ä¤±¤Æ¤¢¤²¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¡¡¤³¤ÎºÝ¤Ë¡¢Á°²ó¤Î¼ê½ç¤ÇºîÀ®¤·¤¿ OnClickGrid ¥á¥½¥Ã¥É¤Î°ú¿ô¤ÎÃͤòÍøÍѤ·¤Þ¤¹¡£
¡¡¥¯¥ê¥Ã¥¯¤·¤¿ Grid ¤«¤é GridNo ¤ÎÃͤ¬ OnClickGrid ¥á¥½¥Ã¥É¤Î°ú¿ô¤È¤·¤ÆÆϤ¤¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
ÇÛÎóÆâ¤Ë¤¢¤ë Grid ¤ò¸«¤Ä¤±¤ëºÝ¤ËÍøÍѤ·¡¢ÇÛÎóÆâ¤Î GridNo ÈÖÌܤξðÊó¤òÍøÍѤ¹¤ë¡¢¤¤¤¦·Á¤Ç³èÍѤ·¤Þ¤¹¡£
¡¡¼ÂºÝ¤Ë½èÍý¤ò½ñ¤¤Ê¤¬¤é¡¢¤É¤ó¤ÊÉ÷¤ËÍøÍѤ·¤Æ¤¤¤ë¤Î¤«¤ò¥¤¥á¡¼¥¸¤·¡¢½èÍý¤òÆɤ߲ò¤¤¤Æ¤¤¤Ã¤Æ¤¯¤À¤µ¤¤¡£
¡¡
¡¡OnClickGrid ¥á¥½¥Ã¥ÉÆâ¤Ë½èÍý¤òÄɲ䷤Ƥ¤¤¤Þ¤¹¡£º£¸åÄɲ乤ëͽÄê¤Î½èÍý¤Ë¤Ä¤¤¤Æ¤â TODO ¤òµ½Ò¤·¤Æ¤ª¤¤Þ¤¹¡£
¤É¤ó¤Ê½èÍý¤¬¤¢¤ì¤Ð¡¢¹Í¤¨¤Æ¤¤¤ë¥¤¥á¡¼¥¸¤òºÆ¸½¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¤«¤ò¸À¸ì²½¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¡¡ÇÛÃÖ¤·¤¿²ó¿ô¤ò¥«¥¦¥ó¥È¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤âÄɲ䷤Ƥª¤¤Þ¤¹¡£
¤³¤Î¾ðÊó¤ò³èÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢°ú¤Ê¬¤±¤Î½èÍý¤ò¼ÂÁõ¤¹¤ëºÝ¤ËÍøÍѤ·¤Þ¤¹¡£
¡¡ºÇ¤â½ÅÍפʽèÍý¤ÏÇÛÎó¤Î³èÍÑÊýË¡¤Ç¤¹¡£À߷פÎÉôʬ¤Ç¤â¤ªÅÁ¤¨¤·¤¿¤è¤¦¤Ë¡¢ÇÛÎó¤ÎÍ×ÁÇÈÖ¹æ¤ËÂФ·¤Æ
OnClickGrid ¥á¥½¥Ã¥É¤Î°ú¿ô¤ÎÃͤòÍøÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢ÇÛÎóÆâ¤Î²¿ÈÖÌܤΠGrid ¤Ç¤¢¤ë¤«¤ò»ØÄꤷ¤ÆÆÃÄꤷ¤Æ¤¤¤Þ¤¹¡£
¡¡¤½¤Î¸å¡¢ÆÃÄꤷ¤¿ÇÛÎó¤Î GridController ¥¹¥¯¥ê¥×¥È¤Î GridOwnerType ÊÑ¿ô¤ÎÃͤò³Îǧ¤·¡¢¤½¤ì¤¬ None ¤Ç¤¢¤ë¤«¡¢¤É¤¦¤«¤Ë¤è¤Ã¤Æ¡¢
¡û¡ß¤¬µºÜ¤µ¤ì¤Æ¤¤¤ë Grid ¤Ç¤¢¤ë¤«¤ò if ʸ¤òÍøÍѤ·¤Æ¡¢É¾²ÁȽÄꤷ¤Æ¤¤¤Þ¤¹¡£
¡¡¤¹¤Ù¤Æ´ðÁù½Ê¸¤Î½èÍý¤Ê¤Î¤Ç¤¹¤¬¡¢¤½¤ì¤é¤ò¾å¼ê¤¯ÁȤ߹ç¤ï¤»¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢¥í¥¸¥Ã¥¯¤òÁȤßΩ¤Æ¤Æ¥¤¥á¡¼¥¸¤·¤Æ¤¤¤ë½èÍý¤ò¹½ÃÛ¤·¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢´ðÁóؽ¬¤¬ÂçÀڤǤ¢¤ë¤Î¤Ï¡¢¤É¤Î¤è¤¦¤Ê½èÍý¤Ë¤Ê¤ë¤«¤òÍý²ò¤·¤¿¾å¤Ç¡¢¤½¤Î½èÍý¤Ë¤Ï¡¢¤É¤Î¤è¤¦¤Ê³èÍÑÊýË¡¤¬¤¢¤ë¤«¡¢
±þÍÑÊýË¡¤ò¹Í¤¨¤Æ¤¤¤¯¤³¤È¤¬½ÅÍפˤʤê¤Þ¤¹¡£
GameManager.cs
¡¡¤Þ¤º¤Ï¤³¤ÎÉôʬ¤Þ¤Ç¤Î½èÍý¤¬¡¢¤É¤Î¤è¤¦¤ËÆ°ºî¤¹¤ë¤Î¤«¤ò³Îǧ¤·¤Þ¤¹¡£
¥²¡¼¥à¤ò¼Â¹Ô¤·¡¢Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¤½¤ÎºÝ¤Ë OnClickGrid ¥á¥½¥Ã¥ÉÆâ¤ËÄɵ¤·¤¿ Debug.Log ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤ë¤³¤È¤Ç
½èÍý¤ÎÆâÍƤò Console ¥Ó¥å¡¼¤Ë¤è¤ê³Îǧ¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¡¡¥¹¥¯¥ê¥×¥È¤ÎÆâÍƤϡ¢Å¬µ¹¤Ê°ÌÃÖ¤Ë Debug.Log ¥á¥½¥Ã¥É¤òµ½Ò¤·¤Æ¤ª¤¯¤³¤È¤Ë¤è¤ê
¡Ö½èÍý¤Îή¤ì¤¬¸«¤¨¤ë¡×¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢³èÍѤ¹¤ëÊýË¡¤ò¼ÂºÝ¤Ë¼«Ê¬¤Ç¹Í¤¨¤Æ¤¤¤Ã¤Æ¤¯¤À¤µ¤¤¡£
¡ã¼Â¹ÔÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡ÌäÂê¤Ê¤¯ Debug.Log ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤³¤È¤¬³Îǧ¤Ç¤¤¿¤é¡¢¼¡¤Î¼ê½ç¤Ë°Ü¤ê¤Þ¤¹¡£
ÇÛÎó¤ÎÍ×ÁǤλØÄêÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¤·¤Ã¤«¤ê¤È³Ð¤¨¤Æ¤ª¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢ÊÑ¿ô¤ËÏǤ蘆¤ì¤Ê¤¤¤è¤¦¤Ë¡¢½èÍý¤ÎÆâÍƤòÍý²ò¤·¤Æ¤¤¤¯¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£
¡¡Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤¿ºÝ¤Ë¡¢Grid ¤ÎÄ̤·ÈÖ¹æ¤Î¾ðÊó¤ò¸µ¤Ë Grid ¤Î¥ª¡¼¥Ê¡¼¥·¥ó¥Ü¥ë(¡û¡ß)¤Î¾ðÊó¤òȽÄê¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤·¤¿¤Î¤Ç¡¢
¼¡¤Ï¤É¤Á¤é¤Î°õ¤â¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢¥¯¥ê¥Ã¥¯¤·¤¿ Grid ¤Ë¡»°õ¤ò¤Ä¤±¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡¡ÆâÍƤˤĤ¤¤Æ¤Ï¡¢OnClickGrid ¥á¥½¥Ã¥ÉÆâ¤Î TODO Éôʬ¤Î¼ÂÁõ¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡¤É¤Î¤è¤¦¤Ê½èÍý¤¬¤¢¤ì¤Ð¡¢Grid ¤ËÂФ·¤Æ¡»°õ¤ò¤Ä¤±¤ë(Text ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Ë ¡» ¤ÈµºÜ¤¹¤ë)¤è¤¦¤ËÌ¿Îá¤ò½Ð¤¹¤³¤È¤¬¤Ç¤¤ë¤«¤ò¹Í¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¡¡¼¡²ó°Ê¹ß¤Ç¤¹¤¬¡¢¤³¤Î¼ê½ç¤Ç¥×¥ì¥¤¥ä¡¼Â¦¤Î¡»°õ¤ÎÀßÃÖȽÄê¤È¼ÂºÝ¤Ë¡»°õ¤ò¤Ä¤±¤ë½èÍý¤ò¼ÂÁõ¤·¡¢ÌäÂê¤Ê¤¯Æ°ºî¤·¤¿¤é¡¢
¼¡¤Ï¡¢¡»°õ¤¬£³¤Ä·Ò¤¬¤Ã¤Æ¤¤¤ë¾ì½ê¤¬¤¢¤ë¤«¤ò³Îǧ¤¹¤ë¾¡ÇÔȽÄê½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¡¡¤½¤Î¤è¤¦¤Ê¼ê½ç¤Ç¼ÂÁõ¤ò¿Ê¤á¤ë¤³¤È¤Ë¤è¤ê¡¢¥×¥ì¥¤¥ä¡¼Â¦¤Î°ìÏ¢¤Î½èÍý¤¬´°À®¤·¤Þ¤¹¤Î¤Ç(¡»°õ¤ÎÇÛÃ֤Ⱦ¡ÇÔȽÄê)
¤½¤ì¤ò¸µ¤Ë¡¢¤½¤Î°ìÏ¢¤Î½èÍý¤ò¥³¥ó¥Ô¥å¡¼¥¿Â¦¤Î¼ê½ç¤È¤·¤Æ¼ÂÁõ¤·¤Þ¤¹¡£
¡¡°ìÏ¢¤Î½èÍý¤Îή¤ì¤òÀè¤Ë¥×¥ì¥¤¥ä¡¼Â¦¤Ë¼ÂÁõ¤·¤Æ¤ª¤¯¤³¤È¤Ë¤è¤ê¡¢¾¡ÇÔȽÄê¤Î½èÍý¤Ê¤É¤¬¥á¥½¥Ã¥É¤È¤·¤ÆÍѰդǤ¤Æ¤¤¤ë¾õÂ֤ˤʤê¤Þ¤¹¤Î¤Ç¡¢
¥³¥ó¥Ô¥å¡¼¥¿Â¦¤Î½èÍý¤Ï¡¢ÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤òÍøÍѤ·¤Ä¤Ä¡¢Â¤ê¤Ê¤¤Éôʬ¤À¤±¤òÊä¤Ã¤Æ¤¤¤¯¤³¤È¤Ç¼ÂÁõ¤¬²Äǽ¤Ë¤Ê¤ë¤¿¤á¤Ç¤¹¡£
¡¡¿·¤·¤¯¥ª¡¼¥Ê¡¼¥·¥ó¥Ü¥ë(º£²ó¤Ï¡»°õ)¤ò¤Ä¤±¤ë½èÍý¤ò¤Þ¤È¤á¤¿ SetOwnerTypeOnGrid ¥á¥½¥Ã¥É¤òºîÀ®¤·¤Þ¤¹¡£
¡¡¤³¤Î SetOwnerTypeOnGrid ¥á¥½¥Ã¥É¤ÎºÇÂç¤Î¥Ý¥¤¥ó¥È¤Ï¡¢°ú¿ô¤Ë¥ª¡¼¥Ê¡¼¥·¥ó¥Ü¥ë¤Î¾ðÊó¤¬Ä󶡤µ¤ì¤Æ¤¤¤ëÉôʬ¤Ç¤¹¡£
¡¡
¡¡°ú¿ô¤Ë¡»¤«¡ß¤Î¾ðÊó¤¬ÆϤ¯¤³¤È¤Ç¡¢£±¤Ä¤Î¥á¥½¥Ã¥É¤Ç¤¢¤ê¤Ê¤¬¤é¡¢¡»¤È¡ß¤ÎξÊý¤Îʸ»úÎó¤Î½èÍý¤Ë¼«Æ°Åª¤ËÂбþ¤µ¤»¤Æ¤¤¤Þ¤¹¡£
¤Ä¤Þ¤ê¡¢¡»ÍѤΥ᥽¥Ã¥É¡¢¡ßÍѤΥ᥽¥Ã¥É¤Èʬ¤±¤Æ½èÍý¤òºîÀ®¤¹¤ëɬÍפ¬¤Ê¤¯¡¢½èÍý¤Î¸úΨ²½¤ò¿Þ¤ë¤³¤È¤¬¤Ç¤¤Æ¤¤¤Þ¤¹¡£
¤è¤Ã¤Æ¡¢À衹¤Î¼ê½ç¤ÇºîÀ®¤·¤Æ¤¤¤¯¥³¥ó¥Ô¥å¡¼¥¿Â¦¤Î¡ß°õ¤ò¤Ä¤±¤Æ¤¤¤¯½èÍý¤Ë¤Ä¤¤¤Æ¤â¡¢¤³¤Î SetOwnerTypeOnGrid ¥á¥½¥Ã¥É¤òÍøÍѤ¹¤ë¤³¤È¤Ç½èÍý¤ò¤Ä¤¯¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¡¡·«¤êÊÖ¤·ÍøÍѤ·¤¿¤¤½èÍý¤ä¡¢°ìÉô¤Î¾ðÊó¤À¤±¤¬°Û¤Ê¤ë¤â¤Î¤Î¡¢¤½¤ì°Ê³°¤ÏƱ¤¸ÆâÍƤˤʤäƤ¤¤ë½èÍý¤ò¤Ä¤¯¤ê¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢
º£²ó¤Î¤è¤¦¤Ë°ú¿ô¤Î¤¢¤ë¥á¥½¥Ã¥É¤òºîÀ®¤·¤Æ¤ª¤¤Þ¤¹¡£¥×¥í¥°¥é¥ß¥ó¥°¤Ï¤³¤¦¤¤¤Ã¤¿½èÍý¤¬ÆÀ°Õ¤Ç¤¢¤ê¡¢½ÅÊ£¤·¤¿½èÍý¤ò½ñ¤«¤Ê¤¯¤ÆºÑ¤à¤Î¤Ç¡¢
¥á¥½¥Ã¥É¤ò³èÍѤ¹¤ë¤³¤È¤¬Â礤ʥá¥ê¥Ã¥È¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡SetOwnerTypeOnGrid ¥á¥½¥Ã¥É¤Ç¤Ï¡¢¥¯¥ê¥Ã¥¯¤·¤¿ Grid ¤ËÂФ·¤Æ¡¢GameManager ¥¹¥¯¥ê¥×¥È¦¤«¤éÌ¿Îá¤ò½Ð¤·¤Þ¤¹¡£
¡¡¤è¤Ã¤Æ¡¢¤³¤³¤Þ¤Ç¤Î°ìÏ¢¤Î½èÍý¤È¤·¤Æ¤Ï¡¢¥¯¥ê¥Ã¥¯¤·¤¿¤é¡¢GridController ¥¹¥¯¥ê¥×¥È¤«¤é GameManager ¥¹¥¯¥ê¥×¥È¤Î OnClickGrid ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Æ¡¢
ºÇ¸å¤Ë¤Ï¡¢GameManager ¥¹¥¯¥ê¥×¥È¤«¤é GridController ¥¹¥¯¥ê¥×¥È¤Î .UpdateGridData ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡¤³¤ÎºÝ¡¢UpdateGridData ¥á¥½¥Ã¥É¤Ë¤Ï°ú¿ô¤È¤·¤Æ¡¢¥ª¡¼¥Ê¡¼¥·¥ó¥Ü¥ë¤Î¾ðÊó¤È¡û¡ß¤Îʸ»úÎó¤Î£²¤Ä¤Î¾ðÊó¤¬Ä󶡤µ¤ì¤Þ¤¹¤Î¤Ç¡¢
¤½¤ì¤ò GridController ¥¹¥¯¥ê¥×¥È¦¤¬³èÍѤ·¤Æ¡¢¥²¡¼¥à²èÌ̤ˡ»°õ¤òɽ¼¨¤¹¤ë½èÍý¤ò¹Ô¤¦¡¢¤È¤¤¤¦¥í¥¸¥Ã¥¯¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
GameManager.cs
¡¡¤³¤³¤Þ¤Ç¤Î½èÍý¤Îή¤ì¤ò¿¶¤êÊ֤äƤߤƤ¯¤À¤µ¤¤¡£
¡¡¤³¤³¤ËÀâÌÀ¤òµ½Ò¤·¤Æ¤ª¤¤Þ¤¹¤¬¡¢¤´¼«Ê¬¤ÎÃæ¤Ç¤âƱ¤¸¥¤¥á¡¼¥¸¤Ç½èÍý¤¬Æ°¤¤¤Æ¤¤¤ë¤«¤É¤¦¤«¡¢³Îǧ¤·¤Æ¤ª¤¤Þ¤·¤ç¤¦¡£
Íý²ò¤¬Æñ¤·¤¤¾ì¹ç¤Ë¤Ï¡¢ºÆÅÙ¡¢½èÍý¤ÎÆɤßÊÖ¤·¤ä¡¢½ñ¤Ä¾¤·¤ò¹Ô¤¤¡¢Íý²ò¤ò¿¼¤á¤Æ¤«¤éÀè¤Ë¿Ê¤à¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
¡ã£±¡¥Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤¿¤é¡ä
¡¡GridController ¥¹¥¯¥ê¥×¥ÈÆâ¤Ç Grid ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î Button ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ËÅÐÏ¿¤·¤¿ GameManager ¥¹¥¯¥ê¥×¥È¤Ë¤¢¤ë OnClickGrid ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢ ¡¡½èÍý¤¬ GameManager ¥¹¥¯¥ê¥×¥È¤Ë°Ü¤ê¡¢GameManager ¥¹¥¯¥ê¥×¥È¤Î OnClickGrid ¤Î°ú¿ô¤Ë¡¢GridController ¥¹¥¯¥ê¥×¥È¤Î gridNo ÊÑ¿ô¤Î¾ðÊó¤¬ÆϤ¯
¡¡¤½¤Î¸å¡¢¤½¤Î gridNo ÊÑ¿ô¤ò girds ÇÛÎóÊÑ¿ô¤ÎÍ×ÁÇÈÖ¹æ¤È¤·¤ÆÍøÍѤ·¡¢¥¯¥ê¥Ã¥¯¤·¤¿ Grid ¤Î¡û¡ß¤Î¾õÂÖ¤ò CurrentGridOwnerType ÊÑ¿ô¤ÎÃͤdzÎǧ¤·¤Þ¤¹¡£
Æäˤ³¤Î if ʸÆ⤪¤±¤ë¡¢ÇÛÎó¤Ë¤è¤ëɾ²Á½èÍý¤¬Æɤ߲ò¤±¤ë¤«¤É¤¦¤«¤¬½ÅÍפǤ¹¡£ÇÛÎó¤ÎÍ×ÁÇÈֹ椬ÊÑ¿ô¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢¤½¤ÎÈÖ¹æ¤ÎÃͤòÆɤ߲ò¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£
grids[no].CurrentGridOwnerType
¡¡grids[no] ¤È¤Ï¡¢GridController ·¿¤ÎÇÛÎó¤Î no ÈÖÌܤÎÍ×ÁǤòÍøÍѤ¹¤ë¡¢¤Ä¤Þ¤ê¡¢no ÈÖÌܤΠGridController ¤Î¾ðÊó¤òÍøÍѤ¹¤ë¡¢¤È¤¤¤¦ÆâÍƤˤʤê¤Þ¤¹¡£
¤½¤·¤Æ¡¢GridController ¥¹¥¯¥ê¥×¥È¤Ë¤¢¤ë CurrentGridOwnerType ÊÑ¿ô¤ÎÃͤ¬ None ¤Ç¤¢¤ë¾ì¹ç¡¢¡û¡ß¤Î¤Ê¤¤ Grid ¤È¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢
if ʸÆâ¤Î½èÍý¤Ë°Ü¤ê¡¢GameManager ¥¹¥¯¥ê¥×¥È¤Î SetOwnerTypeOnGrid ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
¡ã£²¡¥Grid ¤Ë¡»°õ¤ò¤Ä¤±¤ë¡ä
¡¡GameManager ¥¹¥¯¥ê¥×¥È¤Î SetOwnerTypeOnGrid ¥á¥½¥Ã¥É¤ÎÃæ¤Ç¡¢GridController ¥¹¥¯¥ê¥×¥È¤Ë¤¢¤ë UpdateGridData ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë ¡¡¡¡¡¡¡¡¡¡¡¡¢ ¡¡½èÍý¤¬¡¢GridController ¥¹¥¯¥ê¥×¥È¤Ë°Ü¤ê¡¢GridController ¥¹¥¯¥ê¥×¥È¤Ë¤¢¤ë UpdateGridData ¥á¥½¥Ã¥É¤Î°ú¿ô¤Ë¡¢GridOwnerType ¤ÎÃÍ(Player)¤È ¡» ¤Îʸ»úÎó¤¬ÆϤ¯ ¡¡¤½¤Î¾ðÊó¤ò¡¢GridController ¥¹¥¯¥ê¥×¥È¤¬¡¢ÊÑ¿ô¤ËŬÍѤ·¡¢¥²¡¼¥à²èÌ̤ˡ»°õ¤¬É½¼¨¤µ¤ì¤ë
¡¡½èÍý¤¬Æɤ߲ò¤±¤ë¤è¤¦¤Ë¤Ê¤ì¤Ð¡¢¾åµ¤Î¤è¤¦¤Ê·Á¤Ç¼«Ê¬¤Ç½èÍý¤Îή¤ì¤¬ÀâÌÀ¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¤³¤Î¤è¤¦¤Ë¥×¥í¥°¥é¥à¤ÎÆâÍƤò¸À¸ì²½¤Ç¤¤ë¤è¤¦¤Ë¤¬¤ó¤Ð¤Ã¤Æ¤¤¤¤Þ¤·¤ç¤¦¡£
¡¡½èÍý¤¬´°À®¤·¤Þ¤·¤¿¤Î¤Ç¡¢ºÇ½é¤«¤éº£²ó³Ø½¬¤·¤¿ÆâÍƤò¿¶¤êÊ֤ꡢ½èÍý¤ÎÆâÍƤÎÍý²ò¤ò¿¼¤á¤Æ¤¯¤À¤µ¤¤¡£
¡¡¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¡¢Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
Àè¤Û¤É Debug.Log ¥á¥½¥Ã¥É¤Ç¼Â¹Ô¤·¤Æ¤¤¤¿Éôʬ¤Ç¡¢º£²ó¤«¤é¤Ï¡»°õ¤òµ½Ò¤¹¤ë¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
¥¯¥ê¥Ã¥¯¤·¤¿ Grid ¤Ë¡»°õ¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡¤Þ¤¿¡¢¤¹¤Ç¤Ë¡»°õ¤¬¤¢¤ë Grid ¤ò¥¯¥ê¥Ã¥¯¤·¤¿¾ì¹ç¤Ë¤Ï¡¢OnClickGrid ¥á¥½¥Ã¥É¤ÎºÇ½é¤¢¤ë if ʸ¤Îɾ²Á¤¬ false ¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢
else ʸ¤ÎÃæ¤Ë½ñ¤¤¤Æ¤¢¤ë½èÍý¤¬¼Â¹Ô¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤Ã¤Æ¡¢Console ¥Ó¥å¡¼¤ËÇÛÃ֤Ǥ¤Ê¤¤¤È¤¤¤¦Ê¸»úÎó¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï´°À®¤Ç¤¹¡£
¡¡ÀâÌÀ¤Ç¤â½ñ¤¤Þ¤·¤¿¤¬¡¢¤³¤³¤Þ¤Ç¤Î½èÍý¤Ï¤¹¤Ù¤Æ´ðÁù½Ê¸¤Ë¤è¤Ã¤Æ½ÐÍè¤Æ¤¤¤Þ¤¹¡£
¤Ä¤Þ¤ê¡¢´ðÁù½Ê¸¤ò¤¤¤«¤Ë¤¦¤Þ¤¯ÁȤßΩ¤Æ¤Æ¤¤¤¯¤³¤È¤¬½ÐÍè¤ë¤«¡¢¤½¤Î¥¤¥á¡¼¥¸¤òºî¤Ã¤Æ¤¤¤¯¤³¤È¤¬¤Ç¤¤ë¤«¡¢¤¬¤È¤Æ¤â½ÅÍפʥ¹¥¥ë¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡if ʸ¤Ç¤Ï¤É¤¦¤¤¤Ã¤¿¤³¤È¤¬¤Ç¤¤ë¡¢ÇÛÎó¤Ï¤É¤¦¤¤¤Ã¤¿µ¡Ç½¤¬¤¢¤ë¡¢¤È¤¤¤¦¤³¤È¤òÃμ±¤È¤·¤Æ»ý¤Ã¤Æ¤¤¤ë¤À¤±¤Ç¤Ï¤Ê¤¯¤Æ¡¢
¤½¤ì¤é¤Ï¤É¤Î¤è¤¦¤Ë»È¤Ã¤Æ¤¤¤±¤Ð½èÍý¤È¤·¤Æ³èÍѤǤ¤ë¤Î¤«¡¢½èÍý¤È½èÍý¤òÁȤ߹ç¤ï¤»¤ë¤³¤È¤Ç¥í¥¸¥Ã¥¯¤òÁȤßΩ¤Æ¤Æ¤¤¤±¤ë¤Î¤«¡¢¤ò¹Í¤¨¤Æ¤¤¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£
¡¡¤³¤ì¤Ï·«¤êÊÖ¤·¡¢½èÍý¤ò¹Í¤¨¤Æµ½Ò¤¹¤ë¤³¤È¤Ç¤·¤«Íܤ¦¤³¤È¤¬½ÐÍè¤Þ¤»¤ó¡£
¤¿¤¯¤µ¤ó½èÍý¤ò½ñ¤¤¤Æ¡¢¥È¥é¥¤¡õ¥¨¥é¡¼¤ò·«¤êÊÖ¤·¤Æ¥¹¥¥ë¥¢¥Ã¥×¤ò¿Þ¤Ã¤Æ¤¯¤À¤µ¤¤¡£
¡¡¼¡¤Ï¡¡¼ê½ç£¸¡¡¡Ý¾¡ÇÔȽÄ굡ǽ¤ò¼ÂÁõ¤¹¤ë¡Ý¡¡¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯