예제 #1
0
파일: Item.cs 프로젝트: Titwin/TinyWorld
    public static Item AttachItemCopy(Item original, GameObject destination)
    {
        switch (original.itemType)
        {
        case Item.ItemType.Backpack:
            BackpackItem backpack = destination.AddComponent <BackpackItem>();
            BackpackItem.Copy(original as BackpackItem, backpack);
            return(backpack);

        case Item.ItemType.Body:
            BodyItem body = destination.AddComponent <BodyItem>();
            BodyItem.Copy(original as BodyItem, body);
            return(body);

        case Item.ItemType.Head:
            HeadItem head = destination.AddComponent <HeadItem>();
            HeadItem.Copy(original as HeadItem, head);
            return(head);

        case Item.ItemType.Horse:
            HorseItem horse = destination.AddComponent <HorseItem>();
            HorseItem.Copy(original as HorseItem, horse);
            return(horse);

        case Item.ItemType.Second:
            SecondItem second = destination.AddComponent <SecondItem>();
            SecondItem.Copy(original as SecondItem, second);
            return(second);

        case Item.ItemType.Shield:
            ShieldItem shield = destination.AddComponent <ShieldItem>();
            ShieldItem.Copy(original as ShieldItem, shield);
            return(shield);

        case Item.ItemType.Weapon:
            WeaponItem weapon = destination.AddComponent <WeaponItem>();
            WeaponItem.Copy(original as WeaponItem, weapon);
            return(weapon);

        case Item.ItemType.Resource:
            ResourceItem resource = destination.AddComponent <ResourceItem>();
            ResourceItem.Copy(original as ResourceItem, resource);
            return(resource);

        default:
            Debug.LogError("Unsuported Item type");
            return(null);
        }
    }