Exemplo n.º 1
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            if (travelAlongPath != null)
            {
                if (travelAlongPath.isUseable() && !travelAlongPath.isComplete())
                {
                    CharacterTask.Task task = travelAlongPath.getCurrentTask(taskTracker);
                    if (task.taskType == CharacterTask.Type.StepToBlock)
                    {
                        CharacterTask.StepToBlock stepTask = (CharacterTask.StepToBlock)task;
                        Vector3 stepGoal = stepTask.getGoalLoc().toWorldSpaceVector3() + new Vector3(.5f, 0, .5f);
                        stepGoal.Y = boat.getFootLocation().Y;
                        Vector3 newFootLoc = LinearLocationInterpolator.interpolate(boat.getFootLocation(), stepGoal, boat.getSpeed());
                        newFootLoc.Y = boat.getFootLocation().Y;
                        boat.setFootLocation(newFootLoc);
                        boat.setRotationWithGivenDeltaVec(stepGoal - boat.getFootLocation());
                        boat.setVelocity(new Vector3());


                        if (LinearLocationInterpolator.isLinearInterpolationComplete(boat.getFootLocation(),
                                                                                     stepGoal, boat.getSpeed()))
                        {
                            stepTask.taskWasCompleted();
                        }
                    }
                }
                else if (travelAlongPath.isComplete())
                {
                    travelAlongPath = null;
                }
            }

            return(new CharacterTask.CaptainBoat(boat));
        }
Exemplo n.º 2
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            if (character.isCarryingItem() && character.getLoad() == ResourceBlock.ResourceType.standardBlock)
            {
                if (buildSite.numBlocksLeftToBuild() > 0)
                {
                    List<BlockLoc> nextBlocksToBuild = buildSite.getAllBlocksToBuild().ToList();

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

                    }
                    BlockLoc blockFoundToBuild;

                    PathHandlerPreferringLowerBlocks pathhandler = new PathHandlerPreferringLowerBlocks();
                    Path path = pathhandler.getPathToMakeTheseBlocksAvaiable(
                        buildSite.getProfile(),
                        new BlockLoc(character.getFootLocation()),
                        buildSite.getProfile(),
                        nextBlocksToBuild,
                        2, out blockFoundToBuild);



                    PlaceBlockJob placeBlockJob = new PlaceBlockJob(buildSite, character, blockFoundToBuild,
                        new BuildKickoffJob(buildSite, character, workingProfile), workingProfile, buildSite.getTypeAt(blockFoundToBuild));
                    TravelAlongPath walkJob = new TravelAlongPath(path, getWaitJobWithReturn(30, placeBlockJob)); ;
                    return new CharacterTask.SwitchJob(walkJob);

                }

                else
                {
                    return new CharacterTask.SwitchJob(new UnemployedJob());
                }
            }
            else
            {
                if (buildSite.numBlocksLeftToBuild() > 0)
                {
                    List<BlockLoc> nextBlocksToBuild = buildSite.getAllBlocksToBuild().ToList();

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

                    }
                    BlockLoc blockFoundToBuild;

                    PathHandlerPreferringLowerBlocks pathhandler = new PathHandlerPreferringLowerBlocks();
                    Path path = pathhandler.getPathToMakeTheseBlocksAvaiable(
                buildSite.getProfile(),
                new BlockLoc(character.getFootLocation()),
                buildSite.getProfile(),
                nextBlocksToBuild,
                2, out blockFoundToBuild);



                    //PlaceBlockJob placeBlockJob = new PlaceBlockJob(buildSite, character, location, workingProfile);
                    BuildKickoffJob build = new BuildKickoffJob(buildSite, character, workingProfile);
                    FetchResourceJob fetch = new FetchResourceJob(workingProfile, ResourceBlock.ResourceType.standardBlock, character, build);
                    return new CharacterTask.SwitchJob(fetch);

                }

                else
                {
                    return new CharacterTask.SwitchJob(new UnemployedJob());
                }
            }



        }
Exemplo n.º 3
0
 public void cancelPathing()
 {
     travelAlongPath = null;
 }
Exemplo n.º 4
0
 public void setTravelPath(Path nPath)
 {
     travelAlongPath = new TravelAlongPath(nPath);
 }