示例#1
0
    void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        // DummyControlUnit sourceSheet = desc.sourceCell.GetComponentInParent<DummyControlUnit>();
        DummyControlUnit destinationSheet = desc.destinationCell.GetComponentInParent <DummyControlUnit>();

        // If item dropped between different sheets
        //if (destinationSheet != sourceSheet)
        //{
        //  Debug.Log(desc.item.name + " is dropped from " + sourceSheet.name + " to " + destinationSheet.name);
        //}
        // Delete double items
        DragAndDropCell[] liste_cell = destinationSheet.GetComponentsInChildren <DragAndDropCell>();
        foreach (DragAndDropCell c in liste_cell)
        {
            DragAndDropItem[] i = c.GetComponentsInChildren <DragAndDropItem>();
            if (i.Length > 0)
            {
                if ((i[0].name == desc.item.name) && (c.name != desc.destinationCell.name))
                {
                    // Debug.Log(desc.item.name + " de " + desc.destinationCell.name +" n'est pas le meme que " + i[0].name +" de " + c.name);
                    c.RemoveItem();
                }
            }
        }
    }
    /// <summary>
    /// Operate all drag and drop requests and events from children cells
    /// </summary>
    /// <param name="desc"> request or event descriptor </param>
    void OnSimpleDragAndDropEvent(DragAndDropCell.DropEventDescriptor desc)
    {
        // Get control unit of source cell
        DummyControlUnit sourceSheet = desc.sourceCell.GetComponentInParent <DummyControlUnit>();
        // Get control unit of destination cell
        DummyControlUnit destinationSheet = desc.destinationCell.GetComponentInParent <DummyControlUnit>();

        switch (desc.triggerType)                                               // What type event is?
        {
        case DragAndDropCell.TriggerType.DropRequest:                           // Request for item drag (note: do not destroy item on request)
            Debug.Log("Request " + desc.item.name + " from " + sourceSheet.name + " to " + destinationSheet.name);
            SelectedDrop = desc.item.transform.GetComponent <DragAndDropItem>().type.ToString();
            break;

        case DragAndDropCell.TriggerType.DropEventEnd:                          // Drop event completed (successful or not)
            if (desc.permission == true)                                        // If drop successful (was permitted before)
            {
                Debug.Log("Successful drop " + desc.item.name + " from " + sourceSheet.name + " to " + destinationSheet.name);
            }
            else                                                                // If drop unsuccessful (was denied before)
            {
                Debug.Log("Denied drop " + desc.item.name + " from " + sourceSheet.name + " to " + destinationSheet.name);
            }
            break;

        case DragAndDropCell.TriggerType.ItemAdded:                             // New item is added from application
            Debug.Log("Item " + desc.item.name + " added into " + destinationSheet.name);
            break;

        case DragAndDropCell.TriggerType.ItemWillBeDestroyed:                   // Called before item be destructed (can not be canceled)
            Debug.Log("Item " + desc.item.name + " will be destroyed from " + sourceSheet.name);
            SelectedDrag = desc.item.transform.GetComponent <DragAndDropItem>().type.ToString();
            Selected     = desc.item.transform.gameObject;
            if (SelectedDrag == SelectedDrop)
            {
                GameObject parent = desc.item.gameObject.transform.parent.gameObject;
                Debug.Log(desc.item.gameObject.transform.parent.gameObject.name);

                for (int i = 0; i < desc.item.gameObject.transform.parent.transform.childCount; i++)
                {
                    Destroy(desc.item.gameObject.transform.parent.GetChild(i).gameObject);
                }


                StartCoroutine(IntiateEffect(parent));
            }
            else
            {
                Destroy = true;
            }
            break;

        default:
            Debug.Log("Unknown drag and drop event");
            break;
        }
    }
示例#3
0
    void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        DummyControlUnit sourceSheet      = desc.sourceCell.GetComponentInParent <DummyControlUnit>();
        DummyControlUnit destinationSheet = desc.destinationCell.GetComponentInParent <DummyControlUnit>();

        // If item dropped between different sheets
        if (destinationSheet != sourceSheet)
        {
            Debug.Log(desc.item.name + " is dropped from " + sourceSheet.name + " to " + destinationSheet.name);
        }
    }
