Esempio n. 1
0
    public void InsertCardAfter(ColumnController leftColumn, CardController newCard)
    {
        int index = columns.IndexOf(leftColumn);

        //Debug.Log("index = " + index + " while columns are " + columns.Count);
        if (((index + 1) >= columns.Count) ||
            ((index + 1) < columns.Count &&
             columns[index + 1].card))
        {
            //Debug.Log("Need to add a column");
            ColumnController newColumn = Instantiate(columnPrefab);
            columns.Insert(index + 1, newColumn);
            newColumn.transform.parent = transform;
            newColumn.SetSide(this);
            newColumn.transform.localPosition = Vector3.zero;
            Destroy(columns[index + 1].card.gameObject);
            columns[index + 1].SetCard(newCard);
            newCard.SetColumn(columns[index + 1]);
            newCard.transform.localPosition             = Vector3.zero;
            newCard.GetComponent <Collider2D>().enabled = true;
        }
        else if ((index + 1) < columns.Count)
        {
            //Debug.Log("Don't need to add column");
            columns[index + 1].SetCard(newCard);
            newCard.transform.localPosition             = Vector3.zero;
            newCard.GetComponent <Collider2D>().enabled = true;
        }
        else
        {
            //Debug.Log("Neither");
        }
    }