예제 #1
0
    void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        selectedCards.Clear();

        int srcSlotNumber  = desc.sourceCell.slotNumber;
        int destSlotNumber = desc.destinationCell.slotNumber;

        GameObject cardObj = cardObjs [srcSlotNumber];

        cardObjs.RemoveAt(srcSlotNumber);
        cardObjs.Insert(destSlotNumber, cardObj);

        Card card = m_cards [srcSlotNumber];

        m_cards.RemoveAt(srcSlotNumber);
        m_cards.Insert(destSlotNumber, card);

        int i = 0;

        foreach (Transform child in transform)
        {
            GameObject childObj = child.gameObject;
            cardObjs [i].transform.SetParent(childObj.transform, false);
            Vector3 vec3 = cardObjs [i].GetComponent <RectTransform> ().sizeDelta;
            cardObjs [i].GetComponent <RectTransform> ().anchoredPosition = new Vector3(vec3.x / 2, -vec3.y / 2, 0);;
            i++;
        }
    }
예제 #2
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();
                }
            }
        }
    }
예제 #3
0
    /// <summary>
    /// On the event an item is placed, swap the values in the appropiate arrays
    /// </summary>
    /// <param name="desc">The description of the event, containing source and destination cells as well
    /// as item details</param>
    public void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        ContainerData source = desc.sourceCell.gameObject.GetComponent <ContainerData> ();
        ContainerData dest   = desc.destinationCell.gameObject.GetComponent <ContainerData> ();

        Player[] players = data.Players;
        Item     temp;

        if (dest.type == "Item")
        {
            if (source.type == "Item")
            {
                temp = items [source.Index];
                items [source.Index] = items [dest.Index];
                items [dest.Index]   = temp;
            }
            else                 //if source.type == "Player"
            {
                temp = players [source.Index].Item;
                players [source.Index].Item = items [dest.Index];
                items [dest.Index]          = temp;
            }
        }
        else if (dest.type == "Delete")           //  THIS ELSE IF ADDED ASSESSMENT 3
        {
            if (source.type == "Item")
            {
                items[source.Index] = null;
            }
            else
            {         //if source.type == "Player"
                players[source.Index].Item = null;
            }
        }
        else    //if dest.type == "Player"
        {
            if (source.type == "Item")
            {
                temp = items [source.Index];
                items [source.Index]      = players [dest.Index].Item;
                players [dest.Index].Item = temp;
            }
            else                 //if source.type == "Player"
            {
                temp = players [source.Index].Item;
                players [source.Index].Item = players [dest.Index].Item;
                players [dest.Index].Item   = temp;
            }
        }
        for (var i = 0; i <= 5; i++)
        {
            Debug.Log(PlayerData.instance.data.Items[i]);
        }

        Debug.Log("Source: " + source.Type);
        Debug.Log("Destination: " + dest.Type);
        //Debug.Log ("Item Name: " + desc.item.GetComponent<ItemData> ().Item.Name);
    }
예제 #4
0
 private void swapPlayers(string sourceCell, string destCell)
 {
     DragAndDropCell.DropDescriptor desc = new DragAndDropCell.DropDescriptor();
     desc.sourceCell      = GameObject.Find(sourceCell).GetComponent <DragAndDropCell> ();
     desc.destinationCell = GameObject.Find(destCell).GetComponent <DragAndDropCell> ();
     desc.item            = GameObject.Find(sourceCell + "/" + "Container").GetComponent <DragAndDropItem> ();
     partyScript.OnItemPlace(desc);
     desc.sourceCell.SwapItems(desc.destinationCell, desc.sourceCell);
 }
예제 #5
0
    /// <summary>
    /// On the OnItemPlace event called by DragAndDropScript, call <see cref="DataManager.swapPlayers"/> to
    /// swap the two players in the array
    /// </summary>
    /// <param name="desc">Desc.</param>
    public void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        ContainerData source = desc.sourceCell.gameObject.GetComponent <ContainerData> ();
        ContainerData dest   = desc.destinationCell.gameObject.GetComponent <ContainerData> ();

        PlayerData.instance.data.swapPlayers(source.index, dest.index);
        Debug.Log("Source: " + source.Type);
        Debug.Log("Destination: " + dest.Type);
    }
예제 #6
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);
        }
    }
예제 #7
0
    /// <summary>
    /// On the event an item is placed, swap the values in the appropiate arrays
    /// </summary>
    /// <param name="desc">The description of the event, containing source and destination cells as well
    /// as item details</param>
    public void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        ContainerData source = desc.sourceCell.gameObject.GetComponent <ContainerData> ();
        ContainerData dest   = desc.destinationCell.gameObject.GetComponent <ContainerData> ();

        Player[] players = data.Players;
        Item     temp;

        temp = items [source.Index];
        items [source.Index] = items [dest.Index];
        items [dest.Index]   = temp;
        Debug.Log("Source: " + source.Type);
        Debug.Log("Destination: " + dest.Type);
    }
