示例#1
0
    public void Spawn(string pieceName)
    {
        if (CanSpawn() == false)
        {
            return;
        }

        // Spawn
        GameObject piecePrefab = Pieces.GetPiecePrefab(pieceName);
        //Debug.Log (piecePrefab);
        GameObject Piece = Instantiate(piecePrefab, transform.position, Quaternion.identity) as GameObject;
        // spawned piece shouldn't fall
        Rigidbody2D rigidbody2D = Piece.GetComponent <Rigidbody2D>();

        rigidbody2D.isKinematic = true;

        Collider2D[] colliders = Piece.GetComponents <Collider2D>();
        foreach (Collider2D col in colliders)
        {
            col.isTrigger = true;
        }

        lastSpawnedObject = Piece;
        //Debug.Log("Spawn!");
    }