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 override bool Equals(System.Object obj)

        {
            if (obj == null)
            {
                return(false);
            }
            else if (obj is BlockLoc)
            {
                BlockLoc value2 = (BlockLoc)obj;
                bool     result = (worldSpaceX == value2.worldSpaceX &&
                                   worldSpaceY == value2.worldSpaceY &&
                                   worldSpaceZ == value2.worldSpaceZ);
                return(result);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        private void handleFinishDragging(PlayerAction.Action action)
        {
            PlayerAction.FinishDragging finishDragClick = (PlayerAction.FinishDragging)action;
            Ray     finishDragRay   = finishDragClick.getRay();
            Vector3?finishDragBlock = world.getBlockAlongRay(finishDragRay);

            if (finishDragBlock.HasValue)
            {
                BlockLoc currentFinishBlock = new BlockLoc((int)((Vector3)finishDragBlock).X, (int)((Vector3)finishDragBlock).Y, (int)((Vector3)finishDragBlock).Z);
                IEnumerable <BlockLoc> draggedBlocks;
                if (finishDragClick.getDragType() == PlayerAction.Dragging.DragType.excavate)
                {
                    draggedBlocks = world.GetBlocksBoundBy(player.getFirstBlockInDrag(), currentFinishBlock);
                }
                else
                {
                    draggedBlocks = world.getSurfaceBlocksBoundBy(player.getFirstBlockInDrag(), currentFinishBlock);
                }
                world.handlePlayerFinishDrag(player.getCameraLoc(), draggedBlocks.ToList(), finishDragClick.getDragType());
            }
        }
Beispiel #4
0
 public static BlockLoc AddIntVec3(BlockLoc loc1, IntVector3 toAdd)
 {
     return(new BlockLoc(loc1.WSX() + toAdd.X, loc1.WSY() + toAdd.Y, loc1.WSZ() + toAdd.Z));
 }
Beispiel #5
0
 public void setFirstBlockInDrag(BlockLoc toSet)
 {
     firstBlockInDrag = toSet;
 }