示例#1
0
    //if worldobject doesn't exist, create one
    //if item is not skinned mesh, set item to the equip location
    //if item is skinned mesh, replace the default mesh and material with the items
    //set attached-to the equip location
    public void AttachTo(EquipLocation e)
    {
        if (!world_object)
        {
            CreateWorldObject(Vector3.zero);
        }

        BodyPart bone = player.bones [e.GetHashCode()];

        if (type != ItemType.SkinnedArmour)
        {
            world_object.transform.parent        = bone.transform;
            world_object.transform.localPosition = Vector3.zero;
            world_object.transform.localRotation = Quaternion.Euler(0, 0, 0);
        }
        else
        {
            SkinnedMeshRenderer renderer = bone.transform.GetComponent <SkinnedMeshRenderer> ();
            renderer.sharedMesh = world_object.GetComponent <MeshFilter> ().mesh;
            renderer.material   = world_object.GetComponent <MeshRenderer> ().material;
            GameObject.Destroy(world_object);
        }

        attached_to = e;
    }
示例#2
0
    //Equip an item to EquipLocation
    public void Equip(Item item, EquipLocation e)
    {
        RemoveFromInventory(item, item.count);
        Item e_item = equipment_items [e.GetHashCode()];

        if (!e_item.nullified)
        {
            if (e_item.type != ItemType.Null)
            {
                Unequip(e_item);
            }
        }

        equipment_items [e.GetHashCode()] = item;

        item.AttachTo(e);
    }
示例#3
0
    //delete world object,
    //if its a skinned mesh return mesh and material to defaults
    //set attached-to location to null
    public void DestroyWorldObject()
    {
        GameObject.Destroy(world_object);
        world_object = null;
        if (type == ItemType.SkinnedArmour && attached_to != EquipLocation.Null)
        {
            BodyPart            bone     = player.bones[attached_to.GetHashCode()];
            SkinnedMeshRenderer renderer = bone.transform.GetComponent <SkinnedMeshRenderer> ();

            if (renderer != null)
            {
                renderer.sharedMesh = bone.default_mesh;
                renderer.material   = bone.default_material;
            }
        }
        attached_to = EquipLocation.Null;
    }