Ejemplo n.º 1
0
    private void CreateNewItem(int value = 2, int?row = null, int?column = null)
    {
        int randomRow, randomColumn;

        if (row == null && column == null)
        {
            matrix.GetRandomRowColumn(out randomRow, out randomColumn);
        }
        else
        {
            randomRow    = row.Value;
            randomColumn = column.Value;
        }

        var newItem = new Item();

        newItem.Row    = randomRow;
        newItem.Column = randomColumn;
        newItem.Value  = value;

        GameObject newGo = GetGOBasedOnValue(value);

        newGo.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);

        newItem.GO = Instantiate(newGo, this.transform.position +
                                 new Vector3(randomColumn + randomColumn * distance, randomRow + randomRow * distance, ZIndex),
                                 Quaternion.identity) as GameObject;

        newItem.GO.transform.scaleTo(Globals.AnimationDuration, new Vector3(1.0f, 1.0f, 1.0f));

        matrix[randomRow, randomColumn] = newItem;
    }