示例#4
0
    /// <summary>
    /// Operate all drag and drop requests and events from children cells
    /// </summary>
    /// <param name="desc"> request or event descriptor </param>
    void OnSimpleDragAndDropEvent(DragAndDropCell.DropEventDescriptor desc)
    {
        // Get control unit of source cell
        DummyControlUnit sourceSheet = desc.sourceCell.GetComponentInParent <DummyControlUnit>();
        // Get control unit of destination cell
        DummyControlUnit destinationSheet = desc.destinationCell.GetComponentInParent <DummyControlUnit>();

        switch (desc.triggerType)                                               // What type event is?
        {
        case DragAndDropCell.TriggerType.DropRequest:                           // Request for item drag (note: do not destroy item on request)
            //Debug.Log("Request " + desc.item.name + " from " + sourceSheet.name + " to " + destinationSheet.name);
            break;

        case DragAndDropCell.TriggerType.DropEventEnd:                          // Drop event completed (successful or not)
            if (desc.permission == true)                                        // If drop successful (was permitted before)
            {
                change = true;
                // Debug.Log("Successful drop " + desc.item.name + " from " + sourceSheet.name + " to " + destinationSheet.name);
            }
            else                                                                // If drop unsuccessful (was denied before)
            {
                Debug.Log("Denied drop " + desc.item.name + " from " + sourceSheet.name + " to " + destinationSheet.name);
            }
            break;

        case DragAndDropCell.TriggerType.ItemAdded:                             // New item is added from application
            Debug.Log("Item " + desc.item.name + " added into " + destinationSheet.name);
            break;

        case DragAndDropCell.TriggerType.ItemWillBeDestroyed:                   // Called before item be destructed (can not be canceled)
            Debug.Log("Item " + desc.item.name + " will be destroyed from " + sourceSheet.name);
            break;

        default:
            Debug.Log("Unknown drag and drop event");
            break;
        }
    }
示例#5
0
    /// <summary>
    /// Operate all drag and drop requests and events from children cells
    /// </summary>
    /// <param name="desc"> request or event descriptor </param>
    void OnSimpleDragAndDropEvent(DragAndDropCell.DropEventDescriptor desc)
    {
        // Get control unit of source cell
        DummyControlUnit sourceSheet = desc.sourceCell.GetComponentInParent <DummyControlUnit> ();
        // Get control unit of destination cell
        DummyControlUnit destinationSheet = desc.destinationCell.GetComponentInParent <DummyControlUnit> ();

        if (desc.triggerType == DragAndDropCell.TriggerType.DropEventEnd)
        {
            string destinationCellName = desc.destinationCell.ToString().Split(' ') [0];
            string sourceCellName      = desc.sourceCell.ToString().Split(' ') [0];

            if (topicsToTilesMapping.ContainsKey(destinationCellName))
            {
                if (topicsToTilesMapping[destinationCellName].Contains(sourceCellName))
                {
                    ScoreScript.scoreValue += int.Parse(bucketToScoreMapping[destinationCellName]);
                }
                else
                {
                    ScoreScript.scoreValue -= 1;
                }
            }

            var destBucket          = desc.destinationCell.gameObject;
            var gameObjectToDestroy = destBucket.transform.Find("img_" + sourceCellName);
            Destroy(gameObjectToDestroy.gameObject);

            if (bucketToOccupancyMapping[destinationCellName] < 5)
            {
                bucketToOccupancyMapping[destinationCellName] += 1;
                //increase the level fill of the bucket
                object[] sprites        = Resources.LoadAll("bucket/incremental", typeof(Sprite));
                Image    imageComponent = destBucket.transform.GetChild(0).GetComponent <Image> ();
                imageComponent.sprite = (Sprite)sprites[bucketToOccupancyMapping[destinationCellName]];
            }
        }
    }
示例#6
0
 // Start is called before the first frame update
 void Start()
 {
     unit = GetComponent <DummyControlUnit>();
 }