mirror of
				https://github.com/DerTyp7/example-top-down-unity.git
				synced 2025-10-30 21:07:09 +01:00 
			
		
		
		
	-Added Items
-Added item stacking -adding and removing items
This commit is contained in:
		
							
								
								
									
										43
									
								
								Assets/Scripts/Inventory/Slot.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								Assets/Scripts/Inventory/Slot.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class Slot | ||||
| { | ||||
|      | ||||
|     Item item; | ||||
|     int maxItems; | ||||
|     int count; | ||||
|     public Slot(int maxItems) | ||||
|     { | ||||
|         item = null; | ||||
|         this.maxItems = maxItems; | ||||
|         count = 0; | ||||
|  | ||||
|     } | ||||
|     public bool removeItem()  | ||||
|     { | ||||
|         if (count > 0) | ||||
|         { | ||||
|             count--; | ||||
|             if (count == 0)  | ||||
|             { | ||||
|                 item = null; | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|     public bool addItem(int count = 1) | ||||
|     { | ||||
|         this.count += count; | ||||
|         return true; | ||||
|  | ||||
|     } | ||||
|     public Item ItemType { get => item; set => item = value; } | ||||
|     public int Count { get => count; set => count = value; } | ||||
|     public int MaxItems { get => maxItems; set => maxItems = value; } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 julius
					julius