ºÇ½ª¹¹¿·¡§
orika_ex_miyako 2021ǯ11·î17Æü(¿å) 11:24:58ÍúÎò
¤Þ¤º¤ÏºÇ½é¤Ë¡¢¤ª»È¤¤¤Î·Ð²á»þ´Ö¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤Ç¤¤ë¤è¤¦¤Ë OfflineTimeManager ¥¯¥é¥¹¤Ë¤Æ¤ª»È¤¤¤´¤È¤Î»þ´Ö¤Î·Ð²á¤ò´ÉÍý¤Ç¤¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Î½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è(´°À®»þ)¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¼ê½ç£±£´¡¡¡Ý¤ª»È¤¤¤Î»þ´Ö¤Î·Ð²á¤ò´ÉÍý¤¹¤ë½èÍý¤Î¼ÂÁõ¡Ý
£²£´¡¥OfflineTimeManager ¥¹¥¯¥ê¥×¥È¡¢GameManager ¥¹¥¯¥ê¥×¥È¡¢TapPointDetail ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤ò OfflineTimeManager ¥¹¥¯¥ê¥×¥È¤Ë¤Æ´ÉÍý¤Ç¤¤ë¤è¤¦¤Ë¤¹¤ë
¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£
¡¡¡¦¥¯¥é¥¹Æâ¤ËÊ̤Υ¯¥é¥¹¤òºîÀ®¤¹¤ë(Æþ¤ì»Ò¥¯¥é¥¹) ¡¡¡¦List ¤Î»È¤¤Êý¢¡¡¡¼Find ¥á¥½¥Ã¥É¡¢Exists ¥á¥½¥Ã¥É¡¢Add ¥á¥½¥Ã¥É¡¼ ¡¡¡¦new ±é»»»Ò¤Ë¤è¤ë¥¤¥ó¥¹¥¿¥ó¥¹¤ÎºîÀ®¤È¥ª¥Ö¥¸¥§¥¯¥È½é´ü²½»Ò
£²£´¡¥OfflineTimeManager ¥¹¥¯¥ê¥×¥È¡¢GameManager ¥¹¥¯¥ê¥×¥È¡¢TapPointDetail ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤ò OfflineTimeManager ¥¹¥¯¥ê¥×¥È¤Ë¤Æ´ÉÍý¤Ç¤¤ë¤è¤¦¤Ë¤¹¤ë ![](https://static.seesaawiki.jp/img/usr_second/common/icon_pen.gif)
¡¡¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤Î¾ðÊó¤Ï TapPointDetail ¥¹¥¯¥ê¥×¥È¤ËÍÑ°Õ¤·¤Æ¤¤¤ë JobData ¥¯¥é¥¹¤Ë¤Æ´ÉÍý¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¹Ô¤ÀèÍѤΥ²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤¬Ê£¿ô¤¢¤ë¾ì¹ç¡¢¤½¤ì¤é¤ÏÆÈΩ¤·¤Æ¸Ä¡¹¤Ë¸ºß¤·¤Æ¤¤¤ë´Ø·¸¾å¡¢
¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤Î¾ðÊó¤òÇÄ°®¤·¤Æ¡¢´ÉÍý¤¹¤ë¤³¤È¤¬º¤Æñ¤Ê¾õÂ֤ˤʤäƤ¤¤Þ¤¹¡£
¡¡»þ´Ö¤Î´ÉÍý¤Ë¤Ä¤¤¤Æ¤Ï¡¢¥·¥ó¥°¥ë¥È¥ó¥Ç¥¶¥¤¥ó¤Î OfflineTimeManager ¥¯¥é¥¹¤Î¥¹¥¯¥ê¥×¥È¤òºîÀ®¤·¤Æ¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢
¤³¤Á¤é¤Ë¤Æ³Æ¹Ô¤ÀèÍѤΥ²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤¬´ÉÍý¤·¤Æ¤¤¤ë JobTime ¥¯¥é¥¹¤ÎÃ椫¤é¡¢¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤È¡¢¤½¤ì¤Ë´ØÏ¢¤¹¤ë¾ðÊó¤ò½¸Ì󤷤ƴÉÍý¤Ç¤¤ëÀ߷פˤ·¤Þ¤¹¡£
¡¡´ÉÍý¤·¤Æ¤ª¤¯¤³¤È¤¬É¬ÍפʾðÊó¤òÀººº¤·¡¢É¬ÍפʾðÊó¤ò»ý¤Ã¤¿¥¯¥é¥¹¤òºîÀ®¤·¤Æ¡¢¤½¤Î¾ðÊó¤ò List ¤Ë¤Æ´ÉÍý¤ò¹Ô¤¤¤Þ¤¹¡£
Î㤨¤Ð¡¢»Ä¤ê»þ´Ö¤Î¾ðÊó¤ÏɬÍפǤ¹¤¬¡¢¤ª»È¤¤¤Î̾Á°¤Î¾ðÊó¤Ï»È¤¦µ¡²ñ¤¬¤¢¤ê¤Þ¤»¤ó¤·¡¢Ä̤·Èֹ椬ʬ¤«¤ì¤Ð¸¡º÷²Äǽ¤Ë¤Ê¤ë¾ðÊó¤Î¤¿¤á¡¢ÉÔÍפǤ¹¡£
¡¡¤³¤Î»þ´Ö¥Ç¡¼¥¿ÍѤΥ¯¥é¥¹¤ò OfflineTimeManager ¥¯¥é¥¹¤¬´ÉÍý¤¹¤ë¤³¤È¤¬½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤Ï¤¸¤á¤Æ¡¢
¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤ò¥»¡¼¥Ö¡¦¥í¡¼¥É¤¹¤ë½èÍý¤ò¼ÂÁõ½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡º£²ó¤Î¼ÂÁõ¤Ç¤Ï¡¢¤ª»È¤¤¤ò³«»Ï¤¹¤ë¤È¡¢¤ª»È¤¤¤ò³«»Ï¤·¤¿»þ´Ö¤ä¡¢¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤ò´ÉÍý¤¹¤ë¥¯¥é¥¹¤òºîÀ®¤·¤Æ¡¢
¤½¤ì¤ò OfflineTimeManager ¥¯¥é¥¹¤Ç´ÉÍý¤Ç¤¤ë¾õÂÖ¤Þ¤Ç¥í¥¸¥Ã¥¯¤ò¹Í¤¨¤ÆÁȤ߹þ¤ó¤Ç¤¤¤¤Þ¤¹¡£
¡¡½¤Àµ¤¬É¬Íפʥ¹¥¯¥ê¥×¥È¤Ï¡¢OfflineTimeManager¡¢GameManager¡¢TapPointDetail ¤Î³Æ¥¹¥¯¥ê¥×¥È¤Ç¤¹¡£
¤³¤Î¤¦¤Á¡¢GameManager ¥¹¥¯¥ê¥×¥È¤Ë´Ø¤·¤Æ¤Ï¡¢Á°²ó¤Î¼ê½ç¤Ç TODO µ¡Ç½¤ÇÍÑ°Õ¤·¤Æ¤¢¤ëÉôʬ¤Ë½èÍý¤ò¼ÂÁõ¤·¤Æ¤¤¤¯¤³¤È¤ò¹Í¤¨¤Þ¤¹¡£
¡¡¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤ò´ÉÍý¤¹¤ë¤¿¤á¤Î JobTimeData ¥¯¥é¥¹¤ò OfflineTimeManager ¥¹¥¯¥ê¥×¥ÈÆâ¤ËºîÀ®¤·¤Þ¤¹¡£
¤³¤Î¥¯¥é¥¹¤Ç¤Ï¡¢¤ª»È¤¤¤ÎÄ̤·Èֹ桢¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¡¢¤ª»È¤¤¤ò³«»Ï¤·¤¿»þ´Ö¤òÊÝ»ý¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤òÍÑ°Õ¤·¤Æ¤ª¤¤Þ¤¹¡£
¡¡¤ª»È¤¤¤ò³«»Ï¤·¤¿¥¿¥¤¥ß¥ó¥°¤Ç¤³¤Î JobTimeData ¥¯¥é¥¹¤ò¥¤¥ó¥¹¥¿¥ó¥¹¤·¤Æ¡¢ÁªÂò¤·¤Æ¤¤¤ë¹Ô¤Àè¤ÎÆâÍƤξðÊó¤ò¡¢³ÆÊÑ¿ô¤ËÂåÆþ¤·¤Æ¼èÆÀ¤·¤Þ¤¹¡£
¤½¤·¤Æ¡¢Í½¤áÍÑ°Õ¤·¤Æ¤ª¤¤¤¿¡¢JobTimeData ¥¯¥é¥¹·¿¤Î List ¤ËÅÐÏ¿¤·¤Þ¤¹¡£
¤¿¤À¤·¡¢Æ±¤¸¤ª»È¤¤¤ÎÈÖ¹æ¤Ï½ÅÊ£¤·¤ÆÅÐÏ¿¤µ¤ì¤Ê¤¤¤è¤¦¤Ë List ¤Ë JobTimeData ¥¯¥é¥¹¤òÄɲ乤ëÁ°¤Ë³Îǧ¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡¤³¤Î¤è¤¦¤Ë£±¤Ä¤Î List ¤Ë½¸Ìó¤·¤Æ JobTimeData ¥¯¥é¥¹¤ò´ÉÍý¤·¤Æ¤ª¤¯¤³¤È¤Ç¡¢¸½ºß¤É¤Î¤ª»È¤¤¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤Î¤«¤ò¡¢OfflineTimeManager ¥¯¥é¥¹¤¬¤¤¤Ä¤Ç¤â³Îǧ¤Ç¤¤ë¾õÂÖ¤òºî¤ê½Ð¤·¤Æ¤¤¤Þ¤¹¡£
Ê£¿ô¤ÎƱ¤¸¥¯¥é¥¹(·¿)¤Î¾ðÊó¤ò°·¤¦¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¤è¤¦¤Ë List ¤Ê¤É¤Î¥³¥ì¥¯¥·¥ç¥ó¤ò³èÍѤ·¤¿À߷פˤ·¤Æ¤ª¤¯¤³¤È¤ÇÍøÊØÀ¤ËÉÙ¤àÆâÍƤˤʤê¤Þ¤¹¡£
¡¡¤³¤Î°ìÏ¢¤Î½èÍý¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤Ë¡¢Àë¸À¡¢¥Õ¥£¡¼¥ë¥É¤Ë¤Ï¥¯¥é¥¹¤ÎÀë¸À¡¢List ¤ÎÀë¸À¤ò¹Ô¤¤¡¢¿·¤·¤¤¥á¥½¥Ã¥É¤ò£³¤ÄÄɲ䷤Ƥ¤¤Þ¤¹¡£
OfflineTimeManager.cs
¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤·¤Þ¤¹¡£
¡¡OfflineTimeManager ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£
¿·¤·¤¯ public ½¤¾þ»Ò¤ÇÄɲä·¤¿ List ·¿¤ÎÊÑ¿ô¤¬¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤ë¤È»×¤¤¤Þ¤¹¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü
![](https://image02.seesaawiki.jp/i/o/i-school-memo/UT0M6KqMc8.png)
¡¡¤³¤Á¤é¤Ï Size 0 ¤Î¤Þ¤Þ¤ÇÌäÂꤢ¤ê¤Þ¤»¤ó¡£
¥²¡¼¥à¤ò¼Â¹Ô¤·¡¢¤ª»È¤¤¤ò³«»Ï¤·¤¿Ãʳ¬¤Ç¡¢¤³¤Î List ÍѤΥ¯¥é¥¹¤¬À¸À®¤µ¤ì¤Æ¡¢List ¤ËÄɲ䵤ì¤ë½èÍý¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
¡¡º£²ó¼ÂÁõ¤·¤Æ¤¤¤ë½èÍý¤ÎÆâÍƤˤʤê¤Þ¤¹¤Î¤Ç¡¢¤É¤Î¥¿¥¤¥ß¥ó¥°¤Ç¤É¤Î½èÍý¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤¿¤á¤Ë¡¢¤³¤Î¤è¤¦¤ÊÀ©¸æ¤¬¹Ô¤¨¤Æ¤¤¤ë¤Î¤«¡¢Î®¤ì¤ò³Îǧ¤·¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£
¡¡OfflineTimeManager ¥¯¥é¥¹¤ÎÀë¸À¥Õ¥£¡¼¥ë¥É¤Ë¤ª¤¤¤Æ¡¢Ê̤Υ¯¥é¥¹¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£º£²ó¤Ï JobTimeData ¥¯¥é¥¹¤Ç¤¹¡£
¤³¤Î¤è¤¦¤ËC#¤Ç¤Ï¡¢£±¤Ä¤ÎÆÈΩ¤·¤¿¥¯¥é¥¹¡Ê¥Õ¥¡¥¤¥ë¡Ë¤È¤·¤Æ¤Ç¤Ï¤Ê¤¯¡¢¤¢¤ë¥¯¥é¥¹¤ÎÃæ¤ÎÀë¸À¥Õ¥£¡¼¥ë¥É¤ËÊ̤Υ¯¥é¥¹¤òºîÀ®¤·¤Æ¤â»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¤³¤Î¤è¤¦¤Ê¹½Â¤¤òÆþ¤ì»Ò¡Ê¥Í¥¹¥È¡Ë¥¯¥é¥¹¤È¸À¤¤¤Þ¤¹¡£
public class OfflineTimeManager : MonoBehaviour { // Àë¸À¥Õ¥£¡¼¥ë¥É /// <summary> /// ¤ª»È¤¤ÍѤλþ´Ö¥Ç¡¼¥¿¤ò´ÉÍý¤¹¤ë¤¿¤á¤Î¥¯¥é¥¹ /// </summary> [Serializable] public class JobTimeData { public int jobNo; // ¤ª»È¤¤¤ÎÄ̤·ÈÖ¹æ public int elaspedJobTime; // ¤ª»È¤¤¤Î»Ä¤ê»þ´Ö public string jobTimeString; // DateTime ¥¯¥é¥¹¤òʸ»úÎó¤Ë¤¹¤ë¤¿¤á¤ÎÊÑ¿ô /// <summary> /// DateTime ¤òʸ»úÎ󷿤ÇÊݸ¤·¤Æ¤¤¤ë¤Î¤Ç¡¢DateTime ·¿¤ËÌᤷ¤Æ¼èÆÀ /// </summary> /// <returns></returns> public DateTime GetDateTime() { return DateTime.ParseExact(jobTimeString, FORMAT, null); } }
¡¡ÆÃÄê¤Î¥¯¥é¥¹¤Ç¤Î¤ß»ÈÍѤ¹¤ë¤³¤È¤¬³ÎÄꤷ¤Æ¤¤¤ë¤è¤¦¤Ê¡¢»ÈÍÑÈϰϤζ¹¤¤¥¯¥é¥¹¤Ç¤¢¤ì¤Ð¡¢¤³¤Î¤è¤¦¤ËÆþ¤ì»Ò¥¯¥é¥¹¤Ë¤·¤¿Êý¤¬¥¹¥¯¥ê¥×¥È¡¦¥Õ¥¡¥¤¥ë¤¬Áý¤¨¤º¤ËºÑ¤ß¤Þ¤¹¡£
¡¡¤Þ¤¿À߷׾塢¥Õ¥¡¥¤¥ë¤Ë¤Ï¤·¤¿¤¯¤Ê¤¤(±£¤·¤Æ¤ª¤¤¿¤¤)¥¯¥é¥¹¤òºîÀ®¤¹¤ë¾ì¹ç¤Ë¤âÍѤ¤¤é¤ì¤Þ¤¹¡£
¡¡»ÈÍÑÊýË¡¤Ï¾¤Î¥¯¥é¥¹¤ÈƱ¤¸¤Ç¤¹¡£»²¾È¤¹¤ë¾ì¹ç¤Ï¡¢OfflineTimeManager.JobTimeData ¤È¤¤¤¦½ñ¼°¤Ç¡¢Æþ¤ì»Ò¥¯¥é¥¹¤Î¤¢¤ë¥¯¥é¥¹¤Î¸å¤Ë¡¢Æþ¤ì»Ò¥¯¥é¥¹¤ò½çÈ֤˵½Ò¤·¤Þ¤¹¡£
[System.Serializable] °À¤òÉÕÍ¿¤·¤Æ¤ª¤¯¤È¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¾å¤Ëɽ¼¨¤µ¤»¤¿¤ê¡¢Ê̤Υª¥Ö¥¸¥§¥¯¥È¤ËÊÑ´¹¤¹¤ë¤³¤È¤¬½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡º£²óÍøÍѤ·¤Æ¤¤¤ë List ¥¯¥é¥¹¤Î»ý¤Ä¥á¥½¥Ã¥É¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£
¡¡List Æâ¤ÎÍ×ÁǤòÀèƬ¤«¤é¸¡º÷¤·¤Æ¡¢»ØÄꤷ¤¿¾ò·ï¤Ë¹çÃפ·¤¿ºÇ½é¤ÎÍ×ÁÇ£±¤Ä¤ò¼è¤ê½Ð¤·¤ÆÌá¤êÃͤȤ·¤ÆÊÖ¤·¤Æ¤¯¤ì¤ë½èÍý¤Ç¤¹¡£
¤³¤ì¤Ï foreach ʸ¤Çµ½Ò¤¹¤ëÆâÍƤÈƱ¤¸½èÍý¤ò£±¹Ô¤Ç½èÍý¤Ç¤¤Þ¤¹¡£
¡ãFind ¥á¥½¥Ã¥É¡ä
// ¥»¡¼¥ÖÂоݤΠJobTimeData ¤ò List ¤«¤é¸¡º÷¤·¤Æ¼èÆÀ JobTimeData jobTimeData = workingJobTimeDatasList.Find(x => x.jobNo == jobNo);
¡ãforeach ʸ¤òÍøÍѤ·¤¿Æ±¤¸½èÍý¡ä
foreach (JobTimeData jobTimeData in workingJobTimeDatasList) { if(jobTimeData.jobNo == jobNo) { return jobTimeData; } }
¡¡¤³¤Î£²¤Ä¤Î½èÍý¤ÏƱ¤¸ÆâÍƤˤʤê¤Þ¤¹¡£
ºÇ½é¤Ë¹çÃפ·¤¿Ãͤ¬Âоݤˤʤê¤Þ¤¹¤Î¤Ç¡¢¤Þ¤È¤á¤ÆÊ£¿ô¼èÆÀ¤·¤¿¤¤¾ì¹ç¤ä¡¢¹çÃפ¹¤ë¾ò·ï¤òËþ¤¿¤¹Í×ÁǤ¬Ê£¿ô¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢¤³¤Î½èÍý¤À¤±¤Ç¤Ï¼ÂÁõ¤Ç¤¤Þ¤»¤ó¡£
¡¡º¸Êդˤϡ¢¸¡º÷·ë²Ì¤¬ÂåÆþ¤µ¤ì¤ë¤¿¤á¤ÎÊÑ¿ô¤òÍÑ°Õ¤·¤Æ¤ª¤¤Þ¤¹¡£¡ÊList¤¬´ÉÍý¤·¤Æ¤¤¤ë·¿¤ÈƱ¤¸·¿¤ÎÊÑ¿ô¤òÀë¸À¤·¤Þ¤¹¡£¡Ë
¤³¤³¤Ç¤Ï workingJobTimeDatasList ÊÑ¿ô¤Î List ¤ËÂФ·¤Æ Find ¥á¥½¥Ã¥É¤Î½èÍý¤ò¹Ô¤¦¤¿¤á¡¢workingJobTimeDatasList ¤Î´ÉÍý¤·¤Æ¤¤¤ë JobTimeData ·¿¤ÎÊÑ¿ô¤òÀë¸À¤·¤Þ¤¹¡£
¡¡Find ¥á¥½¥Ã¥É¤Î½èÍý¤Ï¥é¥à¥À·¿¤Çµ½Ò¤·¤Þ¤¹¡£
¡¡¤³¤ÎÉôʬ¤Ï¡¢workingJobTimeDatasList ¤ÎÍ×ÁÇ¡ÊÃæ¿È¤Ç¤¢¤ë JobTimeData ¥¯¥é¥¹¡Ë¤ò£±¤Ä¤º¤Ä½çÈ֤˼è¤ê½Ð¤·¤Æ¡¢¤½¤Î JobTimeData ¥¯¥é¥¹Æâ¤Î´ÉÍý¤¹¤ë jobNo ¤ò»È¤Ã¤Æ¾È¹ç¤ò¹Ô¤¦¡¢¤È¤¤¤¦½èÍý¤Ç¤¹¡£
workingJobTimeDatasList ¤Ë¤Ï¼Â¹ÔÃæ¤Î¤ª»È¤¤¤Î¿ô¤À¤±¤ÎÍ×ÁÇ(¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤Î¿ô)¤¬¤¢¤ê¤Þ¤¹¤«¤é¡¢¤½¤Î¿ôʬ¤À¤±¡¢ºÇ½é¤ÎÍ×ÁǤ«¤é½çÈ֤˾ȹç¤ò¹Ô¤Ã¤Æ¤¯¤ì¤Þ¤¹¡£
x ¤ÎÃͤˤϡ¢¤½¤ÎÅÔÅÙ¡¢1¤Ä¤À¤± JobTimeData ¥¯¥é¥¹¤¬ÂåÆþ¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡¤³¤ÎÉôʬ¤Ï¡¢£±¤Ä¤º¤Ä¼è¤ê½Ð¤µ¤ì¤Æ¤¯¤ë JobTimeData ¥¯¥é¥¹¤Î¾ðÊó¤È¡¢¥á¥½¥Ã¥É¤ÇÆϤ¤¤Æ¤¤¤ëÈæ¤Ù¤ëÂоݤǤ¢¤ë jobNo ¤ÎÃͤ¬Æ±¤¸¤«¤É¤¦¤«¾È¹çȽÄꤷ¤Æ¤¤¤Þ¤¹¡£
x.jobNo ¤È¤Ï¡¢¸½ºß¼è¤ê½Ð¤µ¤ì¤Æ¤¤¤ë JobTimeData(¤³¤ì¤¬ x ¤ËÅö¤¿¤ê¤Þ¤¹)¥¯¥é¥¹¤Î»ý¤Ä jobNo ¤ò¸«¤Æ¤¤¤Þ¤¹¡£
¡¡¤½¤·¤Æ¾È¹ç¤Î·ë²Ì¡¢¹çÃפ·¤¿Ãͤ¬¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤ÎÃͤòº¸ÊդؤÈÌᤷ¤Æ¤¯¤ì¤Þ¤¹¡£Find ¥á¥½¥Ã¥É¤Ï¤½¤Î»þÅÀ¤Ç̤¸¡º÷¤Î workingJobTimeDatasList ¤ÎÍ×ÁǤ¬¤¢¤Ã¤Æ¤â½èÍý¤¬½ªÎ»¤·¤Þ¤¹¡£
¡¡¥á¥½¥Ã¥É¡¦¥Á¥§¡¼¥ó¤òÍøÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢¼¡¤Î¤è¤¦¤Ë¡¢Ìá¤êÃͤò³èÍѤ·¤¿½èÍý¤òµ½Ò¤¹¤ë¤³¤È¤â½ÐÍè¤Þ¤¹¡£
// List ¤«¤é³ºÅö¤Î JobTimeData ¤ò¸¡º÷¤·¤Æ¼èÆÀ¤·¡¢elaspedJobTime ¤ÎÃͤò currentJobTime ¤Ë¹¹¿· workingJobTimeDatasList.Find(x => x.jobNo == jobNo).elaspedJobTime = currentJobTime;
¡¡¤³¤Î½èÍý¤Ç¤Ï¤Þ¤ººÇ½é¤Ë Find ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Æ¡¢¸¡º÷¾ò·ï¤Ë³ºÅö¤·¤¿ JobTimeData ¥¯¥é¥¹¤¬£±¤Ä¼èÆÀ¤µ¤ì¤Þ¤¹¡£
¤½¤Î JobTimeData ¤Î»ý¤Ä elaspedJobTime ÊÑ¿ô¤Ë¡¢currentJobTime ÊÑ¿ô¤ÎÃͤòÂåÆþ¤¹¤ë¤È¤¤¤¦½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£
»²¹Í¥µ¥¤¥È
MicroSoft
List<T>.Find(Predicate<T>) ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...
Samurai BlogÍÍ
¡ÚC#ÆþÌç¡ÛList¤ÎÍ×ÁǤò¸¡º÷¤¹¤ëFind¤Î»È¤¤Êý(FindAll/FindIndex)
https://www.sejuku.net/blog/45252
¡¡List<T> ¤Ë¡¢»ØÄꤵ¤ì¤¿½Ò¸ì¤Ë¤è¤Ã¤ÆÄêµÁ¤µ¤ì¤¿¾ò·ï¤È°ìÃפ¹¤ëÍ×ÁǤ¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤òȽÃǤ·¤Þ¤¹¡£
// ¤ª»È¤¤¤ò List ¤ËÄɲ乤ëÁ°¤Ë¡¢¤¹¤Ç¤Ë¥ê¥¹¥È¤Ë¤¢¤ë¤«³Îǧ¤·¤Æ½ÅÊ£ÅÐÏ¿¤òËɤ° if (!workingJobTimeDatasList.Exists(x => x.jobNo == jobTimeData.jobNo)) {
¡¡Find ¥á¥½¥Ã¥É¤È¤Î°ã¤¤¤Ï¡¢Find ¥á¥½¥Ã¥É¤Î¾ì¹ç¤Ï¡¢List Æâ¤Ë List ¤ÇÄêµÁ¤·¤Æ¤¤¤ë¥¯¥é¥¹¤Î¾ðÊ󤬤¢¤ë¤«¤É¤¦¤«¤òȽÄꤷ¡¢¤½¤Î¥¯¥é¥¹¤Î¾ðÊó¤òÌá¤êÃͤǼèÆÀ¤·¤Æ¤¤¤Þ¤¹¡£
¡¡Exists ¥á¥½¥Ã¥É¤Ï¡¢Ìá¤êÃͤ¬ bool ·¿¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢List Æâ¤Ë¾ò·ï¤Ë³ºÅö¤¹¤ë¾ðÊ󤬤¢¤ë¤«¡¢¤Ê¤¤¤«¡¢¤òȽÄꤹ¤ë¥á¥½¥Ã¥É¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
¾åµ¤Î¥±¡¼¥¹¤Ç¤Ï false ¤Î¾ì¹ç¤¬¾ò·ï¤òËþ¤¿¤¹¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢¾ò·ï¼°¤Ë³ºÅö¤¹¤ë¾ðÊó¤¬ List Æâ¤Ë¤Ê¤¤¾ì¹ç¤Î¤ß¡¢if ʸÆâ¤Î½èÍý¤ò¹Ô¤¦ºî¤ê¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
»²¹Í¥µ¥¤¥È
MicroSoft
List<T>.Exists(Predicate<T>) ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...
¡¡List¤ÎËöÈø¤Ë°ú¿ô¤Ç»ØÄꤷ¤¿Í×ÁÇ(¥Ç¡¼¥¿)¤òÄɲä·¤Þ¤¹¡£
°ú¿ô¤¬ T ·¿¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤Ï List ¤òÀë¸À¤·¤¿ºÝ¤Ë»È¤Ã¤¿·¿¤¬¼«Æ°Åª¤ËÆþ¤ê¤Þ¤¹¡£¤½¤ì°Ê³°¤Î·¿¤Î¾ðÊó¤ò»ØÄꤹ¤ë¤ÈÄɲäǤ¤Ê¤¤¤¿¤á¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹¡£
º£²ó¤Ï JobTimeData ·¿¤Î List ¤òÀë¸À¤·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢°ú¿ô¤Ë¤Ï JobTimeData ·¿¤Î¤ß»ØÄê¤Ç¤¤Þ¤¹¡£
¡¡List¤ÇÀë¸À¤·¤Æ¤¤¤ë·¿¤ÈƱ¤¸·¿¤Ç¤¢¤ì¤Ð Add ¥á¥½¥Ã¥É¤Ç List ¤ËÍ×ÁǤòÄɲ乤뤳¤È¤¬½ÐÍè¤Þ¤¹¡£
¡¡// List ¤Ë¤Ê¤¤¾ì¹ç¤Î¤ß¡¢¿·¤·¤¯Äɲä¹¤ë ¡¡workingJobTimeDatasList.Add(jobTimeData);
¡¡Äɲ䵤줿Í×ÁǤϡ¢¼«Æ°Åª¤Ë List ¤ÎºÇ¸å¤Ë½çÈÖ¤ËÄɲ䵤ì¤Æ¤¤¤¤Þ¤¹¡£
Î㤨¤Ð¡¢workingJobTimeDatasList ¤¬¤Þ¤À£±¤Ä¤âÍ×ÁǤ¬¤Ê¤±¤ì¤Ð¡¢workingJobTimeDatasList[0] ¤È¤·¤Æ£±¤ÄÌܤËÍ×ÁǤ¬Äɲ䵤ì¤Þ¤¹¡£
¤½¤Î¤¢¤È¤Ë Add ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢workingJobTimeDatasList[1] ¤È¤·¤Æ£²¤ÄÌܤËÍ×ÁǤ¬Äɲ䵤ì¤Þ¤¹¡£
»²¹Í¥µ¥¤¥È
MicroSoft
List<T>.Add(T) ¥á¥½¥Ã¥É
https://docs.microsoft.com/ja-jp/dotnet/api/system...
SamuraiBlog ÍÍ
¡ÚC#ÆþÌç¡ÛList¤Î»È¤¤ÊýÁí¤Þ¤È¤á(ArrayList/Add/Remove/¥½¡¼¥È/¸¡º÷)
https://www.sejuku.net/blog/47378
¡¡¥¯¥é¥¹(·¿)¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤Ï new ±é»»»Ò¤ò»ÈÍѤ¹¤ë¤³¤È¤ÇºîÀ®¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¤Þ¤¿¡¢¥ª¥Ö¥¸¥§¥¯¥È½é´ü²½»Ò { } ¤ò»ÈÍѤ¹¤ë¤È¡¢¥ª¥Ö¥¸¥§¥¯¥È¤ÎºîÀ®»þ¤Ë¥¢¥¯¥»¥¹¤Ç¤¤ë¥Õ¥£¡¼¥ë¥É(¤Ë¤¢¤ëÊÑ¿ô)¤Þ¤¿¤Ï¥×¥í¥Ñ¥Æ¥£¤Ë¡¢
¥³¥ó¥¹¥È¥é¥¯¥¿¡¼¤ò¸Æ¤Ó½Ð¤·¤ÆÂåÆþ¥¹¥Æ¡¼¥È¥á¥ó¥È¤ò»ÈÍѤ·¤Ê¤¯¤Æ¤â¡¢Ãͤò³ä¤êÅö¤Æ¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
¡ã¥¯¥é¥¹¡£JobNo ÊÑ¿ô¤Ê¤É¤¬¥Õ¥£¡¼¥ë¥É¤Î¾ðÊó¡ä
[Serializable] public class JobTimeData { public int jobNo; // ¤ª»È¤¤¤ÎÄ̤·ÈÖ¹æ public int elaspedJobTime; // ¤ª»È¤¤¤Î»Ä¤ê»þ´Ö public string jobTimeString; // DateTime ¥¯¥é¥¹¤òʸ»úÎó¤Ë¤¹¤ë¤¿¤á¤ÎÊÑ¿ô ¡¡¡¡}
¡ãnew ±é»»»Ò¤Ë¤è¤ë¥¤¥ó¥¹¥¿¥ó¥¹ºîÀ®½èÍý¤È¥ª¥Ö¥¸¥§¥¯¥È½é´ü²½»Ò { } ¤Ë¤è¤ë½é´ü²½½èÍý¡ä
// JobTimeData ¤ò¥¤¥ó¥¹¥¿¥ó¥¹¤·¤Æ½é´ü²½ JobTimeData jobTimeData = new JobTimeData { jobNo = tapPointDetail.jobData.jobNo, elaspedJobTime = tapPointDetail.jobData.jobTime };
¡¡¤³¤Îµ¡Ç½¤Ë¤è¤ê¡¢¿·¤·¤¯ºîÀ®¤µ¤ì¤¿ JobTimeData ¥¯¥é¥¹¤Î³ÆÊÑ¿ô¤Ë¤Ï¡¢{ ¡Ñ(¥ª¥Ö¥¸¥§¥¯¥È½é´ü²½»Ò)Æâ¤Ç»ØÄꤵ¤ì¤¿Ã;ðÊ󤬡¢¤½¤ì¤¾¤ìÂåÆþ½èÍý¤µ¤ì¤Þ¤¹¡£
»²¹Í¥µ¥¤¥È
MicroSoft
new ±é»»»Ò (C# ¥ê¥Õ¥¡¥ì¥ó¥¹)
https://docs.microsoft.com/ja-jp/dotnet/csharp/lan...
MicroSoft
¥ª¥Ö¥¸¥§¥¯¥È½é´ü²½»Ò¤È¥³¥ì¥¯¥·¥ç¥ó½é´ü²½»Ò (C# ¥×¥í¥°¥é¥ß¥ó¥° ¥¬¥¤¥É)
https://docs.microsoft.com/ja-jp/dotnet/csharp/pro...
¡¡Á°²ó¤Î¼ê½ç¤Ç TODO ¤òµ½Ò¤·¤Æ¤¢¤Ã¤¿¾ì½ê¤Î¤¦¤Á¡¢JudgeSubmitJob ¥á¥½¥Ã¥ÉÆâ¤Ë½èÍý¤ò¼ÂÁõ¤·¤Æ¤¤¤¤Þ¤¹¡£
¡¡¼«Ê¬¤Ç¼ÂÁõ¤ò¤·¤Æ¤¤¤¯ºÝ¤Î¥³¥Ä¤Ï TODO µ¡Ç½¤â¤â¤Á¤í¤ó¤Ç¤¹¤¬¡¢ÆüËܸì¤Ç¥³¥á¥ó¥È¤È¤·¤Æ¡¢¼ÂÁõ¤·¤¿¤¤½èÍý¤ò½ç½øΩ¤Æ¤Æ¥¹¥¯¥ê¥×¥ÈÆâ¤Ë½ñ¤¤¤Æ¤ª¤¯¡¢¤È¤¤¤¦¤³¤È¤Ç¤¹¡£
¤³¤ÎÆüËܸì¤Î¥³¥á¥ó¥È¤Î½èÍý¤ò¥×¥í¥°¥é¥à²½¤¹¤ë¤Ë¤Ï¤É¤¦¤¹¤ì¤Ð¤¤¤¤¤Î¤«¡¢¤È¤¤¤¦´ÑÅÀ¤Çª¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¡¡º£²ó¤â½èÍý¤òµ½Ò¤¹¤ëÁ°¤Ë¡¢¡Ö¤É¤ó¤Ê½èÍý¤ò¡×¡Ö¤É¤³¤Ë½ñ¤±¤Ð¤¤¤¤¤Î¤«¡×¤ò¥¤¥á¡¼¥¸¤·¤Æ¡¢½èÍý¤òÄɲ䷤Ƥ¤¤Ã¤Æ¤¯¤À¤µ¤¤¡£
¤½¤Î¤è¤¦¤Ê¾õÂ֤ǽèÍý¤ò½ñ¤¤¤Æ¤¤¤¯¤Î¤È¡¢¶µºà¤Ë¤¢¤ë¤«¤é½ñ¤¤¤Æ¤¤¤ë¡¢¤È¤Ç¤Ï³Ø½¬ÆâÍƤËÂ礤ʺ¹¤¬À¸¤Þ¤ì¤Þ¤¹¤Î¤Ç¡¢À§È󡢶µºà¤ò¤´¼«Ê¬¤Ë¤È¤Ã¤Æ¤è¤¤¾õÂÖ¤ÇÍøÍѤ·¤Æ¤¤¤Ã¤Æ¤¯¤À¤µ¤¤¡£
GameManager.cs
¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤·¤Þ¤¹¡£
¡¡¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤òÈ¿±Ç¤µ¤»¤ë¤¿¤á¤Ë¡¢PrapareteJobs ¥á¥½¥Ã¥É¤È WorkingJobs ¥á¥½¥Ã¥É¤Ë°ú¿ô¤òÄɲä·¡¢¤³¤ÎÃͤòÍøÍѤ·¤Æ¡¢¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤òÀßÄê¤Ç¤¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
º£¤Þ¤Ç¤Ï¸ÇÄêÃͤòÍøÍѤ·¤Æ¤¤¤¿¤¿¤á¡¢¤³¤Î½èÍý¤¬¤Ê¤¤¤È¡¢¥²¡¼¥à½ªÎ»Ãæ¤Î»þ´Ö¤Î·Ð²á¤ò¥²¡¼¥àÆâ¤ËÈ¿±Ç¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¤¿¤á¡¢ÊüÃÖ¥²¡¼¥à¤Î¥·¥¹¥Æ¥à¤¬´°À®¤·¤Ê¤¤¤¿¤á¤Ç¤¹¡£
¡¡¤Þ¤¿¡¢WorkingJobs ¥á¥½¥Ã¥ÉÆâ¤Ë¤â½èÍý¤òÄɲä·¡¢OfflineTimeManager ¥¯¥é¥¹¤Ë¤¢¤ë¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤Î»Ä¤ê»þ´Ö¤ò¡¢¸½ºß¤Î»Ä¤ê»þ´Ö¤ÈƱ´ü¤µ¤»¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤Î½èÍý¤¬¤Ê¤¤¤È¡¢OfflineTimeManager ¥¯¥é¥¹¤Î¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤Î»Ä¤ê»þ´Ö¤Ï½é´üÃͤΤޤÞÊѲ½¤·¤Ê¤¤¤¿¤á¡¢
¥²¡¼¥à¤ò½ªÎ»¤·¤ÆºÆ³«¤¹¤ë¤¿¤Ó¡¢¾ï¤Ë½é´üÃͤ«¤é¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤¬³«»Ï¤µ¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹¤Î¤Ç¡¢¤³¤Î½èÍý¤Ë¤è¤Ã¤Æ¤³¤Î¸½¾Ý¤òËɤ¤¤Ç¤¤¤Þ¤¹¡£
TapPointDetail.cs
¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤·¤Þ¤¹¡£
¡¡½èÍý¤ÎÆâÍÆ¡¢½èÍý¤Îή¤ì¤ò¤·¤Ã¤«¤ê¤ÈÇÄ°®¤·¤¿¾å¤Ç¡¢¥²¡¼¥à¤Î¥Ç¥Ð¥Ã¥°¤ò¹Ô¤Ã¤Æ¡¢Æ°ºî¤Î¸¡¾Ú¤È³Îǧ¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡¤ª»È¤¤¤ò³«»Ï¤·¤¿¤È¤¤Ë¡¢OfflineTimeManager ¥¹¥¯¥ê¥×¥È¤Î WorkingJobsTimeDatasList ÊÑ¿ô¤Ë¡¢¤ª»È¤¤¤Î¾ðÊó(JobTimeData ¥¯¥é¥¹)¤¬ºîÀ®¤µ¤ì¤Æ¡¢List ¤ËÅÐÏ¿¤µ¤ì¤ë¤³¤È¡¢
¤½¤·¤Æ¤½¤ÎÃæ¤Î elaspedTime ÊÑ¿ô¤ÎÃͤ¬¡¢TapPointDetail ¥¹¥¯¥ê¥×¥È¤Î¤ª»È¤¤¤Î»Ä¤ê»þ´Ö¤ÎÃͤÈƱ´ü¤·¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£
¡¡¤³¤Î£²ÅÀ¤¬ÌäÂê¤Ê¤±¤ì¤ÐÀ©¸æÀ®¸ù¤Ç¤¹¡£(²¼µ¤ÎÆ°²è¤Ç¤Ï JobTimeString ¤ÎÃͤâ½ñ¤¹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤Î¥¿¥¤¥ß¥ó¥°¤Ç¤Ï¤Þ¤Àɽ¼¨¤µ¤ì¤Ê¤¯¤ÆÌäÂꤢ¤ê¤Þ¤»¤ó¡£)
¡ã¼ÂÁõÆ°²è¡¡¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£
¡¡
¡¡¼¡¤Ï¡¡¼ê½ç£±£µ¡¡¡Ý¤ª»È¤¤¤Î»þ´Ö¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤¹¤ë½èÍý¤Î¼ÂÁõ¡Ý¡¡¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