Exemplo n.º 1
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            List <BlockLoc> nextBlocksToBuild = workingProfile.getTreeJobSite().getTreeTrunkBlocks();

            foreach (BlockLoc claimed in taskTracker.blocksCurrentlyClaimed())
            {
                nextBlocksToBuild.Remove(claimed);
            }
            BlockLoc blockFoundToChop;

            PathHandler pathHadler = new PathHandler();

            Path path = pathHadler.getPathToMakeTheseBlocksAvaiable(
                workingProfile.getTreeJobSite().getProfile(),
                new BlockLoc(character.getFootLocation()),
                workingProfile.getTreeJobSite().getProfile(),
                nextBlocksToBuild,
                2, out blockFoundToChop);

            TravelAlongPath walkJob = new TravelAlongPath(path, getWaitJobWithReturn(45, new ChopTreeJob(character, workingProfile, blockFoundToChop)));

            if (!walkJob.isUseable())
            {
                failedToFindATreeToChop = true;
                return(new CharacterTask.SwitchJob(new UnemployedJob()));
            }

            return(new CharacterTask.SwitchJob(walkJob));
        }
Exemplo n.º 2
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            List <BlockLoc> goalsForBlockPickup = workingProfile.getBlocksToGetThisTypeFrom(typeToFetch).ToList();
            BlockLoc        blockToPlaceResourceIn;
            PathHandler     pathHandler = new PathHandler();

            foreach (BlockLoc test in taskTracker.blocksCurrentlyClaimed())
            {
                goalsForBlockPickup.Remove(test);
            }

            if (goalsForBlockPickup.Count > 0)
            {
                Path path = pathHandler.
                            getPathToMakeTheseBlocksAvaiable(workingProfile.getPathingProfile(), new BlockLoc(character.getFootLocation()),
                                                             workingProfile.getPathingProfile(), goalsForBlockPickup, 2, out blockToPlaceResourceIn);

                targetBlock = blockToPlaceResourceIn;
                TravelAlongPath travel = new TravelAlongPath(path, new PickUpResourceJob(typeToFetch, character, toReturnTo, workingProfile, blockToPlaceResourceIn));
                return(new CharacterTask.SwitchJob(travel));
            }
            else
            {
                return(new CharacterTask.SwitchJob(new UnemployedJob()));
            }
        }
Exemplo n.º 3
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            if (farm.getNumFarmBlocks() > 0)
            {
                List <BlockLoc> nextBlocksToTend = farm.getBlocksNeedingTending().ToList();

                foreach (BlockLoc claimed in taskTracker.blocksCurrentlyClaimed())
                {
                    nextBlocksToTend.Remove(claimed);
                }
                PathHandler pathHandler = new PathHandler();
                Path        path        = pathHandler.getPathToBlockEnumerable(farm.getProfile(),
                                                                               new BlockLoc(character.getFootLocation()), farm.getProfile(),
                                                                               nextBlocksToTend, 2);

                TravelAlongPath travelJob = new TravelAlongPath(path);

                if (travelJob.isUseable())
                {
                    BlockLoc?toTend = path.getLast();
                    if (toTend != null)
                    {
                        TravelAlongPath travelToSwitchTo = new TravelAlongPath(path, getWaitJobWithReturn(30, new TendFarmBlockJob((BlockLoc)toTend, workingProfile, farm, character)));
                        return(new CharacterTask.SwitchJob(travelToSwitchTo));
                    }
                    return(new CharacterTask.NoTask());
                }
                else
                {
                    hasFailedToFindBlock = true;
                    return(new CharacterTask.NoTask());
                }
            }
            else
            {
                return(new CharacterTask.NoTask());
            }
        }
Exemplo n.º 4
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            List <BlockLoc> blocksToRemove = workingProfile.getExcavationSite().getBlocksToRemove();

            if (blocksToRemove.Count > 0)
            {
                BlockLoc toDestroy;
                foreach (BlockLoc claimed in taskTracker.blocksCurrentlyClaimed())
                {
                    blocksToRemove.Remove(claimed);
                }
                PathHandler pathHandler = new PathHandlerPreferringHigherBlocks();
                Path        path        = pathHandler.getPathToMakeTheseBlocksAvaiable(workingProfile.getPathingProfile(),
                                                                                       new BlockLoc(character.getFootLocation()), workingProfile.getPathingProfile(),
                                                                                       blocksToRemove, 2, out toDestroy);
                TravelAlongPath toSwitchTo = new TravelAlongPath(path, getWaitJobWithReturn(45, new DestroyBlockJob(character, workingProfile, toDestroy)));
                return(new CharacterTask.SwitchJob(toSwitchTo));
            }
            else
            {
                return(new CharacterTask.SwitchJob(new UnemployedJob()));
            }
        }
Exemplo n.º 5
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            //return new CharacterTask.PlaceResource(targetBlock, carriedType);
            List <BlockLoc> goalsForBlockPlacement = workingProfile.getResourcesJobSite().getBlocksToStoreThisTypeIn(carriedType).ToList();

            foreach (BlockLoc test in taskTracker.blocksCurrentlyClaimed())
            {
                goalsForBlockPlacement.Remove(test);
            }

            PathHandler pathHandler = new PathHandlerPreferringLowerBlocks();

            if (goalsForBlockPlacement.Count > 0)
            {
                TravelAlongPath walkJob;

                Path path = pathHandler.
                            getPathToMakeTheseBlocksAvaiable(workingProfile.getPathingProfile(), new BlockLoc(character.getFootLocation()),
                                                             workingProfile.getPathingProfile(), goalsForBlockPlacement, 2, out targetBlock);

                Job toSwichToAfterWalk = new PlaceResourceJob(carriedType, character,
                                                              toReturnTo, workingProfile, targetBlock);

                walkJob = new TravelAlongPath(path, getWaitJobWithReturn(5, toSwichToAfterWalk));
                if (path.length() == 0)
                {
                    return(new CharacterTask.SwitchJob(new UnemployedJob()));
                }

                return(new CharacterTask.SwitchJob(walkJob));
            }
            else
            {
                //TODO: make it find the nearest good maybeSpace to place a resource block
                return(new CharacterTask.SwitchJob(new UnemployedJob()));
            }
        }