Ejemplo n.º 1
0
        protected bool Seek_ActiveHarvesters <T>(int count, float searchRadius) where T : ResourceController
        {
            LogFormat("Seek_ActiveHarvesters<{0}>({1}): ", typeof(T), count);

            if (Has_ActiveHarvesters <T>(count))
            {
                return(true);
            }

            if (!Seek_IdleRobot <HarvesterRobotController>(HarvesterRobotController.Settings_cost()))
            {
                return(false);
            }

            if (!Do_HarvestNearby <T>(searchRadius))
            {
                return(false);
            }

            return(Seek_ActiveHarvesters <T>(count, searchRadius));
        }
Ejemplo n.º 2
0
        protected bool Do_HarvestNearby <T>(float searchRadius) where T : ResourceController
        {
            LogFormat("Do_HarvestNearby<{0}>()", typeof(T));

            HarvesterRobotController harvester = GetOwnedRobot <HarvesterRobotController>(false).FirstOrDefault();

            if (harvester == null)
            {
                return(false);
            }

            ResourceController nearByResource = harvester.FindNearbyCollidingGameObjectsOfType <T>(searchRadius).Take(4).TakeRandom();

            if (nearByResource == null)
            {
                return(false);
            }

            DateTime           timeStart    = DateTime.Now;
            List <Instruction> instructions = FindPathInstructions(harvester.gameObject, nearByResource.gameObject);

            instructions.Add(new Instruction_Harvest());
            instructions.Add(new Instruction_Harvest());
            instructions.Add(new Instruction_Move(MoveDirection.Home));
            instructions.Add(new Instruction_DropInventory());
            harvester.SetInstructions(instructions);
            harvester.CmdStartRobot();
            DateTime timeEnd = DateTime.Now;
            int      msUsed  = (timeEnd - timeStart).Milliseconds;

            LogFormat("   ... Robot pathfound and programmed in in {0}ms!", msUsed);

            activeHarvestersTracker.Add(harvester, nearByResource);

            return(true);
        }
Ejemplo n.º 3
0
 public ActiveHarvester(HarvesterRobotController harvester, ResourceController resource)
 {
     Harvester = harvester;
     Resource  = resource;
 }
Ejemplo n.º 4
0
 public void Add(HarvesterRobotController harvester, ResourceController resource)
 {
     activeHarvesters.Add(new ActiveHarvester(harvester, resource));
 }