示例#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());
                    }
                }
            }
        }
示例#2
0
        private void handleLeftClickAsCharacterSelection(PlayerAction.Action action)
        {
            PlayerAction.LeftClick click = (PlayerAction.LeftClick)action;
            Ray ray = click.getRay();

            ray.Direction.Normalize();
            Vector3?blockVec = world.getBlockAlongRay(ray);

            if (blockVec.HasValue)
            {
                //world.addCharacterAt((Vector3)blockVec+new Vector3(0,1,0));
            }

            Character character  = world.getCharacterAlongRay(ray);
            bool      shouldJump = character != player.getSelectedCharacter();

            if (character == null)
            {
                player.deselectCharacter();
            }
            else
            {
                player.characterWasLeftClicked(character);
            }
            if (character != null && shouldJump)
            {
                //character.jump();
            }
        }
示例#3
0
        private void handleDoubleClick(PlayerAction.Action action)
        {
            PlayerAction.DoubleClick click = (PlayerAction.DoubleClick)action;
            Ray ray = click.getRay();

            Vector3?blockVec = world.getBlockAlongRay(ray);

            if (blockVec.HasValue)
            {
                //world.addCharacterAt((Vector3)blockVec+new Vector3(0,1,0));
            }

            Character character = world.getCharacterAlongRay(ray);

            //player.characterWasLeftClicked(character);
            if (character != null)
            {
                player.embodyCharacter(character);
            }
        }
示例#4
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());
            }
        }