예제 #8
0
    void OnItemSelected(DragAndDropCell.DropDescriptor desc)
    {
        int        srcSlotNumber = desc.sourceCell.slotNumber;
        GameObject cardObj       = cardObjs [srcSlotNumber];

        if (selectedCards.Contains(srcSlotNumber))
        {
            ToggleCardSelect(cardObj, false, true);

            selectedCards.Remove(srcSlotNumber);
        }
        else if (selectedCards.Count < 2)
        {
            ToggleCardSelect(cardObj, true, true);

            selectedCards.Add(srcSlotNumber);
        }
    }
예제 #9
0
    /// <summary>
    /// On the event an item is placed, swap the values in the appropiate arrays
    /// </summary>
    /// <param name="desc">The description of the event, containing source and destination cells as well
    /// as item details</param>
    public void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        ContainerData source = desc.sourceCell.gameObject.GetComponent <ContainerData> ();
        ContainerData dest   = desc.destinationCell.gameObject.GetComponent <ContainerData> ();

        Player[] players = data.Players;
        Item     temp;

        if (dest.type == "Item")
        {
            if (source.type == "Item")
            {
                temp = items [source.Index];
                items [source.Index] = items [dest.Index];
                items [dest.Index]   = temp;
            }
            else                 //if source.type == "Player"
            {
                temp = players [source.Index].Item;
                players [source.Index].Item = items [dest.Index];
                items [dest.Index]          = temp;
            }
        }
        else             //if dest.type == "Player"
        {
            if (source.type == "Item")
            {
                temp = items [source.Index];
                items [source.Index]      = players [dest.Index].Item;
                players [dest.Index].Item = temp;
            }
            else                 //if source.type == "Player"
            {
                temp = players [source.Index].Item;
                players [source.Index].Item = players [dest.Index].Item;
                players [dest.Index].Item   = temp;
            }
        }
        Debug.Log("Source: " + source.Type);
        Debug.Log("Destination: " + dest.Type);
        //Debug.Log ("Item Name: " + desc.item.GetComponent<ItemData> ().Item.Name);
    }
예제 #10
0
    // TODO:
    // - instance block game objects from a generic origin and build them passing the block
    // - Make prefabs for new blocks

    void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        findRecipes();
    }
예제 #11
0
    /// <summary>
    /// On the event an item is placed, swap the values in the appropiate arrays
    /// [EXTENSION] - Call <see cref="updatePlayerStats"/> whenever moved from or moved to a player
    /// </summary>
    /// <param name="desc">The description of the event, containing source and destination cells as well
    /// as item details</param>
    public void OnItemPlace(DragAndDropCell.DropDescriptor desc)
    {
        ContainerData source = desc.sourceCell.gameObject.GetComponent <ContainerData> ();
        ContainerData dest   = desc.destinationCell.gameObject.GetComponent <ContainerData> ();

        Player[] players = data.Players;
        Item     temp;

        if (dest.type == "Item")           //if being drapped to an item slot
        {
            if (source.type == "Item")     //if being dragged from an item slot
            //just swap the item positions
            {
                temp = items [source.Index];
                items [source.Index] = items [dest.Index];
                items [dest.Index]   = temp;
            }
            else                 //if source.type == "Player"
                                 //update player stats as necessary
            {
                temp = players [source.Index].Item;
                players [source.Index].Item = items [dest.Index];
                items [dest.Index]          = temp;
                updatePlayerStats(source.Index);                  //update the stats of the player that has just received a new item
            }
        }
        else if (dest.type == "Delete")           //  THIS ELSE IF ADDED ASSESSMENT 3
        {
            if (source.type == "Item")
            {
                items[source.Index] = null;
            }
            else
            {         //if source.type == "Player"
                players[source.Index].Item = null;
            }
        }
        else                           //if dest.type == "Player"
        {
            if (source.type == "Item") //if from an item slot
            //just update player being drapped to
            {
                temp = items [source.Index];
                items [source.Index]      = players [dest.Index].Item;
                players [dest.Index].Item = temp;
            }
            else                 //if source.type == "Player"
                                 //update both source and destination player stats
            {
                temp = players [source.Index].Item;
                players [source.Index].Item = players [dest.Index].Item;
                players [dest.Index].Item   = temp;
                updatePlayerStats(source.Index);                  //update the stats of the player who has just changed items
            }
            updatePlayerStats(dest.Index);
        }
        for (var i = 0; i <= 5; i++)
        {
            Debug.Log(PlayerData.instance.data.Items[i]);
        }

        Debug.Log("Source: " + source.Type);
        Debug.Log("Destination: " + dest.Type);
        //Debug.Log ("Item Name: " + desc.item.GetComponent<ItemData> ().Item.Name);
    }