Esempio n. 1
0
    //creates an instance that holds the data object
    public Transform createPart(Part newPart)
    {
        if (newPart == null)
            return null;

        //get the part info from library
        ItemInfo info = new ItemInfo();
        if (!itemLibrary.getItemInfo (info, newPart.item.id)) {

            return null;
        }

        Transform oPart = PoolManager.Pools["parts"].Spawn(info.itemPrefab, newPart.getPosition(), newPart.thisRotation);

        oPart.GetComponent<MeshFilter>().mesh = info.mesh;
        oPart.GetComponent<MeshCollider> ().sharedMesh = info.mesh;
        oPart.GetComponent<Renderer>().material = info.material;

        //okay, we kinda need to populate the  new object with the pickup data...
        //this would mean that whatever the prefab just used, hopefully it has a partScript
        partScript sPart = oPart.GetComponent("partScript") as partScript;

        //perhaps in the future we could see how to attach a script from the item data, which would correspond
        //directly to the type of object.
        sPart.partData = newPart.getCopy ();

        return oPart;
    }