Esempio n. 1
0
 void PlaceObject(Vector3 position)
 {
     if (useCommandWorkflow)
     {
         ICommand newCommand = new PlaceObjectCommand(position); //METODO EXPERIMENTAL, NO SE USA POR DEFECTO
         CommandInvoker.AddCommand(newCommand);
     }
     else
     {
         ObjectPlacer.PlaceObject(position, objectSelected); //METODO COMUN PARA COLOCAR OBJETOS USADO POR DEFECTO
     }
 }
Esempio n. 2
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(1))
     {
         Ray ray = cam.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out HitInfo, Mathf.Infinity))
         {
             ICommand command = new PlaceObjectCommand(HitInfo.point, Cube);
             CommandInvoker.AddCommand(command);
         }
     }
 }
Esempio n. 3
0
        public async Task ShouldSucceedPlaceInFrontOfRobot(int x, int y, Direction direction)
        {
            var      robot    = new Robot(Table.GetTableInstance());
            Position position = new Position(x, y, direction);
            var      command  = new PlaceObjectCommand();

            var result = await command.Excute(robot, position);

            // TODO: Add moe tests and allow the test code to verify regardless of the input data
            // This is restrictly developed for the interview

            //result.ShouldBe();
        }
Esempio n. 4
0
    // Update is called once per frame
    private void LateUpdate()
    {
        float scroll = Input.GetAxis("Mouse ScrollWheel");

        if (scroll > 0)
        {
            currentItem = objectHolder.GetNextObject();
        }
        if (scroll < 0)
        {
            currentItem = objectHolder.GetPreviousObject();
        }

        if (Input.GetKeyDown(KeyCode.T))
        {
            snapAmount += snapDif;
        }

        if (Input.GetKeyDown(KeyCode.G))
        {
            snapAmount -= snapDif;
        }
        snapAmount = Mathf.Max(snapAmount, snapDif);

        if (Input.GetKeyDown(KeyCode.R))
        {
            snapToGrid = !snapToGrid;
        }

        RaycastHit hit;

        if (DoRaycastFromCamera(out hit))
        {
            Vector3 pos = hit.point;
            if (snapToGrid)
            {
                pos = SnapToGrid(pos, snapAmount);
            }

            ShowVisual(objectHolder.GetCurrentVisual(), pos, transform.rotation);

            if (Input.GetMouseButtonDown(0))
            {
                if (currentItem != null)
                {
                    Command command = new PlaceObjectCommand(currentItem, pos, transform.rotation);
                    command.Execute();
                    commandIndex++;
                    commandList.Insert(commandIndex, command);
                }
            }
        }

        //Undo
        if (Input.GetMouseButtonDown(1))
        {
            if (commandIndex >= 0)
            {
                commandList[commandIndex].Undo();
                commandIndex--;
            }
        }

        //Redo
        if (Input.GetMouseButtonDown(2))
        {
            if (commandIndex < commandList.Count - 1)
            {
                commandIndex++;
                commandList[commandIndex].Execute();
            }
        }
    }