Пример #1
0
//	bool _isClone = false;
//
//	public bool isClone { get { return _isClone; } }
//
    public DraggableInstruction GetClone()
    {
        DraggableInstruction clone = Instantiate(this) as DraggableInstruction;

        System.Array.ForEach <SpriteRoot>(clone.GetComponentsInChildren <SpriteRoot>(), (obj) => obj.isClone = true);
        clone.transform.parent        = transform.parent;
        clone.transform.localPosition = Vector3.zero;
//		clone._isClone = true;

        return(clone);
    }
    public void SetupDragDropBehaviour(DraggableInstruction draggableButton)
    {
        draggableButton.button.SetDragDropDelegate((parms) =>
        {
            if (parms.evt == EZDragDropEvent.Begin)
            {
                Debug.Log("Begin " + parms.dragObj /*+":"+parms.dragObj.transform.position+":"+parms.ptr.ray*/);
//				Vector3 origin = parms.ptr.ray.origin;
//				origin.z = 0;
//				parms.dragObj.transform.position = origin;
            }
            if (parms.evt == EZDragDropEvent.Cancelled)
            {
                Debug.Log("Cancelled " + parms.dragObj);
                Debug.Log("DropTarget: " + parms.dragObj.DropTarget);

                if (LevelManager.instance.gameState != LevelManager.State.Construction)
                {
                    return;
                }

                if (draggableButton.occupiedSlot != null)
                {
                    selectedGrabber.SetInstruction(draggableButton.occupiedSlot.instructionIndex, Grabber.Instruction.None);
                    RefreshEmptyInstructions();
                }

                EmptyInstructionSlot instructionSlot = parms.dragObj.DropTarget == null ? null : parms.dragObj.DropTarget.GetComponent <EmptyInstructionSlot>();


                if (instructionSlot != null && selectedGrabber != null)
                {
                    selectedGrabber.SetInstruction(instructionSlot.instructionIndex, draggableButton.instructionRepresented);
//					instructionSlot.CurrentInstruction = draggableButton.instructionRepresented;
                    RefreshEmptyInstructions();
                }
//				else
//				{
//					Debug.Log(draggableButton.occupiedSlot);
//				}
            }
            if (parms.evt == EZDragDropEvent.CancelDone)
            {
                Debug.Log("CancelDone " + parms.dragObj);
            }
        });
    }
	public void SetupDragDropBehaviour(DraggableInstruction draggableButton)
	{
		
		draggableButton.button.SetDragDropDelegate((parms) => 
		{
			if (parms.evt == EZDragDropEvent.Begin)
			{
				Debug.Log ("Begin "+parms.dragObj/*+":"+parms.dragObj.transform.position+":"+parms.ptr.ray*/);
//				Vector3 origin = parms.ptr.ray.origin;
//				origin.z = 0;
//				parms.dragObj.transform.position = origin;
					
			}
			if (parms.evt == EZDragDropEvent.Cancelled)
			{
				Debug.Log ("Cancelled "+parms.dragObj);
				Debug.Log ("DropTarget: "+parms.dragObj.DropTarget);
				
				if (LevelManager.instance.gameState != LevelManager.State.Construction)
				{
					return;
				}
				
				if (draggableButton.occupiedSlot != null)
				{
					selectedGrabber.SetInstruction(draggableButton.occupiedSlot.instructionIndex, Grabber.Instruction.None);
					RefreshEmptyInstructions();
				}
				
				EmptyInstructionSlot instructionSlot = parms.dragObj.DropTarget == null ? null : parms.dragObj.DropTarget.GetComponent<EmptyInstructionSlot>();
				
				
				if (instructionSlot != null && selectedGrabber != null)
				{
					selectedGrabber.SetInstruction(instructionSlot.instructionIndex, draggableButton.instructionRepresented);
//					instructionSlot.CurrentInstruction = draggableButton.instructionRepresented;
					RefreshEmptyInstructions();
				}
//				else
//				{
//					Debug.Log(draggableButton.occupiedSlot);
//				}
				
			}
			if (parms.evt == EZDragDropEvent.CancelDone)
			{
				Debug.Log ("CancelDone "+parms.dragObj);
				
			}
		});
	}