Execute() public method

public Execute ( RotateDirection direction, IPhoto items ) : bool
direction RotateDirection
items IPhoto
return bool
        public void Rotates()
        {
            ILogger logger  = new NullLogger <object>();
            var     grid    = new Grid(5, 5);
            State?  state   = new State(MoveDirection.East, new Coordinate(1, 3));
            var     command = new RotateCommand(RotateDirection.Left);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.North, state.Value.Direction);
            Assert.AreEqual(1, state.Value.Coordinate.X);
            Assert.AreEqual(3, state.Value.Coordinate.Y);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.West, state.Value.Direction);

            command = new RotateCommand(RotateDirection.Right);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.North, state.Value.Direction);

            state = command.Execute(logger, state, grid);
            Assert.AreEqual(MoveDirection.East, state.Value.Direction);
            Assert.AreEqual(1, state.Value.Coordinate.X);
            Assert.AreEqual(3, state.Value.Coordinate.Y);
        }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        float z = Input.GetAxisRaw("Vertical");
        float x = Input.GetAxisRaw("Horizontal");

        if (z <= -0.1f || z >= 0.1f)
        {
            //Vector3 current = transform.position;
            //Vector3 destination = new Vector3(current.x, current.y, current.z + z);
            //Vector3 direction = destination - transform.position;
            //transform.Translate(direction.normalized * speed * Time.deltaTime);
            MoveCommand move = new MoveCommand(transform, speed, z);
            move.Execute();
        }

        //if(x >= 0.1f)
        //{
        //    transform.Rotate(new Vector3(0, 1, 0) * r_speed/60f, Space.World);
        //}

        //if (x <= -0.1f)
        //{
        //    transform.Rotate(new Vector3(0, -1, 0) * r_speed/60f, Space.World);
        //}
        if (x <= -0.1f || x >= 0.1f)
        {
            RotateCommand rotate = new RotateCommand(transform, r_speed, x);
            rotate.Execute();
        }
    }
    /// <summary>
    /// This methods rotates hexagons. Rotate information comes from input manager
    /// </summary>
    /// <param name="clockwise"></param>
    /// <returns></returns>
    public IEnumerator CheckRotate(bool clockwise)
    {
        List <Hexagon> matchList = new List <Hexagon>();
        // temporary group
        CellGroup tempGroup = selectedGroup;
        // Initialize our rotate command
        ICommand rotateCommand;

        for (int i = 0; i < selectedGroup.NeighbourGroup.Length; i++)
        {
            SetState(States.RotatingState);
            // create new rotate command for start rotating
            rotateCommand = new RotateCommand(clockwise);
            rotateCommand.Execute();
            // adding new command to command buffer. It can be used for later events
            CommandManager.Instance.AddCommand(rotateCommand);
            yield return(new WaitForSeconds(HexMetrics.ROTATION_DELAY));

            // calculation for matches
            matchList = CalculateMatches(hexagons);

            if (matchList.Count > 0)
            {
                OnMoveMade?.Invoke();
                SetState(States.ExplosionState);
                StartCoroutine(HandleMatch(matchList));
                break;
            }
        }
        // if everything is compleated we are going to take our next input
        SetState(States.InputState);
    }
Beispiel #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Wind"))
     {
         if (rc.direction == Vector3.zero)
         {
             // rc = new RotateCommand(transform, other.transform.forward);
             rc.direction = other.transform.forward;
             rc.Execute();
         }
         else if (other.transform.forward == rc.direction)
         {
             if (_swing)
             {
                 _swing = false;
                 rc     = new RotateCommand(transform, other.transform.forward);
                 // rc.direction = other.transform.forward;
                 rc.Execute();
             }
         }
         else
         {
             if (_swing)
             {
                 rc = new RotateCommand(transform, other.transform.forward);
             }
             else
             {
                 // rc.Stop();
                 first  = Quaternion.LookRotation(rc.direction, Vector3.up);
                 second = Quaternion.LookRotation(other.transform.forward, Vector3.up);
                 // rc = new RotateCommand(transform, other.transform.forward);
                 rc.direction = other.transform.forward;
                 // rc.Execute();
                 _swing = true;
             }
         }
         // ci.command.affected.Push(rc);
     }
 }
Beispiel #5
0
        public void CommandTestRotate()
        {
            //Set up the model
            Model model = new Model();

            model.SetSize(new SizeF(1000, 1000)); //Set the container size so that the shape can be moved

            //Set up the shape element
            Shape shape = new Shape();

            shape.AllowRotate = true;
            shape.Location    = new PointF(100, 100);
            model.Shapes.Add("Shape1", shape);

            //Set up the controller
            Controller controller = new Controller(model);

            //Set up the action
            shape.ActionElement = controller.CloneElement(shape);

            //Set up the command
            RotateCommand command = controller.CommandFactory.CreateRotateCommand();

            command.Elements = new ElementList(true);
            command.Elements.Add(shape);
            command.Degrees = 90;

            //Translate the action and execute the command
            command.Rotate();
            command.Execute();
            Assert.IsTrue(shape.Rotation == 90, "Rotate command not applied correctly to shape.");

            command.Undo();
            Assert.IsTrue(shape.Rotation == 0, "Rotate command not undone correctly for shape.");

            command.Redo();
            Assert.IsTrue(shape.Rotation == 90, "Rotate command not redone correctly to shape.");
        }
