diff --git a/Assets/Scripts/Entities/SyncBases/Inventory.cs b/Assets/Scripts/Entities/SyncBases/Inventory.cs index 239d28e..fa162dd 100644 --- a/Assets/Scripts/Entities/SyncBases/Inventory.cs +++ b/Assets/Scripts/Entities/SyncBases/Inventory.cs @@ -1,6 +1,7 @@  using Cyber.Items; using Cyber.Networking; +using UnityEngine; using UnityEngine.Networking; namespace Cyber.Entities.SyncBases { @@ -21,6 +22,7 @@ namespace Cyber.Entities.SyncBases { public Inventory() { Drive = new Drive(10f); Drive.AddItem(ItemDB.Singleton.Get(0)); + Drive.AddItem(ItemDB.Singleton.Get(1)); } /// diff --git a/Assets/Scripts/Items/DriveInterface.cs b/Assets/Scripts/Items/DriveInterface.cs index c481b31..d16dde2 100644 --- a/Assets/Scripts/Items/DriveInterface.cs +++ b/Assets/Scripts/Items/DriveInterface.cs @@ -11,14 +11,14 @@ namespace Cyber.Items { /// /// Width of the interface. /// - public const int Width = 8; + public const int Width = 7; /// /// Minimun height of the interface. /// public const int MinHeight = 4; - private int[,] ItemGrid = new int[4, Width]; + private int[,] ItemGrid; private Drive Drive; @@ -28,6 +28,7 @@ namespace Cyber.Items { /// public DriveInterface(Drive drive) { Drive = drive; + ItemGrid = CreateEmptyGrid(Width, 4); } /// @@ -37,7 +38,7 @@ namespace Cyber.Items { /// The y-coordinate /// The item or null public Item GetItemAt(int x, int y) { - if (ItemGrid[y, x] == 0) { + if (ItemGrid[y, x] == -1) { return null; } else { return Drive.GetItem(ItemGrid[y, x]); @@ -73,7 +74,7 @@ namespace Cyber.Items { } } - int[,] Temp = new int[RequiredHeight + 1, Width]; + int[,] Temp = CreateEmptyGrid(Width, RequiredHeight + 1); for (int y = 0; y < RequiredHeight - 1; y++) { for (int x = 0; x < Width; x++) { if (GetItemAt(x, y) != null) { @@ -95,9 +96,20 @@ namespace Cyber.Items { for (int x = 0; x < Width; x++) { if (GetItemAt(x, y) == null) { ItemGrid[y, x] = idx; + return; } } } } + + private int[,] CreateEmptyGrid(int width, int height) { + int[,] Grid = new int[height, width]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + Grid[y, x] = -1; + } + } + return Grid; + } } } diff --git a/Assets/Scripts/Items/ItemDB.cs b/Assets/Scripts/Items/ItemDB.cs index 403d3e2..7e60ff8 100644 --- a/Assets/Scripts/Items/ItemDB.cs +++ b/Assets/Scripts/Items/ItemDB.cs @@ -20,6 +20,7 @@ namespace Cyber.Items { /// public ItemDB() { AddItem(new Item(Counter++, 0, "Very Long Item Name", 1.5f, "This item is a rare piece of the \"way too long of a name\" technology, invented by space goblins in ancient times.")); + AddItem(new Item(Counter++, 1, "Outworldly spherical tube", .5f, "It's so spherical and smooth that it seems like it's not even from this world!")); } ///