コード例 #1
0
ファイル: Item.cs プロジェクト: bogstar/project-amiga
        public static Item CreateItem(ItemScriptableObject item)
        {
            if (item is EquipmentScriptableObject)
            {
                Equipment e = new Equipment(item as EquipmentScriptableObject);
                return(e);
            }

            Item i = new Item(item);

            return(i);
        }
コード例 #2
0
ファイル: Item.cs プロジェクト: bogstar/project-amiga
        public Item(ItemScriptableObject data)
        {
            if (data.name == "")
            {
                Debug.LogWarning("Name for item: " + data + " is empty.");
                Name = data.ToString();
            }
            else
            {
                Name = data.name;
            }

            if (data.description == "")
            {
                Debug.LogWarning("Description for item: " + data + " is empty.");
            }
            else
            {
                Description = data.description;
            }

            if (data.image == null)
            {
                Debug.LogWarning("Image for item: " + data + " is null.");
                // TODO: Set some kind of default image.
                Debug.LogError("Set some kind of default image.");
                Image = null;
            }
            else
            {
                Image = data.image;
            }

            if (data.dimensions.x < 1 || data.dimensions.y < 1)
            {
                Debug.LogWarning("Dimensions for item: " + data + " are less than 1.");
                Dimensions = new Vector2Int(Mathf.Max(1, data.dimensions.x), Mathf.Max(1, data.dimensions.y));
            }
            else
            {
                Dimensions = data.dimensions;
            }
        }
コード例 #3
0
        public bool AddToInventory(ItemScriptableObject itemData, Vector2Int location)
        {
            Item newItem = Item.CreateItem(itemData);

            return(AddToInventory(newItem, location));
        }
コード例 #4
0
        public bool AddToInventory(ItemScriptableObject itemData)
        {
            Item newItem = Item.CreateItem(itemData);

            return(AddToInventory(newItem));
        }