コード例 #1
0
 public World()
 {
     setupIslandManager();
     pathingProfile = new WorldPathingProfile(islandManager);
     actorManager   = new ActorManager();
     actorProfile   = new ActorStateProfile(actorManager);
     gameDirector   = new GameDirector();
 }
コード例 #2
0
        public void handleActorActions(List <ActorAction> actions)
        {
            foreach (ActorAction action in actions)
            {
                switch (action.type)
                {
                case ActorActions.placeBoat:
                    addBoatAt(((ActorPlaceBoatAction)action).getBoatLocToPlace().toWorldSpaceVector3());
                    break;

                case ActorActions.addToVelocity:
                    ActorAddToVelocityAction addVelocity = (ActorAddToVelocityAction)action;
                    handleAddVelocityAction(addVelocity.velocityAddition, addVelocity.character, addVelocity.isFootPropelled());
                    break;

                case ActorActions.rightClickAction:
                    Ray ray = new Ray(((ActorRightClickAction)action).nearClickPoint,
                                      ((ActorRightClickAction)action).farClickPoint - ((ActorRightClickAction)action).nearClickPoint);
                    Boat boatClicked = actorManager.getNearestActorOfTypeAlongRay <Boat>(ray);
                    if (boatClicked != null)
                    {
                        ((ActorRightClickAction)action).character.rightClickedBoat(boatClicked);
                    }
                    break;

                case ActorActions.addToShipVelocity:
                    ActorAddToShipVelocity addShipVelocity = (ActorAddToShipVelocity)action;
                    handleAddVelocityAction(addShipVelocity.getVelocityAddition(), addShipVelocity.getBoat(), false);
                    break;

                case ActorActions.PlaceResource:

                    islandManager.addResourceBlock(((ActorPlaceResourceAction)action).getLocToPlace()
                                                   , ((ActorPlaceResourceAction)action).getRescourceTypeToPlace());
                    if (((ActorPlaceResourceAction)action).getRescourceTypeToPlace() == ResourceBlock.ResourceType.Wheat)
                    {
                        SoundsManager.playSoundType(SoundsManager.SoundType.wheatRustling, ((ActorPlaceResourceAction)action).getLocToPlace().getMiddleInWorldSpace());
                    }
                    break;

                case ActorActions.PickUpResource:

                    islandManager.removeResourceBlock(((ActorPickUpResourceAction)action).getLocToPlace()
                                                      , ((ActorPickUpResourceAction)action).getRescourceTypeToPlace());
                    break;

                case ActorActions.strike:
                    handleStrikeAction(action);
                    break;

                case ActorActions.placeBlock:
                    placeBlock(((ActorPlaceBlockAction)action).getlocToPlaceBlock(), ((ActorPlaceBlockAction)action).getTypeToPlace());
                    break;

                case ActorActions.die:
                    actorManager.deleteActor(((ActorDieAction)action).getActorToBeKilled());
                    break;

                case ActorActions.jump:
                    WorldPathingProfile profile = getPathingProfile();
                    if (profile.isStandableAtExactLocation(((ActorJumpAction)action).getActorToJump().getAABB()))
                    {
                        ((ActorJumpAction)action).getActorToJump().addJumpVelocityToVelocity();
                    }
                    break;
                }
            }

            updateActorPhysics();
        }