ã¯ããã«
ã©ãããåéã§ãã
é½å¸éçºã·ãã¥ã¬ã¼ã·ã§ã³ã²ã¼ã ãä½ãã·ãªã¼ãºä¸åç®ã¯ä½æ°ããéã稼ãã§ãã®ãéã使ãã¨ããæµããçã¿åºãã¾ãã
çµæ¸ãåã
ãããç¥ã£ãã®ã§ãã³ã¼ããæ¸ãæãã¾ããã
ä½æ°ããã®ãè²·ã
éãåºãç·ãä½æ°ã®å®¶ã
ä½æ°ããéã稼ã
é»è²ã建ç©ã¯Officeã«è¨å®ãã建ç©ã
é»è²ã建ç©ã§ãéã稼ãã§ãéã建ç©ã§ãéã使ã£ã¦ããã
ç¾ç¶ãå¸æ°ã«å ¨é¨ã®ã³ã¼ããæ¸ãã¦ãã®ã§ã©ãã«ãããããªã¼
Systeméã®åç §ã®ä»æ¹ã¨ãã建ç©ã®ç¨®é¡ãã¨ã®å¦çã®åãåãã®é¨åãECSã®ã«ããã¦ããåãããªãã
ã³ã¼ãã¯é·ãã®ã§ä¸ã«
void Execute(ref CitizenBase citizen, ref LocalTransform transform) // Queryã®ä»£ãããã¯ã¨ãªæ¡ä»¶ããåè´ããEntityãæ¢ãã¦å®è¡ { float minDistanceSq = float.MaxValue; citizen.IncreaseRandomDesire(); if (!citizen.isNowMove) { if (IsAlreadyArrived(transform.Position,citizen.home)) { if (citizen.appetite<500 || citizen.pocketMoney<500) { foreach (var buildingEntity in BuildingEntities) { if (BuildingLookup[buildingEntity].buildingType == BuildingType.Office) { float distanceSq = math.distancesq(BuildingPosLookup[buildingEntity].Position, transform.Position); if (distanceSq < minDistanceSq) { minDistanceSq = distanceSq; closestBuildingEntity = buildingEntity; citizen.destinationEntity = closestBuildingEntity; } } } citizen.destination = BuildingPosLookup[closestBuildingEntity].Position; } else { foreach (var buildingEntity in BuildingEntities) { if (BuildingLookup[buildingEntity].buildingType == BuildingType.Food) { float distanceSq = math.distancesq(BuildingPosLookup[buildingEntity].Position, transform.Position); if (distanceSq < minDistanceSq) { minDistanceSq = distanceSq; closestBuildingEntity = buildingEntity; citizen.destinationEntity = closestBuildingEntity; } } } citizen.destination = BuildingPosLookup[closestBuildingEntity].Position; } } else if (IsAlreadyArrived(transform.Position,citizen.destination)) { if (citizen.destinationEntity==Entity.Null) { citizen.destination = citizen.home; } else { if (BuildingLookup[citizen.destinationEntity].buildingType == BuildingType.Food) { citizen.destination = citizen.home; citizen.appetite = 0; citizen.pocketMoney -= 500; } else if (BuildingLookup[citizen.destinationEntity].buildingType == BuildingType.Office) { citizen.destination = citizen.home; citizen.pocketMoney += 500; } } } } Move(ref citizen, ref transform); }