Beispiel #1
0
        private void handleDragging(PlayerAction.Action action)
        {
            PlayerAction.Dragging dragClick = (PlayerAction.Dragging)action;
            Ray     dragRay   = dragClick.getRay();
            Vector3?dragBlock = world.getBlockAlongRay(dragRay);

            if (dragBlock.HasValue)
            {
                BlockLoc currentDragBlock = new BlockLoc((int)((Vector3)dragBlock).X, (int)((Vector3)dragBlock).Y, (int)((Vector3)dragBlock).Z);
                IEnumerable <BlockLoc> draggedBlocks;
                if (dragClick.getDragType() == PlayerAction.Dragging.DragType.excavate)
                {
                    draggedBlocks = world.GetBlocksBoundBy(player.getFirstBlockInDrag(), currentDragBlock);
                }
                else
                {
                    draggedBlocks = world.getSurfaceBlocksBoundBy(player.getFirstBlockInDrag(), currentDragBlock);
                }
                float draggedBlockOpacity = .5f;
                foreach (BlockLoc test in draggedBlocks)
                {
                    switch (dragClick.getDragType())
                    {
                    case PlayerAction.Dragging.DragType.farm:
                        WorldMarkupHandler.addFlagPathWithPosition(ContentDistributor.getEmptyString() + @"worldMarkup\farmMarker.chr",
                                                                   test.toWorldSpaceVector3() + new Vector3(.5f, .5f, .5f));
                        break;

                    case PlayerAction.Dragging.DragType.storeWheat:
                        WorldMarkupHandler.addCharacter(ResourceBlock.getPathForResourceType(ResourceBlock.ResourceType.Wheat),
                                                        test.toWorldSpaceVector3() + new Vector3(.5f, 1.5f, .5f), 1f / 7f, draggedBlockOpacity);
                        WorldMarkupHandler.addCharacter(ResourceBlock.getPathForResourceType(ResourceBlock.ResourceType.Wheat),
                                                        test.toWorldSpaceVector3() + new Vector3(.5f, 2.5f, .5f), 1f / 7f, draggedBlockOpacity);
                        break;

                    case PlayerAction.Dragging.DragType.storeWood:
                        WorldMarkupHandler.addCharacter(ResourceBlock.getPathForResourceType(ResourceBlock.ResourceType.Wood),
                                                        test.toWorldSpaceVector3() + new Vector3(.5f, 1.5f, .5f), 1f / 7f, draggedBlockOpacity);
                        WorldMarkupHandler.addCharacter(ResourceBlock.getPathForResourceType(ResourceBlock.ResourceType.Wood),
                                                        test.toWorldSpaceVector3() + new Vector3(.5f, 2.5f, .5f), 1f / 7f, draggedBlockOpacity);
                        break;

                    case PlayerAction.Dragging.DragType.storeStone:
                        WorldMarkupHandler.addCharacter(ResourceBlock.getPathForResourceType(ResourceBlock.ResourceType.standardBlock),
                                                        test.toWorldSpaceVector3() + new Vector3(.5f, 1.5f, .5f), 1f / 7f, draggedBlockOpacity);
                        WorldMarkupHandler.addCharacter(ResourceBlock.getPathForResourceType(ResourceBlock.ResourceType.standardBlock),
                                                        test.toWorldSpaceVector3() + new Vector3(.5f, 2.5f, .5f), 1f / 7f, draggedBlockOpacity);
                        break;

                    case PlayerAction.Dragging.DragType.excavate:
                        WorldMarkupHandler.addFlagPathWithPosition(ContentDistributor.getEmptyString() + @"worldMarkup\redCubeOutline.chr",
                                                                   test.toWorldSpaceVector3() + new Vector3(.5f, .5f, .5f), 1.1f / 7f);
                        break;

                    default:
                        throw new Exception("unhandled dragType " + dragClick.getDragType());
                    }
                }
            }
        }
Beispiel #2
0
        public void display3D()
        {
            if (isEmbodyingCharacter())
            {
                if (selectedCharacter.isCarryingItem())
                {
                    ResourceBlock.ResourceType type = selectedCharacter.getLoad();
                    String  blockChrPath            = ResourceBlock.getPathForResourceType(type);
                    Vector3 centerOfFloatingCube    = getPlayerAimingAtPointAtDistance(.7f, currentMouseState);

                    WorldMarkupHandler.addFlagPathWithPosition(blockChrPath, centerOfFloatingCube, 1f / 7f / 12f);
                }
            }

            if (selectedCharacter != null && !isEmbodyingCharacter())
            {
                Compositer.addFlagForThisFrame(selectedCharacter.getLocation() + new Vector3(0, 1.1f, 0), "white");
            }
        }