Beispiel #6
0
 void HandleRotate90Command(object sender, System.EventArgs args)
 {
     RotateCommand command = new RotateCommand (this.Window);
     if (command.Execute (RotateDirection.Clockwise, new IPhoto [] { image_view.Item.Current }))
         collection.MarkChanged (image_view.Item.Index, FullInvalidate.Instance);
 }
	//
	// Commands
	//

	private void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction)
	{
		RotateCommand command = new RotateCommand (parent);
		
		int [] selected_ids = SelectedIds ();
		if (command.Execute (direction, SelectedPhotos (selected_ids)))
#if MONO_1_9_0
			query.MarkChanged (selected_ids, new PhotoChanges () {DataChanged = true});
#else
		{
			PhotoChanges changes = new PhotoChanges ();
			changes.DataChanged = true;
			query.MarkChanged (selected_ids, changes);
		}
#endif
	}
Beispiel #8
0
        // Update is called once per frame
        void Update()
        {
            if (CommandManager.Instance.m_isLocked)
            {
                return;
            }

            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            var move = new MoveCommand(this.transform, v, h, m_speed);

            //move.Execute();

            //(回転と移動)の同時押し
            if (Input.GetKeyDown(KeyCode.Z) && h == 1 || Input.GetKeyDown(KeyCode.Z) && v == 1)
            {
                Debug.Log("同時におした");
                var rotate = new RotateCommand(this.transform, m_rotate_Z);
                rotate.Execute();
                move.Execute();
                commands[0] = rotate;
                commands[1] = move;
                CommandManager.Instance.AddCommand(true, commands);
                return;
            }
            else if (Input.GetKeyDown(KeyCode.X) && h == 1 || Input.GetKeyDown(KeyCode.X) && v == 1)
            {
                Debug.Log("同時におした");
                var rotate = new RotateCommand(this.transform, m_rotate_Z * -1);
                rotate.Execute();
                move.Execute();
                commands[0] = rotate;
                commands[1] = move;
                CommandManager.Instance.AddCommand(true, commands);
                return;
            }

            //通常

            if (Input.GetKeyDown(KeyCode.Z))
            {
                //左回転
                //transform.Rotate(new Vector3(0, 0, m_rotate_Z));
                var rotate = new RotateCommand(this.transform, m_rotate_Z);
                rotate.Execute();
                commands[0] = rotate;
                CommandManager.Instance.AddCommand(false, commands);
                return;
                //CommandManager.Instance.AddCommand(rotate);
            }
            else if (Input.GetKeyDown(KeyCode.X))
            {
                //右回転
                //transform.Rotate(new Vector3(0, 0, m_rotate_Z * -1));
                var rotate = new RotateCommand(this.transform, m_rotate_Z * -1);
                rotate.Execute();
                commands[0] = rotate;
                CommandManager.Instance.AddCommand(false, commands);
                return;
                // CommandManager.Instance.AddCommand(rotate);
            }

            commands[0] = move;
            CommandManager.Instance.AddCommand(false, commands);
        }
Beispiel #9
0
		//
		// Commands
		//

		void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction)
		{
			RotateCommand command = new RotateCommand (parent);

			int[] selected_ids = SelectedIds ();
			if (command.Execute (direction, SelectedPhotos (selected_ids)))
				query.MarkChanged (selected_ids, InvalidateData.Instance);
		}
		void HandleRotate270Command (object sender, System.EventArgs args) 
		{
			RotateCommand command = new RotateCommand (this.Window);
			if (command.Execute (RotateDirection.Counterclockwise, new IBrowsableItem [] { image_view.Item.Current })) {
				collection.MarkChanged (image_view.Item.Index);
			}
		}		
Beispiel #11
0
        //
        // Commands
        //
        private void RotateSelectedPictures(Gtk.Window parent, RotateDirection direction)
        {
            RotateCommand command = new RotateCommand (parent);

            int [] selected_ids = SelectedIds ();
            if (command.Execute (direction, SelectedPhotos (selected_ids)))
                query.MarkChanged (selected_ids, new PhotoChanges () {DataChanged = true});
        }
	//
	// Commands
	//

	private void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction)
	{
		RotateCommand command = new RotateCommand (parent);
		
		int [] selected_ids = SelectedIds ();
		if (command.Execute (direction, SelectedPhotos (selected_ids))) {
			foreach (int num in selected_ids)
				query.MarkChanged (num);
		}
	}